blob: da23ccbaa09d168c6d0226de40154b9edded46b2 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the University
6// of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 SSE instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16
17//===----------------------------------------------------------------------===//
18// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
21def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
23
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
25def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
26def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
27 [SDNPCommutative, SDNPAssociative]>;
28def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
33def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
34def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengf37bf452007-10-01 18:12:48 +000035def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Cheng621216e2007-09-29 00:00:36 +000036def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037def X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
38def X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
39def X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
40
41//===----------------------------------------------------------------------===//
42// SSE 'Special' Instructions
43//===----------------------------------------------------------------------===//
44
Evan 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
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000334// Match intrinisics which expect MM and XMM operand(s).
335def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
336 "cvtps2pi\t{$src, $dst|$dst, $src}",
337 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
338def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
339 "cvtps2pi\t{$src, $dst|$dst, $src}",
340 [(set VR64:$dst, (int_x86_sse_cvtps2pi
341 (load addr:$src)))]>;
342def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
343 "cvttps2pi\t{$src, $dst|$dst, $src}",
344 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
345def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
346 "cvttps2pi\t{$src, $dst|$dst, $src}",
347 [(set VR64:$dst, (int_x86_sse_cvttps2pi
348 (load addr:$src)))]>;
349let isTwoAddress = 1 in {
350 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
351 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
352 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
353 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
354 VR64:$src2))]>;
355 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
356 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
357 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
358 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
359 (load addr:$src2)))]>;
360}
361
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000363def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(set GR32:$dst,
366 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000367def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(set GR32:$dst,
370 (int_x86_sse_cvttss2si(load addr:$src)))]>;
371
372let isTwoAddress = 1 in {
373 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000374 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000375 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
377 GR32:$src2))]>;
378 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000379 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000380 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
382 (loadi32 addr:$src2)))]>;
383}
384
385// Comparison instructions
386let isTwoAddress = 1 in {
387 def CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000388 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 def CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000391 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000392 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393}
394
Evan Cheng55687072007-09-14 21:48:26 +0000395let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000396def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000397 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000398 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000399def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000400 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000401 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000402 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000403} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404
405// Aliases to match intrinsics which expect XMM operand(s).
406let isTwoAddress = 1 in {
407 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
411 VR128:$src, imm:$cc))]>;
412 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000413 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
416 (load addr:$src), imm:$cc))]>;
417}
418
Evan Cheng55687072007-09-14 21:48:26 +0000419let Defs = [EFLAGS] in {
Evan Cheng621216e2007-09-29 00:00:36 +0000420def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000421 (ins VR128:$src1, VR128:$src2),
422 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000423 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000424 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000425def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000426 (ins VR128:$src1, f128mem:$src2),
427 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000428 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000429 (implicit EFLAGS)]>;
430
Evan Cheng621216e2007-09-29 00:00:36 +0000431def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000432 (ins VR128:$src1, VR128:$src2),
433 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000434 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000435 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000436def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000437 (ins VR128:$src1, f128mem:$src2),
438 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000439 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000440 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000441} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442
443// Aliases of packed SSE1 instructions for scalar use. These all have names that
444// start with 'Fs'.
445
446// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +0000447let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000448def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 Requires<[HasSSE1]>, TB, OpSize;
451
452// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
453// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000454def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456
457// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
458// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +0000459let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000460def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000461 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000462 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
464// Alias bitwise logical operations using SSE logical ops on packed FP values.
465let isTwoAddress = 1 in {
466let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000467 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000470 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000471 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000473 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
476}
477
Evan Chengb783fa32007-07-19 01:14:50 +0000478def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000479 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000481 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000482def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000483 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000485 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000486def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000489 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490
491def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000492 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000493 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000495 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497}
498
499/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
500///
501/// In addition, we also have a special variant of the scalar form here to
502/// represent the associated intrinsic operation. This form is unlike the
503/// plain scalar form, in that it takes an entire vector (instead of a scalar)
504/// and leaves the top elements undefined.
505///
506/// These three forms can each be reg+reg or reg+mem, so there are a total of
507/// six "instructions".
508///
509let isTwoAddress = 1 in {
510multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
511 SDNode OpNode, Intrinsic F32Int,
512 bit Commutable = 0> {
513 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000514 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
517 let isCommutable = Commutable;
518 }
519
520 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000521 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000522 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
524
525 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000526 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000527 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
529 let isCommutable = Commutable;
530 }
531
532 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000533 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000534 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000535 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
537 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000538 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
541 let isCommutable = Commutable;
542 }
543
544 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000545 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000546 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547 [(set VR128:$dst, (F32Int VR128:$src1,
548 sse_load_f32:$src2))]>;
549}
550}
551
552// Arithmetic instructions
553defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
554defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
555defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
556defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
557
558/// sse1_fp_binop_rm - Other SSE1 binops
559///
560/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
561/// instructions for a full-vector intrinsic form. Operations that map
562/// onto C operators don't use this form since they just use the plain
563/// vector form instead of having a separate vector intrinsic form.
564///
565/// This provides a total of eight "instructions".
566///
567let isTwoAddress = 1 in {
568multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
569 SDNode OpNode,
570 Intrinsic F32Int,
571 Intrinsic V4F32Int,
572 bit Commutable = 0> {
573
574 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000575 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000576 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
578 let isCommutable = Commutable;
579 }
580
581 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000582 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
585
586 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000587 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
590 let isCommutable = Commutable;
591 }
592
593 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000594 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000595 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000596 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
598 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000599 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
602 let isCommutable = Commutable;
603 }
604
605 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000606 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608 [(set VR128:$dst, (F32Int VR128:$src1,
609 sse_load_f32:$src2))]>;
610
611 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000612 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000613 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
615 let isCommutable = Commutable;
616 }
617
618 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000619 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000620 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
622}
623}
624
625defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
626 int_x86_sse_max_ss, int_x86_sse_max_ps>;
627defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
628 int_x86_sse_min_ss, int_x86_sse_min_ps>;
629
630//===----------------------------------------------------------------------===//
631// SSE packed FP Instructions
632
633// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000634def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000635 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000636let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000637def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000639 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
Evan Chengb783fa32007-07-19 01:14:50 +0000641def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000643 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644
Evan Chengb783fa32007-07-19 01:14:50 +0000645def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000646 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000647let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000648def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000650 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000651def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000653 [(store (v4f32 VR128:$src), addr:$dst)]>;
654
655// Intrinsic forms of MOVUPS load and store
Evan Cheng4e84e452007-08-30 05:49:43 +0000656let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000659 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000662 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663
664let isTwoAddress = 1 in {
665 let AddedComplexity = 20 in {
666 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000667 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669 [(set VR128:$dst,
670 (v4f32 (vector_shuffle VR128:$src1,
671 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
672 MOVLP_shuffle_mask)))]>;
673 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000674 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set VR128:$dst,
677 (v4f32 (vector_shuffle VR128:$src1,
678 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
679 MOVHP_shuffle_mask)))]>;
680 } // AddedComplexity
681} // isTwoAddress
682
Evan Chengb783fa32007-07-19 01:14:50 +0000683def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
686 (iPTR 0))), addr:$dst)]>;
687
688// v2f64 extract element 1 is always custom lowered to unpack high to low
689// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000690def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(store (f64 (vector_extract
693 (v2f64 (vector_shuffle
694 (bc_v2f64 (v4f32 VR128:$src)), (undef),
695 UNPCKH_shuffle_mask)), (iPTR 0))),
696 addr:$dst)]>;
697
698let isTwoAddress = 1 in {
699let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000700def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set VR128:$dst,
703 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
704 MOVHP_shuffle_mask)))]>;
705
Evan Chengb783fa32007-07-19 01:14:50 +0000706def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(set VR128:$dst,
709 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
710 MOVHLPS_shuffle_mask)))]>;
711} // AddedComplexity
712} // isTwoAddress
713
714
715
716// Arithmetic
717
718/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
719///
720/// In addition, we also have a special variant of the scalar form here to
721/// represent the associated intrinsic operation. This form is unlike the
722/// plain scalar form, in that it takes an entire vector (instead of a
723/// scalar) and leaves the top elements undefined.
724///
725/// And, we have a special variant form for a full-vector intrinsic form.
726///
727/// These four forms can each have a reg or a mem operand, so there are a
728/// total of eight "instructions".
729///
730multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
731 SDNode OpNode,
732 Intrinsic F32Int,
733 Intrinsic V4F32Int,
734 bit Commutable = 0> {
735 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000736 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738 [(set FR32:$dst, (OpNode FR32:$src))]> {
739 let isCommutable = Commutable;
740 }
741
742 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000743 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
746
747 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000748 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
751 let isCommutable = Commutable;
752 }
753
754 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000755 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000757 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758
759 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000760 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set VR128:$dst, (F32Int VR128:$src))]> {
763 let isCommutable = Commutable;
764 }
765
766 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000767 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
770
771 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000772 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
775 let isCommutable = Commutable;
776 }
777
778 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000779 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
782}
783
784// Square root.
785defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
786 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
787
788// Reciprocal approximations. Note that these typically require refinement
789// in order to obtain suitable precision.
790defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
791 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
792defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
793 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
794
795// Logical
796let isTwoAddress = 1 in {
797 let isCommutable = 1 in {
798 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000799 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set VR128:$dst, (v2i64
802 (and VR128:$src1, VR128:$src2)))]>;
803 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000804 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(set VR128:$dst, (v2i64
807 (or VR128:$src1, VR128:$src2)))]>;
808 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000809 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 [(set VR128:$dst, (v2i64
812 (xor VR128:$src1, VR128:$src2)))]>;
813 }
814
815 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000816 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000818 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
819 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000823 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
824 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000828 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
829 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set VR128:$dst,
834 (v2i64 (and (xor VR128:$src1,
835 (bc_v2i64 (v4i32 immAllOnesV))),
836 VR128:$src2)))]>;
837 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000841 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000843 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844}
845
846let isTwoAddress = 1 in {
847 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
851 VR128:$src, imm:$cc))]>;
852 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
856 (load addr:$src), imm:$cc))]>;
857}
858
859// Shuffle and unpack instructions
860let isTwoAddress = 1 in {
861 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
862 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 [(set VR128:$dst,
867 (v4f32 (vector_shuffle
868 VR128:$src1, VR128:$src2,
869 SHUFP_shuffle_mask:$src3)))]>;
870 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(set VR128:$dst,
875 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000876 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 SHUFP_shuffle_mask:$src3)))]>;
878
879 let AddedComplexity = 10 in {
880 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set VR128:$dst,
884 (v4f32 (vector_shuffle
885 VR128:$src1, VR128:$src2,
886 UNPCKH_shuffle_mask)))]>;
887 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set VR128:$dst,
891 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000892 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 UNPCKH_shuffle_mask)))]>;
894
895 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set VR128:$dst,
899 (v4f32 (vector_shuffle
900 VR128:$src1, VR128:$src2,
901 UNPCKL_shuffle_mask)))]>;
902 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000903 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set VR128:$dst,
906 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000907 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 UNPCKL_shuffle_mask)))]>;
909 } // AddedComplexity
910} // isTwoAddress
911
912// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000913def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000916def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
919
920// Prefetching loads.
921// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000922def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
923def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
924def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
925def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926
927// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000928def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000929 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
931
932// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000933def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934
935// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000936def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000938def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940
941// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000943def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000945 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946
947// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000948def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set VR128:$dst,
951 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000952def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 [(set VR128:$dst,
955 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
956
957// FIXME: may not be able to eliminate this movss with coalescing the src and
958// dest register classes are different. We really want to write this pattern
959// like this:
960// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
961// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000962def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
965 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000966def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(store (f32 (vector_extract (v4f32 VR128:$src),
969 (iPTR 0))), addr:$dst)]>;
970
971
972// Move to lower bits of a VR128, leaving upper bits alone.
973// Three operand (but two address) aliases.
974let isTwoAddress = 1 in {
975 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978
979 let AddedComplexity = 15 in
980 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set VR128:$dst,
984 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
985 MOVL_shuffle_mask)))]>;
986}
987
988// Move to lower bits of a VR128 and zeroing upper bits.
989// Loading from memory automatically zeroing upper bits.
990let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000991def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "movss\t{$src, $dst|$dst, $src}",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000993 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
995 MOVL_shuffle_mask)))]>;
996
997
998//===----------------------------------------------------------------------===//
999// SSE2 Instructions
1000//===----------------------------------------------------------------------===//
1001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001003def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "movsd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001005let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001006def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001009def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(store FR64:$src, addr:$dst)]>;
1012
1013// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001014def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001015 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001017def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001020def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001023def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001026def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001029def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1032
1033// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001034def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001035 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1037 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001038def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1041 Requires<[HasSSE2]>;
1042
1043// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001044def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001047def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1050 (load addr:$src)))]>;
1051
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001052// Match intrinisics which expect MM and XMM operand(s).
1053def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1054 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1055 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1056def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1057 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1058 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1059 (load addr:$src)))]>;
1060def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1061 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1062 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1063def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1064 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1065 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1066 (load addr:$src)))]>;
1067def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1068 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1069 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1070def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1071 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1072 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1073 (load addr:$src)))]>;
1074
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001076def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001077 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(set GR32:$dst,
1079 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001080def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1083 (load addr:$src)))]>;
1084
1085// Comparison instructions
1086let isTwoAddress = 1 in {
1087 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001088 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001091 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093}
1094
Evan Cheng950aac02007-09-25 01:57:46 +00001095let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001096def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001098 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001099def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001100 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001101 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001102 (implicit EFLAGS)]>;
1103}
1104
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105// Aliases to match intrinsics which expect XMM operand(s).
1106let isTwoAddress = 1 in {
1107 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001108 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001109 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1111 VR128:$src, imm:$cc))]>;
1112 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001113 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1116 (load addr:$src), imm:$cc))]>;
1117}
1118
Evan Cheng950aac02007-09-25 01:57:46 +00001119let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001120def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001122 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1123 (implicit EFLAGS)]>;
1124def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001126 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1127 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128
Evan Chengb783fa32007-07-19 01:14:50 +00001129def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001131 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1132 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001133def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001135 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001136 (implicit EFLAGS)]>;
1137} // Defs = EFLAGS]
1138
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139// Aliases of packed SSE2 instructions for scalar use. These all have names that
1140// start with 'Fs'.
1141
1142// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001143let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001144def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 Requires<[HasSSE2]>, TB, OpSize;
1147
1148// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1149// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001150def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152
1153// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1154// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +00001155let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001156def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001158 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159
1160// Alias bitwise logical operations using SSE logical ops on packed FP values.
1161let isTwoAddress = 1 in {
1162let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001163 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001166 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001169 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1172}
1173
Evan Chengb783fa32007-07-19 01:14:50 +00001174def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001175 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001177 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001178def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001181 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001182def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001185 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186
1187def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001188 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001191 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193}
1194
1195/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1196///
1197/// In addition, we also have a special variant of the scalar form here to
1198/// represent the associated intrinsic operation. This form is unlike the
1199/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1200/// and leaves the top elements undefined.
1201///
1202/// These three forms can each be reg+reg or reg+mem, so there are a total of
1203/// six "instructions".
1204///
1205let isTwoAddress = 1 in {
1206multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1207 SDNode OpNode, Intrinsic F64Int,
1208 bit Commutable = 0> {
1209 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001210 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1213 let isCommutable = Commutable;
1214 }
1215
1216 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001217 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001218 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1220
1221 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001222 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1225 let isCommutable = Commutable;
1226 }
1227
1228 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001229 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001230 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001231 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232
1233 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001234 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1237 let isCommutable = Commutable;
1238 }
1239
1240 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001241 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set VR128:$dst, (F64Int VR128:$src1,
1244 sse_load_f64:$src2))]>;
1245}
1246}
1247
1248// Arithmetic instructions
1249defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1250defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1251defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1252defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1253
1254/// sse2_fp_binop_rm - Other SSE2 binops
1255///
1256/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1257/// instructions for a full-vector intrinsic form. Operations that map
1258/// onto C operators don't use this form since they just use the plain
1259/// vector form instead of having a separate vector intrinsic form.
1260///
1261/// This provides a total of eight "instructions".
1262///
1263let isTwoAddress = 1 in {
1264multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1265 SDNode OpNode,
1266 Intrinsic F64Int,
1267 Intrinsic V2F64Int,
1268 bit Commutable = 0> {
1269
1270 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001271 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1274 let isCommutable = Commutable;
1275 }
1276
1277 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001278 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001279 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1281
1282 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001283 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1286 let isCommutable = Commutable;
1287 }
1288
1289 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001290 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001292 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293
1294 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001295 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1298 let isCommutable = Commutable;
1299 }
1300
1301 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001302 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set VR128:$dst, (F64Int VR128:$src1,
1305 sse_load_f64:$src2))]>;
1306
1307 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001308 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001309 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1311 let isCommutable = Commutable;
1312 }
1313
1314 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001315 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1318}
1319}
1320
1321defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1322 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1323defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1324 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1325
1326//===----------------------------------------------------------------------===//
1327// SSE packed FP Instructions
1328
1329// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001330def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001331 "movapd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001332let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001333def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001335 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336
Evan Chengb783fa32007-07-19 01:14:50 +00001337def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001339 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340
Evan Chengb783fa32007-07-19 01:14:50 +00001341def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001343let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001344def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001346 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001347def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001349 [(store (v2f64 VR128:$src), addr:$dst)]>;
1350
1351// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001352def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001354 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001355def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001357 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358
1359let isTwoAddress = 1 in {
1360 let AddedComplexity = 20 in {
1361 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001362 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set VR128:$dst,
1365 (v2f64 (vector_shuffle VR128:$src1,
1366 (scalar_to_vector (loadf64 addr:$src2)),
1367 MOVLP_shuffle_mask)))]>;
1368 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set VR128:$dst,
1372 (v2f64 (vector_shuffle VR128:$src1,
1373 (scalar_to_vector (loadf64 addr:$src2)),
1374 MOVHP_shuffle_mask)))]>;
1375 } // AddedComplexity
1376} // isTwoAddress
1377
Evan Chengb783fa32007-07-19 01:14:50 +00001378def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(store (f64 (vector_extract (v2f64 VR128:$src),
1381 (iPTR 0))), addr:$dst)]>;
1382
1383// v2f64 extract element 1 is always custom lowered to unpack high to low
1384// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001385def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(store (f64 (vector_extract
1388 (v2f64 (vector_shuffle VR128:$src, (undef),
1389 UNPCKH_shuffle_mask)), (iPTR 0))),
1390 addr:$dst)]>;
1391
1392// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001393def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1396 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001397def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001400 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401 TB, Requires<[HasSSE2]>;
1402
1403// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001404def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001405 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1407 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001408def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001411 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 XS, Requires<[HasSSE2]>;
1413
Evan Chengb783fa32007-07-19 01:14:50 +00001414def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001415 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001417def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1420 (load addr:$src)))]>;
1421// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001422def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001423 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1425 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001426def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1429 (load addr:$src)))]>,
1430 XS, Requires<[HasSSE2]>;
1431
1432// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001433def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1436 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001437def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001438 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1440 (load addr:$src)))]>,
1441 XD, Requires<[HasSSE2]>;
1442
Evan Chengb783fa32007-07-19 01:14:50 +00001443def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001446def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1449 (load addr:$src)))]>;
1450
1451// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001452def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1455 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001456def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1459 (load addr:$src)))]>,
1460 TB, Requires<[HasSSE2]>;
1461
Evan Chengb783fa32007-07-19 01:14:50 +00001462def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001464 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001465def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1468 (load addr:$src)))]>;
1469
1470// Match intrinsics which expect XMM operand(s).
1471// Aliases for intrinsics
1472let isTwoAddress = 1 in {
1473def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001474 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1477 GR32:$src2))]>;
1478def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001479 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1482 (loadi32 addr:$src2)))]>;
1483def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001484 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1487 VR128:$src2))]>;
1488def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001489 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1492 (load addr:$src2)))]>;
1493def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001494 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1497 VR128:$src2))]>, XS,
1498 Requires<[HasSSE2]>;
1499def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001500 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1503 (load addr:$src2)))]>, XS,
1504 Requires<[HasSSE2]>;
1505}
1506
1507// Arithmetic
1508
1509/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1510///
1511/// In addition, we also have a special variant of the scalar form here to
1512/// represent the associated intrinsic operation. This form is unlike the
1513/// plain scalar form, in that it takes an entire vector (instead of a
1514/// scalar) and leaves the top elements undefined.
1515///
1516/// And, we have a special variant form for a full-vector intrinsic form.
1517///
1518/// These four forms can each have a reg or a mem operand, so there are a
1519/// total of eight "instructions".
1520///
1521multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1522 SDNode OpNode,
1523 Intrinsic F64Int,
1524 Intrinsic V2F64Int,
1525 bit Commutable = 0> {
1526 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001527 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(set FR64:$dst, (OpNode FR64:$src))]> {
1530 let isCommutable = Commutable;
1531 }
1532
1533 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001534 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1537
1538 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001539 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1542 let isCommutable = Commutable;
1543 }
1544
1545 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001548 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549
1550 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001551 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(set VR128:$dst, (F64Int VR128:$src))]> {
1554 let isCommutable = Commutable;
1555 }
1556
1557 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1561
1562 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1566 let isCommutable = Commutable;
1567 }
1568
1569 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001570 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1573}
1574
1575// Square root.
1576defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1577 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1578
1579// There is no f64 version of the reciprocal approximation instructions.
1580
1581// Logical
1582let isTwoAddress = 1 in {
1583 let isCommutable = 1 in {
1584 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001585 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set VR128:$dst,
1588 (and (bc_v2i64 (v2f64 VR128:$src1)),
1589 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1590 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001591 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 [(set VR128:$dst,
1594 (or (bc_v2i64 (v2f64 VR128:$src1)),
1595 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1596 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001597 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set VR128:$dst,
1600 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1601 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1602 }
1603
1604 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001605 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(set VR128:$dst,
1608 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001609 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001611 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 [(set VR128:$dst,
1614 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001615 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001617 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 [(set VR128:$dst,
1620 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001621 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001623 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set VR128:$dst,
1626 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1627 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1628 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001629 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(set VR128:$dst,
1632 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001633 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634}
1635
1636let isTwoAddress = 1 in {
1637 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001638 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1641 VR128:$src, imm:$cc))]>;
1642 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001643 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1646 (load addr:$src), imm:$cc))]>;
1647}
1648
1649// Shuffle and unpack instructions
1650let isTwoAddress = 1 in {
1651 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001652 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654 [(set VR128:$dst, (v2f64 (vector_shuffle
1655 VR128:$src1, VR128:$src2,
1656 SHUFP_shuffle_mask:$src3)))]>;
1657 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001658 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 [(set VR128:$dst,
1662 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001663 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 SHUFP_shuffle_mask:$src3)))]>;
1665
1666 let AddedComplexity = 10 in {
1667 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001668 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set VR128:$dst,
1671 (v2f64 (vector_shuffle
1672 VR128:$src1, VR128:$src2,
1673 UNPCKH_shuffle_mask)))]>;
1674 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001675 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(set VR128:$dst,
1678 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001679 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680 UNPCKH_shuffle_mask)))]>;
1681
1682 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(set VR128:$dst,
1686 (v2f64 (vector_shuffle
1687 VR128:$src1, VR128:$src2,
1688 UNPCKL_shuffle_mask)))]>;
1689 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001690 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set VR128:$dst,
1693 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001694 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 UNPCKL_shuffle_mask)))]>;
1696 } // AddedComplexity
1697} // isTwoAddress
1698
1699
1700//===----------------------------------------------------------------------===//
1701// SSE integer instructions
1702
1703// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001704def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001706let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001707def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001709 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001710def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001712 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001713let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001714def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001716 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001718def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001720 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 XS, Requires<[HasSSE2]>;
1722
Dan Gohman4a4f1512007-07-18 20:23:34 +00001723// Intrinsic forms of MOVDQU load and store
Evan Cheng4e84e452007-08-30 05:49:43 +00001724let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001725def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001727 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1728 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001729def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001731 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1732 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733
1734let isTwoAddress = 1 in {
1735
1736multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1737 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001738 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1741 let isCommutable = Commutable;
1742 }
Evan Chengb783fa32007-07-19 01:14:50 +00001743 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001746 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747}
1748
1749multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1750 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001751 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001754 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001757 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001758 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 [(set VR128:$dst, (IntId VR128:$src1,
1761 (scalar_to_vector (i32 imm:$src2))))]>;
1762}
1763
1764
1765/// PDI_binop_rm - Simple SSE2 binary operator.
1766multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1767 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1771 let isCommutable = Commutable;
1772 }
Evan Chengb783fa32007-07-19 01:14:50 +00001773 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001776 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777}
1778
1779/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1780///
1781/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1782/// to collapse (bitconvert VT to VT) into its operand.
1783///
1784multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1785 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1789 let isCommutable = Commutable;
1790 }
Evan Chengb783fa32007-07-19 01:14:50 +00001791 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001793 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794}
1795
1796} // isTwoAddress
1797
1798// 128-bit Integer Arithmetic
1799
1800defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1801defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1802defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1803defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1804
1805defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1806defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1807defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1808defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1809
1810defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1811defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1812defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1813defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1814
1815defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1816defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1817defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1818defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1819
1820defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1821
1822defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1823defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1824defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1825
1826defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1827
1828defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1829defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1830
1831
1832defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1833defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1834defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1835defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1836defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1837
1838
1839defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1840defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1841defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1842
1843defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1844defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1845defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1846
1847defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1848defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1849// PSRAQ doesn't exist in SSE[1-3].
1850
1851// 128-bit logical shifts.
1852let isTwoAddress = 1 in {
1853 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001854 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001857 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859 // PSRADQri doesn't exist in SSE[1-3].
1860}
1861
1862let Predicates = [HasSSE2] in {
1863 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1864 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1865 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1866 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1867 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1868 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1869}
1870
1871// Logical
1872defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1873defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1874defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1875
1876let isTwoAddress = 1 in {
1877 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001878 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1881 VR128:$src2)))]>;
1882
1883 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001884 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001887 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888}
1889
1890// SSE2 Integer comparison
1891defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1892defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1893defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1894defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1895defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1896defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1897
1898// Pack instructions
1899defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1900defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1901defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1902
1903// Shuffle and unpack instructions
1904def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001905 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set VR128:$dst, (v4i32 (vector_shuffle
1908 VR128:$src1, (undef),
1909 PSHUFD_shuffle_mask:$src2)))]>;
1910def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001914 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 (undef),
1916 PSHUFD_shuffle_mask:$src2)))]>;
1917
1918// SSE2 with ImmT == Imm8 and XS prefix.
1919def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001920 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(set VR128:$dst, (v8i16 (vector_shuffle
1923 VR128:$src1, (undef),
1924 PSHUFHW_shuffle_mask:$src2)))]>,
1925 XS, Requires<[HasSSE2]>;
1926def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001927 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001930 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 (undef),
1932 PSHUFHW_shuffle_mask:$src2)))]>,
1933 XS, Requires<[HasSSE2]>;
1934
1935// SSE2 with ImmT == Imm8 and XD prefix.
1936def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001937 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set VR128:$dst, (v8i16 (vector_shuffle
1940 VR128:$src1, (undef),
1941 PSHUFLW_shuffle_mask:$src2)))]>,
1942 XD, Requires<[HasSSE2]>;
1943def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001944 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001947 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 (undef),
1949 PSHUFLW_shuffle_mask:$src2)))]>,
1950 XD, Requires<[HasSSE2]>;
1951
1952
1953let isTwoAddress = 1 in {
1954 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001955 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(set VR128:$dst,
1958 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1959 UNPCKL_shuffle_mask)))]>;
1960 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001961 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set VR128:$dst,
1964 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001965 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 UNPCKL_shuffle_mask)))]>;
1967 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001968 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set VR128:$dst,
1971 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1972 UNPCKL_shuffle_mask)))]>;
1973 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001974 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(set VR128:$dst,
1977 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001978 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 UNPCKL_shuffle_mask)))]>;
1980 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001981 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set VR128:$dst,
1984 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1985 UNPCKL_shuffle_mask)))]>;
1986 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001987 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(set VR128:$dst,
1990 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001991 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 UNPCKL_shuffle_mask)))]>;
1993 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001994 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set VR128:$dst,
1997 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1998 UNPCKL_shuffle_mask)))]>;
1999 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002000 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(set VR128:$dst,
2003 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002004 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 UNPCKL_shuffle_mask)))]>;
2006
2007 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002008 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set VR128:$dst,
2011 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
2012 UNPCKH_shuffle_mask)))]>;
2013 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002014 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set VR128:$dst,
2017 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002018 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 UNPCKH_shuffle_mask)))]>;
2020 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002021 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(set VR128:$dst,
2024 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
2025 UNPCKH_shuffle_mask)))]>;
2026 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002027 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(set VR128:$dst,
2030 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002031 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 UNPCKH_shuffle_mask)))]>;
2033 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002034 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set VR128:$dst,
2037 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2038 UNPCKH_shuffle_mask)))]>;
2039 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002040 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(set VR128:$dst,
2043 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002044 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 UNPCKH_shuffle_mask)))]>;
2046 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002047 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(set VR128:$dst,
2050 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2051 UNPCKH_shuffle_mask)))]>;
2052 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002053 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(set VR128:$dst,
2056 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002057 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 UNPCKH_shuffle_mask)))]>;
2059}
2060
2061// Extract / Insert
2062def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2066 (iPTR imm:$src2)))]>;
2067let isTwoAddress = 1 in {
2068 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002069 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set VR128:$dst,
2073 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2074 GR32:$src2, (iPTR imm:$src3))))]>;
2075 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002076 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(set VR128:$dst,
2080 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2081 (i32 (anyext (loadi16 addr:$src2))),
2082 (iPTR imm:$src3))))]>;
2083}
2084
2085// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002086def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2089
2090// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002091let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002092def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002095
2096// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002097def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002100def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002103def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2106 TB, Requires<[HasSSE2]>;
2107
2108// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002109def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 TB, Requires<[HasSSE2]>;
2112
2113// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002114def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002116def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2118
2119
2120// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002122 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002124 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125
2126// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002127def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set VR128:$dst,
2130 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002131def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set VR128:$dst,
2134 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2135
Evan Chengb783fa32007-07-19 01:14:50 +00002136def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(set VR128:$dst,
2139 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002140def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set VR128:$dst,
2143 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2144
Evan Chengb783fa32007-07-19 01:14:50 +00002145def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2148
Evan Chengb783fa32007-07-19 01:14:50 +00002149def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2152
2153// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002154def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(set VR128:$dst,
2157 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2158 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002159def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(store (i64 (vector_extract (v2i64 VR128:$src),
2162 (iPTR 0))), addr:$dst)]>;
2163
2164// FIXME: may not be able to eliminate this movss with coalescing the src and
2165// dest register classes are different. We really want to write this pattern
2166// like this:
2167// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2168// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002169def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2172 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002173def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(store (f64 (vector_extract (v2f64 VR128:$src),
2176 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002177def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2180 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002181def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(store (i32 (vector_extract (v4i32 VR128:$src),
2184 (iPTR 0))), addr:$dst)]>;
2185
Evan Chengb783fa32007-07-19 01:14:50 +00002186def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002189def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2192
2193
2194// Move to lower bits of a VR128, leaving upper bits alone.
2195// Three operand (but two address) aliases.
2196let isTwoAddress = 1 in {
2197 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002198 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200
2201 let AddedComplexity = 15 in
2202 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002203 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set VR128:$dst,
2206 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2207 MOVL_shuffle_mask)))]>;
2208}
2209
2210// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002211def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2214
2215// Move to lower bits of a VR128 and zeroing upper bits.
2216// Loading from memory automatically zeroing upper bits.
2217let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002218 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 [(set VR128:$dst,
Chris Lattnere6aa3862007-11-25 00:24:49 +00002221 (v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 (v2f64 (scalar_to_vector
2223 (loadf64 addr:$src))),
2224 MOVL_shuffle_mask)))]>;
2225
2226let AddedComplexity = 15 in
2227// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002228def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(set VR128:$dst,
2231 (v4i32 (vector_shuffle immAllZerosV,
2232 (v4i32 (scalar_to_vector GR32:$src)),
2233 MOVL_shuffle_mask)))]>;
2234let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002235def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(set VR128:$dst,
2238 (v4i32 (vector_shuffle immAllZerosV,
2239 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2240 MOVL_shuffle_mask)))]>;
2241
2242// Moving from XMM to XMM but still clear upper 64 bits.
2243let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002244def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2247 XS, Requires<[HasSSE2]>;
2248let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002249def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002252 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 XS, Requires<[HasSSE2]>;
2254
2255
2256//===----------------------------------------------------------------------===//
2257// SSE3 Instructions
2258//===----------------------------------------------------------------------===//
2259
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002261def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(set VR128:$dst, (v4f32 (vector_shuffle
2264 VR128:$src, (undef),
2265 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002266def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002269 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 MOVSHDUP_shuffle_mask)))]>;
2271
Evan Chengb783fa32007-07-19 01:14:50 +00002272def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 [(set VR128:$dst, (v4f32 (vector_shuffle
2275 VR128:$src, (undef),
2276 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002277def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002280 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 MOVSLDUP_shuffle_mask)))]>;
2282
Evan Chengb783fa32007-07-19 01:14:50 +00002283def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 [(set VR128:$dst, (v2f64 (vector_shuffle
2286 VR128:$src, (undef),
2287 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002288def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(set VR128:$dst,
2291 (v2f64 (vector_shuffle
2292 (scalar_to_vector (loadf64 addr:$src)),
2293 (undef),
2294 SSE_splat_lo_mask)))]>;
2295
2296// Arithmetic
2297let isTwoAddress = 1 in {
2298 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002299 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2302 VR128:$src2))]>;
2303 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002304 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2307 (load addr:$src2)))]>;
2308 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002309 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002310 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2312 VR128:$src2))]>;
2313 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002314 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2317 (load addr:$src2)))]>;
2318}
2319
Evan Chengb783fa32007-07-19 01:14:50 +00002320def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2323
2324// Horizontal ops
2325class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002326 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2329class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002330 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002332 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2333class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002334 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002335 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2337class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002338 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2341
2342let isTwoAddress = 1 in {
2343 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2344 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2345 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2346 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2347 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2348 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2349 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2350 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2351}
2352
2353// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002354def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002356def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2358
2359// vector_shuffle v1, <undef> <1, 1, 3, 3>
2360let AddedComplexity = 15 in
2361def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2362 MOVSHDUP_shuffle_mask)),
2363 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2364let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002365def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 MOVSHDUP_shuffle_mask)),
2367 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2368
2369// vector_shuffle v1, <undef> <0, 0, 2, 2>
2370let AddedComplexity = 15 in
2371 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2372 MOVSLDUP_shuffle_mask)),
2373 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2374let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002375 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376 MOVSLDUP_shuffle_mask)),
2377 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2378
2379//===----------------------------------------------------------------------===//
2380// SSSE3 Instructions
2381//===----------------------------------------------------------------------===//
2382
Bill Wendling3b15d722007-08-11 09:52:53 +00002383// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384//
Bill Wendling98680292007-08-10 06:22:27 +00002385// SS38I - SSSE3 instructions with T8 prefix.
2386// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002387//
2388// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2389// uses the MMX registers. We put those instructions here because they better
2390// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391
Evan Chengb783fa32007-07-19 01:14:50 +00002392class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2393 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002394 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002395class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2396 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002397 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
Bill Wendling98680292007-08-10 06:22:27 +00002399/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002401 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2402 Intrinsic IntId64, Intrinsic IntId128,
2403 bit Commutable = 0> {
2404 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2405 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2406 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407 let isCommutable = Commutable;
2408 }
Bill Wendling98680292007-08-10 06:22:27 +00002409 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2410 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2411 [(set VR64:$dst,
2412 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2413
2414 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2415 (ins VR128:$src),
2416 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2417 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2418 OpSize {
2419 let isCommutable = Commutable;
2420 }
2421 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2422 (ins i128mem:$src),
2423 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2424 [(set VR128:$dst,
2425 (IntId128
2426 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427 }
2428}
2429
Bill Wendling98680292007-08-10 06:22:27 +00002430/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2431let isTwoAddress = 1 in {
2432 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2433 Intrinsic IntId64, Intrinsic IntId128,
2434 bit Commutable = 0> {
2435 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2436 (ins VR64:$src),
2437 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2438 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2439 let isCommutable = Commutable;
2440 }
2441 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2442 (ins i64mem:$src),
2443 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2444 [(set VR64:$dst,
2445 (IntId64
2446 (bitconvert (memopv4i16 addr:$src))))]>;
2447
2448 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2449 (ins VR128:$src),
2450 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2451 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2452 OpSize {
2453 let isCommutable = Commutable;
2454 }
2455 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2456 (ins i128mem:$src),
2457 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2458 [(set VR128:$dst,
2459 (IntId128
2460 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2461 }
2462}
2463
2464/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2465let isTwoAddress = 1 in {
2466 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2467 Intrinsic IntId64, Intrinsic IntId128,
2468 bit Commutable = 0> {
2469 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2470 (ins VR64:$src),
2471 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2472 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2473 let isCommutable = Commutable;
2474 }
2475 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2476 (ins i64mem:$src),
2477 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2478 [(set VR64:$dst,
2479 (IntId64
2480 (bitconvert (memopv2i32 addr:$src))))]>;
2481
2482 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2483 (ins VR128:$src),
2484 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2485 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2486 OpSize {
2487 let isCommutable = Commutable;
2488 }
2489 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2490 (ins i128mem:$src),
2491 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2492 [(set VR128:$dst,
2493 (IntId128
2494 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2495 }
2496}
2497
2498defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2499 int_x86_ssse3_pabs_b,
2500 int_x86_ssse3_pabs_b_128>;
2501defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2502 int_x86_ssse3_pabs_w,
2503 int_x86_ssse3_pabs_w_128>;
2504defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2505 int_x86_ssse3_pabs_d,
2506 int_x86_ssse3_pabs_d_128>;
2507
2508/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2509let isTwoAddress = 1 in {
2510 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2511 Intrinsic IntId64, Intrinsic IntId128,
2512 bit Commutable = 0> {
2513 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2514 (ins VR64:$src1, VR64:$src2),
2515 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2516 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2517 let isCommutable = Commutable;
2518 }
2519 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2520 (ins VR64:$src1, i64mem:$src2),
2521 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2522 [(set VR64:$dst,
2523 (IntId64 VR64:$src1,
2524 (bitconvert (memopv8i8 addr:$src2))))]>;
2525
2526 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2527 (ins VR128:$src1, VR128:$src2),
2528 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2529 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2530 OpSize {
2531 let isCommutable = Commutable;
2532 }
2533 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2534 (ins VR128:$src1, i128mem:$src2),
2535 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2536 [(set VR128:$dst,
2537 (IntId128 VR128:$src1,
2538 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2539 }
2540}
2541
2542/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2543let isTwoAddress = 1 in {
2544 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2545 Intrinsic IntId64, Intrinsic IntId128,
2546 bit Commutable = 0> {
2547 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2548 (ins VR64:$src1, VR64:$src2),
2549 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2550 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2551 let isCommutable = Commutable;
2552 }
2553 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2554 (ins VR64:$src1, i64mem:$src2),
2555 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2556 [(set VR64:$dst,
2557 (IntId64 VR64:$src1,
2558 (bitconvert (memopv4i16 addr:$src2))))]>;
2559
2560 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2561 (ins VR128:$src1, VR128:$src2),
2562 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2563 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2564 OpSize {
2565 let isCommutable = Commutable;
2566 }
2567 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2568 (ins VR128:$src1, i128mem:$src2),
2569 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2570 [(set VR128:$dst,
2571 (IntId128 VR128:$src1,
2572 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2573 }
2574}
2575
2576/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2577let isTwoAddress = 1 in {
2578 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2579 Intrinsic IntId64, Intrinsic IntId128,
2580 bit Commutable = 0> {
2581 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2582 (ins VR64:$src1, VR64:$src2),
2583 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2584 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2585 let isCommutable = Commutable;
2586 }
2587 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2588 (ins VR64:$src1, i64mem:$src2),
2589 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2590 [(set VR64:$dst,
2591 (IntId64 VR64:$src1,
2592 (bitconvert (memopv2i32 addr:$src2))))]>;
2593
2594 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2595 (ins VR128:$src1, VR128:$src2),
2596 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2597 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2598 OpSize {
2599 let isCommutable = Commutable;
2600 }
2601 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2602 (ins VR128:$src1, i128mem:$src2),
2603 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2604 [(set VR128:$dst,
2605 (IntId128 VR128:$src1,
2606 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2607 }
2608}
2609
2610defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2611 int_x86_ssse3_phadd_w,
2612 int_x86_ssse3_phadd_w_128, 1>;
2613defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2614 int_x86_ssse3_phadd_d,
2615 int_x86_ssse3_phadd_d_128, 1>;
2616defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2617 int_x86_ssse3_phadd_sw,
2618 int_x86_ssse3_phadd_sw_128, 1>;
2619defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2620 int_x86_ssse3_phsub_w,
2621 int_x86_ssse3_phsub_w_128>;
2622defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2623 int_x86_ssse3_phsub_d,
2624 int_x86_ssse3_phsub_d_128>;
2625defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2626 int_x86_ssse3_phsub_sw,
2627 int_x86_ssse3_phsub_sw_128>;
2628defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2629 int_x86_ssse3_pmadd_ub_sw,
2630 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2631defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2632 int_x86_ssse3_pmul_hr_sw,
2633 int_x86_ssse3_pmul_hr_sw_128, 1>;
2634defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2635 int_x86_ssse3_pshuf_b,
2636 int_x86_ssse3_pshuf_b_128>;
2637defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2638 int_x86_ssse3_psign_b,
2639 int_x86_ssse3_psign_b_128>;
2640defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2641 int_x86_ssse3_psign_w,
2642 int_x86_ssse3_psign_w_128>;
2643defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2644 int_x86_ssse3_psign_d,
2645 int_x86_ssse3_psign_d_128>;
2646
2647let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002648 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2649 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002650 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002651 [(set VR64:$dst,
2652 (int_x86_ssse3_palign_r
2653 VR64:$src1, VR64:$src2,
2654 imm:$src3))]>;
2655 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2656 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002657 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002658 [(set VR64:$dst,
2659 (int_x86_ssse3_palign_r
2660 VR64:$src1,
2661 (bitconvert (memopv2i32 addr:$src2)),
2662 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002663
Bill Wendling1dc817c2007-08-10 09:00:17 +00002664 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2665 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002666 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002667 [(set VR128:$dst,
2668 (int_x86_ssse3_palign_r_128
2669 VR128:$src1, VR128:$src2,
2670 imm:$src3))]>, OpSize;
2671 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2672 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002673 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002674 [(set VR128:$dst,
2675 (int_x86_ssse3_palign_r_128
2676 VR128:$src1,
2677 (bitconvert (memopv4i32 addr:$src2)),
2678 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002679}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002680
2681//===----------------------------------------------------------------------===//
2682// Non-Instruction Patterns
2683//===----------------------------------------------------------------------===//
2684
2685// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002686def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002687def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2688def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2689def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2690def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2691def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2692
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2694// 16-bits matter.
2695def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2696 Requires<[HasSSE2]>;
2697def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2698 Requires<[HasSSE2]>;
2699
2700// bit_convert
2701let Predicates = [HasSSE2] in {
2702 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2703 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2704 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2705 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2706 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2707 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2708 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2709 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2710 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2711 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2712 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2713 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2714 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2715 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2716 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2717 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2718 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2719 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2720 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2721 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2722 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2723 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2724 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2725 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2726 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2727 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2728 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2729 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2730 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2731 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2732}
2733
2734// Move scalar to XMM zero-extended
2735// movd to XMM register zero-extends
2736let AddedComplexity = 15 in {
Chris Lattnere6aa3862007-11-25 00:24:49 +00002737def : Pat<(v8i16 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2739 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002740def : Pat<(v16i8 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2742 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2743// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Chris Lattnere6aa3862007-11-25 00:24:49 +00002744def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002745 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2746 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002747def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2749 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2750}
2751
2752// Splat v2f64 / v2i64
2753let AddedComplexity = 10 in {
2754def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2755 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2756def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2757 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2758def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2759 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2760def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2761 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2762}
2763
2764// Splat v4f32
2765def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2766 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2767 Requires<[HasSSE1]>;
2768
2769// Special unary SHUFPSrri case.
2770// FIXME: when we want non two-address code, then we should use PSHUFD?
2771def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2772 SHUFP_unary_shuffle_mask:$sm),
2773 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2774 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002775// Special unary SHUFPDrri case.
2776def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2777 SHUFP_unary_shuffle_mask:$sm),
2778 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2779 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002781def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002782 SHUFP_unary_shuffle_mask:$sm),
2783 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2784 Requires<[HasSSE2]>;
2785// Special binary v4i32 shuffle cases with SHUFPS.
2786def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2787 PSHUFD_binary_shuffle_mask:$sm),
2788 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2789 Requires<[HasSSE2]>;
2790def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002791 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2793 Requires<[HasSSE2]>;
2794
2795// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2796let AddedComplexity = 10 in {
2797def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2798 UNPCKL_v_undef_shuffle_mask)),
2799 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2800def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2801 UNPCKL_v_undef_shuffle_mask)),
2802 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2803def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2804 UNPCKL_v_undef_shuffle_mask)),
2805 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2806def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2807 UNPCKL_v_undef_shuffle_mask)),
2808 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2809}
2810
2811// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2812let AddedComplexity = 10 in {
2813def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2814 UNPCKH_v_undef_shuffle_mask)),
2815 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2816def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2817 UNPCKH_v_undef_shuffle_mask)),
2818 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2819def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2820 UNPCKH_v_undef_shuffle_mask)),
2821 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2822def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2823 UNPCKH_v_undef_shuffle_mask)),
2824 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2825}
2826
2827let AddedComplexity = 15 in {
2828// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2829def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2830 MOVHP_shuffle_mask)),
2831 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2832
2833// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2834def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2835 MOVHLPS_shuffle_mask)),
2836 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2837
2838// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2839def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2840 MOVHLPS_v_undef_shuffle_mask)),
2841 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2842def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2843 MOVHLPS_v_undef_shuffle_mask)),
2844 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2845}
2846
2847let AddedComplexity = 20 in {
2848// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2849// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002850def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851 MOVLP_shuffle_mask)),
2852 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002853def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854 MOVLP_shuffle_mask)),
2855 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002856def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857 MOVHP_shuffle_mask)),
2858 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002859def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002860 MOVHP_shuffle_mask)),
2861 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2862
Dan Gohman4a4f1512007-07-18 20:23:34 +00002863def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002864 MOVLP_shuffle_mask)),
2865 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002866def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002867 MOVLP_shuffle_mask)),
2868 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002869def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870 MOVHP_shuffle_mask)),
2871 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002872def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873 MOVLP_shuffle_mask)),
2874 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2875}
2876
2877let AddedComplexity = 15 in {
2878// Setting the lowest element in the vector.
2879def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2880 MOVL_shuffle_mask)),
2881 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2882def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2883 MOVL_shuffle_mask)),
2884 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2885
2886// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2887def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2888 MOVLP_shuffle_mask)),
2889 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2890def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2891 MOVLP_shuffle_mask)),
2892 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2893}
2894
2895// Set lowest element and zero upper elements.
2896let AddedComplexity = 20 in
Chris Lattnere6aa3862007-11-25 00:24:49 +00002897def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2899 MOVL_shuffle_mask)),
2900 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2901
2902// FIXME: Temporary workaround since 2-wide shuffle is broken.
2903def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2904 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2905def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2906 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2907def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2908 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2909def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2910 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2911 Requires<[HasSSE2]>;
2912def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2913 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2914 Requires<[HasSSE2]>;
2915def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2916 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2917def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2918 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2919def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2920 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2921def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2922 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2923def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2924 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2925def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2926 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2927def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2928 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2929def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2930 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2931
2932// Some special case pandn patterns.
2933def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2934 VR128:$src2)),
2935 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2936def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2937 VR128:$src2)),
2938 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2939def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2940 VR128:$src2)),
2941 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2942
2943def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002944 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2946def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002947 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2949def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002950 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2952
Nate Begeman78246ca2007-11-17 03:58:34 +00002953// vector -> vector casts
2954def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
2955 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
2956def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
2957 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
2958
Evan Cheng51a49b22007-07-20 00:27:43 +00002959// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002960def : Pat<(alignedloadv4i32 addr:$src),
2961 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2962def : Pat<(loadv4i32 addr:$src),
2963 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002964def : Pat<(alignedloadv2i64 addr:$src),
2965 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2966def : Pat<(loadv2i64 addr:$src),
2967 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2968
2969def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2970 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2971def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2972 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2973def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2974 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2975def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2976 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2977def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2978 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2979def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2980 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2981def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2982 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2983def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2984 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;