blob: e207598144140100c177a3628bb768ac5c976a65 [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Eric Christopher44b93ff2009-07-31 20:07:27 +00002//
Evan Chengffcb95b2006-02-21 19:13:53 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Eric Christopher44b93ff2009-07-31 20:07:27 +00007//
Evan Chengffcb95b2006-02-21 19:13:53 +00008//===----------------------------------------------------------------------===//
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
Chris Lattner3a7cd952006-10-07 21:55:32 +000016
Evan Cheng4e4c71e2006-02-21 20:00:20 +000017//===----------------------------------------------------------------------===//
Evan Cheng2246f842006-03-18 01:23:20 +000018// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
Evan Cheng68c47cb2007-01-05 07:55:56 +000021def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
Nate Begeman30a0de92008-07-17 16:51:19 +000023def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000025
Evan Cheng8ca29322006-11-10 21:43:37 +000026def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
Evan Cheng6be2c582006-04-05 23:38:46 +000028def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
Evan Chengb9df0ca2006-03-22 02:53:00 +000029 [SDNPCommutative, SDNPAssociative]>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000030def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
Evan Cheng6be2c582006-04-05 23:38:46 +000032def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
Evan Chengb9df0ca2006-03-22 02:53:00 +000033 [SDNPCommutative, SDNPAssociative]>;
Dan Gohman20382522007-07-10 00:05:58 +000034def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000036def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengfef922a2007-10-01 18:12:48 +000037def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Chenge5f62042007-09-29 00:00:36 +000038def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000039def X86pshufb : SDNode<"X86ISD::PSHUFB",
Nate Begemanb9a47b82009-02-23 08:49:38 +000040 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
41 SDTCisSameAs<0,2>]>>;
Nate Begeman14d12ca2008-02-11 04:19:36 +000042def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000046def X86pinsrb : SDNode<"X86ISD::PINSRB",
Nate Begeman14d12ca2008-02-11 04:19:36 +000047 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000049def X86pinsrw : SDNode<"X86ISD::PINSRW",
Nate Begeman14d12ca2008-02-11 04:19:36 +000050 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000052def X86insrtps : SDNode<"X86ISD::INSERTPS",
Nate Begeman14d12ca2008-02-11 04:19:36 +000053 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
Eric Christopherfbd66872009-07-24 00:33:09 +000054 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
Evan Chengd880b972008-05-09 21:53:03 +000055def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
Evan Chengf26ffe92008-05-29 08:22:04 +000059def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
Nate Begeman30a0de92008-07-17 16:51:19 +000061def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
Evan Chengc60bd972006-03-25 09:37:23 +000071
Chris Lattnerd486d772010-03-28 05:07:17 +000072def SDTX86CmpPTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>,
73 SDTCisVT<1, v4f32>,
74 SDTCisVT<2, v4f32>]>;
Eric Christopher71c67532009-07-29 00:28:05 +000075def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
76
Evan Cheng2246f842006-03-18 01:23:20 +000077//===----------------------------------------------------------------------===//
Chris Lattner3a7cd952006-10-07 21:55:32 +000078// SSE Complex Patterns
79//===----------------------------------------------------------------------===//
80
81// These are 'extloads' from a scalar to the low element of a vector, zeroing
82// the top elements. These are used for the SSE 'ss' and 'sd' instruction
83// forms.
Rafael Espindola094fad32009-04-08 21:14:34 +000084def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000085 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindola094fad32009-04-08 21:14:34 +000086def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000087 [SDNPHasChain, SDNPMayLoad]>;
Chris Lattner3a7cd952006-10-07 21:55:32 +000088
89def ssmem : Operand<v4f32> {
90 let PrintMethod = "printf32mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000091 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000092 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000093}
94def sdmem : Operand<v2f64> {
95 let PrintMethod = "printf64mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000096 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000097 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000098}
99
100//===----------------------------------------------------------------------===//
Evan Cheng06a8aa12006-03-17 19:55:52 +0000101// SSE pattern fragments
102//===----------------------------------------------------------------------===//
103
Evan Cheng2246f842006-03-18 01:23:20 +0000104def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
105def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
Dan Gohman01976302007-06-25 15:19:03 +0000106def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
Evan Cheng24dc1f52006-03-23 07:44:07 +0000107def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000108
Dan Gohmand3006222007-07-27 17:16:43 +0000109// Like 'store', but always requires vector alignment.
Dan Gohman4106f372007-07-18 20:23:34 +0000110def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000111 (store node:$val, node:$ptr), [{
112 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000113}]>;
114
Dan Gohmand3006222007-07-27 17:16:43 +0000115// Like 'load', but always requires vector alignment.
Dan Gohman33586292008-10-15 06:50:19 +0000116def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
117 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000118}]>;
119
Sean Callanan108934c2009-12-18 00:01:26 +0000120def alignedloadfsf32 : PatFrag<(ops node:$ptr),
121 (f32 (alignedload node:$ptr))>;
122def alignedloadfsf64 : PatFrag<(ops node:$ptr),
123 (f64 (alignedload node:$ptr))>;
124def alignedloadv4f32 : PatFrag<(ops node:$ptr),
125 (v4f32 (alignedload node:$ptr))>;
126def alignedloadv2f64 : PatFrag<(ops node:$ptr),
127 (v2f64 (alignedload node:$ptr))>;
128def alignedloadv4i32 : PatFrag<(ops node:$ptr),
129 (v4i32 (alignedload node:$ptr))>;
130def alignedloadv2i64 : PatFrag<(ops node:$ptr),
131 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000132
133// Like 'load', but uses special alignment checks suitable for use in
134// memory operands in most SSE instructions, which are required to
David Greene95eb2ee2010-01-11 16:29:42 +0000135// be naturally aligned on some targets but not on others. If the subtarget
136// allows unaligned accesses, match any load, though this may require
137// setting a feature bit in the processor (on startup, for example).
138// Opteron 10h and later implement such a feature.
Dan Gohman33586292008-10-15 06:50:19 +0000139def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
David Greene95eb2ee2010-01-11 16:29:42 +0000140 return Subtarget->hasVectorUAMem()
141 || cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000142}]>;
143
Dan Gohmand3006222007-07-27 17:16:43 +0000144def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
145def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000146def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
147def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
148def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
149def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begemanfea2be52008-02-09 23:46:37 +0000150def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000151
Bill Wendling01284b42007-08-11 09:52:53 +0000152// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
153// 16-byte boundary.
Nate Begemanfea2be52008-02-09 23:46:37 +0000154// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohmana7250dd2008-10-16 00:03:00 +0000155def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman33586292008-10-15 06:50:19 +0000156 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling01284b42007-08-11 09:52:53 +0000157}]>;
158
159def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling01284b42007-08-11 09:52:53 +0000160def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
161def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
162def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
163
David Greene8939b0d2010-02-16 20:50:18 +0000164// MOVNT Support
165// Like 'store', but requires the non-temporal bit to be set
166def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
167 (st node:$val, node:$ptr), [{
168 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
169 return ST->isNonTemporal();
170 return false;
171}]>;
172
173def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
174 (st node:$val, node:$ptr), [{
175 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
176 return ST->isNonTemporal() && !ST->isTruncatingStore() &&
177 ST->getAddressingMode() == ISD::UNINDEXED &&
178 ST->getAlignment() >= 16;
179 return false;
180}]>;
181
182def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
183 (st node:$val, node:$ptr), [{
184 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
185 return ST->isNonTemporal() &&
186 ST->getAlignment() < 16;
187 return false;
188}]>;
189
Evan Cheng1b32f222006-03-30 07:33:32 +0000190def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
191def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
Evan Cheng506d3df2006-03-29 23:07:14 +0000192def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
193def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
Evan Cheng5aa97b22006-03-29 18:47:40 +0000194def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
195def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
196
Evan Chengca57f782008-09-24 23:27:55 +0000197def vzmovl_v2i64 : PatFrag<(ops node:$src),
198 (bitconvert (v2i64 (X86vzmovl
199 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
200def vzmovl_v4i32 : PatFrag<(ops node:$src),
201 (bitconvert (v4i32 (X86vzmovl
202 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
203
204def vzload_v2i64 : PatFrag<(ops node:$src),
205 (bitconvert (v2i64 (X86vzload node:$src)))>;
206
207
Evan Cheng386031a2006-03-24 07:29:27 +0000208def fp32imm0 : PatLeaf<(f32 fpimm), [{
209 return N->isExactlyValue(+0.0);
210}]>;
211
Evan Cheng89321162009-10-28 06:30:34 +0000212// BYTE_imm - Transform bit immediates into byte immediates.
213def BYTE_imm : SDNodeXForm<imm, [{
Evan Chengff65e382006-04-04 21:49:39 +0000214 // Transformation function: imm >> 3
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000215 return getI32Imm(N->getZExtValue() >> 3);
Evan Chengff65e382006-04-04 21:49:39 +0000216}]>;
217
Evan Cheng63d33002006-03-22 08:01:21 +0000218// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
219// SHUFP* etc. imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000220def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng63d33002006-03-22 08:01:21 +0000221 return getI8Imm(X86::getShuffleSHUFImmediate(N));
Evan Chengb9df0ca2006-03-22 02:53:00 +0000222}]>;
223
Eric Christopher44b93ff2009-07-31 20:07:27 +0000224// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000225// PSHUFHW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000226def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000227 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
228}]>;
229
Eric Christopher44b93ff2009-07-31 20:07:27 +0000230// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000231// PSHUFLW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000232def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000233 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
234}]>;
235
Nate Begemana09008b2009-10-19 02:17:23 +0000236// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
237// a PALIGNR imm.
238def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
239 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
240}]>;
241
Nate Begeman9008ca62009-04-27 18:41:29 +0000242def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
243 (vector_shuffle node:$lhs, node:$rhs), [{
244 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
245 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
246}]>;
247
248def movddup : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
251}]>;
252
253def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
254 (vector_shuffle node:$lhs, node:$rhs), [{
255 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
256}]>;
257
258def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
259 (vector_shuffle node:$lhs, node:$rhs), [{
260 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
261}]>;
262
Nate Begeman0b10b912009-11-07 23:17:15 +0000263def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
264 (vector_shuffle node:$lhs, node:$rhs), [{
265 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman9008ca62009-04-27 18:41:29 +0000266}]>;
267
268def movlp : PatFrag<(ops node:$lhs, node:$rhs),
269 (vector_shuffle node:$lhs, node:$rhs), [{
270 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
271}]>;
272
273def movl : PatFrag<(ops node:$lhs, node:$rhs),
274 (vector_shuffle node:$lhs, node:$rhs), [{
275 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
276}]>;
277
278def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
279 (vector_shuffle node:$lhs, node:$rhs), [{
280 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
281}]>;
282
283def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
284 (vector_shuffle node:$lhs, node:$rhs), [{
285 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
286}]>;
287
288def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
289 (vector_shuffle node:$lhs, node:$rhs), [{
290 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
291}]>;
292
293def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
294 (vector_shuffle node:$lhs, node:$rhs), [{
295 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
296}]>;
297
298def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
299 (vector_shuffle node:$lhs, node:$rhs), [{
300 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
301}]>;
302
303def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
304 (vector_shuffle node:$lhs, node:$rhs), [{
305 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
306}]>;
307
308def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
309 (vector_shuffle node:$lhs, node:$rhs), [{
310 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng691c9232006-03-29 19:02:40 +0000311}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000312
Nate Begeman9008ca62009-04-27 18:41:29 +0000313def shufp : PatFrag<(ops node:$lhs, node:$rhs),
314 (vector_shuffle node:$lhs, node:$rhs), [{
315 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng14aed5e2006-03-24 01:18:28 +0000316}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000317
Nate Begeman9008ca62009-04-27 18:41:29 +0000318def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
319 (vector_shuffle node:$lhs, node:$rhs), [{
320 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000321}], SHUFFLE_get_pshufhw_imm>;
322
Nate Begeman9008ca62009-04-27 18:41:29 +0000323def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
324 (vector_shuffle node:$lhs, node:$rhs), [{
325 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000326}], SHUFFLE_get_pshuflw_imm>;
327
Nate Begemana09008b2009-10-19 02:17:23 +0000328def palign : PatFrag<(ops node:$lhs, node:$rhs),
329 (vector_shuffle node:$lhs, node:$rhs), [{
330 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
331}], SHUFFLE_get_palign_imm>;
332
Evan Cheng06a8aa12006-03-17 19:55:52 +0000333//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000334// SSE scalar FP Instructions
335//===----------------------------------------------------------------------===//
336
Dan Gohman533297b2009-10-29 18:10:34 +0000337// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
338// instruction selection into a branch sequence.
339let Uses = [EFLAGS], usesCustomInserter = 1 in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000340 def CMOV_FR32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000341 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000342 "#CMOV_FR32 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000343 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
344 EFLAGS))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000345 def CMOV_FR64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000346 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000347 "#CMOV_FR64 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000348 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
349 EFLAGS))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000350 def CMOV_V4F32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000351 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000352 "#CMOV_V4F32 PSEUDO!",
353 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000354 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
355 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000356 def CMOV_V2F64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000357 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000358 "#CMOV_V2F64 PSEUDO!",
359 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000360 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
361 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000362 def CMOV_V2I64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000363 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000364 "#CMOV_V2I64 PSEUDO!",
365 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000366 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng0488db92007-09-25 01:57:46 +0000367 EFLAGS)))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000368}
369
Bill Wendlingddd35322007-05-02 23:11:52 +0000370//===----------------------------------------------------------------------===//
371// SSE1 Instructions
372//===----------------------------------------------------------------------===//
373
Dan Gohman874cada2010-02-28 00:17:42 +0000374// Move Instructions. Register-to-register movss is not used for FR32
375// register copies because it's a partial register update; FsMOVAPSrr is
376// used instead. Register-to-register movss is not modeled as an INSERT_SUBREG
377// because INSERT_SUBREG requires that the insert be implementable in terms of
378// a copy, and just mentioned, we don't use movss for copies.
379let Constraints = "$src1 = $dst" in
380def MOVSSrr : SSI<0x10, MRMSrcReg,
381 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
382 "movss\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +0000383 [(set (v4f32 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +0000384 (movl VR128:$src1, (scalar_to_vector FR32:$src2)))]>;
385
386// Extract the low 32-bit value from one vector and insert it into another.
387let AddedComplexity = 15 in
388def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +0000389 (MOVSSrr (v4f32 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +0000390 (EXTRACT_SUBREG (v4f32 VR128:$src2), x86_subreg_ss))>;
391
392// Implicitly promote a 32-bit scalar to a vector.
393def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
394 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, x86_subreg_ss)>;
395
396// Loading from memory automatically zeroing upper bits.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000397let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000398def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000399 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000400 [(set FR32:$dst, (loadf32 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +0000401
402// MOVSSrm zeros the high parts of the register; represent this
403// with SUBREG_TO_REG.
404let AddedComplexity = 20 in {
405def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
406 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
407def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
408 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
409def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
410 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
411}
412
413// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +0000414def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000415 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000416 [(store FR32:$src, addr:$dst)]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000417
Dan Gohman874cada2010-02-28 00:17:42 +0000418// Extract and store.
419def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
420 addr:$dst),
421 (MOVSSmr addr:$dst,
422 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
423
Evan Chengc46349d2006-03-28 23:51:43 +0000424// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +0000425def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000426 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000427 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000428def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000429 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000430 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000431def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000432 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000433 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000434def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000435 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000436 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
Evan Chengc46349d2006-03-28 23:51:43 +0000437
Evan Chengd2a6d542006-04-12 23:42:44 +0000438// Match intrinsics which expect XMM operand(s).
Sean Callanan108934c2009-12-18 00:01:26 +0000439def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
440 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
441def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
442 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
443
Evan Cheng64d80e32007-07-19 01:14:50 +0000444def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000445 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000446 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000447def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000448 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000449 [(set GR32:$dst, (int_x86_sse_cvtss2si
450 (load addr:$src)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000451
Dale Johannesenc7842082007-10-30 22:15:38 +0000452// Match intrinisics which expect MM and XMM operand(s).
453def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
454 "cvtps2pi\t{$src, $dst|$dst, $src}",
455 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
456def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
457 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000458 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000459 (load addr:$src)))]>;
460def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
461 "cvttps2pi\t{$src, $dst|$dst, $src}",
462 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
463def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
464 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000465 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000466 (load addr:$src)))]>;
Evan Chenge9083d62008-03-05 08:19:16 +0000467let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000468 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesenc7842082007-10-30 22:15:38 +0000469 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
470 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
471 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
472 VR64:$src2))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000473 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesenc7842082007-10-30 22:15:38 +0000474 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
475 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000476 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesenc7842082007-10-30 22:15:38 +0000477 (load addr:$src2)))]>;
478}
479
Evan Chengd2a6d542006-04-12 23:42:44 +0000480// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +0000481def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000482 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000483 [(set GR32:$dst,
484 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000485def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000486 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000487 [(set GR32:$dst,
488 (int_x86_sse_cvttss2si(load addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +0000489
Evan Chenge9083d62008-03-05 08:19:16 +0000490let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000491 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000492 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000493 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000494 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
495 GR32:$src2))]>;
496 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000497 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000498 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000499 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
500 (loadi32 addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000501}
Evan Chengd03db7a2006-04-12 05:20:24 +0000502
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000503// Comparison instructions
Dan Gohmanb1347092009-01-09 02:27:34 +0000504let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000505 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000506 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000507 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000508let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +0000509 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000510 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000511 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000512}
513
Evan Cheng24f2ea32007-09-14 21:48:26 +0000514let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000515def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000516 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000517 [(set EFLAGS, (X86cmp FR32:$src1, FR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000518def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000519 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000520 [(set EFLAGS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000521
522def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
523 "comiss\t{$src2, $src1|$src1, $src2}", []>;
524def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
525 "comiss\t{$src2, $src1|$src1, $src2}", []>;
526
Evan Cheng24f2ea32007-09-14 21:48:26 +0000527} // Defs = [EFLAGS]
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000528
Evan Cheng0876aa52006-03-30 06:21:22 +0000529// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +0000530let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000531 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +0000532 (outs VR128:$dst),
533 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000534 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +0000535 [(set VR128:$dst, (int_x86_sse_cmp_ss
536 VR128:$src1,
537 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000538 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +0000539 (outs VR128:$dst),
540 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000541 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000542 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
543 (load addr:$src), imm:$cc))]>;
Evan Cheng0876aa52006-03-30 06:21:22 +0000544}
545
Evan Cheng24f2ea32007-09-14 21:48:26 +0000546let Defs = [EFLAGS] in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000547def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000548 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000549 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
550 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000551def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000552 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000553 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
554 (load addr:$src2)))]>;
Evan Cheng0488db92007-09-25 01:57:46 +0000555
Dan Gohmanb1347092009-01-09 02:27:34 +0000556def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000557 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000558 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
559 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000560def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000561 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000562 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
563 (load addr:$src2)))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000564} // Defs = [EFLAGS]
Evan Cheng0876aa52006-03-30 06:21:22 +0000565
Eric Christopher44b93ff2009-07-31 20:07:27 +0000566// Aliases of packed SSE1 instructions for scalar use. These all have names
567// that start with 'Fs'.
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000568
569// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +0000570let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
571 canFoldAsLoad = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +0000572 // FIXME: Set encoding to pseudo!
Chris Lattnerbe1778f2010-02-05 21:34:18 +0000573def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
574 [(set FR32:$dst, fp32imm0)]>,
575 Requires<[HasSSE1]>, TB, OpSize;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000576
Bill Wendlingddd35322007-05-02 23:11:52 +0000577// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
578// disregarded.
Eric Christopher44b93ff2009-07-31 20:07:27 +0000579let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000580def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000581 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000582
Bill Wendlingddd35322007-05-02 23:11:52 +0000583// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
584// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000585let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000586def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000587 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +0000588 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000589
590// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +0000591let Constraints = "$src1 = $dst" in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000592let isCommutable = 1 in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000593 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
594 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000595 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000596 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000597 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
598 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000599 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000600 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000601 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
602 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000603 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000604 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000605}
Bill Wendlingddd35322007-05-02 23:11:52 +0000606
Dan Gohmanb1347092009-01-09 02:27:34 +0000607def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
608 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000609 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000610 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000611 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000612def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
613 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000614 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000615 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000616 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000617def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
618 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000619 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000620 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000621 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000622
Chris Lattnerba7e7562008-01-10 07:59:24 +0000623let neverHasSideEffects = 1 in {
Dan Gohman32791e02007-06-25 15:44:19 +0000624def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000625 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000626 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000627let mayLoad = 1 in
Dan Gohman32791e02007-06-25 15:44:19 +0000628def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000629 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000630 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000631}
Chris Lattnerba7e7562008-01-10 07:59:24 +0000632}
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000633
Dan Gohman20382522007-07-10 00:05:58 +0000634/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000635///
Dan Gohman20382522007-07-10 00:05:58 +0000636/// In addition, we also have a special variant of the scalar form here to
637/// represent the associated intrinsic operation. This form is unlike the
638/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +0000639/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +0000640///
641/// These three forms can each be reg+reg or reg+mem, so there are a total of
642/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +0000643///
Evan Chenge9083d62008-03-05 08:19:16 +0000644let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000645multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
646 SDNode OpNode, Intrinsic F32Int,
647 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000648 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000649 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000650 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman32791e02007-06-25 15:44:19 +0000651 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000652 let isCommutable = Commutable;
653 }
654
655 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000656 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
657 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000658 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000659 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000660
Dan Gohman20382522007-07-10 00:05:58 +0000661 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000662 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
663 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000664 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000665 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
666 let isCommutable = Commutable;
667 }
668
669 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000670 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
671 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000672 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000673 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000674
675 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000676 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
677 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000678 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +0000679 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000680
Dan Gohman20382522007-07-10 00:05:58 +0000681 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000682 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
683 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000684 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000685 [(set VR128:$dst, (F32Int VR128:$src1,
686 sse_load_f32:$src2))]>;
687}
688}
689
690// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +0000691defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
692defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
693defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
694defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000695
Dan Gohman20382522007-07-10 00:05:58 +0000696/// sse1_fp_binop_rm - Other SSE1 binops
697///
698/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
699/// instructions for a full-vector intrinsic form. Operations that map
700/// onto C operators don't use this form since they just use the plain
701/// vector form instead of having a separate vector intrinsic form.
702///
703/// This provides a total of eight "instructions".
704///
Evan Chenge9083d62008-03-05 08:19:16 +0000705let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000706multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
707 SDNode OpNode,
708 Intrinsic F32Int,
709 Intrinsic V4F32Int,
710 bit Commutable = 0> {
711
712 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000713 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000714 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000715 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
716 let isCommutable = Commutable;
717 }
718
719 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000720 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
721 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000722 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000723 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000724
Dan Gohman20382522007-07-10 00:05:58 +0000725 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000726 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
727 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000728 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000729 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
730 let isCommutable = Commutable;
731 }
732
733 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000734 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
735 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000736 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000737 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000738
739 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000740 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
741 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000742 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000743 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
744 let isCommutable = Commutable;
745 }
746
747 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000748 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
749 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000750 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000751 [(set VR128:$dst, (F32Int VR128:$src1,
752 sse_load_f32:$src2))]>;
753
754 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000755 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
756 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000757 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000758 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
759 let isCommutable = Commutable;
760 }
761
762 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000763 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
764 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000765 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000766 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000767}
768}
769
770defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
771 int_x86_sse_max_ss, int_x86_sse_max_ps>;
772defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
773 int_x86_sse_min_ss, int_x86_sse_min_ps>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000774
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000775//===----------------------------------------------------------------------===//
Evan Cheng9ab1ac52006-04-14 23:32:40 +0000776// SSE packed FP Instructions
Evan Chengc12e6c42006-03-19 09:38:54 +0000777
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000778// Move Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +0000779let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000780def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000781 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000782let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000783def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000784 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000785 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000786
Evan Cheng64d80e32007-07-19 01:14:50 +0000787def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000788 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000789 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000790
Chris Lattnerf77e0372008-01-11 06:59:07 +0000791let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000792def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000793 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000794let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000795def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000796 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000797 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000798def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000799 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000800 [(store (v4f32 VR128:$src), addr:$dst)]>;
801
802// Intrinsic forms of MOVUPS load and store
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000803let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000804def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000805 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000806 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000807def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000808 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000809 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000810
Evan Chenge9083d62008-03-05 08:19:16 +0000811let Constraints = "$src1 = $dst" in {
Dan Gohman32791e02007-06-25 15:44:19 +0000812 let AddedComplexity = 20 in {
813 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000814 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000815 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000816 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000817 (movlp VR128:$src1,
818 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000819 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000820 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000821 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000822 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000823 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +0000824 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000825 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000826} // Constraints = "$src1 = $dst"
Evan Cheng4fcb9222006-03-28 02:43:26 +0000827
Evan Chengb70ea0b2008-05-10 00:59:18 +0000828
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000829def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
Chris Lattner3485b512010-03-08 18:57:56 +0000830 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000831
Evan Cheng64d80e32007-07-19 01:14:50 +0000832def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000833 "movlps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000834 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
Evan Cheng015188f2006-06-15 08:14:54 +0000835 (iPTR 0))), addr:$dst)]>;
Evan Cheng9bbfd4f2006-03-28 07:01:28 +0000836
Evan Cheng664ade72006-04-07 21:20:58 +0000837// v2f64 extract element 1 is always custom lowered to unpack high to low
838// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +0000839def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000840 "movhps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000841 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +0000842 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
843 (undef)), (iPTR 0))), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000844
Evan Chenge9083d62008-03-05 08:19:16 +0000845let Constraints = "$src1 = $dst" in {
Evan Chengb7a75a52008-09-26 23:41:32 +0000846let AddedComplexity = 20 in {
Evan Cheng0af934e2009-05-12 20:17:52 +0000847def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
848 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000849 "movlhps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000850 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000851 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2c0dbd02006-03-24 02:58:06 +0000852
Evan Cheng0af934e2009-05-12 20:17:52 +0000853def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
854 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000855 "movhlps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000856 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000857 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2dadaea2006-04-19 20:37:34 +0000858} // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000859} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +0000860
Nate Begemanec8eee22009-04-29 22:47:44 +0000861let AddedComplexity = 20 in {
Nate Begeman9008ca62009-04-27 18:41:29 +0000862def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000863 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000864def : Pat<(v2i64 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000865 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000866}
Evan Cheng0b457f02008-09-25 20:50:48 +0000867
Bill Wendlingddd35322007-05-02 23:11:52 +0000868
869
Dan Gohman20382522007-07-10 00:05:58 +0000870// Arithmetic
871
872/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000873///
Dan Gohman20382522007-07-10 00:05:58 +0000874/// In addition, we also have a special variant of the scalar form here to
875/// represent the associated intrinsic operation. This form is unlike the
876/// plain scalar form, in that it takes an entire vector (instead of a
877/// scalar) and leaves the top elements undefined.
878///
879/// And, we have a special variant form for a full-vector intrinsic form.
880///
881/// These four forms can each have a reg or a mem operand, so there are a
882/// total of eight "instructions".
883///
884multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
885 SDNode OpNode,
886 Intrinsic F32Int,
887 Intrinsic V4F32Int,
888 bit Commutable = 0> {
889 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000890 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000891 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000892 [(set FR32:$dst, (OpNode FR32:$src))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000893 let isCommutable = Commutable;
894 }
895
Dan Gohman20382522007-07-10 00:05:58 +0000896 // Scalar operation, mem.
Evan Cheng400073d2009-12-18 07:40:29 +0000897 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000898 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Cheng400073d2009-12-18 07:40:29 +0000899 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +0000900 Requires<[HasSSE1, OptForSize]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000901
Dan Gohman20382522007-07-10 00:05:58 +0000902 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000903 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000904 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000905 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
906 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +0000907 }
908
Dan Gohman20382522007-07-10 00:05:58 +0000909 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000910 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000911 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +0000912 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000913
914 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000915 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000916 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000917 [(set VR128:$dst, (F32Int VR128:$src))]> {
918 let isCommutable = Commutable;
919 }
920
921 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000922 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000923 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000924 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
925
926 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +0000927 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000928 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000929 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
930 let isCommutable = Commutable;
931 }
932
933 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +0000934 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000935 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +0000936 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000937}
938
Dan Gohman20382522007-07-10 00:05:58 +0000939// Square root.
940defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
941 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
942
943// Reciprocal approximations. Note that these typically require refinement
944// in order to obtain suitable precision.
945defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
946 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
947defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
948 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
949
Bill Wendlingddd35322007-05-02 23:11:52 +0000950// Logical
Evan Chenge9083d62008-03-05 08:19:16 +0000951let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000952 let isCommutable = 1 in {
953 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000954 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000955 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000956 [(set VR128:$dst, (v2i64
957 (and VR128:$src1, VR128:$src2)))]>;
958 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000959 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000960 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000961 [(set VR128:$dst, (v2i64
962 (or VR128:$src1, VR128:$src2)))]>;
963 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000964 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000965 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000966 [(set VR128:$dst, (v2i64
967 (xor VR128:$src1, VR128:$src2)))]>;
968 }
969
970 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000971 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000972 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000973 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
974 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000975 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000976 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000977 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000978 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
979 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000980 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000981 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000982 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000983 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
984 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000985 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000986 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000987 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000988 [(set VR128:$dst,
989 (v2i64 (and (xor VR128:$src1,
990 (bc_v2i64 (v4i32 immAllOnesV))),
991 VR128:$src2)))]>;
992 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000993 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000994 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000995 [(set VR128:$dst,
Evan Cheng31d3a652007-07-19 23:34:10 +0000996 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Bill Wendlingddd35322007-05-02 23:11:52 +0000997 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng31d3a652007-07-19 23:34:10 +0000998 (memopv2i64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000999}
1000
Evan Chenge9083d62008-03-05 08:19:16 +00001001let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001002 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begemanc2616e42008-05-12 20:34:32 +00001003 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1004 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1005 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
1006 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001007 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begemanc2616e42008-05-12 20:34:32 +00001008 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1009 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1010 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001011 (memop addr:$src), imm:$cc))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001012}
Nate Begeman30a0de92008-07-17 16:51:19 +00001013def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001014 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00001015def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001016 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001017
1018// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001019let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001020 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher44b93ff2009-07-31 20:07:27 +00001021 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001022 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001023 VR128:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001024 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001025 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001026 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001027 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001028 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001029 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001030 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001031 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001032 (v4f32 (shufp:$src3
1033 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001034
1035 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001036 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001037 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001038 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001039 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001040 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001041 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001042 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001043 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001044 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001045 (v4f32 (unpckh VR128:$src1,
1046 (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001047
Eric Christopher44b93ff2009-07-31 20:07:27 +00001048 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001049 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001050 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001051 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001052 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001053 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001054 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001055 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001056 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001057 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001058 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001059} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001060
1061// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00001062def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001063 "movmskps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001064 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Cheng8a0b2da2009-05-28 18:55:28 +00001065def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001066 "movmskpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001067 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1068
Evan Cheng27b7db52008-03-08 00:58:38 +00001069// Prefetch intrinsic.
1070def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1071 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1072def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1073 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1074def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1075 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1076def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1077 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001078
1079// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00001080def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001081 "movntps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001082 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1083
David Greene8939b0d2010-02-16 20:50:18 +00001084let AddedComplexity = 400 in { // Prefer non-temporal versions
1085def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1086 "movntps\t{$src, $dst|$dst, $src}",
1087 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1088
1089def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1090 "movntdq\t{$src, $dst|$dst, $src}",
1091 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
1092
David Greene8939b0d2010-02-16 20:50:18 +00001093def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1094 "movnti\t{$src, $dst|$dst, $src}",
1095 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
1096 TB, Requires<[HasSSE2]>;
1097
1098def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
1099 "movnti\t{$src, $dst|$dst, $src}",
1100 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
1101 TB, Requires<[HasSSE2]>;
1102}
1103
Bill Wendlingddd35322007-05-02 23:11:52 +00001104// Load, store, and memory fence
Evan Chengbc9be212009-05-27 18:38:01 +00001105def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001106
1107// MXCSR register
Evan Cheng64d80e32007-07-19 01:14:50 +00001108def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001109 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001110def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001111 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001112
1113// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00001114// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00001115// load of an all-zeros value if folding it would be beneficial.
Chris Lattner28c1d292010-02-05 21:30:49 +00001116// FIXME: Change encoding to pseudo!
Daniel Dunbar7417b762009-08-11 22:17:52 +00001117let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1118 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00001119def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00001120 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001121
Dan Gohmane13709a2010-02-26 01:14:30 +00001122def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1123def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1124def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1125def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1126def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
Evan Chengc8e3b142008-03-12 07:02:50 +00001127
Dan Gohman874cada2010-02-28 00:17:42 +00001128def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1129 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001130
Eric Christopher44b93ff2009-07-31 20:07:27 +00001131//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001132// SSE2 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00001133//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001134
Dan Gohman874cada2010-02-28 00:17:42 +00001135// Move Instructions. Register-to-register movsd is not used for FR64
1136// register copies because it's a partial register update; FsMOVAPDrr is
1137// used instead. Register-to-register movsd is not modeled as an INSERT_SUBREG
1138// because INSERT_SUBREG requires that the insert be implementable in terms of
1139// a copy, and just mentioned, we don't use movsd for copies.
1140let Constraints = "$src1 = $dst" in
1141def MOVSDrr : SDI<0x10, MRMSrcReg,
1142 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
1143 "movsd\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +00001144 [(set (v2f64 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +00001145 (movl VR128:$src1, (scalar_to_vector FR64:$src2)))]>;
1146
1147// Extract the low 64-bit value from one vector and insert it into another.
1148let AddedComplexity = 15 in
1149def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +00001150 (MOVSDrr (v2f64 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +00001151 (EXTRACT_SUBREG (v2f64 VR128:$src2), x86_subreg_sd))>;
1152
1153// Implicitly promote a 64-bit scalar to a vector.
1154def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
1155 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, x86_subreg_sd)>;
1156
1157// Loading from memory automatically zeroing upper bits.
1158let canFoldAsLoad = 1, isReMaterializable = 1, AddedComplexity = 20 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001159def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001160 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001161 [(set FR64:$dst, (loadf64 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +00001162
1163// MOVSDrm zeros the high parts of the register; represent this
1164// with SUBREG_TO_REG.
1165let AddedComplexity = 20 in {
1166def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
1167 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1168def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
1169 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1170def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
1171 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1172def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
1173 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1174def : Pat<(v2f64 (X86vzload addr:$src)),
1175 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1176}
1177
1178// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +00001179def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001180 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001181 [(store FR64:$src, addr:$dst)]>;
1182
Dan Gohman874cada2010-02-28 00:17:42 +00001183// Extract and store.
1184def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
1185 addr:$dst),
1186 (MOVSDmr addr:$dst,
1187 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
1188
Bill Wendlingddd35322007-05-02 23:11:52 +00001189// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00001190def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001191 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001192 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001193def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001194 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001195 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001196def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001197 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001198 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001199def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001200 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Cheng400073d2009-12-18 07:40:29 +00001201 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengb1f49812009-12-22 17:47:23 +00001202 Requires<[HasSSE2, OptForSize]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001203def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001204 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001205 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001206def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001207 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001208 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1209
Sean Callanan5ab94032009-09-16 01:13:52 +00001210def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1211 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1212def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1213 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1214def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1215 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1216def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1217 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1218def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1219 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1220def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1221 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1222def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1223 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1224def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1225 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1226def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1227 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1228def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1229 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1230
Bill Wendlingddd35322007-05-02 23:11:52 +00001231// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001232def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001233 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001234 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1235 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001236def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001237 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001238 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +00001239 Requires<[HasSSE2, OptForSize]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001240
1241def : Pat<(extloadf32 addr:$src),
Dan Gohman874cada2010-02-28 00:17:42 +00001242 (CVTSS2SDrr (MOVSSrm addr:$src))>,
1243 Requires<[HasSSE2, OptForSpeed]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001244
1245// Match intrinsics which expect XMM operand(s).
Evan Cheng64d80e32007-07-19 01:14:50 +00001246def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001247 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001248 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001249def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001250 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001251 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1252 (load addr:$src)))]>;
1253
Dale Johannesenc7842082007-10-30 22:15:38 +00001254// Match intrinisics which expect MM and XMM operand(s).
1255def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1256 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1257 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1258def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1259 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001260 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001261 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001262def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1263 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1264 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1265def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1266 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001267 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001268 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001269def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1270 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1271 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1272def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1273 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001274 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesenc7842082007-10-30 22:15:38 +00001275 (load addr:$src)))]>;
1276
Bill Wendlingddd35322007-05-02 23:11:52 +00001277// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +00001278def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001279 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001280 [(set GR32:$dst,
1281 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001282def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001283 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001284 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1285 (load addr:$src)))]>;
1286
1287// Comparison instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001288let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001289 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001290 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001291 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001292let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +00001293 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001294 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001295 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001296}
1297
Evan Cheng0488db92007-09-25 01:57:46 +00001298let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001299def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001300 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001301 [(set EFLAGS, (X86cmp FR64:$src1, FR64:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001302def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001303 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001304 [(set EFLAGS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001305} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001306
Bill Wendlingddd35322007-05-02 23:11:52 +00001307// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +00001308let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001309 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +00001310 (outs VR128:$dst),
1311 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001312 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001313 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1314 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001315 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +00001316 (outs VR128:$dst),
1317 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001318 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001319 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1320 (load addr:$src), imm:$cc))]>;
1321}
1322
Evan Cheng0488db92007-09-25 01:57:46 +00001323let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001324def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001325 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001326 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1327 VR128:$src2))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00001328def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001329 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001330 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1331 (load addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001332
Evan Cheng64d80e32007-07-19 01:14:50 +00001333def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001334 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001335 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1336 VR128:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001337def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001338 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001339 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1340 (load addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001341} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001342
Eric Christopher44b93ff2009-07-31 20:07:27 +00001343// Aliases of packed SSE2 instructions for scalar use. These all have names
1344// that start with 'Fs'.
Bill Wendlingddd35322007-05-02 23:11:52 +00001345
1346// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +00001347let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1348 canFoldAsLoad = 1 in
Chris Lattnerbe1778f2010-02-05 21:34:18 +00001349def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1350 [(set FR64:$dst, fpimm0)]>,
Bill Wendlingddd35322007-05-02 23:11:52 +00001351 Requires<[HasSSE2]>, TB, OpSize;
1352
Dan Gohman32791e02007-06-25 15:44:19 +00001353// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001354// disregarded.
Chris Lattnerba7e7562008-01-10 07:59:24 +00001355let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001356def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001357 "movapd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001358
Dan Gohman32791e02007-06-25 15:44:19 +00001359// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001360// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001361let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001362def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001363 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +00001364 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001365
1366// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +00001367let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001368let isCommutable = 1 in {
Evan Chengb6093392008-05-02 07:53:32 +00001369 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1370 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001371 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001372 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001373 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1374 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001375 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001376 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001377 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1378 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001379 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001380 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1381}
1382
Evan Chengb6093392008-05-02 07:53:32 +00001383def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1384 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001385 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001386 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001387 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001388def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1389 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001390 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001391 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001392 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001393def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1394 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001395 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001396 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001397 (memopfsf64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001398
Chris Lattnerba7e7562008-01-10 07:59:24 +00001399let neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001400def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001401 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001402 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001403let mayLoad = 1 in
Bill Wendlingddd35322007-05-02 23:11:52 +00001404def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001405 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001406 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001407}
Chris Lattnerba7e7562008-01-10 07:59:24 +00001408}
Bill Wendlingddd35322007-05-02 23:11:52 +00001409
Dan Gohman20382522007-07-10 00:05:58 +00001410/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +00001411///
Dan Gohman20382522007-07-10 00:05:58 +00001412/// In addition, we also have a special variant of the scalar form here to
1413/// represent the associated intrinsic operation. This form is unlike the
1414/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +00001415/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +00001416///
1417/// These three forms can each be reg+reg or reg+mem, so there are a total of
1418/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +00001419///
Evan Chenge9083d62008-03-05 08:19:16 +00001420let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001421multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1422 SDNode OpNode, Intrinsic F64Int,
1423 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +00001424 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001425 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001426 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001427 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1428 let isCommutable = Commutable;
1429 }
1430
1431 // Scalar operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001432 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1433 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001434 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001435 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001436
Dan Gohman20382522007-07-10 00:05:58 +00001437 // Vector operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001438 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1439 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001440 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001441 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1442 let isCommutable = Commutable;
1443 }
1444
1445 // Vector operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001446 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1447 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001448 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanb1347092009-01-09 02:27:34 +00001449 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001450
1451 // Intrinsic operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001452 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1453 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001454 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +00001455 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001456
Dan Gohman20382522007-07-10 00:05:58 +00001457 // Intrinsic operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001458 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1459 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001460 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001461 [(set VR128:$dst, (F64Int VR128:$src1,
1462 sse_load_f64:$src2))]>;
1463}
1464}
1465
1466// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +00001467defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1468defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1469defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1470defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001471
Dan Gohman20382522007-07-10 00:05:58 +00001472/// sse2_fp_binop_rm - Other SSE2 binops
1473///
1474/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1475/// instructions for a full-vector intrinsic form. Operations that map
1476/// onto C operators don't use this form since they just use the plain
1477/// vector form instead of having a separate vector intrinsic form.
1478///
1479/// This provides a total of eight "instructions".
1480///
Evan Chenge9083d62008-03-05 08:19:16 +00001481let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001482multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1483 SDNode OpNode,
1484 Intrinsic F64Int,
1485 Intrinsic V2F64Int,
1486 bit Commutable = 0> {
1487
1488 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001489 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001490 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001491 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1492 let isCommutable = Commutable;
1493 }
1494
1495 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001496 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1497 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001498 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001499 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001500
Dan Gohman20382522007-07-10 00:05:58 +00001501 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001502 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1503 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001504 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001505 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1506 let isCommutable = Commutable;
1507 }
1508
1509 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001510 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1511 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001512 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001513 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001514
1515 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001516 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1517 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001518 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001519 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1520 let isCommutable = Commutable;
1521 }
1522
1523 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001524 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1525 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001526 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001527 [(set VR128:$dst, (F64Int VR128:$src1,
1528 sse_load_f64:$src2))]>;
1529
1530 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001531 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1532 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001533 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001534 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1535 let isCommutable = Commutable;
1536 }
1537
1538 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001539 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1540 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001541 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001542 [(set VR128:$dst, (V2F64Int VR128:$src1,
1543 (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001544}
1545}
1546
1547defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1548 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1549defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1550 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001551
Eric Christopher44b93ff2009-07-31 20:07:27 +00001552//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001553// SSE packed FP Instructions
1554
1555// Move Instructions
Chris Lattnerba7e7562008-01-10 07:59:24 +00001556let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001557def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001558 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001559let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001560def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001561 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001562 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001563
Evan Cheng64d80e32007-07-19 01:14:50 +00001564def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001565 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001566 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001567
Chris Lattnerf77e0372008-01-11 06:59:07 +00001568let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001569def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001570 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001571let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001572def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001573 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001574 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001575def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001576 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001577 [(store (v2f64 VR128:$src), addr:$dst)]>;
1578
1579// Intrinsic forms of MOVUPD load and store
Evan Cheng64d80e32007-07-19 01:14:50 +00001580def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001581 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001582 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001583def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001584 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001585 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001586
Evan Chenge9083d62008-03-05 08:19:16 +00001587let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001588 let AddedComplexity = 20 in {
1589 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001590 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001591 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001592 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001593 (v2f64 (movlp VR128:$src1,
1594 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001595 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001596 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001597 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001598 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +00001599 (v2f64 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001600 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001601 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001602} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001603
Evan Cheng64d80e32007-07-19 01:14:50 +00001604def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001605 "movlpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001606 [(store (f64 (vector_extract (v2f64 VR128:$src),
1607 (iPTR 0))), addr:$dst)]>;
1608
1609// v2f64 extract element 1 is always custom lowered to unpack high to low
1610// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +00001611def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001612 "movhpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001613 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +00001614 (v2f64 (unpckh VR128:$src, (undef))),
1615 (iPTR 0))), addr:$dst)]>;
Evan Chengd9539472006-04-14 21:59:03 +00001616
Evan Cheng470a6ad2006-02-22 02:26:30 +00001617// SSE2 instructions without OpSize prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001618def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001619 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001620 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1621 TB, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001622def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001623 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1624 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1625 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001626 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001627
1628// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001629def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001630 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001631 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1632 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001633def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001634 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1635 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1636 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001637 XS, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001638
Evan Cheng64d80e32007-07-19 01:14:50 +00001639def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001640 "cvtps2dq\t{$src, $dst|$dst, $src}",
1641 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001642def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001643 "cvtps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001644 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001645 (memop addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001646// SSE2 packed instructions with XS prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001647def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1648 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1649def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1650 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1651
Evan Cheng64d80e32007-07-19 01:14:50 +00001652def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001653 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +00001654 [(set VR128:$dst,
1655 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001656 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001657def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001658 "cvttps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001659 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001660 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001661 XS, Requires<[HasSSE2]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001662
Evan Cheng470a6ad2006-02-22 02:26:30 +00001663// SSE2 packed instructions with XD prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001664def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001665 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001666 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1667 XD, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001668def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001669 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001670 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001671 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001672 XD, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001673
Evan Cheng64d80e32007-07-19 01:14:50 +00001674def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001676 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng029d9da2008-03-14 07:46:48 +00001677def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001678 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001679 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001680 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001681
1682// SSE2 instructions without OpSize prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001683def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1684 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1685def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1686 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1687
Evan Cheng64d80e32007-07-19 01:14:50 +00001688def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001689 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001690 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1691 TB, Requires<[HasSSE2]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001692def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001693 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001694 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
Chris Lattner15258d52006-10-07 06:17:43 +00001695 (load addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001696 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001697
Sean Callanan108934c2009-12-18 00:01:26 +00001698def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1699 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1700def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1701 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1702
1703
Evan Cheng64d80e32007-07-19 01:14:50 +00001704def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001705 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001706 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001707def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001708 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001709 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Chengb1938262008-05-23 00:37:07 +00001710 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001711
Evan Chengd2a6d542006-04-12 23:42:44 +00001712// Match intrinsics which expect XMM operand(s).
1713// Aliases for intrinsics
Evan Chenge9083d62008-03-05 08:19:16 +00001714let Constraints = "$src1 = $dst" in {
Evan Chengd2a6d542006-04-12 23:42:44 +00001715def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001716 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001717 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001718 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
Evan Cheng069287d2006-05-16 07:21:53 +00001719 GR32:$src2))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001720def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001721 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001722 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001723 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1724 (loadi32 addr:$src2)))]>;
1725def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001726 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001727 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001728 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1729 VR128:$src2))]>;
1730def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00001731 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001733 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001734 (load addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001735def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001736 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001737 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001738 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1739 VR128:$src2))]>, XS,
1740 Requires<[HasSSE2]>;
1741def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001742 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001743 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001744 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001745 (load addr:$src2)))]>, XS,
Evan Chengd2a6d542006-04-12 23:42:44 +00001746 Requires<[HasSSE2]>;
1747}
1748
Dan Gohman20382522007-07-10 00:05:58 +00001749// Arithmetic
1750
1751/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
Chris Lattner6f987732006-10-07 21:17:13 +00001752///
Dan Gohman20382522007-07-10 00:05:58 +00001753/// In addition, we also have a special variant of the scalar form here to
1754/// represent the associated intrinsic operation. This form is unlike the
1755/// plain scalar form, in that it takes an entire vector (instead of a
1756/// scalar) and leaves the top elements undefined.
1757///
1758/// And, we have a special variant form for a full-vector intrinsic form.
1759///
1760/// These four forms can each have a reg or a mem operand, so there are a
1761/// total of eight "instructions".
1762///
1763multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1764 SDNode OpNode,
1765 Intrinsic F64Int,
1766 Intrinsic V2F64Int,
1767 bit Commutable = 0> {
1768 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001769 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001770 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001771 [(set FR64:$dst, (OpNode FR64:$src))]> {
Chris Lattner6f987732006-10-07 21:17:13 +00001772 let isCommutable = Commutable;
1773 }
Bill Wendlingddd35322007-05-02 23:11:52 +00001774
Dan Gohman20382522007-07-10 00:05:58 +00001775 // Scalar operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001776 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001777 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001778 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001779
Dan Gohman20382522007-07-10 00:05:58 +00001780 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001781 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001782 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001783 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1784 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001785 }
1786
Dan Gohman20382522007-07-10 00:05:58 +00001787 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001788 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001790 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001791
1792 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001793 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001794 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001795 [(set VR128:$dst, (F64Int VR128:$src))]> {
1796 let isCommutable = Commutable;
1797 }
1798
1799 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001800 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001801 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001802 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1803
1804 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001805 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001806 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001807 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1808 let isCommutable = Commutable;
1809 }
1810
1811 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001812 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001814 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Evan Cheng97ac5fa2006-04-03 23:49:17 +00001815}
Evan Chengffcb95b2006-02-21 19:13:53 +00001816
Dan Gohman20382522007-07-10 00:05:58 +00001817// Square root.
1818defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1819 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1820
1821// There is no f64 version of the reciprocal approximation instructions.
1822
Evan Chengffcb95b2006-02-21 19:13:53 +00001823// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001824let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001825 let isCommutable = 1 in {
1826 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001827 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001828 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001829 [(set VR128:$dst,
1830 (and (bc_v2i64 (v2f64 VR128:$src1)),
Chris Lattner3b57a832006-10-07 06:27:03 +00001831 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001832 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001835 [(set VR128:$dst,
1836 (or (bc_v2i64 (v2f64 VR128:$src1)),
1837 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1838 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001839 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001840 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001841 [(set VR128:$dst,
1842 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1843 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1844 }
1845
1846 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001847 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001848 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001849 [(set VR128:$dst,
1850 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001851 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001852 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001853 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001854 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001855 [(set VR128:$dst,
1856 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001857 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001858 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001859 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001860 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001861 [(set VR128:$dst,
1862 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001863 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001864 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001865 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001866 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001867 [(set VR128:$dst,
1868 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Chris Lattner3b57a832006-10-07 06:27:03 +00001869 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001870 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001871 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001872 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001873 [(set VR128:$dst,
1874 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001875 (memopv2i64 addr:$src2)))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +00001876}
Evan Chengbf156d12006-02-21 19:26:52 +00001877
Evan Chenge9083d62008-03-05 08:19:16 +00001878let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001879 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001880 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1881 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1882 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begemanc2616e42008-05-12 20:34:32 +00001883 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001884 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng029d9da2008-03-14 07:46:48 +00001885 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1886 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1887 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001888 (memop addr:$src), imm:$cc))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001889}
Evan Chenge9d50352008-08-05 22:19:15 +00001890def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001891 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Chenge9d50352008-08-05 22:19:15 +00001892def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001893 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001894
1895// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001896let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001897 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001898 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1899 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman9008ca62009-04-27 18:41:29 +00001900 [(set VR128:$dst,
1901 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001902 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001903 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00001904 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001905 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001906 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001907 (v2f64 (shufp:$src3
1908 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001909
Bill Wendlingddd35322007-05-02 23:11:52 +00001910 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001911 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001912 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001913 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001914 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001915 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001916 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001917 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001918 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001919 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001920 (v2f64 (unpckh VR128:$src1,
1921 (memopv2f64 addr:$src2))))]>;
Evan Cheng4fcb9222006-03-28 02:43:26 +00001922
Eric Christopher44b93ff2009-07-31 20:07:27 +00001923 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001924 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001925 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001926 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001927 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001928 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001929 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001930 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001931 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001932 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001933 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001934} // Constraints = "$src1 = $dst"
Evan Cheng470a6ad2006-02-22 02:26:30 +00001935
Evan Cheng4b1734f2006-03-31 21:29:33 +00001936
Eric Christopher44b93ff2009-07-31 20:07:27 +00001937//===---------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001938// SSE integer instructions
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00001939let ExeDomain = SSEPackedInt in {
Evan Chengbf156d12006-02-21 19:26:52 +00001940
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001941// Move Instructions
Chris Lattnerf77e0372008-01-11 06:59:07 +00001942let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001943def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001945let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001946def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001947 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001948 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001949let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001950def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001951 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001952 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001953let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001954def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001955 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001956 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001957 XS, Requires<[HasSSE2]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001958let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001959def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001960 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001961 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001962 XS, Requires<[HasSSE2]>;
Evan Cheng24dc1f52006-03-23 07:44:07 +00001963
Dan Gohman4106f372007-07-18 20:23:34 +00001964// Intrinsic forms of MOVDQU load and store
Dan Gohman15511cf2008-12-03 18:15:48 +00001965let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001966def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001967 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001968 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1969 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001970def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001971 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001972 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1973 XS, Requires<[HasSSE2]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001974
Evan Chenge7b8a8b2008-03-05 08:11:27 +00001975let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001976
Chris Lattner45e123c2006-10-07 19:02:31 +00001977multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1978 bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00001979 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1980 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001981 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001982 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1983 let isCommutable = Commutable;
1984 }
Sean Callanan108934c2009-12-18 00:01:26 +00001985 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1986 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001987 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001988 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00001989 (bitconvert (memopv2i64
1990 addr:$src2))))]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001991}
Chris Lattner8139e282006-10-07 18:39:00 +00001992
Evan Cheng22b942a2008-05-03 00:52:09 +00001993multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1994 string OpcodeStr,
1995 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan108934c2009-12-18 00:01:26 +00001996 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1997 (ins VR128:$src1, VR128:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00001998 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1999 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002000 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2001 (ins VR128:$src1, i128mem:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002002 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2003 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002004 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002005 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
2006 (ins VR128:$src1, i32i8imm:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002007 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2008 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2009}
2010
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002011/// PDI_binop_rm - Simple SSE2 binary operator.
2012multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2013 ValueType OpVT, bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00002014 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2015 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002016 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002017 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
2018 let isCommutable = Commutable;
2019 }
Sean Callanan108934c2009-12-18 00:01:26 +00002020 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2021 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002022 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002023 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002024 (bitconvert (memopv2i64 addr:$src2)))))]>;
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002025}
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002026
2027/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2028///
2029/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2030/// to collapse (bitconvert VT to VT) into its operand.
2031///
2032multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2033 bit Commutable = 0> {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002034 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002035 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002037 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
2038 let isCommutable = Commutable;
2039 }
Eric Christopher44b93ff2009-07-31 20:07:27 +00002040 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002041 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002042 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002043 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00002044 (memopv2i64 addr:$src2)))]>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002045}
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002046
Evan Chenge9083d62008-03-05 08:19:16 +00002047} // Constraints = "$src1 = $dst"
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002048} // ExeDomain = SSEPackedInt
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002049
2050// 128-bit Integer Arithmetic
2051
2052defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2053defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2054defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002055defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002056
Chris Lattner45e123c2006-10-07 19:02:31 +00002057defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2058defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2059defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2060defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002061
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002062defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2063defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2064defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002065defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002066
Chris Lattner45e123c2006-10-07 19:02:31 +00002067defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2068defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2069defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2070defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002071
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002072defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002073
Chris Lattner45e123c2006-10-07 19:02:31 +00002074defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2075defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2076defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002077
Chris Lattner45e123c2006-10-07 19:02:31 +00002078defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
Chris Lattner77337992006-10-07 07:06:17 +00002079
Chris Lattner45e123c2006-10-07 19:02:31 +00002080defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2081defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
Chris Lattner8139e282006-10-07 18:39:00 +00002082
Chris Lattner77337992006-10-07 07:06:17 +00002083
Chris Lattner45e123c2006-10-07 19:02:31 +00002084defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2085defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2086defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2087defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling3b1259b2009-05-28 02:04:00 +00002088defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Evan Chengc60bd972006-03-25 09:37:23 +00002089
Chris Lattner77337992006-10-07 07:06:17 +00002090
Evan Cheng22b942a2008-05-03 00:52:09 +00002091defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2092 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2093defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2094 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2095defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2096 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002097
Evan Cheng22b942a2008-05-03 00:52:09 +00002098defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2099 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2100defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2101 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begeman32097bd2008-05-13 17:52:09 +00002102defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Cheng22b942a2008-05-03 00:52:09 +00002103 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002104
Evan Cheng22b942a2008-05-03 00:52:09 +00002105defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2106 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemanc9bdb002008-05-13 01:47:52 +00002107defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Cheng22b942a2008-05-03 00:52:09 +00002108 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Chris Lattner77337992006-10-07 07:06:17 +00002109
Chris Lattner6970eda2006-10-07 19:49:05 +00002110// 128-bit logical shifts.
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002111let Constraints = "$src1 = $dst", neverHasSideEffects = 1,
2112 ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002113 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002114 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002115 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002116 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002117 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002118 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002119 // PSRADQri doesn't exist in SSE[1-3].
Evan Chengff65e382006-04-04 21:49:39 +00002120}
2121
Chris Lattner6970eda2006-10-07 19:49:05 +00002122let Predicates = [HasSSE2] in {
2123 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002124 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002125 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002126 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling5e249b42008-10-02 05:56:52 +00002127 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2128 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2129 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2130 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Evan Cheng68c47cb2007-01-05 07:55:56 +00002131 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng89321162009-10-28 06:30:34 +00002132 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002133
2134 // Shift up / down and insert zero's.
2135 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002136 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002137 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002138 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002139}
2140
Evan Cheng506d3df2006-03-29 23:07:14 +00002141// Logical
Chris Lattnera7ebe552006-10-07 19:37:30 +00002142defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2143defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2144defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2145
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002146let Constraints = "$src1 = $dst", ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002147 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002148 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002149 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002150 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2151 VR128:$src2)))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002152
Bill Wendlingddd35322007-05-02 23:11:52 +00002153 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002154 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002155 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002156 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7f55fcb2007-08-02 21:17:01 +00002157 (memopv2i64 addr:$src2))))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002158}
2159
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002160// SSE2 Integer comparison
Bill Wendlingddd35322007-05-02 23:11:52 +00002161defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2162defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2163defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2164defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2165defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2166defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002167
Nate Begeman30a0de92008-07-17 16:51:19 +00002168def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002169 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002170def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002171 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002172def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002173 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002174def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002175 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002176def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002177 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002178def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002179 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2180
Nate Begeman30a0de92008-07-17 16:51:19 +00002181def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002182 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002183def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002184 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002185def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002186 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002187def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002188 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002189def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002190 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002191def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002192 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2193
2194
Evan Cheng506d3df2006-03-29 23:07:14 +00002195// Pack instructions
Chris Lattner45e123c2006-10-07 19:02:31 +00002196defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2197defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2198defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002199
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002200let ExeDomain = SSEPackedInt in {
2201
Evan Cheng506d3df2006-03-29 23:07:14 +00002202// Shuffle and unpack instructions
Nate Begemana09008b2009-10-19 02:17:23 +00002203let AddedComplexity = 5 in {
Evan Cheng8703be42006-04-04 19:12:30 +00002204def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002205 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002206 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002207 [(set VR128:$dst, (v4i32 (pshufd:$src2
2208 VR128:$src1, (undef))))]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002209def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002210 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002211 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002212 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chengc3630942009-12-09 21:00:30 +00002213 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002214 (undef))))]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002215}
Evan Cheng506d3df2006-03-29 23:07:14 +00002216
2217// SSE2 with ImmT == Imm8 and XS prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002218def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002219 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002221 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2222 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002223 XS, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002224def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002225 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002226 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002227 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher44b93ff2009-07-31 20:07:27 +00002228 (bc_v8i16 (memopv2i64 addr:$src1)),
2229 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002230 XS, Requires<[HasSSE2]>;
2231
2232// SSE2 with ImmT == Imm8 and XD prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002233def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman9008ca62009-04-27 18:41:29 +00002234 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002236 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2237 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002238 XD, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002239def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman9008ca62009-04-27 18:41:29 +00002240 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002242 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2243 (bc_v8i16 (memopv2i64 addr:$src1)),
2244 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002245 XD, Requires<[HasSSE2]>;
2246
Evan Chengc60bd972006-03-25 09:37:23 +00002247
Evan Chenge9083d62008-03-05 08:19:16 +00002248let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002249 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002250 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002251 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002252 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002253 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002254 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002255 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002256 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002257 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002258 (unpckl VR128:$src1,
2259 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002260 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002261 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002262 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002263 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002264 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002265 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002266 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002267 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002268 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002269 (unpckl VR128:$src1,
2270 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002271 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002272 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002273 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002274 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002275 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002276 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002277 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002278 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002279 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002280 (unpckl VR128:$src1,
2281 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002282 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002283 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002284 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002285 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002286 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002287 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002288 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002290 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002291 (v2i64 (unpckl VR128:$src1,
2292 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002293
2294 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002295 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002296 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002297 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002298 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002299 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002302 [(set VR128:$dst,
2303 (unpckh VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00002304 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002305 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002306 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002307 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002308 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002309 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002310 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002311 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002312 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002313 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002314 (unpckh VR128:$src1,
2315 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002316 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002317 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002318 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002319 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002320 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002321 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002322 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002323 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002324 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002325 (unpckh VR128:$src1,
2326 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002327 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002328 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002329 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002330 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002331 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002332 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002333 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002334 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002335 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002336 (v2i64 (unpckh VR128:$src1,
2337 (memopv2i64 addr:$src2))))]>;
Evan Chenga971f6f2006-03-23 01:57:24 +00002338}
Evan Cheng82521dd2006-03-21 07:09:35 +00002339
Evan Chengb067a1e2006-03-31 19:22:53 +00002340// Extract / Insert
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002341def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002342 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002343 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002344 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begeman14d12ca2008-02-11 04:19:36 +00002345 imm:$src2))]>;
Evan Chenge9083d62008-03-05 08:19:16 +00002346let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002347 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002348 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002349 GR32:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002350 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002351 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002352 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002353 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002354 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002355 i16mem:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002356 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002357 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002358 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2359 imm:$src3))]>;
Evan Chengb067a1e2006-03-31 19:22:53 +00002360}
2361
Evan Chengc5fb2b12006-03-30 00:33:26 +00002362// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00002363def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002364 "pmovmskb\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002365 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
Evan Chengc5fb2b12006-03-30 00:33:26 +00002366
Evan Chengfcf5e212006-04-11 06:57:30 +00002367// Conditional store
Evan Cheng071a2792007-09-11 19:55:27 +00002368let Uses = [EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +00002369def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002370 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng071a2792007-09-11 19:55:27 +00002371 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Evan Chengfcf5e212006-04-11 06:57:30 +00002372
Evan Cheng1d768642009-02-10 22:06:28 +00002373let Uses = [RDI] in
2374def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2375 "maskmovdqu\t{$mask, $src|$src, $mask}",
2376 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2377
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002378} // ExeDomain = SSEPackedInt
2379
Evan Chengecac9cb2006-03-25 06:03:26 +00002380// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00002381def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2382 "movntpd\t{$src, $dst|$dst, $src}",
2383 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002384let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002385def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2386 "movntdq\t{$src, $dst|$dst, $src}",
2387 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2388def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002389 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002390 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Evan Chengfcf5e212006-04-11 06:57:30 +00002391 TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002392
David Greene8939b0d2010-02-16 20:50:18 +00002393let AddedComplexity = 400 in { // Prefer non-temporal versions
2394def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2395 "movntpd\t{$src, $dst|$dst, $src}",
2396 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2397
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002398let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002399def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2400 "movntdq\t{$src, $dst|$dst, $src}",
2401 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
David Greene8939b0d2010-02-16 20:50:18 +00002402}
2403
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002404// Flush cache
Evan Cheng64d80e32007-07-19 01:14:50 +00002405def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002406 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002407 TB, Requires<[HasSSE2]>;
2408
2409// Load, store, and memory fence
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002410def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002411 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002412def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002413 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002414
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002415//TODO: custom lower this so as to never even generate the noop
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002416def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002417 (i8 0)), (NOOP)>;
2418def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2419def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002420def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002421 (i8 1)), (MFENCE)>;
2422
Evan Chengffea91e2006-03-26 09:53:12 +00002423// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00002424// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00002425// load of an all-ones value if folding it would be beneficial.
Daniel Dunbar7417b762009-08-11 22:17:52 +00002426let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2427 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00002428 // FIXME: Change encoding to pseudo.
2429 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00002430 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Evan Cheng386031a2006-03-24 07:29:27 +00002431
Evan Cheng64d80e32007-07-19 01:14:50 +00002432def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002433 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002434 [(set VR128:$dst,
Evan Cheng069287d2006-05-16 07:21:53 +00002435 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002436def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002437 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002438 [(set VR128:$dst,
2439 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Evan Chengebf01d62006-11-16 23:33:25 +00002440
Evan Cheng64d80e32007-07-19 01:14:50 +00002441def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002442 "movd\t{$src, $dst|$dst, $src}",
Chris Lattnerf3597a12006-12-05 18:45:06 +00002443 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2444
Evan Cheng64d80e32007-07-19 01:14:50 +00002445def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002446 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002447 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002448
Evan Cheng11e15b32006-04-03 20:53:28 +00002449// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00002450def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002451 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002452 [(set VR128:$dst,
2453 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2454 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002455def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002456 "movq\t{$src, $dst|$dst, $src}",
Evan Chengebf01d62006-11-16 23:33:25 +00002457 [(store (i64 (vector_extract (v2i64 VR128:$src),
2458 (iPTR 0))), addr:$dst)]>;
2459
Dan Gohman874cada2010-02-28 00:17:42 +00002460def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
2461 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
2462
Evan Cheng64d80e32007-07-19 01:14:50 +00002463def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002464 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002465 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002466 (iPTR 0)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002467def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002468 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002469 [(store (i32 (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002470 (iPTR 0))), addr:$dst)]>;
Evan Cheng11e15b32006-04-03 20:53:28 +00002471
Evan Cheng64d80e32007-07-19 01:14:50 +00002472def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002473 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002474 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002475def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002476 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002477 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002478
Evan Cheng397edef2006-04-11 22:28:25 +00002479// Store / copy lower 64-bits of a XMM register.
Evan Cheng64d80e32007-07-19 01:14:50 +00002480def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002481 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng397edef2006-04-11 22:28:25 +00002482 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2483
Evan Cheng017dcc62006-04-21 01:05:10 +00002484// movd / movq to XMM register zero-extends
Evan Cheng7a831ce2007-12-15 03:00:47 +00002485let AddedComplexity = 15 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002486def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002487 "movd\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002488 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002489 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002490// This is X86-64 only.
2491def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2492 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002493 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002494 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002495}
2496
2497let AddedComplexity = 20 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002498def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002499 "movd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002500 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002501 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002502 (loadi32 addr:$src))))))]>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002503
2504def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2505 (MOVZDI2PDIrm addr:$src)>;
2506def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2507 (MOVZDI2PDIrm addr:$src)>;
Duncan Sandsd4b9c172008-06-13 19:07:40 +00002508def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2509 (MOVZDI2PDIrm addr:$src)>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002510
Evan Cheng64d80e32007-07-19 01:14:50 +00002511def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002512 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng7a831ce2007-12-15 03:00:47 +00002513 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002514 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002515 (loadi64 addr:$src))))))]>, XS,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002516 Requires<[HasSSE2]>;
Evan Cheng48090aa2006-03-21 23:01:21 +00002517
Evan Chengc36c0ab2008-05-22 18:56:56 +00002518def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2519 (MOVZQI2PQIrm addr:$src)>;
2520def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2521 (MOVZQI2PQIrm addr:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00002522def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengb70ea0b2008-05-10 00:59:18 +00002523}
Evan Chengd880b972008-05-09 21:53:03 +00002524
Evan Cheng7a831ce2007-12-15 03:00:47 +00002525// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2526// IA32 document. movq xmm1, xmm2 does clear the high bits.
2527let AddedComplexity = 15 in
2528def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2529 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002530 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002531 XS, Requires<[HasSSE2]>;
2532
Evan Cheng8e8de682008-05-20 18:24:47 +00002533let AddedComplexity = 20 in {
Evan Cheng7a831ce2007-12-15 03:00:47 +00002534def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2535 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002536 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng8e8de682008-05-20 18:24:47 +00002537 (loadv2i64 addr:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002538 XS, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002539
Evan Cheng8e8de682008-05-20 18:24:47 +00002540def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2541 (MOVZPQILo2PQIrm addr:$src)>;
2542}
2543
Sean Callanan108934c2009-12-18 00:01:26 +00002544// Instructions for the disassembler
2545// xr = XMM register
2546// xm = mem64
2547
2548def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2549 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2550
Eric Christopher44b93ff2009-07-31 20:07:27 +00002551//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002552// SSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002553//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002554
Bill Wendlingddd35322007-05-02 23:11:52 +00002555// Move Instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00002556def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002557 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002558 [(set VR128:$dst, (v4f32 (movshdup
2559 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002560def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002561 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002562 [(set VR128:$dst, (movshdup
2563 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002564
Evan Cheng64d80e32007-07-19 01:14:50 +00002565def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002566 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002567 [(set VR128:$dst, (v4f32 (movsldup
2568 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002569def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002570 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002571 [(set VR128:$dst, (movsldup
2572 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002573
Evan Cheng64d80e32007-07-19 01:14:50 +00002574def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002575 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002576 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002577def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002578 "movddup\t{$src, $dst|$dst, $src}",
Evan Cheng0b457f02008-09-25 20:50:48 +00002579 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002580 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2581 (undef))))]>;
Evan Cheng0b457f02008-09-25 20:50:48 +00002582
Nate Begeman9008ca62009-04-27 18:41:29 +00002583def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2584 (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002585 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002586
2587let AddedComplexity = 5 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00002588def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002589 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002590def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2591 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2592def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2593 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2594def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2595 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2596}
Bill Wendlingddd35322007-05-02 23:11:52 +00002597
2598// Arithmetic
Evan Chenge9083d62008-03-05 08:19:16 +00002599let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002600 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002601 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002602 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002603 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2604 VR128:$src2))]>;
2605 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002606 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002607 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002608 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002609 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002610 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002611 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002612 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002613 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2614 VR128:$src2))]>;
2615 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002616 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002617 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002618 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002619 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002620}
2621
Evan Cheng64d80e32007-07-19 01:14:50 +00002622def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 "lddqu\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002624 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2625
2626// Horizontal ops
2627class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002628 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002629 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002630 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2631class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002632 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002633 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002634 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002635class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002636 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002637 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002638 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2639class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002640 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002641 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002642 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002643
Evan Chenge9083d62008-03-05 08:19:16 +00002644let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002645 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2646 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2647 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2648 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2649 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2650 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2651 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2652 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2653}
2654
2655// Thread synchronization
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002656def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
Bill Wendlingddd35322007-05-02 23:11:52 +00002657 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002658def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
Bill Wendlingddd35322007-05-02 23:11:52 +00002659 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2660
2661// vector_shuffle v1, <undef> <1, 1, 3, 3>
2662let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002663def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002664 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2665let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002666def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002667 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2668
2669// vector_shuffle v1, <undef> <0, 0, 2, 2>
2670let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002671 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002672 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2673let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002674 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002675 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2676
Eric Christopher44b93ff2009-07-31 20:07:27 +00002677//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002678// SSSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002679//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002680
Bill Wendling76d708b2007-08-10 06:22:27 +00002681/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begemanfea2be52008-02-09 23:46:37 +00002682multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2683 Intrinsic IntId64, Intrinsic IntId128> {
2684 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2685 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2686 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002687
Nate Begemanfea2be52008-02-09 23:46:37 +00002688 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2689 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2690 [(set VR64:$dst,
2691 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2692
2693 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2694 (ins VR128:$src),
2695 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2696 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2697 OpSize;
2698
2699 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2700 (ins i128mem:$src),
2701 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2702 [(set VR128:$dst,
2703 (IntId128
2704 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Bill Wendlingddd35322007-05-02 23:11:52 +00002705}
2706
Bill Wendling76d708b2007-08-10 06:22:27 +00002707/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begemanfea2be52008-02-09 23:46:37 +00002708multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2709 Intrinsic IntId64, Intrinsic IntId128> {
2710 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2711 (ins VR64:$src),
2712 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2713 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002714
Nate Begemanfea2be52008-02-09 23:46:37 +00002715 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2716 (ins i64mem:$src),
2717 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2718 [(set VR64:$dst,
2719 (IntId64
2720 (bitconvert (memopv4i16 addr:$src))))]>;
2721
2722 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2723 (ins VR128:$src),
2724 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2725 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2726 OpSize;
2727
2728 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2729 (ins i128mem:$src),
2730 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2731 [(set VR128:$dst,
2732 (IntId128
2733 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002734}
2735
2736/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begemanfea2be52008-02-09 23:46:37 +00002737multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2738 Intrinsic IntId64, Intrinsic IntId128> {
2739 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2740 (ins VR64:$src),
2741 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2742 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002743
Nate Begemanfea2be52008-02-09 23:46:37 +00002744 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2745 (ins i64mem:$src),
2746 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2747 [(set VR64:$dst,
2748 (IntId64
2749 (bitconvert (memopv2i32 addr:$src))))]>;
2750
2751 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2752 (ins VR128:$src),
2753 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2754 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2755 OpSize;
2756
2757 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2758 (ins i128mem:$src),
2759 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2760 [(set VR128:$dst,
2761 (IntId128
2762 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002763}
2764
2765defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2766 int_x86_ssse3_pabs_b,
2767 int_x86_ssse3_pabs_b_128>;
2768defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2769 int_x86_ssse3_pabs_w,
2770 int_x86_ssse3_pabs_w_128>;
2771defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2772 int_x86_ssse3_pabs_d,
2773 int_x86_ssse3_pabs_d_128>;
2774
2775/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Chenge9083d62008-03-05 08:19:16 +00002776let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002777 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2778 Intrinsic IntId64, Intrinsic IntId128,
2779 bit Commutable = 0> {
2780 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2781 (ins VR64:$src1, VR64:$src2),
2782 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2783 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2784 let isCommutable = Commutable;
2785 }
2786 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2787 (ins VR64:$src1, i64mem:$src2),
2788 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2789 [(set VR64:$dst,
2790 (IntId64 VR64:$src1,
2791 (bitconvert (memopv8i8 addr:$src2))))]>;
2792
2793 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2794 (ins VR128:$src1, VR128:$src2),
2795 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2796 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2797 OpSize {
2798 let isCommutable = Commutable;
2799 }
2800 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2801 (ins VR128:$src1, i128mem:$src2),
2802 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2803 [(set VR128:$dst,
2804 (IntId128 VR128:$src1,
2805 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2806 }
2807}
2808
2809/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Chenge9083d62008-03-05 08:19:16 +00002810let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002811 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2812 Intrinsic IntId64, Intrinsic IntId128,
2813 bit Commutable = 0> {
2814 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2815 (ins VR64:$src1, VR64:$src2),
2816 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2817 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2818 let isCommutable = Commutable;
2819 }
2820 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2821 (ins VR64:$src1, i64mem:$src2),
2822 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2823 [(set VR64:$dst,
2824 (IntId64 VR64:$src1,
2825 (bitconvert (memopv4i16 addr:$src2))))]>;
2826
2827 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2828 (ins VR128:$src1, VR128:$src2),
2829 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2830 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2831 OpSize {
2832 let isCommutable = Commutable;
2833 }
2834 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2835 (ins VR128:$src1, i128mem:$src2),
2836 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2837 [(set VR128:$dst,
2838 (IntId128 VR128:$src1,
2839 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2840 }
2841}
2842
2843/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Chenge9083d62008-03-05 08:19:16 +00002844let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002845 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2846 Intrinsic IntId64, Intrinsic IntId128,
2847 bit Commutable = 0> {
2848 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2849 (ins VR64:$src1, VR64:$src2),
2850 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2851 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2852 let isCommutable = Commutable;
2853 }
2854 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2855 (ins VR64:$src1, i64mem:$src2),
2856 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2857 [(set VR64:$dst,
2858 (IntId64 VR64:$src1,
2859 (bitconvert (memopv2i32 addr:$src2))))]>;
2860
2861 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2862 (ins VR128:$src1, VR128:$src2),
2863 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2864 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2865 OpSize {
2866 let isCommutable = Commutable;
2867 }
2868 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2869 (ins VR128:$src1, i128mem:$src2),
2870 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2871 [(set VR128:$dst,
2872 (IntId128 VR128:$src1,
2873 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2874 }
2875}
2876
2877defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2878 int_x86_ssse3_phadd_w,
Evan Cheng4e444432008-06-16 21:16:24 +00002879 int_x86_ssse3_phadd_w_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002880defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2881 int_x86_ssse3_phadd_d,
Evan Cheng4e444432008-06-16 21:16:24 +00002882 int_x86_ssse3_phadd_d_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002883defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2884 int_x86_ssse3_phadd_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002885 int_x86_ssse3_phadd_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002886defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2887 int_x86_ssse3_phsub_w,
2888 int_x86_ssse3_phsub_w_128>;
2889defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2890 int_x86_ssse3_phsub_d,
2891 int_x86_ssse3_phsub_d_128>;
2892defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2893 int_x86_ssse3_phsub_sw,
2894 int_x86_ssse3_phsub_sw_128>;
2895defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2896 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002897 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002898defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2899 int_x86_ssse3_pmul_hr_sw,
2900 int_x86_ssse3_pmul_hr_sw_128, 1>;
2901defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2902 int_x86_ssse3_pshuf_b,
2903 int_x86_ssse3_pshuf_b_128>;
2904defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2905 int_x86_ssse3_psign_b,
2906 int_x86_ssse3_psign_b_128>;
2907defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2908 int_x86_ssse3_psign_w,
2909 int_x86_ssse3_psign_w_128>;
Evan Chenged7f56b2009-05-28 18:48:53 +00002910defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling76d708b2007-08-10 06:22:27 +00002911 int_x86_ssse3_psign_d,
2912 int_x86_ssse3_psign_d_128>;
2913
Evan Chenge9083d62008-03-05 08:19:16 +00002914let Constraints = "$src1 = $dst" in {
Bill Wendlingae9671b2007-08-10 09:00:17 +00002915 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002916 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002917 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002918 []>;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002919 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002920 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002921 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002922 []>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002923
Bill Wendlingae9671b2007-08-10 09:00:17 +00002924 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002925 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002926 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002927 []>, OpSize;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002928 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002929 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002930 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002931 []>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002932}
Bill Wendlingddd35322007-05-02 23:11:52 +00002933
Nate Begemana09008b2009-10-19 02:17:23 +00002934// palignr patterns.
Sean Callananb9e6b342009-11-20 22:28:42 +00002935def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002936 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2937 Requires<[HasSSSE3]>;
2938def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2939 (memop64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002940 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002941 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2942 Requires<[HasSSSE3]>;
2943
Sean Callananb9e6b342009-11-20 22:28:42 +00002944def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002945 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2946 Requires<[HasSSSE3]>;
2947def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2948 (memopv2i64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002949 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002950 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2951 Requires<[HasSSSE3]>;
2952
Nate Begemana09008b2009-10-19 02:17:23 +00002953let AddedComplexity = 5 in {
2954def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2955 (PALIGNR128rr VR128:$src2, VR128:$src1,
2956 (SHUFFLE_get_palign_imm VR128:$src3))>,
2957 Requires<[HasSSSE3]>;
2958def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2959 (PALIGNR128rr VR128:$src2, VR128:$src1,
2960 (SHUFFLE_get_palign_imm VR128:$src3))>,
2961 Requires<[HasSSSE3]>;
2962def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2963 (PALIGNR128rr VR128:$src2, VR128:$src1,
2964 (SHUFFLE_get_palign_imm VR128:$src3))>,
2965 Requires<[HasSSSE3]>;
2966def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2967 (PALIGNR128rr VR128:$src2, VR128:$src1,
2968 (SHUFFLE_get_palign_imm VR128:$src3))>,
2969 Requires<[HasSSSE3]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002970}
Nate Begemana09008b2009-10-19 02:17:23 +00002971
Nate Begemanb9a47b82009-02-23 08:49:38 +00002972def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2973 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2974def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2975 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2976
Eric Christopher44b93ff2009-07-31 20:07:27 +00002977//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002978// Non-Instruction Patterns
Eric Christopher44b93ff2009-07-31 20:07:27 +00002979//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002980
Eric Christopher44b93ff2009-07-31 20:07:27 +00002981// extload f32 -> f64. This matches load+fextend because we have a hack in
2982// the isel (PreprocessForFPConvert) that can introduce loads after dag
2983// combine.
Chris Lattnerd43d00c2008-01-24 08:07:48 +00002984// Since these loads aren't folded into the fextend, we have to match it
2985// explicitly here.
2986let Predicates = [HasSSE2] in
2987 def : Pat<(fextend (loadf32 addr:$src)),
2988 (CVTSS2SDrm addr:$src)>;
2989
Evan Cheng2c0dbd02006-03-24 02:58:06 +00002990// bit_convert
Chris Lattner4cc84ed2006-10-07 04:52:09 +00002991let Predicates = [HasSSE2] in {
2992 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2993 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2994 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2995 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2996 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2997 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2998 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2999 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
3000 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
3001 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
3002 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
3003 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
3004 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
3005 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
3006 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
3007 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3008 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3009 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3010 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3011 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3012 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3013 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3014 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3015 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3016 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3017 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3018 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3019 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3020 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3021 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3022}
Evan Chengb9df0ca2006-03-22 02:53:00 +00003023
Evan Cheng017dcc62006-04-21 01:05:10 +00003024// Move scalar to XMM zero-extended
3025// movd to XMM register zero-extends
Evan Chengf2ea84a2006-10-09 21:42:15 +00003026let AddedComplexity = 15 in {
Evan Cheng017dcc62006-04-21 01:05:10 +00003027// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chengd880b972008-05-09 21:53:03 +00003028def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003029 (MOVSDrr (v2f64 (V_SET0)), FR64:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00003030def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003031 (MOVSSrr (v4f32 (V_SET0)), FR32:$src)>;
Evan Cheng23573e52008-05-09 23:37:55 +00003032def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003033 (MOVSSrr (v4f32 (V_SET0)),
3034 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss)))>;
Evan Cheng331e2bd2008-07-10 01:08:23 +00003035def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003036 (MOVSSrr (v4i32 (V_SET0)),
3037 (EXTRACT_SUBREG (v4i32 VR128:$src), x86_subreg_ss))>;
Evan Cheng017dcc62006-04-21 01:05:10 +00003038}
Evan Chengbc4832b2006-03-24 23:15:12 +00003039
Evan Chengb9df0ca2006-03-22 02:53:00 +00003040// Splat v2f64 / v2i64
Evan Chengfd111b52006-04-19 21:15:24 +00003041let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003042def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003043 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003044def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003045 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003046def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003047 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003048def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003049 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengfd111b52006-04-19 21:15:24 +00003050}
Evan Cheng475aecf2006-03-29 03:04:49 +00003051
Evan Chengb7a5c522006-04-18 21:55:35 +00003052// Special unary SHUFPSrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003053def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3054 (SHUFPSrri VR128:$src1, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003055 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003056let AddedComplexity = 5 in
3057def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3058 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3059 Requires<[HasSSE2]>;
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003060// Special unary SHUFPDrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003061def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003062 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003063 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3064 Requires<[HasSSE2]>;
3065// Special unary SHUFPDrri case.
3066def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003067 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003068 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003069 Requires<[HasSSE2]>;
Evan Cheng3d60df42006-04-10 22:35:16 +00003070// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman9008ca62009-04-27 18:41:29 +00003071def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3072 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng7d9061e2006-03-30 19:54:57 +00003073 Requires<[HasSSE2]>;
Evan Chengb7a75a52008-09-26 23:41:32 +00003074
Evan Cheng3d60df42006-04-10 22:35:16 +00003075// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman9008ca62009-04-27 18:41:29 +00003076def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003077 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003078 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003079 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003080def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003081 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003082 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003083 Requires<[HasSSE2]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00003084// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman9008ca62009-04-27 18:41:29 +00003085def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003086 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003087 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00003088 Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003089
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003090// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003091let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003092def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3093 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003094 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003095def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3096 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003097 Requires<[OptForSpeed, HasSSE2]>;
3098}
Evan Chengfd111b52006-04-19 21:15:24 +00003099let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003100def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003101 (UNPCKLPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003102def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003103 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003104def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003105 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003106def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003107 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
Evan Chengfd111b52006-04-19 21:15:24 +00003108}
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003109
Evan Cheng174f8032007-05-17 18:44:37 +00003110// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003111let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003112def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3113 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003114 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003115def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3116 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003117 Requires<[OptForSpeed, HasSSE2]>;
3118}
Evan Cheng174f8032007-05-17 18:44:37 +00003119let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003120def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003121 (UNPCKHPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003122def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003123 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003124def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003125 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003126def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003127 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
Evan Cheng174f8032007-05-17 18:44:37 +00003128}
3129
Evan Chengb7a75a52008-09-26 23:41:32 +00003130let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003131// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman0b10b912009-11-07 23:17:15 +00003132def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003133 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003134
3135// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003136def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003137 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003138
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003139// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003140def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003141 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003142def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003143 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003144}
Evan Cheng9d09b892006-05-31 00:51:37 +00003145
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003146let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003147// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003148def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003149 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003150def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003151 (MOVLPDrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003152def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003153 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003154def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003155 (MOVLPDrm VR128:$src1, addr:$src2)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003156}
Evan Cheng64e97692006-04-24 21:58:20 +00003157
Evan Chengcd0baf22008-05-23 21:23:16 +00003158// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003159def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003160 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003161def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003162 (MOVLPDmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003163def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3164 addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003165 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003166def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003167 (MOVLPDmr addr:$src1, VR128:$src2)>;
Evan Chengcd0baf22008-05-23 21:23:16 +00003168
Evan Chengf2ea84a2006-10-09 21:42:15 +00003169let AddedComplexity = 15 in {
Evan Cheng64e97692006-04-24 21:58:20 +00003170// Setting the lowest element in the vector.
Nate Begeman9008ca62009-04-27 18:41:29 +00003171def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003172 (MOVSSrr (v4i32 VR128:$src1),
3173 (EXTRACT_SUBREG (v4i32 VR128:$src2), x86_subreg_ss))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003174def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003175 (MOVSDrr (v2i64 VR128:$src1),
3176 (EXTRACT_SUBREG (v2i64 VR128:$src2), x86_subreg_sd))>;
Evan Chenga7fc6422006-04-24 23:34:56 +00003177
Dan Gohman874cada2010-02-28 00:17:42 +00003178// vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
Nate Begeman9008ca62009-04-27 18:41:29 +00003179def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003180 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3181 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003182def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003183 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3184 Requires<[HasSSE2]>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003185}
Evan Cheng9e062ed2006-05-03 20:32:03 +00003186
Eli Friedman7e2242b2009-06-19 07:00:55 +00003187// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3188// fall back to this for SSE1)
3189def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003190 (SHUFPSrri VR128:$src2, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003191 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Eli Friedman7e2242b2009-06-19 07:00:55 +00003192
Evan Chenga7fc6422006-04-24 23:34:56 +00003193// Set lowest element and zero upper elements.
Evan Chengd880b972008-05-09 21:53:03 +00003194def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengfd17f422008-05-08 22:35:02 +00003195 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengcdfc3c82006-04-17 22:45:49 +00003196
Evan Cheng2c3ae372006-04-12 21:21:57 +00003197// Some special case pandn patterns.
3198def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3199 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003200 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003201def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3202 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003203 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003204def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3205 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003206 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003207
Evan Cheng2c3ae372006-04-12 21:21:57 +00003208def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003209 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003210 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003211def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003212 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003213 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003214def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003215 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003216 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng206ee9d2006-07-07 08:33:52 +00003217
Nate Begemanb348d182007-11-17 03:58:34 +00003218// vector -> vector casts
3219def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3220 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3221def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3222 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedmand0c0fae2008-09-05 23:07:03 +00003223def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3224 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3225def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3226 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb348d182007-11-17 03:58:34 +00003227
Evan Chengb4162fd2007-07-20 00:27:43 +00003228// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohmand3006222007-07-27 17:16:43 +00003229def : Pat<(alignedloadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003230 (MOVAPSrm addr:$src)>;
Dan Gohmand3006222007-07-27 17:16:43 +00003231def : Pat<(loadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003232 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003233def : Pat<(alignedloadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003234 (MOVAPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003235def : Pat<(loadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003236 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003237
3238def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003239 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003240def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003241 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003242def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003243 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003244def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003245 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003246def : Pat<(store (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003247 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003248def : Pat<(store (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003249 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003250def : Pat<(store (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003251 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003252def : Pat<(store (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003253 (MOVUPSmr addr:$dst, VR128:$src)>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003254
Nate Begeman63ec90a2008-02-03 07:18:54 +00003255//===----------------------------------------------------------------------===//
3256// SSE4.1 Instructions
3257//===----------------------------------------------------------------------===//
3258
Dale Johannesene397acc2008-10-10 23:51:03 +00003259multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003260 string OpcodeStr,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003261 Intrinsic V4F32Int,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003262 Intrinsic V2F64Int> {
Nate Begeman63ec90a2008-02-03 07:18:54 +00003263 // Intrinsic operation, reg.
Nate Begeman63ec90a2008-02-03 07:18:54 +00003264 // Vector intrinsic operation, reg
Eric Christopher44b93ff2009-07-31 20:07:27 +00003265 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003266 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003267 !strconcat(OpcodeStr,
3268 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003269 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3270 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003271
3272 // Vector intrinsic operation, mem
Evan Cheng400073d2009-12-18 07:40:29 +00003273 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003274 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003275 !strconcat(OpcodeStr,
3276 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003277 [(set VR128:$dst,
3278 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Cheng400073d2009-12-18 07:40:29 +00003279 TA, OpSize,
Evan Chengb1f49812009-12-22 17:47:23 +00003280 Requires<[HasSSE41]>;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003281
Nate Begeman63ec90a2008-02-03 07:18:54 +00003282 // Vector intrinsic operation, reg
Evan Cheng172b7942008-03-14 07:39:27 +00003283 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003284 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003285 !strconcat(OpcodeStr,
3286 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003287 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3288 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003289
3290 // Vector intrinsic operation, mem
Evan Cheng172b7942008-03-14 07:39:27 +00003291 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003292 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003293 !strconcat(OpcodeStr,
3294 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003295 [(set VR128:$dst,
3296 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003297 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003298}
3299
Dale Johannesene397acc2008-10-10 23:51:03 +00003300let Constraints = "$src1 = $dst" in {
3301multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3302 string OpcodeStr,
3303 Intrinsic F32Int,
3304 Intrinsic F64Int> {
3305 // Intrinsic operation, reg.
3306 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003307 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003308 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3309 !strconcat(OpcodeStr,
3310 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003311 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003312 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3313 OpSize;
3314
3315 // Intrinsic operation, mem.
Eric Christopher44b93ff2009-07-31 20:07:27 +00003316 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3317 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003318 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003319 !strconcat(OpcodeStr,
Dale Johannesene397acc2008-10-10 23:51:03 +00003320 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003321 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003322 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3323 OpSize;
3324
3325 // Intrinsic operation, reg.
3326 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003327 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003328 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3329 !strconcat(OpcodeStr,
3330 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003331 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003332 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3333 OpSize;
3334
3335 // Intrinsic operation, mem.
3336 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003337 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003338 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3339 !strconcat(OpcodeStr,
3340 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003341 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003342 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3343 OpSize;
3344}
3345}
3346
Nate Begeman63ec90a2008-02-03 07:18:54 +00003347// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesene397acc2008-10-10 23:51:03 +00003348defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3349 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3350defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3351 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003352
3353// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3354multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3355 Intrinsic IntId128> {
3356 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3357 (ins VR128:$src),
3358 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3359 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3360 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3361 (ins i128mem:$src),
3362 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3363 [(set VR128:$dst,
3364 (IntId128
3365 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3366}
3367
3368defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3369 int_x86_sse41_phminposuw>;
3370
3371/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003372let Constraints = "$src1 = $dst" in {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003373 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3374 Intrinsic IntId128, bit Commutable = 0> {
Nate Begemanfea2be52008-02-09 23:46:37 +00003375 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3376 (ins VR128:$src1, VR128:$src2),
3377 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3378 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3379 OpSize {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003380 let isCommutable = Commutable;
3381 }
Nate Begemanfea2be52008-02-09 23:46:37 +00003382 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3383 (ins VR128:$src1, i128mem:$src2),
3384 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3385 [(set VR128:$dst,
3386 (IntId128 VR128:$src1,
3387 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003388 }
3389}
3390
3391defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3392 int_x86_sse41_pcmpeqq, 1>;
3393defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3394 int_x86_sse41_packusdw, 0>;
3395defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3396 int_x86_sse41_pminsb, 1>;
3397defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3398 int_x86_sse41_pminsd, 1>;
3399defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3400 int_x86_sse41_pminud, 1>;
3401defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3402 int_x86_sse41_pminuw, 1>;
3403defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3404 int_x86_sse41_pmaxsb, 1>;
3405defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3406 int_x86_sse41_pmaxsd, 1>;
3407defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3408 int_x86_sse41_pmaxud, 1>;
3409defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3410 int_x86_sse41_pmaxuw, 1>;
Nate Begeman204e84e2008-02-04 06:00:24 +00003411
Mon P Wangaf9b9522008-12-18 21:42:19 +00003412defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3413
Nate Begeman30a0de92008-07-17 16:51:19 +00003414def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3415 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3416def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3417 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3418
Nate Begeman1426d522008-02-09 01:38:08 +00003419/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003420let Constraints = "$src1 = $dst" in {
Dan Gohman0b924dc2008-05-23 17:49:40 +00003421 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3422 SDNode OpNode, Intrinsic IntId128,
3423 bit Commutable = 0> {
Nate Begeman1426d522008-02-09 01:38:08 +00003424 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3425 (ins VR128:$src1, VR128:$src2),
3426 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman0b924dc2008-05-23 17:49:40 +00003427 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3428 VR128:$src2))]>, OpSize {
Nate Begeman1426d522008-02-09 01:38:08 +00003429 let isCommutable = Commutable;
3430 }
3431 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3432 (ins VR128:$src1, VR128:$src2),
3433 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3434 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3435 OpSize {
3436 let isCommutable = Commutable;
3437 }
3438 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3439 (ins VR128:$src1, i128mem:$src2),
3440 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3441 [(set VR128:$dst,
Chris Lattner1a7d0872010-02-18 06:33:42 +00003442 (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003443 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3444 (ins VR128:$src1, i128mem:$src2),
3445 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3446 [(set VR128:$dst,
Evan Chengb1938262008-05-23 00:37:07 +00003447 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman1426d522008-02-09 01:38:08 +00003448 OpSize;
3449 }
3450}
Eric Christopher8258d0b2010-03-30 18:49:01 +00003451
3452/// SS48I_binop_rm - Simple SSE41 binary operator.
3453let Constraints = "$src1 = $dst" in {
3454multiclass SS48I_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
3455 ValueType OpVT, bit Commutable = 0> {
3456 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3457 (ins VR128:$src1, VR128:$src2),
3458 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3459 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>,
3460 OpSize {
3461 let isCommutable = Commutable;
3462 }
3463 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3464 (ins VR128:$src1, i128mem:$src2),
3465 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3466 [(set VR128:$dst, (OpNode VR128:$src1,
3467 (bc_v4i32 (memopv2i64 addr:$src2))))]>,
3468 OpSize;
3469}
3470}
3471
3472defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003473
Evan Cheng172b7942008-03-14 07:39:27 +00003474/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Chenge9083d62008-03-05 08:19:16 +00003475let Constraints = "$src1 = $dst" in {
Nate Begeman204e84e2008-02-04 06:00:24 +00003476 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3477 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng172b7942008-03-14 07:39:27 +00003478 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003479 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003480 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003481 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003482 [(set VR128:$dst,
Nate Begemanfea2be52008-02-09 23:46:37 +00003483 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3484 OpSize {
Nate Begeman204e84e2008-02-04 06:00:24 +00003485 let isCommutable = Commutable;
3486 }
Evan Cheng172b7942008-03-14 07:39:27 +00003487 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003488 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3489 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003490 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begemanfea2be52008-02-09 23:46:37 +00003491 [(set VR128:$dst,
3492 (IntId128 VR128:$src1,
3493 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3494 OpSize;
Nate Begeman204e84e2008-02-04 06:00:24 +00003495 }
3496}
3497
3498defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3499 int_x86_sse41_blendps, 0>;
3500defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3501 int_x86_sse41_blendpd, 0>;
3502defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3503 int_x86_sse41_pblendw, 0>;
3504defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3505 int_x86_sse41_dpps, 1>;
3506defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3507 int_x86_sse41_dppd, 1>;
3508defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng35b9a772008-06-16 20:25:59 +00003509 int_x86_sse41_mpsadbw, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003510
Nate Begemanfea2be52008-02-09 23:46:37 +00003511
Evan Cheng172b7942008-03-14 07:39:27 +00003512/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003513let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanab5d56c2008-02-10 18:47:57 +00003514 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3515 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3516 (ins VR128:$src1, VR128:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003517 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003518 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3519 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3520 OpSize;
3521
3522 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3523 (ins VR128:$src1, i128mem:$src2),
3524 !strconcat(OpcodeStr,
3525 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3526 [(set VR128:$dst,
3527 (IntId VR128:$src1,
3528 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3529 }
3530}
3531
3532defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3533defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3534defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3535
3536
Nate Begemanfea2be52008-02-09 23:46:37 +00003537multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3538 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3539 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3540 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3541
3542 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3543 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003544 [(set VR128:$dst,
3545 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3546 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003547}
3548
3549defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3550defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3551defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3552defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3553defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3554defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3555
Evan Chengca57f782008-09-24 23:27:55 +00003556// Common patterns involving scalar load.
3557def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3558 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3559def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3560 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3561
3562def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3563 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3564def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3565 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3566
3567def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3568 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3569def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3570 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3571
3572def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3573 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3574def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3575 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3576
3577def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3578 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3579def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3580 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3581
3582def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3583 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3584def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3585 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3586
3587
Nate Begemanfea2be52008-02-09 23:46:37 +00003588multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3589 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3590 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3591 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3592
3593 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3594 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003595 [(set VR128:$dst,
3596 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3597 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003598}
3599
3600defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3601defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3602defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3603defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3604
Evan Chengca57f782008-09-24 23:27:55 +00003605// Common patterns involving scalar load
3606def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003607 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003608def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003609 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003610
3611def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003612 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003613def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003614 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003615
3616
Nate Begemanfea2be52008-02-09 23:46:37 +00003617multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3618 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3619 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3620 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3621
Evan Chengca57f782008-09-24 23:27:55 +00003622 // Expecting a i16 load any extended to i32 value.
Nate Begemanfea2be52008-02-09 23:46:37 +00003623 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3624 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003625 [(set VR128:$dst, (IntId (bitconvert
3626 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3627 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003628}
3629
3630defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman9d47b8d2009-06-06 05:55:37 +00003631defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begemanfea2be52008-02-09 23:46:37 +00003632
Evan Chengca57f782008-09-24 23:27:55 +00003633// Common patterns involving scalar load
3634def : Pat<(int_x86_sse41_pmovsxbq
3635 (bitconvert (v4i32 (X86vzmovl
3636 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003637 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003638
3639def : Pat<(int_x86_sse41_pmovzxbq
3640 (bitconvert (v4i32 (X86vzmovl
3641 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003642 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003643
Nate Begemanfea2be52008-02-09 23:46:37 +00003644
Nate Begeman14d12ca2008-02-11 04:19:36 +00003645/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3646multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003647 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003648 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003649 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003650 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003651 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3652 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003653 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003654 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003655 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003656 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003657 []>, OpSize;
3658// FIXME:
3659// There's an AssertZext in the way of writing the store pattern
3660// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begemanfea2be52008-02-09 23:46:37 +00003661}
3662
Nate Begeman14d12ca2008-02-11 04:19:36 +00003663defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003664
Nate Begeman14d12ca2008-02-11 04:19:36 +00003665
3666/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3667multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003668 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003669 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003670 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003671 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3672 []>, OpSize;
3673// FIXME:
3674// There's an AssertZext in the way of writing the store pattern
3675// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3676}
3677
3678defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3679
3680
3681/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3682multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003683 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003684 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003685 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003686 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3687 [(set GR32:$dst,
3688 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003689 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003690 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003691 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003692 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3693 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3694 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003695}
3696
Nate Begeman14d12ca2008-02-11 04:19:36 +00003697defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman1426d522008-02-09 01:38:08 +00003698
Nate Begeman14d12ca2008-02-11 04:19:36 +00003699
Evan Cheng62a3f152008-03-24 21:52:23 +00003700/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3701/// destination
Nate Begeman14d12ca2008-02-11 04:19:36 +00003702multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003703 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003704 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003705 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003706 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman171c11e2008-04-16 02:32:24 +00003707 [(set GR32:$dst,
3708 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng62a3f152008-03-24 21:52:23 +00003709 OpSize;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003710 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003711 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003712 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003713 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng62a3f152008-03-24 21:52:23 +00003714 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begemanfea2be52008-02-09 23:46:37 +00003715 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003716}
3717
Nate Begeman14d12ca2008-02-11 04:19:36 +00003718defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003719
Dan Gohmand9ced092008-08-08 18:30:21 +00003720// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3721def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3722 imm:$src2))),
3723 addr:$dst),
3724 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3725 Requires<[HasSSE41]>;
3726
Evan Chenge9083d62008-03-05 08:19:16 +00003727let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003728 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003729 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003730 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003731 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003732 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003733 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003734 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003735 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003736 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3737 !strconcat(OpcodeStr,
3738 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003739 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003740 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3741 imm:$src3))]>, OpSize;
3742 }
3743}
3744
3745defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3746
Evan Chenge9083d62008-03-05 08:19:16 +00003747let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003748 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003749 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003750 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003751 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003752 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003753 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003754 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3755 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003756 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003757 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3758 !strconcat(OpcodeStr,
3759 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003760 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003761 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3762 imm:$src3)))]>, OpSize;
3763 }
3764}
3765
3766defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3767
Eric Christopher1e5cdea2009-07-23 02:22:41 +00003768// insertps has a few different modes, there's the first two here below which
3769// are optimized inserts that won't zero arbitrary elements in the destination
3770// vector. The next one matches the intrinsic and could zero arbitrary elements
3771// in the target vector.
Evan Chenge9083d62008-03-05 08:19:16 +00003772let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003773 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherfbd66872009-07-24 00:33:09 +00003774 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3775 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003776 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003777 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003778 [(set VR128:$dst,
3779 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003780 OpSize;
Eric Christopherfbd66872009-07-24 00:33:09 +00003781 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003782 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3783 !strconcat(OpcodeStr,
3784 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003785 [(set VR128:$dst,
Eric Christopherfbd66872009-07-24 00:33:09 +00003786 (X86insrtps VR128:$src1,
3787 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003788 imm:$src3))]>, OpSize;
3789 }
3790}
3791
Evan Cheng7aae8762008-03-26 08:11:49 +00003792defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003793
Eric Christopherfbd66872009-07-24 00:33:09 +00003794def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3795 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3796
Eric Christopher71c67532009-07-29 00:28:05 +00003797// ptest instruction we'll lower to this in X86ISelLowering primarily from
3798// the intel intrinsic that corresponds to this.
Nate Begemanbc4efb82008-03-16 21:14:46 +00003799let Defs = [EFLAGS] in {
3800def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003801 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003802 [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>,
3803 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003804def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003805 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003806 [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>,
3807 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003808}
3809
3810def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3811 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderby40fe18f2010-02-10 00:10:31 +00003812 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3813 OpSize;
Nate Begeman30a0de92008-07-17 16:51:19 +00003814
Eric Christopherb120ab42009-08-18 22:50:32 +00003815
3816//===----------------------------------------------------------------------===//
3817// SSE4.2 Instructions
3818//===----------------------------------------------------------------------===//
3819
Nate Begeman30a0de92008-07-17 16:51:19 +00003820/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3821let Constraints = "$src1 = $dst" in {
3822 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3823 Intrinsic IntId128, bit Commutable = 0> {
3824 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3825 (ins VR128:$src1, VR128:$src2),
3826 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3827 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3828 OpSize {
3829 let isCommutable = Commutable;
3830 }
3831 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3832 (ins VR128:$src1, i128mem:$src2),
3833 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3834 [(set VR128:$dst,
3835 (IntId128 VR128:$src1,
3836 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3837 }
3838}
3839
Nate Begemane99b2552008-07-17 17:04:58 +00003840defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman30a0de92008-07-17 16:51:19 +00003841
3842def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3843 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3844def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3845 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003846
Bob Wilson86afec72010-03-25 16:36:14 +00003847defm AESIMC : SS42I_binop_rm_int<0xDB, "aesimc",
3848 int_x86_sse42_aesimc>;
3849defm AESENC : SS42I_binop_rm_int<0xDC, "aesenc",
3850 int_x86_sse42_aesenc>;
3851defm AESENCLAST : SS42I_binop_rm_int<0xDD, "aesenclast",
3852 int_x86_sse42_aesenclast>;
3853defm AESDEC : SS42I_binop_rm_int<0xDE, "aesdec",
3854 int_x86_sse42_aesdec>;
3855defm AESDECLAST : SS42I_binop_rm_int<0xDF, "aesdeclast",
3856 int_x86_sse42_aesdeclast>;
3857
Eric Christopher545d3b12010-03-29 20:41:51 +00003858def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, VR128:$src2)),
Bob Wilson86afec72010-03-25 16:36:14 +00003859 (AESIMCrr VR128:$src1, VR128:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003860def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, (memop addr:$src2))),
Bob Wilson86afec72010-03-25 16:36:14 +00003861 (AESIMCrm VR128:$src1, addr:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003862def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, VR128:$src2)),
Bob Wilson86afec72010-03-25 16:36:14 +00003863 (AESENCrr VR128:$src1, VR128:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003864def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, (memop addr:$src2))),
Bob Wilson86afec72010-03-25 16:36:14 +00003865 (AESENCrm VR128:$src1, addr:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003866def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, VR128:$src2)),
Bob Wilson86afec72010-03-25 16:36:14 +00003867 (AESENCLASTrr VR128:$src1, VR128:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003868def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, (memop addr:$src2))),
Bob Wilson86afec72010-03-25 16:36:14 +00003869 (AESENCLASTrm VR128:$src1, addr:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003870def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, VR128:$src2)),
Bob Wilson86afec72010-03-25 16:36:14 +00003871 (AESDECrr VR128:$src1, VR128:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003872def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, (memop addr:$src2))),
Bob Wilson86afec72010-03-25 16:36:14 +00003873 (AESDECrm VR128:$src1, addr:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003874def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, VR128:$src2)),
Bob Wilson86afec72010-03-25 16:36:14 +00003875 (AESDECLASTrr VR128:$src1, VR128:$src2)>;
Eric Christopher545d3b12010-03-29 20:41:51 +00003876def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, (memop addr:$src2))),
Bob Wilson86afec72010-03-25 16:36:14 +00003877 (AESDECLASTrm VR128:$src1, addr:$src2)>;
3878
3879def AESKEYGENASSIST128rr : SS42AI<0xDF, MRMSrcReg, (outs),
3880 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3881 "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
3882def AESKEYGENASSIST128rm : SS42AI<0xDF, MRMSrcMem, (outs),
3883 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3884 "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
3885
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003886// crc intrinsic instruction
3887// This set of instructions are only rm, the only difference is the size
3888// of r and m.
3889let Constraints = "$src1 = $dst" in {
Eric Christopher027c2b12009-08-10 21:48:58 +00003890 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003891 (ins GR32:$src1, i8mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003892 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003893 [(set GR32:$dst,
3894 (int_x86_sse42_crc32_8 GR32:$src1,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003895 (load addr:$src2)))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003896 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003897 (ins GR32:$src1, GR8:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003898 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003899 [(set GR32:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003900 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003901 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003902 (ins GR32:$src1, i16mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003903 "crc32{w} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003904 [(set GR32:$dst,
3905 (int_x86_sse42_crc32_16 GR32:$src1,
3906 (load addr:$src2)))]>,
3907 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003908 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003909 (ins GR32:$src1, GR16:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003910 "crc32{w} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003911 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003912 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003913 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003914 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003915 (ins GR32:$src1, i32mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003916 "crc32{l} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003917 [(set GR32:$dst,
3918 (int_x86_sse42_crc32_32 GR32:$src1,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003919 (load addr:$src2)))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003920 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003921 (ins GR32:$src1, GR32:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003922 "crc32{l} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003923 [(set GR32:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003924 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>;
3925 def CRC64m8 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
3926 (ins GR64:$src1, i8mem:$src2),
3927 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003928 [(set GR64:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003929 (int_x86_sse42_crc64_8 GR64:$src1,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003930 (load addr:$src2)))]>,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003931 REX_W;
3932 def CRC64r8 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
3933 (ins GR64:$src1, GR8:$src2),
3934 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003935 [(set GR64:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003936 (int_x86_sse42_crc64_8 GR64:$src1, GR8:$src2))]>,
3937 REX_W;
3938 def CRC64m64 : SS42FI<0xF1, MRMSrcMem, (outs GR64:$dst),
3939 (ins GR64:$src1, i64mem:$src2),
3940 "crc32{q} \t{$src2, $src1|$src1, $src2}",
3941 [(set GR64:$dst,
3942 (int_x86_sse42_crc64_64 GR64:$src1,
3943 (load addr:$src2)))]>,
3944 REX_W;
3945 def CRC64r64 : SS42FI<0xF1, MRMSrcReg, (outs GR64:$dst),
3946 (ins GR64:$src1, GR64:$src2),
3947 "crc32{q} \t{$src2, $src1|$src1, $src2}",
3948 [(set GR64:$dst,
3949 (int_x86_sse42_crc64_64 GR64:$src1, GR64:$src2))]>,
3950 REX_W;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003951}
Eric Christopherb120ab42009-08-18 22:50:32 +00003952
3953// String/text processing instructions.
Dan Gohman533297b2009-10-29 18:10:34 +00003954let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003955def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003956 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3957 "#PCMPISTRM128rr PSEUDO!",
3958 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3959 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003960def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003961 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3962 "#PCMPISTRM128rm PSEUDO!",
3963 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3964 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003965}
3966
3967let Defs = [XMM0, EFLAGS] in {
3968def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003969 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3970 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003971def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003972 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3973 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003974}
3975
Sean Callanan108934c2009-12-18 00:01:26 +00003976let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003977def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003978 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3979 "#PCMPESTRM128rr PSEUDO!",
3980 [(set VR128:$dst,
3981 (int_x86_sse42_pcmpestrm128
3982 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3983
Eric Christopherb120ab42009-08-18 22:50:32 +00003984def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003985 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3986 "#PCMPESTRM128rm PSEUDO!",
3987 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3988 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3989 OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003990}
3991
3992let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callanan47234e62009-08-20 18:24:27 +00003993def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003994 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3995 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callanan47234e62009-08-20 18:24:27 +00003996def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003997 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3998 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003999}
4000
4001let Defs = [ECX, EFLAGS] in {
4002 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan108934c2009-12-18 00:01:26 +00004003 def rr : SS42AI<0x63, MRMSrcReg, (outs),
4004 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4005 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
4006 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
4007 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004008 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00004009 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4010 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
4011 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
4012 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004013 }
4014}
4015
4016defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
4017defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
4018defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
4019defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
4020defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
4021defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
4022
4023let Defs = [ECX, EFLAGS] in {
4024let Uses = [EAX, EDX] in {
4025 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
4026 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00004027 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4028 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
4029 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
4030 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004031 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00004032 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4033 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
4034 [(set ECX,
4035 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
4036 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004037 }
4038}
4039}
4040
4041defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
4042defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
4043defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
4044defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
4045defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
4046defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;