blob: bd6e1b8c190e4fd4ffe54651b16226f5c9071a9c [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
Eric Christopher027c2b12009-08-10 21:48:58 +000072def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>,
Sean Callanan108934c2009-12-18 00:01:26 +000073 SDTCisVT<1, v4f32>]>;
Eric Christopher71c67532009-07-29 00:28:05 +000074def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
75
Evan Cheng2246f842006-03-18 01:23:20 +000076//===----------------------------------------------------------------------===//
Chris Lattner3a7cd952006-10-07 21:55:32 +000077// SSE Complex Patterns
78//===----------------------------------------------------------------------===//
79
80// These are 'extloads' from a scalar to the low element of a vector, zeroing
81// the top elements. These are used for the SSE 'ss' and 'sd' instruction
82// forms.
Rafael Espindola094fad32009-04-08 21:14:34 +000083def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000084 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindola094fad32009-04-08 21:14:34 +000085def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000086 [SDNPHasChain, SDNPMayLoad]>;
Chris Lattner3a7cd952006-10-07 21:55:32 +000087
88def ssmem : Operand<v4f32> {
89 let PrintMethod = "printf32mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000090 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000091 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000092}
93def sdmem : Operand<v2f64> {
94 let PrintMethod = "printf64mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000095 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000096 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000097}
98
99//===----------------------------------------------------------------------===//
Evan Cheng06a8aa12006-03-17 19:55:52 +0000100// SSE pattern fragments
101//===----------------------------------------------------------------------===//
102
Evan Cheng2246f842006-03-18 01:23:20 +0000103def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
104def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
Dan Gohman01976302007-06-25 15:19:03 +0000105def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
Evan Cheng24dc1f52006-03-23 07:44:07 +0000106def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000107
Dan Gohmand3006222007-07-27 17:16:43 +0000108// Like 'store', but always requires vector alignment.
Dan Gohman4106f372007-07-18 20:23:34 +0000109def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000110 (store node:$val, node:$ptr), [{
111 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000112}]>;
113
Dan Gohmand3006222007-07-27 17:16:43 +0000114// Like 'load', but always requires vector alignment.
Dan Gohman33586292008-10-15 06:50:19 +0000115def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
116 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000117}]>;
118
Sean Callanan108934c2009-12-18 00:01:26 +0000119def alignedloadfsf32 : PatFrag<(ops node:$ptr),
120 (f32 (alignedload node:$ptr))>;
121def alignedloadfsf64 : PatFrag<(ops node:$ptr),
122 (f64 (alignedload node:$ptr))>;
123def alignedloadv4f32 : PatFrag<(ops node:$ptr),
124 (v4f32 (alignedload node:$ptr))>;
125def alignedloadv2f64 : PatFrag<(ops node:$ptr),
126 (v2f64 (alignedload node:$ptr))>;
127def alignedloadv4i32 : PatFrag<(ops node:$ptr),
128 (v4i32 (alignedload node:$ptr))>;
129def alignedloadv2i64 : PatFrag<(ops node:$ptr),
130 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000131
132// Like 'load', but uses special alignment checks suitable for use in
133// memory operands in most SSE instructions, which are required to
David Greene95eb2ee2010-01-11 16:29:42 +0000134// be naturally aligned on some targets but not on others. If the subtarget
135// allows unaligned accesses, match any load, though this may require
136// setting a feature bit in the processor (on startup, for example).
137// Opteron 10h and later implement such a feature.
Dan Gohman33586292008-10-15 06:50:19 +0000138def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
David Greene95eb2ee2010-01-11 16:29:42 +0000139 return Subtarget->hasVectorUAMem()
140 || cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000141}]>;
142
Dan Gohmand3006222007-07-27 17:16:43 +0000143def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
144def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000145def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
146def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
147def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
148def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begemanfea2be52008-02-09 23:46:37 +0000149def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000150
Bill Wendling01284b42007-08-11 09:52:53 +0000151// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
152// 16-byte boundary.
Nate Begemanfea2be52008-02-09 23:46:37 +0000153// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohmana7250dd2008-10-16 00:03:00 +0000154def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman33586292008-10-15 06:50:19 +0000155 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling01284b42007-08-11 09:52:53 +0000156}]>;
157
158def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling01284b42007-08-11 09:52:53 +0000159def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
160def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
161def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
162
David Greene8939b0d2010-02-16 20:50:18 +0000163// MOVNT Support
164// Like 'store', but requires the non-temporal bit to be set
165def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
166 (st node:$val, node:$ptr), [{
167 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
168 return ST->isNonTemporal();
169 return false;
170}]>;
171
172def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
173 (st node:$val, node:$ptr), [{
174 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
175 return ST->isNonTemporal() && !ST->isTruncatingStore() &&
176 ST->getAddressingMode() == ISD::UNINDEXED &&
177 ST->getAlignment() >= 16;
178 return false;
179}]>;
180
181def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
182 (st node:$val, node:$ptr), [{
183 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
184 return ST->isNonTemporal() &&
185 ST->getAlignment() < 16;
186 return false;
187}]>;
188
Evan Cheng1b32f222006-03-30 07:33:32 +0000189def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
190def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
Evan Cheng506d3df2006-03-29 23:07:14 +0000191def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
192def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
Evan Cheng5aa97b22006-03-29 18:47:40 +0000193def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
194def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
195
Evan Chengca57f782008-09-24 23:27:55 +0000196def vzmovl_v2i64 : PatFrag<(ops node:$src),
197 (bitconvert (v2i64 (X86vzmovl
198 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
199def vzmovl_v4i32 : PatFrag<(ops node:$src),
200 (bitconvert (v4i32 (X86vzmovl
201 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
202
203def vzload_v2i64 : PatFrag<(ops node:$src),
204 (bitconvert (v2i64 (X86vzload node:$src)))>;
205
206
Evan Cheng386031a2006-03-24 07:29:27 +0000207def fp32imm0 : PatLeaf<(f32 fpimm), [{
208 return N->isExactlyValue(+0.0);
209}]>;
210
Evan Cheng89321162009-10-28 06:30:34 +0000211// BYTE_imm - Transform bit immediates into byte immediates.
212def BYTE_imm : SDNodeXForm<imm, [{
Evan Chengff65e382006-04-04 21:49:39 +0000213 // Transformation function: imm >> 3
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000214 return getI32Imm(N->getZExtValue() >> 3);
Evan Chengff65e382006-04-04 21:49:39 +0000215}]>;
216
Evan Cheng63d33002006-03-22 08:01:21 +0000217// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
218// SHUFP* etc. imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000219def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng63d33002006-03-22 08:01:21 +0000220 return getI8Imm(X86::getShuffleSHUFImmediate(N));
Evan Chengb9df0ca2006-03-22 02:53:00 +0000221}]>;
222
Eric Christopher44b93ff2009-07-31 20:07:27 +0000223// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000224// PSHUFHW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000225def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000226 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
227}]>;
228
Eric Christopher44b93ff2009-07-31 20:07:27 +0000229// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000230// PSHUFLW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000231def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000232 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
233}]>;
234
Nate Begemana09008b2009-10-19 02:17:23 +0000235// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
236// a PALIGNR imm.
237def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
238 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
239}]>;
240
Nate Begeman9008ca62009-04-27 18:41:29 +0000241def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
242 (vector_shuffle node:$lhs, node:$rhs), [{
243 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
244 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
245}]>;
246
247def movddup : PatFrag<(ops node:$lhs, node:$rhs),
248 (vector_shuffle node:$lhs, node:$rhs), [{
249 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
250}]>;
251
252def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
253 (vector_shuffle node:$lhs, node:$rhs), [{
254 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
255}]>;
256
257def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
258 (vector_shuffle node:$lhs, node:$rhs), [{
259 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
260}]>;
261
Nate Begeman0b10b912009-11-07 23:17:15 +0000262def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
263 (vector_shuffle node:$lhs, node:$rhs), [{
264 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman9008ca62009-04-27 18:41:29 +0000265}]>;
266
267def movlp : PatFrag<(ops node:$lhs, node:$rhs),
268 (vector_shuffle node:$lhs, node:$rhs), [{
269 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
270}]>;
271
272def movl : PatFrag<(ops node:$lhs, node:$rhs),
273 (vector_shuffle node:$lhs, node:$rhs), [{
274 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
275}]>;
276
277def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
278 (vector_shuffle node:$lhs, node:$rhs), [{
279 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
280}]>;
281
282def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
283 (vector_shuffle node:$lhs, node:$rhs), [{
284 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
285}]>;
286
287def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
288 (vector_shuffle node:$lhs, node:$rhs), [{
289 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
290}]>;
291
292def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
293 (vector_shuffle node:$lhs, node:$rhs), [{
294 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
295}]>;
296
297def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
298 (vector_shuffle node:$lhs, node:$rhs), [{
299 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
300}]>;
301
302def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
303 (vector_shuffle node:$lhs, node:$rhs), [{
304 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
305}]>;
306
307def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
308 (vector_shuffle node:$lhs, node:$rhs), [{
309 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng691c9232006-03-29 19:02:40 +0000310}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000311
Nate Begeman9008ca62009-04-27 18:41:29 +0000312def shufp : PatFrag<(ops node:$lhs, node:$rhs),
313 (vector_shuffle node:$lhs, node:$rhs), [{
314 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng14aed5e2006-03-24 01:18:28 +0000315}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000316
Nate Begeman9008ca62009-04-27 18:41:29 +0000317def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
318 (vector_shuffle node:$lhs, node:$rhs), [{
319 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000320}], SHUFFLE_get_pshufhw_imm>;
321
Nate Begeman9008ca62009-04-27 18:41:29 +0000322def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
323 (vector_shuffle node:$lhs, node:$rhs), [{
324 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000325}], SHUFFLE_get_pshuflw_imm>;
326
Nate Begemana09008b2009-10-19 02:17:23 +0000327def palign : PatFrag<(ops node:$lhs, node:$rhs),
328 (vector_shuffle node:$lhs, node:$rhs), [{
329 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
330}], SHUFFLE_get_palign_imm>;
331
Evan Cheng06a8aa12006-03-17 19:55:52 +0000332//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000333// SSE scalar FP Instructions
334//===----------------------------------------------------------------------===//
335
Dan Gohman533297b2009-10-29 18:10:34 +0000336// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
337// instruction selection into a branch sequence.
338let Uses = [EFLAGS], usesCustomInserter = 1 in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000339 def CMOV_FR32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000340 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000341 "#CMOV_FR32 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000342 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
343 EFLAGS))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000344 def CMOV_FR64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000345 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000346 "#CMOV_FR64 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000347 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
348 EFLAGS))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000349 def CMOV_V4F32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000350 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000351 "#CMOV_V4F32 PSEUDO!",
352 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000353 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
354 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000355 def CMOV_V2F64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000356 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000357 "#CMOV_V2F64 PSEUDO!",
358 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000359 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
360 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000361 def CMOV_V2I64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000362 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000363 "#CMOV_V2I64 PSEUDO!",
364 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000365 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng0488db92007-09-25 01:57:46 +0000366 EFLAGS)))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000367}
368
Bill Wendlingddd35322007-05-02 23:11:52 +0000369//===----------------------------------------------------------------------===//
370// SSE1 Instructions
371//===----------------------------------------------------------------------===//
372
Dan Gohman874cada2010-02-28 00:17:42 +0000373// Move Instructions. Register-to-register movss is not used for FR32
374// register copies because it's a partial register update; FsMOVAPSrr is
375// used instead. Register-to-register movss is not modeled as an INSERT_SUBREG
376// because INSERT_SUBREG requires that the insert be implementable in terms of
377// a copy, and just mentioned, we don't use movss for copies.
378let Constraints = "$src1 = $dst" in
379def MOVSSrr : SSI<0x10, MRMSrcReg,
380 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
381 "movss\t{$src2, $dst|$dst, $src2}",
382 [(set VR128:$dst,
383 (movl VR128:$src1, (scalar_to_vector FR32:$src2)))]>;
384
385// Extract the low 32-bit value from one vector and insert it into another.
386let AddedComplexity = 15 in
387def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +0000388 (MOVSSrr (v4f32 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +0000389 (EXTRACT_SUBREG (v4f32 VR128:$src2), x86_subreg_ss))>;
390
391// Implicitly promote a 32-bit scalar to a vector.
392def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
393 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, x86_subreg_ss)>;
394
395// Loading from memory automatically zeroing upper bits.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000396let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000397def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000398 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000399 [(set FR32:$dst, (loadf32 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +0000400
401// MOVSSrm zeros the high parts of the register; represent this
402// with SUBREG_TO_REG.
403let AddedComplexity = 20 in {
404def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
405 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
406def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
407 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
408def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
409 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
410}
411
412// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +0000413def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000414 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000415 [(store FR32:$src, addr:$dst)]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000416
Dan Gohman874cada2010-02-28 00:17:42 +0000417// Extract and store.
418def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
419 addr:$dst),
420 (MOVSSmr addr:$dst,
421 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
422
Evan Chengc46349d2006-03-28 23:51:43 +0000423// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +0000424def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000425 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000426 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000427def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000428 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000429 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000430def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000431 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000432 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000433def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000434 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000435 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
Evan Chengc46349d2006-03-28 23:51:43 +0000436
Evan Chengd2a6d542006-04-12 23:42:44 +0000437// Match intrinsics which expect XMM operand(s).
Sean Callanan108934c2009-12-18 00:01:26 +0000438def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
439 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
440def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
441 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
442
Evan Cheng64d80e32007-07-19 01:14:50 +0000443def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000444 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000445 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000446def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000447 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000448 [(set GR32:$dst, (int_x86_sse_cvtss2si
449 (load addr:$src)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000450
Dale Johannesenc7842082007-10-30 22:15:38 +0000451// Match intrinisics which expect MM and XMM operand(s).
452def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
453 "cvtps2pi\t{$src, $dst|$dst, $src}",
454 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
455def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
456 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000457 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000458 (load addr:$src)))]>;
459def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
460 "cvttps2pi\t{$src, $dst|$dst, $src}",
461 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
462def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
463 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000464 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000465 (load addr:$src)))]>;
Evan Chenge9083d62008-03-05 08:19:16 +0000466let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000467 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesenc7842082007-10-30 22:15:38 +0000468 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
469 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
470 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
471 VR64:$src2))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000472 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesenc7842082007-10-30 22:15:38 +0000473 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
474 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000475 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesenc7842082007-10-30 22:15:38 +0000476 (load addr:$src2)))]>;
477}
478
Evan Chengd2a6d542006-04-12 23:42:44 +0000479// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +0000480def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000481 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000482 [(set GR32:$dst,
483 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000484def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000485 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000486 [(set GR32:$dst,
487 (int_x86_sse_cvttss2si(load addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +0000488
Evan Chenge9083d62008-03-05 08:19:16 +0000489let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000490 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000491 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000492 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000493 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
494 GR32:$src2))]>;
495 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000496 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000497 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000498 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
499 (loadi32 addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000500}
Evan Chengd03db7a2006-04-12 05:20:24 +0000501
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000502// Comparison instructions
Dan Gohmanb1347092009-01-09 02:27:34 +0000503let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000504 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000505 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000506 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000507let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +0000508 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000509 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000510 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000511}
512
Evan Cheng24f2ea32007-09-14 21:48:26 +0000513let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000514def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000515 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +0000516 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000517def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000518 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +0000519 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng0488db92007-09-25 01:57:46 +0000520 (implicit EFLAGS)]>;
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}",
Evan Chenge5f62042007-09-29 00:00:36 +0000549 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000550 (implicit EFLAGS)]>;
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}",
Evan Chenge5f62042007-09-29 00:00:36 +0000553 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng0488db92007-09-25 01:57:46 +0000554 (implicit EFLAGS)]>;
555
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}",
Evan Chenge5f62042007-09-29 00:00:36 +0000558 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000559 (implicit EFLAGS)]>;
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}",
Evan Chenge5f62042007-09-29 00:00:36 +0000562 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng0488db92007-09-25 01:57:46 +0000563 (implicit EFLAGS)]>;
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}",
1144 [(set VR128:$dst,
1145 (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}",
Evan Chenge5f62042007-09-29 00:00:36 +00001301 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
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}",
Evan Chenge5f62042007-09-29 00:00:36 +00001304 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng0488db92007-09-25 01:57:46 +00001305 (implicit EFLAGS)]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001306} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001307
Bill Wendlingddd35322007-05-02 23:11:52 +00001308// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +00001309let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001310 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +00001311 (outs VR128:$dst),
1312 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001313 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001314 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1315 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001316 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +00001317 (outs VR128:$dst),
1318 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001319 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001320 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1321 (load addr:$src), imm:$cc))]>;
1322}
1323
Evan Cheng0488db92007-09-25 01:57:46 +00001324let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001325def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001326 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00001327 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1328 (implicit EFLAGS)]>;
1329def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001330 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00001331 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1332 (implicit EFLAGS)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001333
Evan Cheng64d80e32007-07-19 01:14:50 +00001334def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00001336 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1337 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001338def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001339 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00001340 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng0488db92007-09-25 01:57:46 +00001341 (implicit EFLAGS)]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001342} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001343
Eric Christopher44b93ff2009-07-31 20:07:27 +00001344// Aliases of packed SSE2 instructions for scalar use. These all have names
1345// that start with 'Fs'.
Bill Wendlingddd35322007-05-02 23:11:52 +00001346
1347// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +00001348let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1349 canFoldAsLoad = 1 in
Chris Lattnerbe1778f2010-02-05 21:34:18 +00001350def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1351 [(set FR64:$dst, fpimm0)]>,
Bill Wendlingddd35322007-05-02 23:11:52 +00001352 Requires<[HasSSE2]>, TB, OpSize;
1353
Dan Gohman32791e02007-06-25 15:44:19 +00001354// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001355// disregarded.
Chris Lattnerba7e7562008-01-10 07:59:24 +00001356let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001357def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001358 "movapd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001359
Dan Gohman32791e02007-06-25 15:44:19 +00001360// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001361// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001362let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001363def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001364 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +00001365 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001366
1367// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +00001368let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001369let isCommutable = 1 in {
Evan Chengb6093392008-05-02 07:53:32 +00001370 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1371 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001372 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001373 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001374 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1375 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001376 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001377 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001378 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1379 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001380 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001381 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1382}
1383
Evan Chengb6093392008-05-02 07:53:32 +00001384def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1385 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001386 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001387 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001388 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001389def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1390 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001391 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001392 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001393 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001394def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1395 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001397 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001398 (memopfsf64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001399
Chris Lattnerba7e7562008-01-10 07:59:24 +00001400let neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001401def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001402 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001403 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001404let mayLoad = 1 in
Bill Wendlingddd35322007-05-02 23:11:52 +00001405def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001406 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001407 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001408}
Chris Lattnerba7e7562008-01-10 07:59:24 +00001409}
Bill Wendlingddd35322007-05-02 23:11:52 +00001410
Dan Gohman20382522007-07-10 00:05:58 +00001411/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +00001412///
Dan Gohman20382522007-07-10 00:05:58 +00001413/// In addition, we also have a special variant of the scalar form here to
1414/// represent the associated intrinsic operation. This form is unlike the
1415/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +00001416/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +00001417///
1418/// These three forms can each be reg+reg or reg+mem, so there are a total of
1419/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +00001420///
Evan Chenge9083d62008-03-05 08:19:16 +00001421let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001422multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1423 SDNode OpNode, Intrinsic F64Int,
1424 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +00001425 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001426 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001427 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001428 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1429 let isCommutable = Commutable;
1430 }
1431
1432 // Scalar operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001433 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1434 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001435 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001436 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001437
Dan Gohman20382522007-07-10 00:05:58 +00001438 // Vector operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001439 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1440 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001441 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001442 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1443 let isCommutable = Commutable;
1444 }
1445
1446 // Vector operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001447 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1448 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanb1347092009-01-09 02:27:34 +00001450 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001451
1452 // Intrinsic operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001453 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1454 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001455 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +00001456 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001457
Dan Gohman20382522007-07-10 00:05:58 +00001458 // Intrinsic operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001459 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1460 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001461 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001462 [(set VR128:$dst, (F64Int VR128:$src1,
1463 sse_load_f64:$src2))]>;
1464}
1465}
1466
1467// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +00001468defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1469defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1470defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1471defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001472
Dan Gohman20382522007-07-10 00:05:58 +00001473/// sse2_fp_binop_rm - Other SSE2 binops
1474///
1475/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1476/// instructions for a full-vector intrinsic form. Operations that map
1477/// onto C operators don't use this form since they just use the plain
1478/// vector form instead of having a separate vector intrinsic form.
1479///
1480/// This provides a total of eight "instructions".
1481///
Evan Chenge9083d62008-03-05 08:19:16 +00001482let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001483multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1484 SDNode OpNode,
1485 Intrinsic F64Int,
1486 Intrinsic V2F64Int,
1487 bit Commutable = 0> {
1488
1489 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001490 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001491 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001492 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1493 let isCommutable = Commutable;
1494 }
1495
1496 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001497 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1498 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001499 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001500 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001501
Dan Gohman20382522007-07-10 00:05:58 +00001502 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001503 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1504 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001505 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001506 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1507 let isCommutable = Commutable;
1508 }
1509
1510 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001511 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1512 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001513 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001514 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001515
1516 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001517 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1518 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001519 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001520 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1521 let isCommutable = Commutable;
1522 }
1523
1524 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001525 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1526 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001527 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001528 [(set VR128:$dst, (F64Int VR128:$src1,
1529 sse_load_f64:$src2))]>;
1530
1531 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001532 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1533 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001534 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001535 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1536 let isCommutable = Commutable;
1537 }
1538
1539 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001540 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1541 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001542 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001543 [(set VR128:$dst, (V2F64Int VR128:$src1,
1544 (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001545}
1546}
1547
1548defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1549 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1550defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1551 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001552
Eric Christopher44b93ff2009-07-31 20:07:27 +00001553//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001554// SSE packed FP Instructions
1555
1556// Move Instructions
Chris Lattnerba7e7562008-01-10 07:59:24 +00001557let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001558def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001559 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001560let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001561def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001562 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001563 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001564
Evan Cheng64d80e32007-07-19 01:14:50 +00001565def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001566 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001567 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001568
Chris Lattnerf77e0372008-01-11 06:59:07 +00001569let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001570def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001571 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001572let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001573def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001574 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001575 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001576def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001577 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001578 [(store (v2f64 VR128:$src), addr:$dst)]>;
1579
1580// Intrinsic forms of MOVUPD load and store
Evan Cheng64d80e32007-07-19 01:14:50 +00001581def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001582 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001583 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001584def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001586 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001587
Evan Chenge9083d62008-03-05 08:19:16 +00001588let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001589 let AddedComplexity = 20 in {
1590 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001591 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001592 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001593 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001594 (v2f64 (movlp VR128:$src1,
1595 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001596 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001597 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001598 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001599 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +00001600 (v2f64 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001601 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001602 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001603} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001604
Evan Cheng64d80e32007-07-19 01:14:50 +00001605def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001606 "movlpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001607 [(store (f64 (vector_extract (v2f64 VR128:$src),
1608 (iPTR 0))), addr:$dst)]>;
1609
1610// v2f64 extract element 1 is always custom lowered to unpack high to low
1611// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +00001612def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001613 "movhpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001614 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +00001615 (v2f64 (unpckh VR128:$src, (undef))),
1616 (iPTR 0))), addr:$dst)]>;
Evan Chengd9539472006-04-14 21:59:03 +00001617
Evan Cheng470a6ad2006-02-22 02:26:30 +00001618// SSE2 instructions without OpSize prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001619def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001620 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001621 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1622 TB, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001623def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001624 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1625 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1626 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001627 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001628
1629// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001630def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001631 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001632 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1633 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001634def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001635 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1636 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1637 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001638 XS, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001639
Evan Cheng64d80e32007-07-19 01:14:50 +00001640def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001641 "cvtps2dq\t{$src, $dst|$dst, $src}",
1642 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001643def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001644 "cvtps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001645 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001646 (memop addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001647// SSE2 packed instructions with XS prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001648def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1649 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1650def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1651 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1652
Evan Cheng64d80e32007-07-19 01:14:50 +00001653def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +00001655 [(set VR128:$dst,
1656 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001657 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001658def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659 "cvttps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001660 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001661 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001662 XS, Requires<[HasSSE2]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001663
Evan Cheng470a6ad2006-02-22 02:26:30 +00001664// SSE2 packed instructions with XD prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001665def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001667 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1668 XD, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001669def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001670 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001671 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001672 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001673 XD, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001674
Evan Cheng64d80e32007-07-19 01:14:50 +00001675def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001676 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001677 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng029d9da2008-03-14 07:46:48 +00001678def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001679 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001680 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001681 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001682
1683// SSE2 instructions without OpSize prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001684def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1685 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1686def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1687 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1688
Evan Cheng64d80e32007-07-19 01:14:50 +00001689def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001691 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1692 TB, Requires<[HasSSE2]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001693def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001694 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001695 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
Chris Lattner15258d52006-10-07 06:17:43 +00001696 (load addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001697 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001698
Sean Callanan108934c2009-12-18 00:01:26 +00001699def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1700 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1701def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1702 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1703
1704
Evan Cheng64d80e32007-07-19 01:14:50 +00001705def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001706 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001707 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001708def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001709 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001710 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Chengb1938262008-05-23 00:37:07 +00001711 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001712
Evan Chengd2a6d542006-04-12 23:42:44 +00001713// Match intrinsics which expect XMM operand(s).
1714// Aliases for intrinsics
Evan Chenge9083d62008-03-05 08:19:16 +00001715let Constraints = "$src1 = $dst" in {
Evan Chengd2a6d542006-04-12 23:42:44 +00001716def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001717 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001719 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
Evan Cheng069287d2006-05-16 07:21:53 +00001720 GR32:$src2))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001721def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001722 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001724 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1725 (loadi32 addr:$src2)))]>;
1726def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001727 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001728 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001729 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1730 VR128:$src2))]>;
1731def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00001732 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001733 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001734 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001735 (load addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001736def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001737 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001738 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001739 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1740 VR128:$src2))]>, XS,
1741 Requires<[HasSSE2]>;
1742def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001743 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001744 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001745 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001746 (load addr:$src2)))]>, XS,
Evan Chengd2a6d542006-04-12 23:42:44 +00001747 Requires<[HasSSE2]>;
1748}
1749
Dan Gohman20382522007-07-10 00:05:58 +00001750// Arithmetic
1751
1752/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
Chris Lattner6f987732006-10-07 21:17:13 +00001753///
Dan Gohman20382522007-07-10 00:05:58 +00001754/// In addition, we also have a special variant of the scalar form here to
1755/// represent the associated intrinsic operation. This form is unlike the
1756/// plain scalar form, in that it takes an entire vector (instead of a
1757/// scalar) and leaves the top elements undefined.
1758///
1759/// And, we have a special variant form for a full-vector intrinsic form.
1760///
1761/// These four forms can each have a reg or a mem operand, so there are a
1762/// total of eight "instructions".
1763///
1764multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1765 SDNode OpNode,
1766 Intrinsic F64Int,
1767 Intrinsic V2F64Int,
1768 bit Commutable = 0> {
1769 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001770 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001771 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001772 [(set FR64:$dst, (OpNode FR64:$src))]> {
Chris Lattner6f987732006-10-07 21:17:13 +00001773 let isCommutable = Commutable;
1774 }
Bill Wendlingddd35322007-05-02 23:11:52 +00001775
Dan Gohman20382522007-07-10 00:05:58 +00001776 // Scalar operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001777 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001778 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001779 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001780
Dan Gohman20382522007-07-10 00:05:58 +00001781 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001782 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001783 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001784 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1785 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001786 }
1787
Dan Gohman20382522007-07-10 00:05:58 +00001788 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001789 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001790 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001791 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001792
1793 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001794 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001795 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001796 [(set VR128:$dst, (F64Int VR128:$src))]> {
1797 let isCommutable = Commutable;
1798 }
1799
1800 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001801 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001802 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001803 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1804
1805 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001806 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001807 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001808 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1809 let isCommutable = Commutable;
1810 }
1811
1812 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001813 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001814 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001815 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Evan Cheng97ac5fa2006-04-03 23:49:17 +00001816}
Evan Chengffcb95b2006-02-21 19:13:53 +00001817
Dan Gohman20382522007-07-10 00:05:58 +00001818// Square root.
1819defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1820 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1821
1822// There is no f64 version of the reciprocal approximation instructions.
1823
Evan Chengffcb95b2006-02-21 19:13:53 +00001824// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001825let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001826 let isCommutable = 1 in {
1827 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001828 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001829 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001830 [(set VR128:$dst,
1831 (and (bc_v2i64 (v2f64 VR128:$src1)),
Chris Lattner3b57a832006-10-07 06:27:03 +00001832 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001833 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001834 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001835 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001836 [(set VR128:$dst,
1837 (or (bc_v2i64 (v2f64 VR128:$src1)),
1838 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1839 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001840 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001841 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001842 [(set VR128:$dst,
1843 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1844 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1845 }
1846
1847 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001848 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001849 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001850 [(set VR128:$dst,
1851 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001852 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001853 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001854 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001855 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001856 [(set VR128:$dst,
1857 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001858 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001859 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001860 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001861 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001862 [(set VR128:$dst,
1863 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001864 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001865 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001866 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001868 [(set VR128:$dst,
1869 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Chris Lattner3b57a832006-10-07 06:27:03 +00001870 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001871 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001872 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001873 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001874 [(set VR128:$dst,
1875 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001876 (memopv2i64 addr:$src2)))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +00001877}
Evan Chengbf156d12006-02-21 19:26:52 +00001878
Evan Chenge9083d62008-03-05 08:19:16 +00001879let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001880 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001881 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1882 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1883 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begemanc2616e42008-05-12 20:34:32 +00001884 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001885 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng029d9da2008-03-14 07:46:48 +00001886 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1887 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1888 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001889 (memop addr:$src), imm:$cc))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001890}
Evan Chenge9d50352008-08-05 22:19:15 +00001891def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001892 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Chenge9d50352008-08-05 22:19:15 +00001893def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001894 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001895
1896// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001897let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001898 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001899 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1900 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman9008ca62009-04-27 18:41:29 +00001901 [(set VR128:$dst,
1902 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001903 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001904 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00001905 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001906 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001907 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001908 (v2f64 (shufp:$src3
1909 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001910
Bill Wendlingddd35322007-05-02 23:11:52 +00001911 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001912 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001913 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001914 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001915 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001916 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001917 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001918 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001919 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001920 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001921 (v2f64 (unpckh VR128:$src1,
1922 (memopv2f64 addr:$src2))))]>;
Evan Cheng4fcb9222006-03-28 02:43:26 +00001923
Eric Christopher44b93ff2009-07-31 20:07:27 +00001924 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001925 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001926 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001927 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001928 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001929 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001930 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001932 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001933 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001934 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001935} // Constraints = "$src1 = $dst"
Evan Cheng470a6ad2006-02-22 02:26:30 +00001936
Evan Cheng4b1734f2006-03-31 21:29:33 +00001937
Eric Christopher44b93ff2009-07-31 20:07:27 +00001938//===---------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001939// SSE integer instructions
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"
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002048
2049// 128-bit Integer Arithmetic
2050
2051defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2052defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2053defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002054defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002055
Chris Lattner45e123c2006-10-07 19:02:31 +00002056defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2057defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2058defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2059defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002060
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002061defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2062defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2063defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002064defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002065
Chris Lattner45e123c2006-10-07 19:02:31 +00002066defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2067defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2068defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2069defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002070
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002071defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002072
Chris Lattner45e123c2006-10-07 19:02:31 +00002073defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2074defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2075defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002076
Chris Lattner45e123c2006-10-07 19:02:31 +00002077defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
Chris Lattner77337992006-10-07 07:06:17 +00002078
Chris Lattner45e123c2006-10-07 19:02:31 +00002079defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2080defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
Chris Lattner8139e282006-10-07 18:39:00 +00002081
Chris Lattner77337992006-10-07 07:06:17 +00002082
Chris Lattner45e123c2006-10-07 19:02:31 +00002083defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2084defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2085defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2086defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling3b1259b2009-05-28 02:04:00 +00002087defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Evan Chengc60bd972006-03-25 09:37:23 +00002088
Chris Lattner77337992006-10-07 07:06:17 +00002089
Evan Cheng22b942a2008-05-03 00:52:09 +00002090defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2091 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2092defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2093 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2094defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2095 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002096
Evan Cheng22b942a2008-05-03 00:52:09 +00002097defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2098 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2099defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2100 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begeman32097bd2008-05-13 17:52:09 +00002101defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Cheng22b942a2008-05-03 00:52:09 +00002102 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002103
Evan Cheng22b942a2008-05-03 00:52:09 +00002104defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2105 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemanc9bdb002008-05-13 01:47:52 +00002106defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Cheng22b942a2008-05-03 00:52:09 +00002107 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Chris Lattner77337992006-10-07 07:06:17 +00002108
Chris Lattner6970eda2006-10-07 19:49:05 +00002109// 128-bit logical shifts.
Evan Chenge9083d62008-03-05 08:19:16 +00002110let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002111 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002112 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002113 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002114 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002115 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002116 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002117 // PSRADQri doesn't exist in SSE[1-3].
Evan Chengff65e382006-04-04 21:49:39 +00002118}
2119
Chris Lattner6970eda2006-10-07 19:49:05 +00002120let Predicates = [HasSSE2] in {
2121 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002122 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002123 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002124 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling5e249b42008-10-02 05:56:52 +00002125 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2126 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2127 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2128 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Evan Cheng68c47cb2007-01-05 07:55:56 +00002129 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng89321162009-10-28 06:30:34 +00002130 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002131
2132 // Shift up / down and insert zero's.
2133 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002134 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002135 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002136 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002137}
2138
Evan Cheng506d3df2006-03-29 23:07:14 +00002139// Logical
Chris Lattnera7ebe552006-10-07 19:37:30 +00002140defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2141defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2142defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2143
Evan Chenge9083d62008-03-05 08:19:16 +00002144let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002145 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002146 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002147 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002148 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2149 VR128:$src2)))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002150
Bill Wendlingddd35322007-05-02 23:11:52 +00002151 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002152 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002153 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002154 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7f55fcb2007-08-02 21:17:01 +00002155 (memopv2i64 addr:$src2))))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002156}
2157
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002158// SSE2 Integer comparison
Bill Wendlingddd35322007-05-02 23:11:52 +00002159defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2160defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2161defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2162defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2163defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2164defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002165
Nate Begeman30a0de92008-07-17 16:51:19 +00002166def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002167 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002168def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002169 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002170def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002171 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002172def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002173 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002174def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002175 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002176def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002177 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2178
Nate Begeman30a0de92008-07-17 16:51:19 +00002179def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002180 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002181def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002182 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002183def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002184 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002185def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002186 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002187def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002188 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002189def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002190 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2191
2192
Evan Cheng506d3df2006-03-29 23:07:14 +00002193// Pack instructions
Chris Lattner45e123c2006-10-07 19:02:31 +00002194defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2195defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2196defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002197
2198// Shuffle and unpack instructions
Nate Begemana09008b2009-10-19 02:17:23 +00002199let AddedComplexity = 5 in {
Evan Cheng8703be42006-04-04 19:12:30 +00002200def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002201 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002202 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002203 [(set VR128:$dst, (v4i32 (pshufd:$src2
2204 VR128:$src1, (undef))))]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002205def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002206 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002207 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002208 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chengc3630942009-12-09 21:00:30 +00002209 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002210 (undef))))]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002211}
Evan Cheng506d3df2006-03-29 23:07:14 +00002212
2213// SSE2 with ImmT == Imm8 and XS prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002214def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002215 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002216 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002217 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2218 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002219 XS, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002220def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002221 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002222 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002223 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher44b93ff2009-07-31 20:07:27 +00002224 (bc_v8i16 (memopv2i64 addr:$src1)),
2225 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002226 XS, Requires<[HasSSE2]>;
2227
2228// SSE2 with ImmT == Imm8 and XD prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002229def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman9008ca62009-04-27 18:41:29 +00002230 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002231 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002232 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2233 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002234 XD, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002235def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman9008ca62009-04-27 18:41:29 +00002236 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002237 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002238 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2239 (bc_v8i16 (memopv2i64 addr:$src1)),
2240 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002241 XD, Requires<[HasSSE2]>;
2242
Evan Chengc60bd972006-03-25 09:37:23 +00002243
Evan Chenge9083d62008-03-05 08:19:16 +00002244let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002245 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002246 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002247 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002248 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002249 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002250 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002251 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002252 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002253 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002254 (unpckl VR128:$src1,
2255 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002256 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002257 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002258 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002259 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002260 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002261 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002262 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002264 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002265 (unpckl VR128:$src1,
2266 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002267 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002268 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002269 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002270 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002271 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002272 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002273 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002274 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002275 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002276 (unpckl VR128:$src1,
2277 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002278 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002279 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002280 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002281 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002282 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002283 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002284 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002285 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002286 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002287 (v2i64 (unpckl VR128:$src1,
2288 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002289
2290 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002291 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002292 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002293 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002294 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002295 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002296 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002297 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002298 [(set VR128:$dst,
2299 (unpckh VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00002300 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002301 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002302 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002303 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002304 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002305 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002306 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002307 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002308 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002309 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002310 (unpckh VR128:$src1,
2311 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002312 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002313 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002314 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002315 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002316 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002317 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002318 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002319 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002320 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002321 (unpckh VR128:$src1,
2322 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002323 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002324 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002325 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002326 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002327 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002328 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002329 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002330 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002331 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002332 (v2i64 (unpckh VR128:$src1,
2333 (memopv2i64 addr:$src2))))]>;
Evan Chenga971f6f2006-03-23 01:57:24 +00002334}
Evan Cheng82521dd2006-03-21 07:09:35 +00002335
Evan Chengb067a1e2006-03-31 19:22:53 +00002336// Extract / Insert
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002337def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002338 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002339 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002340 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begeman14d12ca2008-02-11 04:19:36 +00002341 imm:$src2))]>;
Evan Chenge9083d62008-03-05 08:19:16 +00002342let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002343 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002344 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002345 GR32:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002346 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002347 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002348 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002349 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002350 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002351 i16mem:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002352 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002353 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002354 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2355 imm:$src3))]>;
Evan Chengb067a1e2006-03-31 19:22:53 +00002356}
2357
Evan Chengc5fb2b12006-03-30 00:33:26 +00002358// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00002359def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002360 "pmovmskb\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002361 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
Evan Chengc5fb2b12006-03-30 00:33:26 +00002362
Evan Chengfcf5e212006-04-11 06:57:30 +00002363// Conditional store
Evan Cheng071a2792007-09-11 19:55:27 +00002364let Uses = [EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +00002365def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002366 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng071a2792007-09-11 19:55:27 +00002367 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Evan Chengfcf5e212006-04-11 06:57:30 +00002368
Evan Cheng1d768642009-02-10 22:06:28 +00002369let Uses = [RDI] in
2370def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2371 "maskmovdqu\t{$mask, $src|$src, $mask}",
2372 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2373
Evan Chengecac9cb2006-03-25 06:03:26 +00002374// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00002375def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2376 "movntpd\t{$src, $dst|$dst, $src}",
2377 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2378def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2379 "movntdq\t{$src, $dst|$dst, $src}",
2380 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2381def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002382 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002383 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Evan Chengfcf5e212006-04-11 06:57:30 +00002384 TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002385
David Greene8939b0d2010-02-16 20:50:18 +00002386let AddedComplexity = 400 in { // Prefer non-temporal versions
2387def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2388 "movntpd\t{$src, $dst|$dst, $src}",
2389 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2390
2391def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2392 "movntdq\t{$src, $dst|$dst, $src}",
2393 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
David Greene8939b0d2010-02-16 20:50:18 +00002394}
2395
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002396// Flush cache
Evan Cheng64d80e32007-07-19 01:14:50 +00002397def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002398 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002399 TB, Requires<[HasSSE2]>;
2400
2401// Load, store, and memory fence
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002402def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002403 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002404def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002405 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002406
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002407//TODO: custom lower this so as to never even generate the noop
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002408def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002409 (i8 0)), (NOOP)>;
2410def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2411def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002412def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002413 (i8 1)), (MFENCE)>;
2414
Evan Chengffea91e2006-03-26 09:53:12 +00002415// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00002416// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00002417// load of an all-ones value if folding it would be beneficial.
Daniel Dunbar7417b762009-08-11 22:17:52 +00002418let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2419 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00002420 // FIXME: Change encoding to pseudo.
2421 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00002422 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Evan Cheng386031a2006-03-24 07:29:27 +00002423
Evan Cheng64d80e32007-07-19 01:14:50 +00002424def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002425 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002426 [(set VR128:$dst,
Evan Cheng069287d2006-05-16 07:21:53 +00002427 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002428def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002429 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002430 [(set VR128:$dst,
2431 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Evan Chengebf01d62006-11-16 23:33:25 +00002432
Evan Cheng64d80e32007-07-19 01:14:50 +00002433def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002434 "movd\t{$src, $dst|$dst, $src}",
Chris Lattnerf3597a12006-12-05 18:45:06 +00002435 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2436
Evan Cheng64d80e32007-07-19 01:14:50 +00002437def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002438 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002439 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002440
Evan Cheng11e15b32006-04-03 20:53:28 +00002441// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00002442def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002443 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002444 [(set VR128:$dst,
2445 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2446 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002447def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002448 "movq\t{$src, $dst|$dst, $src}",
Evan Chengebf01d62006-11-16 23:33:25 +00002449 [(store (i64 (vector_extract (v2i64 VR128:$src),
2450 (iPTR 0))), addr:$dst)]>;
2451
Dan Gohman874cada2010-02-28 00:17:42 +00002452def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
2453 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
2454
Evan Cheng64d80e32007-07-19 01:14:50 +00002455def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002456 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002457 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002458 (iPTR 0)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002459def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002460 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002461 [(store (i32 (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002462 (iPTR 0))), addr:$dst)]>;
Evan Cheng11e15b32006-04-03 20:53:28 +00002463
Evan Cheng64d80e32007-07-19 01:14:50 +00002464def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002466 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002467def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002468 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002469 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002470
Evan Cheng397edef2006-04-11 22:28:25 +00002471// Store / copy lower 64-bits of a XMM register.
Evan Cheng64d80e32007-07-19 01:14:50 +00002472def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002473 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng397edef2006-04-11 22:28:25 +00002474 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2475
Evan Cheng017dcc62006-04-21 01:05:10 +00002476// movd / movq to XMM register zero-extends
Evan Cheng7a831ce2007-12-15 03:00:47 +00002477let AddedComplexity = 15 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002478def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002479 "movd\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002480 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002481 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002482// This is X86-64 only.
2483def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2484 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002485 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002486 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002487}
2488
2489let AddedComplexity = 20 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002490def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002491 "movd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002492 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002493 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002494 (loadi32 addr:$src))))))]>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002495
2496def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2497 (MOVZDI2PDIrm addr:$src)>;
2498def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2499 (MOVZDI2PDIrm addr:$src)>;
Duncan Sandsd4b9c172008-06-13 19:07:40 +00002500def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2501 (MOVZDI2PDIrm addr:$src)>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002502
Evan Cheng64d80e32007-07-19 01:14:50 +00002503def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002504 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng7a831ce2007-12-15 03:00:47 +00002505 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002506 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002507 (loadi64 addr:$src))))))]>, XS,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002508 Requires<[HasSSE2]>;
Evan Cheng48090aa2006-03-21 23:01:21 +00002509
Evan Chengc36c0ab2008-05-22 18:56:56 +00002510def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2511 (MOVZQI2PQIrm addr:$src)>;
2512def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2513 (MOVZQI2PQIrm addr:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00002514def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengb70ea0b2008-05-10 00:59:18 +00002515}
Evan Chengd880b972008-05-09 21:53:03 +00002516
Evan Cheng7a831ce2007-12-15 03:00:47 +00002517// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2518// IA32 document. movq xmm1, xmm2 does clear the high bits.
2519let AddedComplexity = 15 in
2520def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2521 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002522 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002523 XS, Requires<[HasSSE2]>;
2524
Evan Cheng8e8de682008-05-20 18:24:47 +00002525let AddedComplexity = 20 in {
Evan Cheng7a831ce2007-12-15 03:00:47 +00002526def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2527 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002528 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng8e8de682008-05-20 18:24:47 +00002529 (loadv2i64 addr:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002530 XS, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002531
Evan Cheng8e8de682008-05-20 18:24:47 +00002532def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2533 (MOVZPQILo2PQIrm addr:$src)>;
2534}
2535
Sean Callanan108934c2009-12-18 00:01:26 +00002536// Instructions for the disassembler
2537// xr = XMM register
2538// xm = mem64
2539
2540def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2541 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2542
Eric Christopher44b93ff2009-07-31 20:07:27 +00002543//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002544// SSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002545//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002546
Bill Wendlingddd35322007-05-02 23:11:52 +00002547// Move Instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00002548def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002549 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002550 [(set VR128:$dst, (v4f32 (movshdup
2551 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002552def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002553 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002554 [(set VR128:$dst, (movshdup
2555 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002556
Evan Cheng64d80e32007-07-19 01:14:50 +00002557def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002558 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002559 [(set VR128:$dst, (v4f32 (movsldup
2560 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002561def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002562 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002563 [(set VR128:$dst, (movsldup
2564 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002565
Evan Cheng64d80e32007-07-19 01:14:50 +00002566def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002567 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002568 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002569def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002570 "movddup\t{$src, $dst|$dst, $src}",
Evan Cheng0b457f02008-09-25 20:50:48 +00002571 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002572 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2573 (undef))))]>;
Evan Cheng0b457f02008-09-25 20:50:48 +00002574
Nate Begeman9008ca62009-04-27 18:41:29 +00002575def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2576 (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002577 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002578
2579let AddedComplexity = 5 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00002580def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002581 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002582def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2583 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2584def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2585 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2586def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2587 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2588}
Bill Wendlingddd35322007-05-02 23:11:52 +00002589
2590// Arithmetic
Evan Chenge9083d62008-03-05 08:19:16 +00002591let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002592 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002593 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002594 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002595 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2596 VR128:$src2))]>;
2597 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002598 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002599 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002600 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002601 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002602 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002603 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002604 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002605 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2606 VR128:$src2))]>;
2607 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002608 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002609 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002610 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002611 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002612}
2613
Evan Cheng64d80e32007-07-19 01:14:50 +00002614def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002615 "lddqu\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002616 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2617
2618// Horizontal ops
2619class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002620 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002621 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002622 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2623class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002624 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002625 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002626 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002627class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002628 : S3I<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, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2631class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002632 : S3I<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, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002635
Evan Chenge9083d62008-03-05 08:19:16 +00002636let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002637 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2638 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2639 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2640 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2641 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2642 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2643 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2644 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2645}
2646
2647// Thread synchronization
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002648def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
Bill Wendlingddd35322007-05-02 23:11:52 +00002649 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002650def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
Bill Wendlingddd35322007-05-02 23:11:52 +00002651 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2652
2653// vector_shuffle v1, <undef> <1, 1, 3, 3>
2654let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002655def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002656 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2657let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002658def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002659 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2660
2661// vector_shuffle v1, <undef> <0, 0, 2, 2>
2662let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002663 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002664 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2665let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002666 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002667 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2668
Eric Christopher44b93ff2009-07-31 20:07:27 +00002669//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002670// SSSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002671//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002672
Bill Wendling76d708b2007-08-10 06:22:27 +00002673/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begemanfea2be52008-02-09 23:46:37 +00002674multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2675 Intrinsic IntId64, Intrinsic IntId128> {
2676 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2677 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2678 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002679
Nate Begemanfea2be52008-02-09 23:46:37 +00002680 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2681 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2682 [(set VR64:$dst,
2683 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2684
2685 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2686 (ins VR128:$src),
2687 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2688 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2689 OpSize;
2690
2691 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2692 (ins i128mem:$src),
2693 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2694 [(set VR128:$dst,
2695 (IntId128
2696 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Bill Wendlingddd35322007-05-02 23:11:52 +00002697}
2698
Bill Wendling76d708b2007-08-10 06:22:27 +00002699/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begemanfea2be52008-02-09 23:46:37 +00002700multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2701 Intrinsic IntId64, Intrinsic IntId128> {
2702 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2703 (ins VR64:$src),
2704 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2705 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002706
Nate Begemanfea2be52008-02-09 23:46:37 +00002707 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2708 (ins i64mem:$src),
2709 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2710 [(set VR64:$dst,
2711 (IntId64
2712 (bitconvert (memopv4i16 addr:$src))))]>;
2713
2714 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2715 (ins VR128:$src),
2716 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2717 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2718 OpSize;
2719
2720 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2721 (ins i128mem:$src),
2722 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2723 [(set VR128:$dst,
2724 (IntId128
2725 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002726}
2727
2728/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begemanfea2be52008-02-09 23:46:37 +00002729multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2730 Intrinsic IntId64, Intrinsic IntId128> {
2731 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2732 (ins VR64:$src),
2733 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2734 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002735
Nate Begemanfea2be52008-02-09 23:46:37 +00002736 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2737 (ins i64mem:$src),
2738 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2739 [(set VR64:$dst,
2740 (IntId64
2741 (bitconvert (memopv2i32 addr:$src))))]>;
2742
2743 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2744 (ins VR128:$src),
2745 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2746 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2747 OpSize;
2748
2749 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2750 (ins i128mem:$src),
2751 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2752 [(set VR128:$dst,
2753 (IntId128
2754 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002755}
2756
2757defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2758 int_x86_ssse3_pabs_b,
2759 int_x86_ssse3_pabs_b_128>;
2760defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2761 int_x86_ssse3_pabs_w,
2762 int_x86_ssse3_pabs_w_128>;
2763defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2764 int_x86_ssse3_pabs_d,
2765 int_x86_ssse3_pabs_d_128>;
2766
2767/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Chenge9083d62008-03-05 08:19:16 +00002768let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002769 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2770 Intrinsic IntId64, Intrinsic IntId128,
2771 bit Commutable = 0> {
2772 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2773 (ins VR64:$src1, VR64:$src2),
2774 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2775 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2776 let isCommutable = Commutable;
2777 }
2778 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2779 (ins VR64:$src1, i64mem:$src2),
2780 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2781 [(set VR64:$dst,
2782 (IntId64 VR64:$src1,
2783 (bitconvert (memopv8i8 addr:$src2))))]>;
2784
2785 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2786 (ins VR128:$src1, VR128:$src2),
2787 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2788 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2789 OpSize {
2790 let isCommutable = Commutable;
2791 }
2792 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2793 (ins VR128:$src1, i128mem:$src2),
2794 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2795 [(set VR128:$dst,
2796 (IntId128 VR128:$src1,
2797 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2798 }
2799}
2800
2801/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Chenge9083d62008-03-05 08:19:16 +00002802let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002803 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2804 Intrinsic IntId64, Intrinsic IntId128,
2805 bit Commutable = 0> {
2806 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2807 (ins VR64:$src1, VR64:$src2),
2808 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2809 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2810 let isCommutable = Commutable;
2811 }
2812 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2813 (ins VR64:$src1, i64mem:$src2),
2814 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2815 [(set VR64:$dst,
2816 (IntId64 VR64:$src1,
2817 (bitconvert (memopv4i16 addr:$src2))))]>;
2818
2819 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2820 (ins VR128:$src1, VR128:$src2),
2821 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2822 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2823 OpSize {
2824 let isCommutable = Commutable;
2825 }
2826 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2827 (ins VR128:$src1, i128mem:$src2),
2828 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2829 [(set VR128:$dst,
2830 (IntId128 VR128:$src1,
2831 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2832 }
2833}
2834
2835/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Chenge9083d62008-03-05 08:19:16 +00002836let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002837 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2838 Intrinsic IntId64, Intrinsic IntId128,
2839 bit Commutable = 0> {
2840 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2841 (ins VR64:$src1, VR64:$src2),
2842 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2843 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2844 let isCommutable = Commutable;
2845 }
2846 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2847 (ins VR64:$src1, i64mem:$src2),
2848 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2849 [(set VR64:$dst,
2850 (IntId64 VR64:$src1,
2851 (bitconvert (memopv2i32 addr:$src2))))]>;
2852
2853 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2854 (ins VR128:$src1, VR128:$src2),
2855 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2856 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2857 OpSize {
2858 let isCommutable = Commutable;
2859 }
2860 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2861 (ins VR128:$src1, i128mem:$src2),
2862 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2863 [(set VR128:$dst,
2864 (IntId128 VR128:$src1,
2865 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2866 }
2867}
2868
2869defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2870 int_x86_ssse3_phadd_w,
Evan Cheng4e444432008-06-16 21:16:24 +00002871 int_x86_ssse3_phadd_w_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002872defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2873 int_x86_ssse3_phadd_d,
Evan Cheng4e444432008-06-16 21:16:24 +00002874 int_x86_ssse3_phadd_d_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002875defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2876 int_x86_ssse3_phadd_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002877 int_x86_ssse3_phadd_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002878defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2879 int_x86_ssse3_phsub_w,
2880 int_x86_ssse3_phsub_w_128>;
2881defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2882 int_x86_ssse3_phsub_d,
2883 int_x86_ssse3_phsub_d_128>;
2884defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2885 int_x86_ssse3_phsub_sw,
2886 int_x86_ssse3_phsub_sw_128>;
2887defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2888 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002889 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002890defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2891 int_x86_ssse3_pmul_hr_sw,
2892 int_x86_ssse3_pmul_hr_sw_128, 1>;
2893defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2894 int_x86_ssse3_pshuf_b,
2895 int_x86_ssse3_pshuf_b_128>;
2896defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2897 int_x86_ssse3_psign_b,
2898 int_x86_ssse3_psign_b_128>;
2899defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2900 int_x86_ssse3_psign_w,
2901 int_x86_ssse3_psign_w_128>;
Evan Chenged7f56b2009-05-28 18:48:53 +00002902defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling76d708b2007-08-10 06:22:27 +00002903 int_x86_ssse3_psign_d,
2904 int_x86_ssse3_psign_d_128>;
2905
Evan Chenge9083d62008-03-05 08:19:16 +00002906let Constraints = "$src1 = $dst" in {
Bill Wendlingae9671b2007-08-10 09:00:17 +00002907 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002908 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002909 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002910 []>;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002911 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002912 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002913 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002914 []>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002915
Bill Wendlingae9671b2007-08-10 09:00:17 +00002916 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002917 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002918 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002919 []>, OpSize;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002920 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002921 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002922 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002923 []>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002924}
Bill Wendlingddd35322007-05-02 23:11:52 +00002925
Nate Begemana09008b2009-10-19 02:17:23 +00002926// palignr patterns.
Sean Callananb9e6b342009-11-20 22:28:42 +00002927def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002928 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2929 Requires<[HasSSSE3]>;
2930def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2931 (memop64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002932 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002933 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2934 Requires<[HasSSSE3]>;
2935
Sean Callananb9e6b342009-11-20 22:28:42 +00002936def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002937 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2938 Requires<[HasSSSE3]>;
2939def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2940 (memopv2i64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002941 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002942 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2943 Requires<[HasSSSE3]>;
2944
Nate Begemana09008b2009-10-19 02:17:23 +00002945let AddedComplexity = 5 in {
2946def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2947 (PALIGNR128rr VR128:$src2, VR128:$src1,
2948 (SHUFFLE_get_palign_imm VR128:$src3))>,
2949 Requires<[HasSSSE3]>;
2950def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2951 (PALIGNR128rr VR128:$src2, VR128:$src1,
2952 (SHUFFLE_get_palign_imm VR128:$src3))>,
2953 Requires<[HasSSSE3]>;
2954def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2955 (PALIGNR128rr VR128:$src2, VR128:$src1,
2956 (SHUFFLE_get_palign_imm VR128:$src3))>,
2957 Requires<[HasSSSE3]>;
2958def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2959 (PALIGNR128rr VR128:$src2, VR128:$src1,
2960 (SHUFFLE_get_palign_imm VR128:$src3))>,
2961 Requires<[HasSSSE3]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002962}
Nate Begemana09008b2009-10-19 02:17:23 +00002963
Nate Begemanb9a47b82009-02-23 08:49:38 +00002964def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2965 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2966def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2967 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2968
Eric Christopher44b93ff2009-07-31 20:07:27 +00002969//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002970// Non-Instruction Patterns
Eric Christopher44b93ff2009-07-31 20:07:27 +00002971//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002972
Eric Christopher44b93ff2009-07-31 20:07:27 +00002973// extload f32 -> f64. This matches load+fextend because we have a hack in
2974// the isel (PreprocessForFPConvert) that can introduce loads after dag
2975// combine.
Chris Lattnerd43d00c2008-01-24 08:07:48 +00002976// Since these loads aren't folded into the fextend, we have to match it
2977// explicitly here.
2978let Predicates = [HasSSE2] in
2979 def : Pat<(fextend (loadf32 addr:$src)),
2980 (CVTSS2SDrm addr:$src)>;
2981
Evan Cheng2c0dbd02006-03-24 02:58:06 +00002982// bit_convert
Chris Lattner4cc84ed2006-10-07 04:52:09 +00002983let Predicates = [HasSSE2] in {
2984 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2985 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2986 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2987 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2988 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2989 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2990 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2991 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2992 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2993 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2994 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2995 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2996 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2997 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2998 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2999 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3000 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3001 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3002 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3003 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3004 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3005 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3006 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3007 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3008 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3009 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3010 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3011 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3012 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3013 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3014}
Evan Chengb9df0ca2006-03-22 02:53:00 +00003015
Evan Cheng017dcc62006-04-21 01:05:10 +00003016// Move scalar to XMM zero-extended
3017// movd to XMM register zero-extends
Evan Chengf2ea84a2006-10-09 21:42:15 +00003018let AddedComplexity = 15 in {
Evan Cheng017dcc62006-04-21 01:05:10 +00003019// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chengd880b972008-05-09 21:53:03 +00003020def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003021 (MOVSDrr (v2f64 (V_SET0)), FR64:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00003022def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003023 (MOVSSrr (v4f32 (V_SET0)), FR32:$src)>;
Evan Cheng23573e52008-05-09 23:37:55 +00003024def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003025 (MOVSSrr (v4f32 (V_SET0)),
3026 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss)))>;
Evan Cheng331e2bd2008-07-10 01:08:23 +00003027def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003028 (MOVSSrr (v4i32 (V_SET0)),
3029 (EXTRACT_SUBREG (v4i32 VR128:$src), x86_subreg_ss))>;
Evan Cheng017dcc62006-04-21 01:05:10 +00003030}
Evan Chengbc4832b2006-03-24 23:15:12 +00003031
Evan Chengb9df0ca2006-03-22 02:53:00 +00003032// Splat v2f64 / v2i64
Evan Chengfd111b52006-04-19 21:15:24 +00003033let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003034def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003035 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003036def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003037 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003038def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003039 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003040def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003041 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengfd111b52006-04-19 21:15:24 +00003042}
Evan Cheng475aecf2006-03-29 03:04:49 +00003043
Evan Chengb7a5c522006-04-18 21:55:35 +00003044// Special unary SHUFPSrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003045def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3046 (SHUFPSrri VR128:$src1, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003047 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003048let AddedComplexity = 5 in
3049def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3050 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3051 Requires<[HasSSE2]>;
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003052// Special unary SHUFPDrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003053def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003054 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003055 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3056 Requires<[HasSSE2]>;
3057// Special unary SHUFPDrri case.
3058def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003059 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003060 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003061 Requires<[HasSSE2]>;
Evan Cheng3d60df42006-04-10 22:35:16 +00003062// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman9008ca62009-04-27 18:41:29 +00003063def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3064 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng7d9061e2006-03-30 19:54:57 +00003065 Requires<[HasSSE2]>;
Evan Chengb7a75a52008-09-26 23:41:32 +00003066
Evan Cheng3d60df42006-04-10 22:35:16 +00003067// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman9008ca62009-04-27 18:41:29 +00003068def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003069 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003070 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003071 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003072def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003073 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003074 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003075 Requires<[HasSSE2]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00003076// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman9008ca62009-04-27 18:41:29 +00003077def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003078 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003079 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00003080 Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003081
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003082// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003083let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003084def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3085 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003086 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003087def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3088 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003089 Requires<[OptForSpeed, HasSSE2]>;
3090}
Evan Chengfd111b52006-04-19 21:15:24 +00003091let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003092def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003093 (UNPCKLPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003094def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003095 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003096def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003097 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003098def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003099 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
Evan Chengfd111b52006-04-19 21:15:24 +00003100}
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003101
Evan Cheng174f8032007-05-17 18:44:37 +00003102// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003103let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003104def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3105 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003106 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003107def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3108 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003109 Requires<[OptForSpeed, HasSSE2]>;
3110}
Evan Cheng174f8032007-05-17 18:44:37 +00003111let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003112def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003113 (UNPCKHPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003114def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003115 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003116def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003117 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003118def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003119 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
Evan Cheng174f8032007-05-17 18:44:37 +00003120}
3121
Evan Chengb7a75a52008-09-26 23:41:32 +00003122let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003123// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman0b10b912009-11-07 23:17:15 +00003124def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003125 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003126
3127// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003128def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003129 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003130
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003131// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003132def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003133 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003134def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003135 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003136}
Evan Cheng9d09b892006-05-31 00:51:37 +00003137
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003138let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003139// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003140def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003141 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003142def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003143 (MOVLPDrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003144def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003145 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003146def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003147 (MOVLPDrm VR128:$src1, addr:$src2)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003148}
Evan Cheng64e97692006-04-24 21:58:20 +00003149
Evan Chengcd0baf22008-05-23 21:23:16 +00003150// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003151def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003152 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003153def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003154 (MOVLPDmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003155def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3156 addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003157 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003158def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003159 (MOVLPDmr addr:$src1, VR128:$src2)>;
Evan Chengcd0baf22008-05-23 21:23:16 +00003160
Evan Chengf2ea84a2006-10-09 21:42:15 +00003161let AddedComplexity = 15 in {
Evan Cheng64e97692006-04-24 21:58:20 +00003162// Setting the lowest element in the vector.
Nate Begeman9008ca62009-04-27 18:41:29 +00003163def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003164 (MOVSSrr (v4i32 VR128:$src1),
3165 (EXTRACT_SUBREG (v4i32 VR128:$src2), x86_subreg_ss))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003166def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003167 (MOVSDrr (v2i64 VR128:$src1),
3168 (EXTRACT_SUBREG (v2i64 VR128:$src2), x86_subreg_sd))>;
Evan Chenga7fc6422006-04-24 23:34:56 +00003169
Dan Gohman874cada2010-02-28 00:17:42 +00003170// vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
Nate Begeman9008ca62009-04-27 18:41:29 +00003171def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003172 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3173 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003174def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003175 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3176 Requires<[HasSSE2]>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003177}
Evan Cheng9e062ed2006-05-03 20:32:03 +00003178
Eli Friedman7e2242b2009-06-19 07:00:55 +00003179// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3180// fall back to this for SSE1)
3181def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003182 (SHUFPSrri VR128:$src2, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003183 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Eli Friedman7e2242b2009-06-19 07:00:55 +00003184
Evan Chenga7fc6422006-04-24 23:34:56 +00003185// Set lowest element and zero upper elements.
Evan Cheng7a831ce2007-12-15 03:00:47 +00003186let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00003187def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng7a831ce2007-12-15 03:00:47 +00003188 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengd880b972008-05-09 21:53:03 +00003189def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengfd17f422008-05-08 22:35:02 +00003190 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengcdfc3c82006-04-17 22:45:49 +00003191
Evan Cheng2c3ae372006-04-12 21:21:57 +00003192// Some special case pandn patterns.
3193def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3194 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003195 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003196def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3197 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003198 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003199def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3200 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003201 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003202
Evan Cheng2c3ae372006-04-12 21:21:57 +00003203def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003204 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003205 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003206def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003207 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003208 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003209def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003210 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003211 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng206ee9d2006-07-07 08:33:52 +00003212
Nate Begemanb348d182007-11-17 03:58:34 +00003213// vector -> vector casts
3214def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3215 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3216def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3217 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedmand0c0fae2008-09-05 23:07:03 +00003218def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3219 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3220def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3221 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb348d182007-11-17 03:58:34 +00003222
Evan Chengb4162fd2007-07-20 00:27:43 +00003223// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohmand3006222007-07-27 17:16:43 +00003224def : Pat<(alignedloadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003225 (MOVAPSrm addr:$src)>;
Dan Gohmand3006222007-07-27 17:16:43 +00003226def : Pat<(loadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003227 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003228def : Pat<(alignedloadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003229 (MOVAPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003230def : Pat<(loadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003231 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003232
3233def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003234 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003235def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003236 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003237def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003238 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003239def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003240 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003241def : Pat<(store (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003242 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003243def : Pat<(store (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003244 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003245def : Pat<(store (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003246 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003247def : Pat<(store (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003248 (MOVUPSmr addr:$dst, VR128:$src)>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003249
Nate Begeman63ec90a2008-02-03 07:18:54 +00003250//===----------------------------------------------------------------------===//
3251// SSE4.1 Instructions
3252//===----------------------------------------------------------------------===//
3253
Dale Johannesene397acc2008-10-10 23:51:03 +00003254multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003255 string OpcodeStr,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003256 Intrinsic V4F32Int,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003257 Intrinsic V2F64Int> {
Nate Begeman63ec90a2008-02-03 07:18:54 +00003258 // Intrinsic operation, reg.
Nate Begeman63ec90a2008-02-03 07:18:54 +00003259 // Vector intrinsic operation, reg
Eric Christopher44b93ff2009-07-31 20:07:27 +00003260 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003261 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003262 !strconcat(OpcodeStr,
3263 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003264 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3265 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003266
3267 // Vector intrinsic operation, mem
Evan Cheng400073d2009-12-18 07:40:29 +00003268 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003269 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003270 !strconcat(OpcodeStr,
3271 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003272 [(set VR128:$dst,
3273 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Cheng400073d2009-12-18 07:40:29 +00003274 TA, OpSize,
Evan Chengb1f49812009-12-22 17:47:23 +00003275 Requires<[HasSSE41]>;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003276
Nate Begeman63ec90a2008-02-03 07:18:54 +00003277 // Vector intrinsic operation, reg
Evan Cheng172b7942008-03-14 07:39:27 +00003278 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003279 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003280 !strconcat(OpcodeStr,
3281 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003282 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3283 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003284
3285 // Vector intrinsic operation, mem
Evan Cheng172b7942008-03-14 07:39:27 +00003286 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003287 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003288 !strconcat(OpcodeStr,
3289 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003290 [(set VR128:$dst,
3291 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003292 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003293}
3294
Dale Johannesene397acc2008-10-10 23:51:03 +00003295let Constraints = "$src1 = $dst" in {
3296multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3297 string OpcodeStr,
3298 Intrinsic F32Int,
3299 Intrinsic F64Int> {
3300 // Intrinsic operation, reg.
3301 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003302 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003303 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3304 !strconcat(OpcodeStr,
3305 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003306 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003307 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3308 OpSize;
3309
3310 // Intrinsic operation, mem.
Eric Christopher44b93ff2009-07-31 20:07:27 +00003311 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3312 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003313 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003314 !strconcat(OpcodeStr,
Dale Johannesene397acc2008-10-10 23:51:03 +00003315 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003316 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003317 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3318 OpSize;
3319
3320 // Intrinsic operation, reg.
3321 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003322 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003323 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3324 !strconcat(OpcodeStr,
3325 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003326 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003327 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3328 OpSize;
3329
3330 // Intrinsic operation, mem.
3331 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003332 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003333 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3334 !strconcat(OpcodeStr,
3335 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003336 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003337 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3338 OpSize;
3339}
3340}
3341
Nate Begeman63ec90a2008-02-03 07:18:54 +00003342// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesene397acc2008-10-10 23:51:03 +00003343defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3344 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3345defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3346 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003347
3348// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3349multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3350 Intrinsic IntId128> {
3351 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3352 (ins VR128:$src),
3353 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3354 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3355 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3356 (ins i128mem:$src),
3357 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3358 [(set VR128:$dst,
3359 (IntId128
3360 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3361}
3362
3363defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3364 int_x86_sse41_phminposuw>;
3365
3366/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003367let Constraints = "$src1 = $dst" in {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003368 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3369 Intrinsic IntId128, bit Commutable = 0> {
Nate Begemanfea2be52008-02-09 23:46:37 +00003370 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3371 (ins VR128:$src1, VR128:$src2),
3372 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3373 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3374 OpSize {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003375 let isCommutable = Commutable;
3376 }
Nate Begemanfea2be52008-02-09 23:46:37 +00003377 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3378 (ins VR128:$src1, i128mem:$src2),
3379 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3380 [(set VR128:$dst,
3381 (IntId128 VR128:$src1,
3382 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003383 }
3384}
3385
3386defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3387 int_x86_sse41_pcmpeqq, 1>;
3388defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3389 int_x86_sse41_packusdw, 0>;
3390defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3391 int_x86_sse41_pminsb, 1>;
3392defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3393 int_x86_sse41_pminsd, 1>;
3394defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3395 int_x86_sse41_pminud, 1>;
3396defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3397 int_x86_sse41_pminuw, 1>;
3398defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3399 int_x86_sse41_pmaxsb, 1>;
3400defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3401 int_x86_sse41_pmaxsd, 1>;
3402defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3403 int_x86_sse41_pmaxud, 1>;
3404defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3405 int_x86_sse41_pmaxuw, 1>;
Nate Begeman204e84e2008-02-04 06:00:24 +00003406
Mon P Wangaf9b9522008-12-18 21:42:19 +00003407defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3408
Nate Begeman30a0de92008-07-17 16:51:19 +00003409def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3410 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3411def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3412 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3413
Nate Begeman1426d522008-02-09 01:38:08 +00003414/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003415let Constraints = "$src1 = $dst" in {
Dan Gohman0b924dc2008-05-23 17:49:40 +00003416 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3417 SDNode OpNode, Intrinsic IntId128,
3418 bit Commutable = 0> {
Nate Begeman1426d522008-02-09 01:38:08 +00003419 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3420 (ins VR128:$src1, VR128:$src2),
3421 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman0b924dc2008-05-23 17:49:40 +00003422 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3423 VR128:$src2))]>, OpSize {
Nate Begeman1426d522008-02-09 01:38:08 +00003424 let isCommutable = Commutable;
3425 }
3426 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3427 (ins VR128:$src1, VR128:$src2),
3428 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3429 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3430 OpSize {
3431 let isCommutable = Commutable;
3432 }
3433 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3434 (ins VR128:$src1, i128mem:$src2),
3435 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3436 [(set VR128:$dst,
Chris Lattner1a7d0872010-02-18 06:33:42 +00003437 (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003438 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3439 (ins VR128:$src1, i128mem:$src2),
3440 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3441 [(set VR128:$dst,
Evan Chengb1938262008-05-23 00:37:07 +00003442 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman1426d522008-02-09 01:38:08 +00003443 OpSize;
3444 }
3445}
Dan Gohman0b924dc2008-05-23 17:49:40 +00003446defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman1426d522008-02-09 01:38:08 +00003447 int_x86_sse41_pmulld, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003448
Evan Cheng172b7942008-03-14 07:39:27 +00003449/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Chenge9083d62008-03-05 08:19:16 +00003450let Constraints = "$src1 = $dst" in {
Nate Begeman204e84e2008-02-04 06:00:24 +00003451 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3452 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng172b7942008-03-14 07:39:27 +00003453 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003454 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003455 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003456 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003457 [(set VR128:$dst,
Nate Begemanfea2be52008-02-09 23:46:37 +00003458 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3459 OpSize {
Nate Begeman204e84e2008-02-04 06:00:24 +00003460 let isCommutable = Commutable;
3461 }
Evan Cheng172b7942008-03-14 07:39:27 +00003462 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003463 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3464 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003465 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begemanfea2be52008-02-09 23:46:37 +00003466 [(set VR128:$dst,
3467 (IntId128 VR128:$src1,
3468 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3469 OpSize;
Nate Begeman204e84e2008-02-04 06:00:24 +00003470 }
3471}
3472
3473defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3474 int_x86_sse41_blendps, 0>;
3475defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3476 int_x86_sse41_blendpd, 0>;
3477defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3478 int_x86_sse41_pblendw, 0>;
3479defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3480 int_x86_sse41_dpps, 1>;
3481defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3482 int_x86_sse41_dppd, 1>;
3483defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng35b9a772008-06-16 20:25:59 +00003484 int_x86_sse41_mpsadbw, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003485
Nate Begemanfea2be52008-02-09 23:46:37 +00003486
Evan Cheng172b7942008-03-14 07:39:27 +00003487/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003488let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanab5d56c2008-02-10 18:47:57 +00003489 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3490 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3491 (ins VR128:$src1, VR128:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003492 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003493 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3494 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3495 OpSize;
3496
3497 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3498 (ins VR128:$src1, i128mem:$src2),
3499 !strconcat(OpcodeStr,
3500 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3501 [(set VR128:$dst,
3502 (IntId VR128:$src1,
3503 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3504 }
3505}
3506
3507defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3508defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3509defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3510
3511
Nate Begemanfea2be52008-02-09 23:46:37 +00003512multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3513 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3514 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3515 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3516
3517 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3518 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003519 [(set VR128:$dst,
3520 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3521 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003522}
3523
3524defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3525defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3526defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3527defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3528defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3529defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3530
Evan Chengca57f782008-09-24 23:27:55 +00003531// Common patterns involving scalar load.
3532def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3533 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3534def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3535 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3536
3537def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3538 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3539def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3540 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3541
3542def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3543 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3544def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3545 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3546
3547def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3548 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3549def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3550 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3551
3552def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3553 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3554def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3555 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3556
3557def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3558 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3559def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3560 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3561
3562
Nate Begemanfea2be52008-02-09 23:46:37 +00003563multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3564 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3565 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3566 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3567
3568 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3569 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003570 [(set VR128:$dst,
3571 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3572 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003573}
3574
3575defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3576defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3577defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3578defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3579
Evan Chengca57f782008-09-24 23:27:55 +00003580// Common patterns involving scalar load
3581def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003582 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003583def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003584 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003585
3586def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003587 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003588def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003589 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003590
3591
Nate Begemanfea2be52008-02-09 23:46:37 +00003592multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3593 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3594 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3595 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3596
Evan Chengca57f782008-09-24 23:27:55 +00003597 // Expecting a i16 load any extended to i32 value.
Nate Begemanfea2be52008-02-09 23:46:37 +00003598 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3599 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003600 [(set VR128:$dst, (IntId (bitconvert
3601 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3602 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003603}
3604
3605defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman9d47b8d2009-06-06 05:55:37 +00003606defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begemanfea2be52008-02-09 23:46:37 +00003607
Evan Chengca57f782008-09-24 23:27:55 +00003608// Common patterns involving scalar load
3609def : Pat<(int_x86_sse41_pmovsxbq
3610 (bitconvert (v4i32 (X86vzmovl
3611 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003612 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003613
3614def : Pat<(int_x86_sse41_pmovzxbq
3615 (bitconvert (v4i32 (X86vzmovl
3616 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003617 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003618
Nate Begemanfea2be52008-02-09 23:46:37 +00003619
Nate Begeman14d12ca2008-02-11 04:19:36 +00003620/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3621multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003622 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003623 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003624 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003625 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003626 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3627 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003628 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003629 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003630 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003631 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003632 []>, OpSize;
3633// FIXME:
3634// There's an AssertZext in the way of writing the store pattern
3635// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begemanfea2be52008-02-09 23:46:37 +00003636}
3637
Nate Begeman14d12ca2008-02-11 04:19:36 +00003638defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003639
Nate Begeman14d12ca2008-02-11 04:19:36 +00003640
3641/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3642multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003643 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003644 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003645 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003646 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3647 []>, OpSize;
3648// FIXME:
3649// There's an AssertZext in the way of writing the store pattern
3650// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3651}
3652
3653defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3654
3655
3656/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3657multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003658 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003659 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003660 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003661 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3662 [(set GR32:$dst,
3663 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003664 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003665 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003666 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003667 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3668 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3669 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003670}
3671
Nate Begeman14d12ca2008-02-11 04:19:36 +00003672defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman1426d522008-02-09 01:38:08 +00003673
Nate Begeman14d12ca2008-02-11 04:19:36 +00003674
Evan Cheng62a3f152008-03-24 21:52:23 +00003675/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3676/// destination
Nate Begeman14d12ca2008-02-11 04:19:36 +00003677multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003678 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003679 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003680 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003681 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman171c11e2008-04-16 02:32:24 +00003682 [(set GR32:$dst,
3683 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng62a3f152008-03-24 21:52:23 +00003684 OpSize;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003685 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003686 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003687 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003688 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng62a3f152008-03-24 21:52:23 +00003689 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begemanfea2be52008-02-09 23:46:37 +00003690 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003691}
3692
Nate Begeman14d12ca2008-02-11 04:19:36 +00003693defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003694
Dan Gohmand9ced092008-08-08 18:30:21 +00003695// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3696def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3697 imm:$src2))),
3698 addr:$dst),
3699 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3700 Requires<[HasSSE41]>;
3701
Evan Chenge9083d62008-03-05 08:19:16 +00003702let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003703 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003704 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003705 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003706 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003707 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003708 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003709 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003710 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003711 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3712 !strconcat(OpcodeStr,
3713 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003714 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003715 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3716 imm:$src3))]>, OpSize;
3717 }
3718}
3719
3720defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3721
Evan Chenge9083d62008-03-05 08:19:16 +00003722let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003723 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003724 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003725 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003726 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003727 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003728 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003729 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3730 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003731 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003732 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3733 !strconcat(OpcodeStr,
3734 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003735 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003736 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3737 imm:$src3)))]>, OpSize;
3738 }
3739}
3740
3741defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3742
Eric Christopher1e5cdea2009-07-23 02:22:41 +00003743// insertps has a few different modes, there's the first two here below which
3744// are optimized inserts that won't zero arbitrary elements in the destination
3745// vector. The next one matches the intrinsic and could zero arbitrary elements
3746// in the target vector.
Evan Chenge9083d62008-03-05 08:19:16 +00003747let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003748 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherfbd66872009-07-24 00:33:09 +00003749 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3750 (ins VR128:$src1, VR128:$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,
3754 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003755 OpSize;
Eric Christopherfbd66872009-07-24 00:33:09 +00003756 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003757 (ins VR128:$src1, f32mem:$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,
Eric Christopherfbd66872009-07-24 00:33:09 +00003761 (X86insrtps VR128:$src1,
3762 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003763 imm:$src3))]>, OpSize;
3764 }
3765}
3766
Evan Cheng7aae8762008-03-26 08:11:49 +00003767defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003768
Eric Christopherfbd66872009-07-24 00:33:09 +00003769def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3770 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3771
Eric Christopher71c67532009-07-29 00:28:05 +00003772// ptest instruction we'll lower to this in X86ISelLowering primarily from
3773// the intel intrinsic that corresponds to this.
Nate Begemanbc4efb82008-03-16 21:14:46 +00003774let Defs = [EFLAGS] in {
3775def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003776 "ptest \t{$src2, $src1|$src1, $src2}",
3777 [(X86ptest VR128:$src1, VR128:$src2),
3778 (implicit EFLAGS)]>, OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003779def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003780 "ptest \t{$src2, $src1|$src1, $src2}",
3781 [(X86ptest VR128:$src1, (load addr:$src2)),
3782 (implicit EFLAGS)]>, OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003783}
3784
3785def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3786 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderby40fe18f2010-02-10 00:10:31 +00003787 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3788 OpSize;
Nate Begeman30a0de92008-07-17 16:51:19 +00003789
Eric Christopherb120ab42009-08-18 22:50:32 +00003790
3791//===----------------------------------------------------------------------===//
3792// SSE4.2 Instructions
3793//===----------------------------------------------------------------------===//
3794
Nate Begeman30a0de92008-07-17 16:51:19 +00003795/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3796let Constraints = "$src1 = $dst" in {
3797 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3798 Intrinsic IntId128, bit Commutable = 0> {
3799 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3800 (ins VR128:$src1, VR128:$src2),
3801 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3802 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3803 OpSize {
3804 let isCommutable = Commutable;
3805 }
3806 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3807 (ins VR128:$src1, i128mem:$src2),
3808 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3809 [(set VR128:$dst,
3810 (IntId128 VR128:$src1,
3811 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3812 }
3813}
3814
Nate Begemane99b2552008-07-17 17:04:58 +00003815defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman30a0de92008-07-17 16:51:19 +00003816
3817def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3818 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3819def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3820 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003821
3822// crc intrinsic instruction
3823// This set of instructions are only rm, the only difference is the size
3824// of r and m.
3825let Constraints = "$src1 = $dst" in {
Eric Christopher027c2b12009-08-10 21:48:58 +00003826 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003827 (ins GR32:$src1, i8mem:$src2),
3828 "crc32 \t{$src2, $src1|$src1, $src2}",
3829 [(set GR32:$dst,
3830 (int_x86_sse42_crc32_8 GR32:$src1,
3831 (load addr:$src2)))]>, OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003832 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003833 (ins GR32:$src1, GR8:$src2),
3834 "crc32 \t{$src2, $src1|$src1, $src2}",
3835 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003836 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003837 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003838 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003839 (ins GR32:$src1, i16mem:$src2),
3840 "crc32 \t{$src2, $src1|$src1, $src2}",
3841 [(set GR32:$dst,
3842 (int_x86_sse42_crc32_16 GR32:$src1,
3843 (load addr:$src2)))]>,
3844 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003845 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003846 (ins GR32:$src1, GR16:$src2),
3847 "crc32 \t{$src2, $src1|$src1, $src2}",
3848 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003849 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003850 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003851 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003852 (ins GR32:$src1, i32mem:$src2),
3853 "crc32 \t{$src2, $src1|$src1, $src2}",
3854 [(set GR32:$dst,
3855 (int_x86_sse42_crc32_32 GR32:$src1,
3856 (load addr:$src2)))]>, OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003857 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003858 (ins GR32:$src1, GR32:$src2),
3859 "crc32 \t{$src2, $src1|$src1, $src2}",
3860 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003861 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003862 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003863 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003864 (ins GR64:$src1, i64mem:$src2),
3865 "crc32 \t{$src2, $src1|$src1, $src2}",
3866 [(set GR64:$dst,
3867 (int_x86_sse42_crc32_64 GR64:$src1,
3868 (load addr:$src2)))]>,
3869 OpSize, REX_W;
Eric Christopher027c2b12009-08-10 21:48:58 +00003870 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003871 (ins GR64:$src1, GR64:$src2),
3872 "crc32 \t{$src2, $src1|$src1, $src2}",
3873 [(set GR64:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003874 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003875 OpSize, REX_W;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003876}
Eric Christopherb120ab42009-08-18 22:50:32 +00003877
3878// String/text processing instructions.
Dan Gohman533297b2009-10-29 18:10:34 +00003879let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003880def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003881 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3882 "#PCMPISTRM128rr PSEUDO!",
3883 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3884 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003885def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003886 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3887 "#PCMPISTRM128rm PSEUDO!",
3888 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3889 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003890}
3891
3892let Defs = [XMM0, EFLAGS] in {
3893def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003894 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3895 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003896def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003897 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3898 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003899}
3900
Sean Callanan108934c2009-12-18 00:01:26 +00003901let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003902def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003903 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3904 "#PCMPESTRM128rr PSEUDO!",
3905 [(set VR128:$dst,
3906 (int_x86_sse42_pcmpestrm128
3907 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3908
Eric Christopherb120ab42009-08-18 22:50:32 +00003909def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003910 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3911 "#PCMPESTRM128rm PSEUDO!",
3912 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3913 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3914 OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003915}
3916
3917let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callanan47234e62009-08-20 18:24:27 +00003918def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003919 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3920 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callanan47234e62009-08-20 18:24:27 +00003921def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003922 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3923 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003924}
3925
3926let Defs = [ECX, EFLAGS] in {
3927 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan108934c2009-12-18 00:01:26 +00003928 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3929 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3930 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3931 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3932 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003933 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003934 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3935 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3936 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3937 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003938 }
3939}
3940
3941defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3942defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3943defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3944defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3945defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3946defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3947
3948let Defs = [ECX, EFLAGS] in {
3949let Uses = [EAX, EDX] in {
3950 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3951 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003952 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3953 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3954 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3955 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003956 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003957 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3958 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3959 [(set ECX,
3960 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
3961 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003962 }
3963}
3964}
3965
3966defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3967defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3968defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3969defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3970defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3971defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;