blob: 1c00a36e134e8da9ac4f2200dc4c1a294e9cb4b9 [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}",
Chris Lattner3d005782010-03-15 05:53:30 +0000382 [(set (v4f32 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +0000383 (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}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000516 [(set EFLAGS, (X86cmp FR32:$src1, FR32:$src2))]>;
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}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000519 [(set EFLAGS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000520
521def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
522 "comiss\t{$src2, $src1|$src1, $src2}", []>;
523def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
524 "comiss\t{$src2, $src1|$src1, $src2}", []>;
525
Evan Cheng24f2ea32007-09-14 21:48:26 +0000526} // Defs = [EFLAGS]
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000527
Evan Cheng0876aa52006-03-30 06:21:22 +0000528// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +0000529let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000530 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +0000531 (outs VR128:$dst),
532 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000533 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +0000534 [(set VR128:$dst, (int_x86_sse_cmp_ss
535 VR128:$src1,
536 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000537 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +0000538 (outs VR128:$dst),
539 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000540 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000541 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
542 (load addr:$src), imm:$cc))]>;
Evan Cheng0876aa52006-03-30 06:21:22 +0000543}
544
Evan Cheng24f2ea32007-09-14 21:48:26 +0000545let Defs = [EFLAGS] in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000546def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000547 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000548 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
549 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000550def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000551 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000552 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
553 (load addr:$src2)))]>;
Evan Cheng0488db92007-09-25 01:57:46 +0000554
Dan Gohmanb1347092009-01-09 02:27:34 +0000555def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000556 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000557 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
558 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000559def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000560 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000561 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
562 (load addr:$src2)))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000563} // Defs = [EFLAGS]
Evan Cheng0876aa52006-03-30 06:21:22 +0000564
Eric Christopher44b93ff2009-07-31 20:07:27 +0000565// Aliases of packed SSE1 instructions for scalar use. These all have names
566// that start with 'Fs'.
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000567
568// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +0000569let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
570 canFoldAsLoad = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +0000571 // FIXME: Set encoding to pseudo!
Chris Lattnerbe1778f2010-02-05 21:34:18 +0000572def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
573 [(set FR32:$dst, fp32imm0)]>,
574 Requires<[HasSSE1]>, TB, OpSize;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000575
Bill Wendlingddd35322007-05-02 23:11:52 +0000576// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
577// disregarded.
Eric Christopher44b93ff2009-07-31 20:07:27 +0000578let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000579def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000580 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000581
Bill Wendlingddd35322007-05-02 23:11:52 +0000582// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
583// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000584let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000585def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000586 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +0000587 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000588
589// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +0000590let Constraints = "$src1 = $dst" in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000591let isCommutable = 1 in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000592 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
593 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000594 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000595 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000596 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
597 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000598 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000599 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000600 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
601 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000602 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000603 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000604}
Bill Wendlingddd35322007-05-02 23:11:52 +0000605
Dan Gohmanb1347092009-01-09 02:27:34 +0000606def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
607 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000608 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000609 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000610 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000611def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
612 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000613 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000614 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000615 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000616def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
617 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000618 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000619 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000620 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000621
Chris Lattnerba7e7562008-01-10 07:59:24 +0000622let neverHasSideEffects = 1 in {
Dan Gohman32791e02007-06-25 15:44:19 +0000623def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000624 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000625 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000626let mayLoad = 1 in
Dan Gohman32791e02007-06-25 15:44:19 +0000627def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000628 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000629 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000630}
Chris Lattnerba7e7562008-01-10 07:59:24 +0000631}
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000632
Dan Gohman20382522007-07-10 00:05:58 +0000633/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000634///
Dan Gohman20382522007-07-10 00:05:58 +0000635/// In addition, we also have a special variant of the scalar form here to
636/// represent the associated intrinsic operation. This form is unlike the
637/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +0000638/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +0000639///
640/// These three forms can each be reg+reg or reg+mem, so there are a total of
641/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +0000642///
Evan Chenge9083d62008-03-05 08:19:16 +0000643let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000644multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
645 SDNode OpNode, Intrinsic F32Int,
646 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000647 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000648 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000649 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman32791e02007-06-25 15:44:19 +0000650 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000651 let isCommutable = Commutable;
652 }
653
654 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000655 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
656 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000657 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000658 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000659
Dan Gohman20382522007-07-10 00:05:58 +0000660 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000661 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
662 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000663 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000664 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
665 let isCommutable = Commutable;
666 }
667
668 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000669 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
670 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000671 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000672 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000673
674 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000675 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
676 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000677 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +0000678 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000679
Dan Gohman20382522007-07-10 00:05:58 +0000680 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000681 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
682 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000683 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000684 [(set VR128:$dst, (F32Int VR128:$src1,
685 sse_load_f32:$src2))]>;
686}
687}
688
689// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +0000690defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
691defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
692defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
693defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000694
Dan Gohman20382522007-07-10 00:05:58 +0000695/// sse1_fp_binop_rm - Other SSE1 binops
696///
697/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
698/// instructions for a full-vector intrinsic form. Operations that map
699/// onto C operators don't use this form since they just use the plain
700/// vector form instead of having a separate vector intrinsic form.
701///
702/// This provides a total of eight "instructions".
703///
Evan Chenge9083d62008-03-05 08:19:16 +0000704let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000705multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
706 SDNode OpNode,
707 Intrinsic F32Int,
708 Intrinsic V4F32Int,
709 bit Commutable = 0> {
710
711 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000712 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000713 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000714 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
715 let isCommutable = Commutable;
716 }
717
718 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000719 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
720 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000721 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000722 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000723
Dan Gohman20382522007-07-10 00:05:58 +0000724 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000725 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
726 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000727 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000728 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
729 let isCommutable = Commutable;
730 }
731
732 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000733 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
734 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000735 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000736 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000737
738 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000739 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
740 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000741 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000742 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
743 let isCommutable = Commutable;
744 }
745
746 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000747 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
748 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000749 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000750 [(set VR128:$dst, (F32Int VR128:$src1,
751 sse_load_f32:$src2))]>;
752
753 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000754 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
755 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000756 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000757 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
758 let isCommutable = Commutable;
759 }
760
761 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000762 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
763 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000764 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000765 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000766}
767}
768
769defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
770 int_x86_sse_max_ss, int_x86_sse_max_ps>;
771defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
772 int_x86_sse_min_ss, int_x86_sse_min_ps>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000773
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000774//===----------------------------------------------------------------------===//
Evan Cheng9ab1ac52006-04-14 23:32:40 +0000775// SSE packed FP Instructions
Evan Chengc12e6c42006-03-19 09:38:54 +0000776
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000777// Move Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +0000778let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000779def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000780 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000781let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000782def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000783 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000784 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000785
Evan Cheng64d80e32007-07-19 01:14:50 +0000786def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000787 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000788 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000789
Chris Lattnerf77e0372008-01-11 06:59:07 +0000790let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000791def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000792 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000793let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000794def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000795 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000796 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000797def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000798 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000799 [(store (v4f32 VR128:$src), addr:$dst)]>;
800
801// Intrinsic forms of MOVUPS load and store
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000802let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000803def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000804 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000805 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000806def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000807 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000808 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000809
Evan Chenge9083d62008-03-05 08:19:16 +0000810let Constraints = "$src1 = $dst" in {
Dan Gohman32791e02007-06-25 15:44:19 +0000811 let AddedComplexity = 20 in {
812 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000813 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000814 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000815 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000816 (movlp VR128:$src1,
817 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000818 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000819 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000820 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000821 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000822 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +0000823 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000824 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000825} // Constraints = "$src1 = $dst"
Evan Cheng4fcb9222006-03-28 02:43:26 +0000826
Evan Chengb70ea0b2008-05-10 00:59:18 +0000827
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000828def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
Chris Lattner3485b512010-03-08 18:57:56 +0000829 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000830
Evan Cheng64d80e32007-07-19 01:14:50 +0000831def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000832 "movlps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000833 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
Evan Cheng015188f2006-06-15 08:14:54 +0000834 (iPTR 0))), addr:$dst)]>;
Evan Cheng9bbfd4f2006-03-28 07:01:28 +0000835
Evan Cheng664ade72006-04-07 21:20:58 +0000836// v2f64 extract element 1 is always custom lowered to unpack high to low
837// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +0000838def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000839 "movhps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000840 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +0000841 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
842 (undef)), (iPTR 0))), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000843
Evan Chenge9083d62008-03-05 08:19:16 +0000844let Constraints = "$src1 = $dst" in {
Evan Chengb7a75a52008-09-26 23:41:32 +0000845let AddedComplexity = 20 in {
Evan Cheng0af934e2009-05-12 20:17:52 +0000846def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
847 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000848 "movlhps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000849 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000850 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2c0dbd02006-03-24 02:58:06 +0000851
Evan Cheng0af934e2009-05-12 20:17:52 +0000852def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
853 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000854 "movhlps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000855 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000856 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2dadaea2006-04-19 20:37:34 +0000857} // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000858} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +0000859
Nate Begemanec8eee22009-04-29 22:47:44 +0000860let AddedComplexity = 20 in {
Nate Begeman9008ca62009-04-27 18:41:29 +0000861def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000862 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000863def : Pat<(v2i64 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000864 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000865}
Evan Cheng0b457f02008-09-25 20:50:48 +0000866
Bill Wendlingddd35322007-05-02 23:11:52 +0000867
868
Dan Gohman20382522007-07-10 00:05:58 +0000869// Arithmetic
870
871/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000872///
Dan Gohman20382522007-07-10 00:05:58 +0000873/// In addition, we also have a special variant of the scalar form here to
874/// represent the associated intrinsic operation. This form is unlike the
875/// plain scalar form, in that it takes an entire vector (instead of a
876/// scalar) and leaves the top elements undefined.
877///
878/// And, we have a special variant form for a full-vector intrinsic form.
879///
880/// These four forms can each have a reg or a mem operand, so there are a
881/// total of eight "instructions".
882///
883multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
884 SDNode OpNode,
885 Intrinsic F32Int,
886 Intrinsic V4F32Int,
887 bit Commutable = 0> {
888 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000889 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000890 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000891 [(set FR32:$dst, (OpNode FR32:$src))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000892 let isCommutable = Commutable;
893 }
894
Dan Gohman20382522007-07-10 00:05:58 +0000895 // Scalar operation, mem.
Evan Cheng400073d2009-12-18 07:40:29 +0000896 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000897 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Cheng400073d2009-12-18 07:40:29 +0000898 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +0000899 Requires<[HasSSE1, OptForSize]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000900
Dan Gohman20382522007-07-10 00:05:58 +0000901 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000902 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000903 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000904 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
905 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +0000906 }
907
Dan Gohman20382522007-07-10 00:05:58 +0000908 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000909 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000910 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +0000911 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000912
913 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000914 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000915 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000916 [(set VR128:$dst, (F32Int VR128:$src))]> {
917 let isCommutable = Commutable;
918 }
919
920 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000921 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000922 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000923 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
924
925 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +0000926 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000927 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000928 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
929 let isCommutable = Commutable;
930 }
931
932 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +0000933 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000934 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +0000935 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000936}
937
Dan Gohman20382522007-07-10 00:05:58 +0000938// Square root.
939defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
940 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
941
942// Reciprocal approximations. Note that these typically require refinement
943// in order to obtain suitable precision.
944defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
945 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
946defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
947 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
948
Bill Wendlingddd35322007-05-02 23:11:52 +0000949// Logical
Evan Chenge9083d62008-03-05 08:19:16 +0000950let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000951 let isCommutable = 1 in {
952 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000953 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000954 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000955 [(set VR128:$dst, (v2i64
956 (and VR128:$src1, VR128:$src2)))]>;
957 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000958 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000959 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000960 [(set VR128:$dst, (v2i64
961 (or VR128:$src1, VR128:$src2)))]>;
962 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000963 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000964 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000965 [(set VR128:$dst, (v2i64
966 (xor VR128:$src1, VR128:$src2)))]>;
967 }
968
969 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000970 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000971 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000972 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
973 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000974 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000975 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000976 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000977 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
978 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000979 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000980 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000981 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000982 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
983 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000984 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000985 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000987 [(set VR128:$dst,
988 (v2i64 (and (xor VR128:$src1,
989 (bc_v2i64 (v4i32 immAllOnesV))),
990 VR128:$src2)))]>;
991 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000992 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000993 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000994 [(set VR128:$dst,
Evan Cheng31d3a652007-07-19 23:34:10 +0000995 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Bill Wendlingddd35322007-05-02 23:11:52 +0000996 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng31d3a652007-07-19 23:34:10 +0000997 (memopv2i64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000998}
999
Evan Chenge9083d62008-03-05 08:19:16 +00001000let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001001 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begemanc2616e42008-05-12 20:34:32 +00001002 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1003 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1004 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
1005 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001006 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begemanc2616e42008-05-12 20:34:32 +00001007 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1008 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1009 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001010 (memop addr:$src), imm:$cc))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001011}
Nate Begeman30a0de92008-07-17 16:51:19 +00001012def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001013 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00001014def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001015 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001016
1017// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001018let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001019 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher44b93ff2009-07-31 20:07:27 +00001020 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001021 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001022 VR128:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001023 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001024 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001025 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001026 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001027 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001028 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001029 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001030 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001031 (v4f32 (shufp:$src3
1032 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001033
1034 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001035 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001036 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001037 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001038 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001039 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001040 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001041 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001042 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001043 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001044 (v4f32 (unpckh VR128:$src1,
1045 (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001046
Eric Christopher44b93ff2009-07-31 20:07:27 +00001047 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001048 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001049 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001050 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001051 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001052 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001053 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001054 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001055 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001056 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001057 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001058} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001059
1060// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00001061def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001062 "movmskps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001063 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Cheng8a0b2da2009-05-28 18:55:28 +00001064def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001065 "movmskpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001066 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1067
Evan Cheng27b7db52008-03-08 00:58:38 +00001068// Prefetch intrinsic.
1069def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1070 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1071def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1072 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1073def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1074 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1075def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1076 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001077
1078// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00001079def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001080 "movntps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001081 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1082
David Greene8939b0d2010-02-16 20:50:18 +00001083let AddedComplexity = 400 in { // Prefer non-temporal versions
1084def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1085 "movntps\t{$src, $dst|$dst, $src}",
1086 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1087
1088def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1089 "movntdq\t{$src, $dst|$dst, $src}",
1090 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
1091
David Greene8939b0d2010-02-16 20:50:18 +00001092def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1093 "movnti\t{$src, $dst|$dst, $src}",
1094 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
1095 TB, Requires<[HasSSE2]>;
1096
1097def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
1098 "movnti\t{$src, $dst|$dst, $src}",
1099 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
1100 TB, Requires<[HasSSE2]>;
1101}
1102
Bill Wendlingddd35322007-05-02 23:11:52 +00001103// Load, store, and memory fence
Evan Chengbc9be212009-05-27 18:38:01 +00001104def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001105
1106// MXCSR register
Evan Cheng64d80e32007-07-19 01:14:50 +00001107def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001108 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001109def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001110 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001111
1112// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00001113// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00001114// load of an all-zeros value if folding it would be beneficial.
Chris Lattner28c1d292010-02-05 21:30:49 +00001115// FIXME: Change encoding to pseudo!
Daniel Dunbar7417b762009-08-11 22:17:52 +00001116let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1117 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00001118def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00001119 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001120
Dan Gohmane13709a2010-02-26 01:14:30 +00001121def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1122def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1123def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1124def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1125def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
Evan Chengc8e3b142008-03-12 07:02:50 +00001126
Dan Gohman874cada2010-02-28 00:17:42 +00001127def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1128 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001129
Eric Christopher44b93ff2009-07-31 20:07:27 +00001130//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001131// SSE2 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00001132//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001133
Dan Gohman874cada2010-02-28 00:17:42 +00001134// Move Instructions. Register-to-register movsd is not used for FR64
1135// register copies because it's a partial register update; FsMOVAPDrr is
1136// used instead. Register-to-register movsd is not modeled as an INSERT_SUBREG
1137// because INSERT_SUBREG requires that the insert be implementable in terms of
1138// a copy, and just mentioned, we don't use movsd for copies.
1139let Constraints = "$src1 = $dst" in
1140def MOVSDrr : SDI<0x10, MRMSrcReg,
1141 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
1142 "movsd\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +00001143 [(set (v2f64 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +00001144 (movl VR128:$src1, (scalar_to_vector FR64:$src2)))]>;
1145
1146// Extract the low 64-bit value from one vector and insert it into another.
1147let AddedComplexity = 15 in
1148def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +00001149 (MOVSDrr (v2f64 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +00001150 (EXTRACT_SUBREG (v2f64 VR128:$src2), x86_subreg_sd))>;
1151
1152// Implicitly promote a 64-bit scalar to a vector.
1153def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
1154 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, x86_subreg_sd)>;
1155
1156// Loading from memory automatically zeroing upper bits.
1157let canFoldAsLoad = 1, isReMaterializable = 1, AddedComplexity = 20 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001158def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001159 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001160 [(set FR64:$dst, (loadf64 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +00001161
1162// MOVSDrm zeros the high parts of the register; represent this
1163// with SUBREG_TO_REG.
1164let AddedComplexity = 20 in {
1165def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
1166 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1167def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
1168 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1169def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
1170 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1171def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
1172 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1173def : Pat<(v2f64 (X86vzload addr:$src)),
1174 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1175}
1176
1177// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +00001178def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001179 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001180 [(store FR64:$src, addr:$dst)]>;
1181
Dan Gohman874cada2010-02-28 00:17:42 +00001182// Extract and store.
1183def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
1184 addr:$dst),
1185 (MOVSDmr addr:$dst,
1186 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
1187
Bill Wendlingddd35322007-05-02 23:11:52 +00001188// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00001189def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001190 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001191 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001192def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001193 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001194 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001195def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001196 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001197 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001198def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001199 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Cheng400073d2009-12-18 07:40:29 +00001200 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengb1f49812009-12-22 17:47:23 +00001201 Requires<[HasSSE2, OptForSize]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001202def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001203 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001204 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001205def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001206 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001207 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1208
Sean Callanan5ab94032009-09-16 01:13:52 +00001209def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1210 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1211def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1212 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1213def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1214 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1215def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1216 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1217def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1218 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1219def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1220 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1221def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1222 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1223def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1224 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1225def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1226 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1227def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1228 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1229
Bill Wendlingddd35322007-05-02 23:11:52 +00001230// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001231def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001232 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001233 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1234 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001235def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001236 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001237 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +00001238 Requires<[HasSSE2, OptForSize]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001239
1240def : Pat<(extloadf32 addr:$src),
Dan Gohman874cada2010-02-28 00:17:42 +00001241 (CVTSS2SDrr (MOVSSrm addr:$src))>,
1242 Requires<[HasSSE2, OptForSpeed]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001243
1244// Match intrinsics which expect XMM operand(s).
Evan Cheng64d80e32007-07-19 01:14:50 +00001245def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001246 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001247 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001248def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001249 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001250 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1251 (load addr:$src)))]>;
1252
Dale Johannesenc7842082007-10-30 22:15:38 +00001253// Match intrinisics which expect MM and XMM operand(s).
1254def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1255 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1256 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1257def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1258 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001259 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001260 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001261def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1262 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1263 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1264def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1265 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001266 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001267 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001268def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1269 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1270 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1271def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1272 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001273 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesenc7842082007-10-30 22:15:38 +00001274 (load addr:$src)))]>;
1275
Bill Wendlingddd35322007-05-02 23:11:52 +00001276// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +00001277def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001278 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001279 [(set GR32:$dst,
1280 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001281def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001282 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001283 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1284 (load addr:$src)))]>;
1285
1286// Comparison instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001287let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001288 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001289 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001290 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001291let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +00001292 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001293 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001294 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001295}
1296
Evan Cheng0488db92007-09-25 01:57:46 +00001297let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001298def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001299 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001300 [(set EFLAGS, (X86cmp FR64:$src1, FR64:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001301def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001302 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001303 [(set EFLAGS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001304} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001305
Bill Wendlingddd35322007-05-02 23:11:52 +00001306// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +00001307let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001308 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +00001309 (outs VR128:$dst),
1310 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001311 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001312 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1313 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001314 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +00001315 (outs VR128:$dst),
1316 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001317 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001318 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1319 (load addr:$src), imm:$cc))]>;
1320}
1321
Evan Cheng0488db92007-09-25 01:57:46 +00001322let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001323def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001324 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001325 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1326 VR128:$src2))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00001327def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001328 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001329 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1330 (load addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001331
Evan Cheng64d80e32007-07-19 01:14:50 +00001332def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001333 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001334 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1335 VR128:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001336def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001337 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001338 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1339 (load addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001340} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001341
Eric Christopher44b93ff2009-07-31 20:07:27 +00001342// Aliases of packed SSE2 instructions for scalar use. These all have names
1343// that start with 'Fs'.
Bill Wendlingddd35322007-05-02 23:11:52 +00001344
1345// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +00001346let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1347 canFoldAsLoad = 1 in
Chris Lattnerbe1778f2010-02-05 21:34:18 +00001348def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1349 [(set FR64:$dst, fpimm0)]>,
Bill Wendlingddd35322007-05-02 23:11:52 +00001350 Requires<[HasSSE2]>, TB, OpSize;
1351
Dan Gohman32791e02007-06-25 15:44:19 +00001352// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001353// disregarded.
Chris Lattnerba7e7562008-01-10 07:59:24 +00001354let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001355def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001356 "movapd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001357
Dan Gohman32791e02007-06-25 15:44:19 +00001358// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001359// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001360let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001361def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001362 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +00001363 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001364
1365// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +00001366let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001367let isCommutable = 1 in {
Evan Chengb6093392008-05-02 07:53:32 +00001368 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1369 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001370 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001371 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001372 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1373 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001374 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001375 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001376 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1377 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001378 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001379 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1380}
1381
Evan Chengb6093392008-05-02 07:53:32 +00001382def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1383 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001384 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001385 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001386 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001387def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1388 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001389 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001390 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001391 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001392def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1393 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001394 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001395 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001396 (memopfsf64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001397
Chris Lattnerba7e7562008-01-10 07:59:24 +00001398let neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001399def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001400 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001401 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001402let mayLoad = 1 in
Bill Wendlingddd35322007-05-02 23:11:52 +00001403def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001404 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001405 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001406}
Chris Lattnerba7e7562008-01-10 07:59:24 +00001407}
Bill Wendlingddd35322007-05-02 23:11:52 +00001408
Dan Gohman20382522007-07-10 00:05:58 +00001409/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +00001410///
Dan Gohman20382522007-07-10 00:05:58 +00001411/// In addition, we also have a special variant of the scalar form here to
1412/// represent the associated intrinsic operation. This form is unlike the
1413/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +00001414/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +00001415///
1416/// These three forms can each be reg+reg or reg+mem, so there are a total of
1417/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +00001418///
Evan Chenge9083d62008-03-05 08:19:16 +00001419let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001420multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1421 SDNode OpNode, Intrinsic F64Int,
1422 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +00001423 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001424 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001425 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001426 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1427 let isCommutable = Commutable;
1428 }
1429
1430 // Scalar operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001431 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1432 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001433 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001434 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001435
Dan Gohman20382522007-07-10 00:05:58 +00001436 // Vector operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001437 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1438 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001439 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001440 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1441 let isCommutable = Commutable;
1442 }
1443
1444 // Vector operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001445 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1446 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001447 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanb1347092009-01-09 02:27:34 +00001448 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001449
1450 // Intrinsic operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001451 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1452 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001453 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +00001454 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001455
Dan Gohman20382522007-07-10 00:05:58 +00001456 // Intrinsic operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001457 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1458 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001459 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001460 [(set VR128:$dst, (F64Int VR128:$src1,
1461 sse_load_f64:$src2))]>;
1462}
1463}
1464
1465// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +00001466defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1467defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1468defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1469defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001470
Dan Gohman20382522007-07-10 00:05:58 +00001471/// sse2_fp_binop_rm - Other SSE2 binops
1472///
1473/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1474/// instructions for a full-vector intrinsic form. Operations that map
1475/// onto C operators don't use this form since they just use the plain
1476/// vector form instead of having a separate vector intrinsic form.
1477///
1478/// This provides a total of eight "instructions".
1479///
Evan Chenge9083d62008-03-05 08:19:16 +00001480let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001481multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1482 SDNode OpNode,
1483 Intrinsic F64Int,
1484 Intrinsic V2F64Int,
1485 bit Commutable = 0> {
1486
1487 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001488 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001489 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001490 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1491 let isCommutable = Commutable;
1492 }
1493
1494 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001495 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1496 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001497 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001498 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001499
Dan Gohman20382522007-07-10 00:05:58 +00001500 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001501 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1502 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001503 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001504 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1505 let isCommutable = Commutable;
1506 }
1507
1508 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001509 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1510 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001511 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001512 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001513
1514 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001515 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1516 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001518 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1519 let isCommutable = Commutable;
1520 }
1521
1522 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001523 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1524 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001525 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001526 [(set VR128:$dst, (F64Int VR128:$src1,
1527 sse_load_f64:$src2))]>;
1528
1529 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001530 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1531 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001532 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001533 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1534 let isCommutable = Commutable;
1535 }
1536
1537 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001538 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1539 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001540 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001541 [(set VR128:$dst, (V2F64Int VR128:$src1,
1542 (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001543}
1544}
1545
1546defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1547 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1548defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1549 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001550
Eric Christopher44b93ff2009-07-31 20:07:27 +00001551//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001552// SSE packed FP Instructions
1553
1554// Move Instructions
Chris Lattnerba7e7562008-01-10 07:59:24 +00001555let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001556def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001557 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001558let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001559def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001560 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001561 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001562
Evan Cheng64d80e32007-07-19 01:14:50 +00001563def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001564 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001565 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001566
Chris Lattnerf77e0372008-01-11 06:59:07 +00001567let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001568def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001569 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001570let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001571def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001572 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001573 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001574def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001575 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001576 [(store (v2f64 VR128:$src), addr:$dst)]>;
1577
1578// Intrinsic forms of MOVUPD load and store
Evan Cheng64d80e32007-07-19 01:14:50 +00001579def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001580 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001581 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001582def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001583 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001584 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001585
Evan Chenge9083d62008-03-05 08:19:16 +00001586let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001587 let AddedComplexity = 20 in {
1588 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001589 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001591 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001592 (v2f64 (movlp VR128:$src1,
1593 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001594 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001595 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001596 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001597 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +00001598 (v2f64 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001599 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001600 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001601} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001602
Evan Cheng64d80e32007-07-19 01:14:50 +00001603def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001604 "movlpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001605 [(store (f64 (vector_extract (v2f64 VR128:$src),
1606 (iPTR 0))), addr:$dst)]>;
1607
1608// v2f64 extract element 1 is always custom lowered to unpack high to low
1609// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +00001610def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001611 "movhpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001612 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +00001613 (v2f64 (unpckh VR128:$src, (undef))),
1614 (iPTR 0))), addr:$dst)]>;
Evan Chengd9539472006-04-14 21:59:03 +00001615
Evan Cheng470a6ad2006-02-22 02:26:30 +00001616// SSE2 instructions without OpSize prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001617def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001618 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001619 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1620 TB, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001621def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001622 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1623 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1624 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001625 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001626
1627// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001628def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001630 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1631 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001632def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001633 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1634 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1635 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001636 XS, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001637
Evan Cheng64d80e32007-07-19 01:14:50 +00001638def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001639 "cvtps2dq\t{$src, $dst|$dst, $src}",
1640 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001641def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001642 "cvtps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001643 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001644 (memop addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001645// SSE2 packed instructions with XS prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001646def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1647 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1648def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1649 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1650
Evan Cheng64d80e32007-07-19 01:14:50 +00001651def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001652 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +00001653 [(set VR128:$dst,
1654 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001655 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001656def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001657 "cvttps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001658 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001659 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001660 XS, Requires<[HasSSE2]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001661
Evan Cheng470a6ad2006-02-22 02:26:30 +00001662// SSE2 packed instructions with XD prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001663def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001664 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001665 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1666 XD, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001667def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001668 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001669 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001670 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001671 XD, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001672
Evan Cheng64d80e32007-07-19 01:14:50 +00001673def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001674 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001675 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng029d9da2008-03-14 07:46:48 +00001676def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001677 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001678 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001679 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001680
1681// SSE2 instructions without OpSize prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001682def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1683 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1684def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1685 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1686
Evan Cheng64d80e32007-07-19 01:14:50 +00001687def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001688 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001689 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1690 TB, Requires<[HasSSE2]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001691def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001692 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001693 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
Chris Lattner15258d52006-10-07 06:17:43 +00001694 (load addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001695 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001696
Sean Callanan108934c2009-12-18 00:01:26 +00001697def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1698 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1699def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1700 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1701
1702
Evan Cheng64d80e32007-07-19 01:14:50 +00001703def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001704 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001705 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001706def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001707 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001708 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Chengb1938262008-05-23 00:37:07 +00001709 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001710
Evan Chengd2a6d542006-04-12 23:42:44 +00001711// Match intrinsics which expect XMM operand(s).
1712// Aliases for intrinsics
Evan Chenge9083d62008-03-05 08:19:16 +00001713let Constraints = "$src1 = $dst" in {
Evan Chengd2a6d542006-04-12 23:42:44 +00001714def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001715 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001716 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001717 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
Evan Cheng069287d2006-05-16 07:21:53 +00001718 GR32:$src2))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001719def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001720 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001721 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001722 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1723 (loadi32 addr:$src2)))]>;
1724def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001725 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001726 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001727 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1728 VR128:$src2))]>;
1729def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00001730 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001731 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001732 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001733 (load addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001734def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001735 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001736 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001737 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1738 VR128:$src2))]>, XS,
1739 Requires<[HasSSE2]>;
1740def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001741 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001742 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001743 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001744 (load addr:$src2)))]>, XS,
Evan Chengd2a6d542006-04-12 23:42:44 +00001745 Requires<[HasSSE2]>;
1746}
1747
Dan Gohman20382522007-07-10 00:05:58 +00001748// Arithmetic
1749
1750/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
Chris Lattner6f987732006-10-07 21:17:13 +00001751///
Dan Gohman20382522007-07-10 00:05:58 +00001752/// In addition, we also have a special variant of the scalar form here to
1753/// represent the associated intrinsic operation. This form is unlike the
1754/// plain scalar form, in that it takes an entire vector (instead of a
1755/// scalar) and leaves the top elements undefined.
1756///
1757/// And, we have a special variant form for a full-vector intrinsic form.
1758///
1759/// These four forms can each have a reg or a mem operand, so there are a
1760/// total of eight "instructions".
1761///
1762multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1763 SDNode OpNode,
1764 Intrinsic F64Int,
1765 Intrinsic V2F64Int,
1766 bit Commutable = 0> {
1767 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001768 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001769 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001770 [(set FR64:$dst, (OpNode FR64:$src))]> {
Chris Lattner6f987732006-10-07 21:17:13 +00001771 let isCommutable = Commutable;
1772 }
Bill Wendlingddd35322007-05-02 23:11:52 +00001773
Dan Gohman20382522007-07-10 00:05:58 +00001774 // Scalar operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001775 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001776 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001777 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001778
Dan Gohman20382522007-07-10 00:05:58 +00001779 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001780 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001781 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001782 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1783 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001784 }
1785
Dan Gohman20382522007-07-10 00:05:58 +00001786 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001787 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001789 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001790
1791 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001792 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001794 [(set VR128:$dst, (F64Int VR128:$src))]> {
1795 let isCommutable = Commutable;
1796 }
1797
1798 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001799 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001800 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001801 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1802
1803 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001804 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001805 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001806 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1807 let isCommutable = Commutable;
1808 }
1809
1810 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001811 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001812 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001813 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Evan Cheng97ac5fa2006-04-03 23:49:17 +00001814}
Evan Chengffcb95b2006-02-21 19:13:53 +00001815
Dan Gohman20382522007-07-10 00:05:58 +00001816// Square root.
1817defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1818 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1819
1820// There is no f64 version of the reciprocal approximation instructions.
1821
Evan Chengffcb95b2006-02-21 19:13:53 +00001822// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001823let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001824 let isCommutable = 1 in {
1825 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001826 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001828 [(set VR128:$dst,
1829 (and (bc_v2i64 (v2f64 VR128:$src1)),
Chris Lattner3b57a832006-10-07 06:27:03 +00001830 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001831 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001832 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001833 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001834 [(set VR128:$dst,
1835 (or (bc_v2i64 (v2f64 VR128:$src1)),
1836 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1837 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001838 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001839 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001840 [(set VR128:$dst,
1841 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1842 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1843 }
1844
1845 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001846 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001847 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001848 [(set VR128:$dst,
1849 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001850 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001851 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001852 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001853 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001854 [(set VR128:$dst,
1855 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001856 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001857 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001858 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001859 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001860 [(set VR128:$dst,
1861 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001862 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001863 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001864 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001865 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001866 [(set VR128:$dst,
1867 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Chris Lattner3b57a832006-10-07 06:27:03 +00001868 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001869 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001870 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001871 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001872 [(set VR128:$dst,
1873 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001874 (memopv2i64 addr:$src2)))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +00001875}
Evan Chengbf156d12006-02-21 19:26:52 +00001876
Evan Chenge9083d62008-03-05 08:19:16 +00001877let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001878 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001879 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1880 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1881 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begemanc2616e42008-05-12 20:34:32 +00001882 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001883 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng029d9da2008-03-14 07:46:48 +00001884 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1885 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1886 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001887 (memop addr:$src), imm:$cc))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001888}
Evan Chenge9d50352008-08-05 22:19:15 +00001889def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001890 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Chenge9d50352008-08-05 22:19:15 +00001891def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001892 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001893
1894// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001895let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001896 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1898 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman9008ca62009-04-27 18:41:29 +00001899 [(set VR128:$dst,
1900 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001901 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001902 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00001903 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001904 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001905 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001906 (v2f64 (shufp:$src3
1907 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001908
Bill Wendlingddd35322007-05-02 23:11:52 +00001909 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001910 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001911 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001912 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001913 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001914 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001915 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001916 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001918 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001919 (v2f64 (unpckh VR128:$src1,
1920 (memopv2f64 addr:$src2))))]>;
Evan Cheng4fcb9222006-03-28 02:43:26 +00001921
Eric Christopher44b93ff2009-07-31 20:07:27 +00001922 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001923 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001924 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001925 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001926 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001927 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001928 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001929 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001930 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001931 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001932 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001933} // Constraints = "$src1 = $dst"
Evan Cheng470a6ad2006-02-22 02:26:30 +00001934
Evan Cheng4b1734f2006-03-31 21:29:33 +00001935
Eric Christopher44b93ff2009-07-31 20:07:27 +00001936//===---------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001937// SSE integer instructions
Evan Chengbf156d12006-02-21 19:26:52 +00001938
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001939// Move Instructions
Chris Lattnerf77e0372008-01-11 06:59:07 +00001940let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001941def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001942 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001943let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001944def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001945 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001946 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001947let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001948def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001949 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001950 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001951let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001952def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001953 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001954 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001955 XS, Requires<[HasSSE2]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001956let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001957def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001959 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001960 XS, Requires<[HasSSE2]>;
Evan Cheng24dc1f52006-03-23 07:44:07 +00001961
Dan Gohman4106f372007-07-18 20:23:34 +00001962// Intrinsic forms of MOVDQU load and store
Dan Gohman15511cf2008-12-03 18:15:48 +00001963let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001964def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001966 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1967 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001968def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001969 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001970 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1971 XS, Requires<[HasSSE2]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001972
Evan Chenge7b8a8b2008-03-05 08:11:27 +00001973let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001974
Chris Lattner45e123c2006-10-07 19:02:31 +00001975multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1976 bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00001977 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1978 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001979 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001980 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1981 let isCommutable = Commutable;
1982 }
Sean Callanan108934c2009-12-18 00:01:26 +00001983 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1984 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001985 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001986 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00001987 (bitconvert (memopv2i64
1988 addr:$src2))))]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001989}
Chris Lattner8139e282006-10-07 18:39:00 +00001990
Evan Cheng22b942a2008-05-03 00:52:09 +00001991multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1992 string OpcodeStr,
1993 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan108934c2009-12-18 00:01:26 +00001994 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1995 (ins VR128:$src1, VR128:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00001996 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1997 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001998 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1999 (ins VR128:$src1, i128mem:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002000 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2001 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002002 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002003 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
2004 (ins VR128:$src1, i32i8imm:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002005 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2006 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2007}
2008
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002009/// PDI_binop_rm - Simple SSE2 binary operator.
2010multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2011 ValueType OpVT, bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00002012 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2013 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002014 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002015 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
2016 let isCommutable = Commutable;
2017 }
Sean Callanan108934c2009-12-18 00:01:26 +00002018 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2019 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002020 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002021 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002022 (bitconvert (memopv2i64 addr:$src2)))))]>;
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002023}
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002024
2025/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2026///
2027/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2028/// to collapse (bitconvert VT to VT) into its operand.
2029///
2030multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2031 bit Commutable = 0> {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002032 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002033 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002034 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002035 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
2036 let isCommutable = Commutable;
2037 }
Eric Christopher44b93ff2009-07-31 20:07:27 +00002038 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002039 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002040 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002041 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00002042 (memopv2i64 addr:$src2)))]>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002043}
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002044
Evan Chenge9083d62008-03-05 08:19:16 +00002045} // Constraints = "$src1 = $dst"
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002046
2047// 128-bit Integer Arithmetic
2048
2049defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2050defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2051defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002052defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002053
Chris Lattner45e123c2006-10-07 19:02:31 +00002054defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2055defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2056defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2057defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002058
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002059defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2060defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2061defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002062defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002063
Chris Lattner45e123c2006-10-07 19:02:31 +00002064defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2065defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2066defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2067defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002068
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002069defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002070
Chris Lattner45e123c2006-10-07 19:02:31 +00002071defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2072defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2073defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002074
Chris Lattner45e123c2006-10-07 19:02:31 +00002075defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
Chris Lattner77337992006-10-07 07:06:17 +00002076
Chris Lattner45e123c2006-10-07 19:02:31 +00002077defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2078defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
Chris Lattner8139e282006-10-07 18:39:00 +00002079
Chris Lattner77337992006-10-07 07:06:17 +00002080
Chris Lattner45e123c2006-10-07 19:02:31 +00002081defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2082defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2083defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2084defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling3b1259b2009-05-28 02:04:00 +00002085defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Evan Chengc60bd972006-03-25 09:37:23 +00002086
Chris Lattner77337992006-10-07 07:06:17 +00002087
Evan Cheng22b942a2008-05-03 00:52:09 +00002088defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2089 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2090defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2091 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2092defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2093 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002094
Evan Cheng22b942a2008-05-03 00:52:09 +00002095defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2096 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2097defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2098 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begeman32097bd2008-05-13 17:52:09 +00002099defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Cheng22b942a2008-05-03 00:52:09 +00002100 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002101
Evan Cheng22b942a2008-05-03 00:52:09 +00002102defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2103 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemanc9bdb002008-05-13 01:47:52 +00002104defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Cheng22b942a2008-05-03 00:52:09 +00002105 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Chris Lattner77337992006-10-07 07:06:17 +00002106
Chris Lattner6970eda2006-10-07 19:49:05 +00002107// 128-bit logical shifts.
Evan Chenge9083d62008-03-05 08:19:16 +00002108let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002109 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002110 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002111 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002112 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002113 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002114 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002115 // PSRADQri doesn't exist in SSE[1-3].
Evan Chengff65e382006-04-04 21:49:39 +00002116}
2117
Chris Lattner6970eda2006-10-07 19:49:05 +00002118let Predicates = [HasSSE2] in {
2119 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002120 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002121 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002122 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling5e249b42008-10-02 05:56:52 +00002123 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2124 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2125 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2126 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Evan Cheng68c47cb2007-01-05 07:55:56 +00002127 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng89321162009-10-28 06:30:34 +00002128 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002129
2130 // Shift up / down and insert zero's.
2131 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002132 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002133 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002134 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002135}
2136
Evan Cheng506d3df2006-03-29 23:07:14 +00002137// Logical
Chris Lattnera7ebe552006-10-07 19:37:30 +00002138defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2139defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2140defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2141
Evan Chenge9083d62008-03-05 08:19:16 +00002142let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002143 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002144 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002145 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002146 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2147 VR128:$src2)))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002148
Bill Wendlingddd35322007-05-02 23:11:52 +00002149 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002150 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002151 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002152 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7f55fcb2007-08-02 21:17:01 +00002153 (memopv2i64 addr:$src2))))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002154}
2155
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002156// SSE2 Integer comparison
Bill Wendlingddd35322007-05-02 23:11:52 +00002157defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2158defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2159defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2160defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2161defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2162defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002163
Nate Begeman30a0de92008-07-17 16:51:19 +00002164def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002165 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002166def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002167 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002168def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002169 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002170def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002171 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002172def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002173 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002174def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002175 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2176
Nate Begeman30a0de92008-07-17 16:51:19 +00002177def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002178 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002179def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002180 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002181def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002182 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002183def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002184 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002185def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002186 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002187def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002188 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2189
2190
Evan Cheng506d3df2006-03-29 23:07:14 +00002191// Pack instructions
Chris Lattner45e123c2006-10-07 19:02:31 +00002192defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2193defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2194defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002195
2196// Shuffle and unpack instructions
Nate Begemana09008b2009-10-19 02:17:23 +00002197let AddedComplexity = 5 in {
Evan Cheng8703be42006-04-04 19:12:30 +00002198def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002199 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002200 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002201 [(set VR128:$dst, (v4i32 (pshufd:$src2
2202 VR128:$src1, (undef))))]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002203def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002204 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002205 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002206 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chengc3630942009-12-09 21:00:30 +00002207 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002208 (undef))))]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002209}
Evan Cheng506d3df2006-03-29 23:07:14 +00002210
2211// SSE2 with ImmT == Imm8 and XS prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002212def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002213 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002214 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002215 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2216 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002217 XS, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002218def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002219 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002221 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher44b93ff2009-07-31 20:07:27 +00002222 (bc_v8i16 (memopv2i64 addr:$src1)),
2223 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002224 XS, Requires<[HasSSE2]>;
2225
2226// SSE2 with ImmT == Imm8 and XD prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002227def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman9008ca62009-04-27 18:41:29 +00002228 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002230 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2231 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002232 XD, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002233def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman9008ca62009-04-27 18:41:29 +00002234 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002236 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2237 (bc_v8i16 (memopv2i64 addr:$src1)),
2238 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002239 XD, Requires<[HasSSE2]>;
2240
Evan Chengc60bd972006-03-25 09:37:23 +00002241
Evan Chenge9083d62008-03-05 08:19:16 +00002242let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002243 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002244 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002245 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002246 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002247 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002248 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002249 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002250 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002251 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002252 (unpckl VR128:$src1,
2253 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002254 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002255 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002256 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002257 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002258 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002259 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002260 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002261 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002262 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002263 (unpckl VR128:$src1,
2264 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002265 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002266 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002267 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002268 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002269 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002270 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002271 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002272 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002273 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002274 (unpckl VR128:$src1,
2275 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002276 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002277 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002278 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002279 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002280 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002281 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002282 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002283 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002284 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002285 (v2i64 (unpckl VR128:$src1,
2286 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002287
2288 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002289 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002290 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002291 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002292 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002293 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002294 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002296 [(set VR128:$dst,
2297 (unpckh VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00002298 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002299 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002302 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002303 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002304 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002305 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002306 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002307 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002308 (unpckh VR128:$src1,
2309 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002310 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002311 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002312 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002313 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002314 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002315 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002316 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002317 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002318 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002319 (unpckh VR128:$src1,
2320 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002321 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002322 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002323 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002324 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002325 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002326 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002327 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002328 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002329 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002330 (v2i64 (unpckh VR128:$src1,
2331 (memopv2i64 addr:$src2))))]>;
Evan Chenga971f6f2006-03-23 01:57:24 +00002332}
Evan Cheng82521dd2006-03-21 07:09:35 +00002333
Evan Chengb067a1e2006-03-31 19:22:53 +00002334// Extract / Insert
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002335def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002336 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002337 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002338 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begeman14d12ca2008-02-11 04:19:36 +00002339 imm:$src2))]>;
Evan Chenge9083d62008-03-05 08:19:16 +00002340let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002341 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002342 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002343 GR32:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002344 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002345 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002346 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002347 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002348 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002349 i16mem:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002350 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002351 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002352 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2353 imm:$src3))]>;
Evan Chengb067a1e2006-03-31 19:22:53 +00002354}
2355
Evan Chengc5fb2b12006-03-30 00:33:26 +00002356// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00002357def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002358 "pmovmskb\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002359 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
Evan Chengc5fb2b12006-03-30 00:33:26 +00002360
Evan Chengfcf5e212006-04-11 06:57:30 +00002361// Conditional store
Evan Cheng071a2792007-09-11 19:55:27 +00002362let Uses = [EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +00002363def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002364 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng071a2792007-09-11 19:55:27 +00002365 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Evan Chengfcf5e212006-04-11 06:57:30 +00002366
Evan Cheng1d768642009-02-10 22:06:28 +00002367let Uses = [RDI] in
2368def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2369 "maskmovdqu\t{$mask, $src|$src, $mask}",
2370 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2371
Evan Chengecac9cb2006-03-25 06:03:26 +00002372// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00002373def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2374 "movntpd\t{$src, $dst|$dst, $src}",
2375 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2376def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2377 "movntdq\t{$src, $dst|$dst, $src}",
2378 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2379def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002380 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002381 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Evan Chengfcf5e212006-04-11 06:57:30 +00002382 TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002383
David Greene8939b0d2010-02-16 20:50:18 +00002384let AddedComplexity = 400 in { // Prefer non-temporal versions
2385def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2386 "movntpd\t{$src, $dst|$dst, $src}",
2387 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2388
2389def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2390 "movntdq\t{$src, $dst|$dst, $src}",
2391 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
David Greene8939b0d2010-02-16 20:50:18 +00002392}
2393
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002394// Flush cache
Evan Cheng64d80e32007-07-19 01:14:50 +00002395def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002396 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002397 TB, Requires<[HasSSE2]>;
2398
2399// Load, store, and memory fence
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002400def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002401 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002402def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002403 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002404
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002405//TODO: custom lower this so as to never even generate the noop
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002406def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002407 (i8 0)), (NOOP)>;
2408def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2409def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002410def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002411 (i8 1)), (MFENCE)>;
2412
Evan Chengffea91e2006-03-26 09:53:12 +00002413// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00002414// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00002415// load of an all-ones value if folding it would be beneficial.
Daniel Dunbar7417b762009-08-11 22:17:52 +00002416let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2417 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00002418 // FIXME: Change encoding to pseudo.
2419 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00002420 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Evan Cheng386031a2006-03-24 07:29:27 +00002421
Evan Cheng64d80e32007-07-19 01:14:50 +00002422def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002423 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002424 [(set VR128:$dst,
Evan Cheng069287d2006-05-16 07:21:53 +00002425 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002426def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002427 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002428 [(set VR128:$dst,
2429 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Evan Chengebf01d62006-11-16 23:33:25 +00002430
Evan Cheng64d80e32007-07-19 01:14:50 +00002431def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002432 "movd\t{$src, $dst|$dst, $src}",
Chris Lattnerf3597a12006-12-05 18:45:06 +00002433 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2434
Evan Cheng64d80e32007-07-19 01:14:50 +00002435def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002436 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002437 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002438
Evan Cheng11e15b32006-04-03 20:53:28 +00002439// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00002440def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002441 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002442 [(set VR128:$dst,
2443 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2444 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002445def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002446 "movq\t{$src, $dst|$dst, $src}",
Evan Chengebf01d62006-11-16 23:33:25 +00002447 [(store (i64 (vector_extract (v2i64 VR128:$src),
2448 (iPTR 0))), addr:$dst)]>;
2449
Dan Gohman874cada2010-02-28 00:17:42 +00002450def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
2451 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
2452
Evan Cheng64d80e32007-07-19 01:14:50 +00002453def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002454 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002455 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002456 (iPTR 0)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002457def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002458 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002459 [(store (i32 (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002460 (iPTR 0))), addr:$dst)]>;
Evan Cheng11e15b32006-04-03 20:53:28 +00002461
Evan Cheng64d80e32007-07-19 01:14:50 +00002462def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002463 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002464 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002465def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002466 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002467 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002468
Evan Cheng397edef2006-04-11 22:28:25 +00002469// Store / copy lower 64-bits of a XMM register.
Evan Cheng64d80e32007-07-19 01:14:50 +00002470def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002471 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng397edef2006-04-11 22:28:25 +00002472 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2473
Evan Cheng017dcc62006-04-21 01:05:10 +00002474// movd / movq to XMM register zero-extends
Evan Cheng7a831ce2007-12-15 03:00:47 +00002475let AddedComplexity = 15 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002476def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002477 "movd\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002478 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002479 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002480// This is X86-64 only.
2481def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2482 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002483 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002484 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002485}
2486
2487let AddedComplexity = 20 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002488def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002489 "movd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002490 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002491 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002492 (loadi32 addr:$src))))))]>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002493
2494def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2495 (MOVZDI2PDIrm addr:$src)>;
2496def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2497 (MOVZDI2PDIrm addr:$src)>;
Duncan Sandsd4b9c172008-06-13 19:07:40 +00002498def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2499 (MOVZDI2PDIrm addr:$src)>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002500
Evan Cheng64d80e32007-07-19 01:14:50 +00002501def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002502 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng7a831ce2007-12-15 03:00:47 +00002503 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002504 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002505 (loadi64 addr:$src))))))]>, XS,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002506 Requires<[HasSSE2]>;
Evan Cheng48090aa2006-03-21 23:01:21 +00002507
Evan Chengc36c0ab2008-05-22 18:56:56 +00002508def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2509 (MOVZQI2PQIrm addr:$src)>;
2510def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2511 (MOVZQI2PQIrm addr:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00002512def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengb70ea0b2008-05-10 00:59:18 +00002513}
Evan Chengd880b972008-05-09 21:53:03 +00002514
Evan Cheng7a831ce2007-12-15 03:00:47 +00002515// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2516// IA32 document. movq xmm1, xmm2 does clear the high bits.
2517let AddedComplexity = 15 in
2518def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2519 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002520 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002521 XS, Requires<[HasSSE2]>;
2522
Evan Cheng8e8de682008-05-20 18:24:47 +00002523let AddedComplexity = 20 in {
Evan Cheng7a831ce2007-12-15 03:00:47 +00002524def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2525 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002526 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng8e8de682008-05-20 18:24:47 +00002527 (loadv2i64 addr:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002528 XS, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002529
Evan Cheng8e8de682008-05-20 18:24:47 +00002530def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2531 (MOVZPQILo2PQIrm addr:$src)>;
2532}
2533
Sean Callanan108934c2009-12-18 00:01:26 +00002534// Instructions for the disassembler
2535// xr = XMM register
2536// xm = mem64
2537
2538def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2539 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2540
Eric Christopher44b93ff2009-07-31 20:07:27 +00002541//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002542// SSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002543//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002544
Bill Wendlingddd35322007-05-02 23:11:52 +00002545// Move Instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00002546def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002547 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002548 [(set VR128:$dst, (v4f32 (movshdup
2549 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002550def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002551 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002552 [(set VR128:$dst, (movshdup
2553 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002554
Evan Cheng64d80e32007-07-19 01:14:50 +00002555def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002556 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002557 [(set VR128:$dst, (v4f32 (movsldup
2558 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002559def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002560 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002561 [(set VR128:$dst, (movsldup
2562 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002563
Evan Cheng64d80e32007-07-19 01:14:50 +00002564def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002565 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002566 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002567def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002568 "movddup\t{$src, $dst|$dst, $src}",
Evan Cheng0b457f02008-09-25 20:50:48 +00002569 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002570 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2571 (undef))))]>;
Evan Cheng0b457f02008-09-25 20:50:48 +00002572
Nate Begeman9008ca62009-04-27 18:41:29 +00002573def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2574 (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002575 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002576
2577let AddedComplexity = 5 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00002578def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002579 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002580def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2581 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2582def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2583 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2584def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2585 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2586}
Bill Wendlingddd35322007-05-02 23:11:52 +00002587
2588// Arithmetic
Evan Chenge9083d62008-03-05 08:19:16 +00002589let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002590 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002591 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002592 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002593 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2594 VR128:$src2))]>;
2595 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002596 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002597 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002598 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002599 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002600 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002601 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002602 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002603 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2604 VR128:$src2))]>;
2605 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002606 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002607 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002608 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002609 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002610}
2611
Evan Cheng64d80e32007-07-19 01:14:50 +00002612def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002613 "lddqu\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002614 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2615
2616// Horizontal ops
2617class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002618 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002619 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002620 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2621class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002622 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002624 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002625class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002626 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002627 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002628 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2629class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002630 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002631 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002632 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002633
Evan Chenge9083d62008-03-05 08:19:16 +00002634let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002635 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2636 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2637 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2638 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2639 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2640 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2641 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2642 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2643}
2644
2645// Thread synchronization
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002646def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
Bill Wendlingddd35322007-05-02 23:11:52 +00002647 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002648def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
Bill Wendlingddd35322007-05-02 23:11:52 +00002649 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2650
2651// vector_shuffle v1, <undef> <1, 1, 3, 3>
2652let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002653def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002654 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2655let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002656def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002657 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2658
2659// vector_shuffle v1, <undef> <0, 0, 2, 2>
2660let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002661 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002662 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2663let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002664 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002665 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2666
Eric Christopher44b93ff2009-07-31 20:07:27 +00002667//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002668// SSSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002669//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002670
Bill Wendling76d708b2007-08-10 06:22:27 +00002671/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begemanfea2be52008-02-09 23:46:37 +00002672multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2673 Intrinsic IntId64, Intrinsic IntId128> {
2674 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2675 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2676 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002677
Nate Begemanfea2be52008-02-09 23:46:37 +00002678 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2679 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2680 [(set VR64:$dst,
2681 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2682
2683 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2684 (ins VR128:$src),
2685 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2686 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2687 OpSize;
2688
2689 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2690 (ins i128mem:$src),
2691 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2692 [(set VR128:$dst,
2693 (IntId128
2694 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Bill Wendlingddd35322007-05-02 23:11:52 +00002695}
2696
Bill Wendling76d708b2007-08-10 06:22:27 +00002697/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begemanfea2be52008-02-09 23:46:37 +00002698multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2699 Intrinsic IntId64, Intrinsic IntId128> {
2700 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2701 (ins VR64:$src),
2702 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2703 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002704
Nate Begemanfea2be52008-02-09 23:46:37 +00002705 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2706 (ins i64mem:$src),
2707 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2708 [(set VR64:$dst,
2709 (IntId64
2710 (bitconvert (memopv4i16 addr:$src))))]>;
2711
2712 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2713 (ins VR128:$src),
2714 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2715 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2716 OpSize;
2717
2718 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2719 (ins i128mem:$src),
2720 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2721 [(set VR128:$dst,
2722 (IntId128
2723 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002724}
2725
2726/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begemanfea2be52008-02-09 23:46:37 +00002727multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2728 Intrinsic IntId64, Intrinsic IntId128> {
2729 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2730 (ins VR64:$src),
2731 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2732 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002733
Nate Begemanfea2be52008-02-09 23:46:37 +00002734 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2735 (ins i64mem:$src),
2736 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2737 [(set VR64:$dst,
2738 (IntId64
2739 (bitconvert (memopv2i32 addr:$src))))]>;
2740
2741 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2742 (ins VR128:$src),
2743 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2744 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2745 OpSize;
2746
2747 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2748 (ins i128mem:$src),
2749 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2750 [(set VR128:$dst,
2751 (IntId128
2752 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002753}
2754
2755defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2756 int_x86_ssse3_pabs_b,
2757 int_x86_ssse3_pabs_b_128>;
2758defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2759 int_x86_ssse3_pabs_w,
2760 int_x86_ssse3_pabs_w_128>;
2761defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2762 int_x86_ssse3_pabs_d,
2763 int_x86_ssse3_pabs_d_128>;
2764
2765/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Chenge9083d62008-03-05 08:19:16 +00002766let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002767 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2768 Intrinsic IntId64, Intrinsic IntId128,
2769 bit Commutable = 0> {
2770 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2771 (ins VR64:$src1, VR64:$src2),
2772 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2773 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2774 let isCommutable = Commutable;
2775 }
2776 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2777 (ins VR64:$src1, i64mem:$src2),
2778 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2779 [(set VR64:$dst,
2780 (IntId64 VR64:$src1,
2781 (bitconvert (memopv8i8 addr:$src2))))]>;
2782
2783 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2784 (ins VR128:$src1, VR128:$src2),
2785 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2786 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2787 OpSize {
2788 let isCommutable = Commutable;
2789 }
2790 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2791 (ins VR128:$src1, i128mem:$src2),
2792 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2793 [(set VR128:$dst,
2794 (IntId128 VR128:$src1,
2795 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2796 }
2797}
2798
2799/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Chenge9083d62008-03-05 08:19:16 +00002800let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002801 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2802 Intrinsic IntId64, Intrinsic IntId128,
2803 bit Commutable = 0> {
2804 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2805 (ins VR64:$src1, VR64:$src2),
2806 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2807 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2808 let isCommutable = Commutable;
2809 }
2810 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2811 (ins VR64:$src1, i64mem:$src2),
2812 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2813 [(set VR64:$dst,
2814 (IntId64 VR64:$src1,
2815 (bitconvert (memopv4i16 addr:$src2))))]>;
2816
2817 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2818 (ins VR128:$src1, VR128:$src2),
2819 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2820 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2821 OpSize {
2822 let isCommutable = Commutable;
2823 }
2824 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2825 (ins VR128:$src1, i128mem:$src2),
2826 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2827 [(set VR128:$dst,
2828 (IntId128 VR128:$src1,
2829 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2830 }
2831}
2832
2833/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Chenge9083d62008-03-05 08:19:16 +00002834let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002835 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2836 Intrinsic IntId64, Intrinsic IntId128,
2837 bit Commutable = 0> {
2838 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2839 (ins VR64:$src1, VR64:$src2),
2840 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2841 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2842 let isCommutable = Commutable;
2843 }
2844 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2845 (ins VR64:$src1, i64mem:$src2),
2846 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2847 [(set VR64:$dst,
2848 (IntId64 VR64:$src1,
2849 (bitconvert (memopv2i32 addr:$src2))))]>;
2850
2851 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2852 (ins VR128:$src1, VR128:$src2),
2853 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2854 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2855 OpSize {
2856 let isCommutable = Commutable;
2857 }
2858 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2859 (ins VR128:$src1, i128mem:$src2),
2860 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2861 [(set VR128:$dst,
2862 (IntId128 VR128:$src1,
2863 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2864 }
2865}
2866
2867defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2868 int_x86_ssse3_phadd_w,
Evan Cheng4e444432008-06-16 21:16:24 +00002869 int_x86_ssse3_phadd_w_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002870defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2871 int_x86_ssse3_phadd_d,
Evan Cheng4e444432008-06-16 21:16:24 +00002872 int_x86_ssse3_phadd_d_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002873defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2874 int_x86_ssse3_phadd_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002875 int_x86_ssse3_phadd_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002876defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2877 int_x86_ssse3_phsub_w,
2878 int_x86_ssse3_phsub_w_128>;
2879defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2880 int_x86_ssse3_phsub_d,
2881 int_x86_ssse3_phsub_d_128>;
2882defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2883 int_x86_ssse3_phsub_sw,
2884 int_x86_ssse3_phsub_sw_128>;
2885defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2886 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002887 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002888defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2889 int_x86_ssse3_pmul_hr_sw,
2890 int_x86_ssse3_pmul_hr_sw_128, 1>;
2891defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2892 int_x86_ssse3_pshuf_b,
2893 int_x86_ssse3_pshuf_b_128>;
2894defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2895 int_x86_ssse3_psign_b,
2896 int_x86_ssse3_psign_b_128>;
2897defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2898 int_x86_ssse3_psign_w,
2899 int_x86_ssse3_psign_w_128>;
Evan Chenged7f56b2009-05-28 18:48:53 +00002900defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling76d708b2007-08-10 06:22:27 +00002901 int_x86_ssse3_psign_d,
2902 int_x86_ssse3_psign_d_128>;
2903
Evan Chenge9083d62008-03-05 08:19:16 +00002904let Constraints = "$src1 = $dst" in {
Bill Wendlingae9671b2007-08-10 09:00:17 +00002905 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002906 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002907 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002908 []>;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002909 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002910 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002911 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002912 []>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002913
Bill Wendlingae9671b2007-08-10 09:00:17 +00002914 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002915 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002916 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002917 []>, OpSize;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002918 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002919 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002920 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002921 []>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002922}
Bill Wendlingddd35322007-05-02 23:11:52 +00002923
Nate Begemana09008b2009-10-19 02:17:23 +00002924// palignr patterns.
Sean Callananb9e6b342009-11-20 22:28:42 +00002925def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002926 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2927 Requires<[HasSSSE3]>;
2928def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2929 (memop64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002930 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002931 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2932 Requires<[HasSSSE3]>;
2933
Sean Callananb9e6b342009-11-20 22:28:42 +00002934def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002935 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2936 Requires<[HasSSSE3]>;
2937def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2938 (memopv2i64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002939 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002940 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2941 Requires<[HasSSSE3]>;
2942
Nate Begemana09008b2009-10-19 02:17:23 +00002943let AddedComplexity = 5 in {
2944def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2945 (PALIGNR128rr VR128:$src2, VR128:$src1,
2946 (SHUFFLE_get_palign_imm VR128:$src3))>,
2947 Requires<[HasSSSE3]>;
2948def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2949 (PALIGNR128rr VR128:$src2, VR128:$src1,
2950 (SHUFFLE_get_palign_imm VR128:$src3))>,
2951 Requires<[HasSSSE3]>;
2952def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2953 (PALIGNR128rr VR128:$src2, VR128:$src1,
2954 (SHUFFLE_get_palign_imm VR128:$src3))>,
2955 Requires<[HasSSSE3]>;
2956def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2957 (PALIGNR128rr VR128:$src2, VR128:$src1,
2958 (SHUFFLE_get_palign_imm VR128:$src3))>,
2959 Requires<[HasSSSE3]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002960}
Nate Begemana09008b2009-10-19 02:17:23 +00002961
Nate Begemanb9a47b82009-02-23 08:49:38 +00002962def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2963 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2964def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2965 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2966
Eric Christopher44b93ff2009-07-31 20:07:27 +00002967//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002968// Non-Instruction Patterns
Eric Christopher44b93ff2009-07-31 20:07:27 +00002969//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002970
Eric Christopher44b93ff2009-07-31 20:07:27 +00002971// extload f32 -> f64. This matches load+fextend because we have a hack in
2972// the isel (PreprocessForFPConvert) that can introduce loads after dag
2973// combine.
Chris Lattnerd43d00c2008-01-24 08:07:48 +00002974// Since these loads aren't folded into the fextend, we have to match it
2975// explicitly here.
2976let Predicates = [HasSSE2] in
2977 def : Pat<(fextend (loadf32 addr:$src)),
2978 (CVTSS2SDrm addr:$src)>;
2979
Evan Cheng2c0dbd02006-03-24 02:58:06 +00002980// bit_convert
Chris Lattner4cc84ed2006-10-07 04:52:09 +00002981let Predicates = [HasSSE2] in {
2982 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2983 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2984 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2985 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2986 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2987 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2988 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2989 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2990 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2991 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2992 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2993 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2994 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2995 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2996 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2997 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2998 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2999 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3000 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3001 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3002 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3003 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3004 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3005 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3006 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3007 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3008 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3009 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3010 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3011 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3012}
Evan Chengb9df0ca2006-03-22 02:53:00 +00003013
Evan Cheng017dcc62006-04-21 01:05:10 +00003014// Move scalar to XMM zero-extended
3015// movd to XMM register zero-extends
Evan Chengf2ea84a2006-10-09 21:42:15 +00003016let AddedComplexity = 15 in {
Evan Cheng017dcc62006-04-21 01:05:10 +00003017// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chengd880b972008-05-09 21:53:03 +00003018def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003019 (MOVSDrr (v2f64 (V_SET0)), FR64:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00003020def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003021 (MOVSSrr (v4f32 (V_SET0)), FR32:$src)>;
Evan Cheng23573e52008-05-09 23:37:55 +00003022def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003023 (MOVSSrr (v4f32 (V_SET0)),
3024 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss)))>;
Evan Cheng331e2bd2008-07-10 01:08:23 +00003025def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003026 (MOVSSrr (v4i32 (V_SET0)),
3027 (EXTRACT_SUBREG (v4i32 VR128:$src), x86_subreg_ss))>;
Evan Cheng017dcc62006-04-21 01:05:10 +00003028}
Evan Chengbc4832b2006-03-24 23:15:12 +00003029
Evan Chengb9df0ca2006-03-22 02:53:00 +00003030// Splat v2f64 / v2i64
Evan Chengfd111b52006-04-19 21:15:24 +00003031let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003032def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003033 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003034def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003035 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003036def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003037 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003038def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003039 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengfd111b52006-04-19 21:15:24 +00003040}
Evan Cheng475aecf2006-03-29 03:04:49 +00003041
Evan Chengb7a5c522006-04-18 21:55:35 +00003042// Special unary SHUFPSrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003043def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3044 (SHUFPSrri VR128:$src1, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003045 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003046let AddedComplexity = 5 in
3047def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3048 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3049 Requires<[HasSSE2]>;
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003050// Special unary SHUFPDrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003051def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003052 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003053 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3054 Requires<[HasSSE2]>;
3055// Special unary SHUFPDrri case.
3056def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003057 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003058 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003059 Requires<[HasSSE2]>;
Evan Cheng3d60df42006-04-10 22:35:16 +00003060// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman9008ca62009-04-27 18:41:29 +00003061def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3062 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng7d9061e2006-03-30 19:54:57 +00003063 Requires<[HasSSE2]>;
Evan Chengb7a75a52008-09-26 23:41:32 +00003064
Evan Cheng3d60df42006-04-10 22:35:16 +00003065// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman9008ca62009-04-27 18:41:29 +00003066def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003067 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003068 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003069 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003070def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003071 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003072 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003073 Requires<[HasSSE2]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00003074// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman9008ca62009-04-27 18:41:29 +00003075def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003076 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003077 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00003078 Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003079
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003080// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003081let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003082def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3083 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003084 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003085def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3086 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003087 Requires<[OptForSpeed, HasSSE2]>;
3088}
Evan Chengfd111b52006-04-19 21:15:24 +00003089let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003090def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003091 (UNPCKLPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003092def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003093 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003094def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003095 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003096def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003097 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
Evan Chengfd111b52006-04-19 21:15:24 +00003098}
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003099
Evan Cheng174f8032007-05-17 18:44:37 +00003100// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003101let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003102def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3103 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003104 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003105def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3106 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003107 Requires<[OptForSpeed, HasSSE2]>;
3108}
Evan Cheng174f8032007-05-17 18:44:37 +00003109let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003110def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003111 (UNPCKHPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003112def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003113 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003114def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003115 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003116def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003117 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
Evan Cheng174f8032007-05-17 18:44:37 +00003118}
3119
Evan Chengb7a75a52008-09-26 23:41:32 +00003120let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003121// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman0b10b912009-11-07 23:17:15 +00003122def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003123 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003124
3125// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003126def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003127 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003128
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003129// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003130def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003131 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003132def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003133 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003134}
Evan Cheng9d09b892006-05-31 00:51:37 +00003135
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003136let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003137// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003138def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003139 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003140def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003141 (MOVLPDrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003142def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003143 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003144def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003145 (MOVLPDrm VR128:$src1, addr:$src2)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003146}
Evan Cheng64e97692006-04-24 21:58:20 +00003147
Evan Chengcd0baf22008-05-23 21:23:16 +00003148// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003149def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003150 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003151def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003152 (MOVLPDmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003153def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3154 addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003155 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003156def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003157 (MOVLPDmr addr:$src1, VR128:$src2)>;
Evan Chengcd0baf22008-05-23 21:23:16 +00003158
Evan Chengf2ea84a2006-10-09 21:42:15 +00003159let AddedComplexity = 15 in {
Evan Cheng64e97692006-04-24 21:58:20 +00003160// Setting the lowest element in the vector.
Nate Begeman9008ca62009-04-27 18:41:29 +00003161def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003162 (MOVSSrr (v4i32 VR128:$src1),
3163 (EXTRACT_SUBREG (v4i32 VR128:$src2), x86_subreg_ss))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003164def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003165 (MOVSDrr (v2i64 VR128:$src1),
3166 (EXTRACT_SUBREG (v2i64 VR128:$src2), x86_subreg_sd))>;
Evan Chenga7fc6422006-04-24 23:34:56 +00003167
Dan Gohman874cada2010-02-28 00:17:42 +00003168// vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
Nate Begeman9008ca62009-04-27 18:41:29 +00003169def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003170 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3171 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003172def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003173 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3174 Requires<[HasSSE2]>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003175}
Evan Cheng9e062ed2006-05-03 20:32:03 +00003176
Eli Friedman7e2242b2009-06-19 07:00:55 +00003177// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3178// fall back to this for SSE1)
3179def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003180 (SHUFPSrri VR128:$src2, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003181 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Eli Friedman7e2242b2009-06-19 07:00:55 +00003182
Evan Chenga7fc6422006-04-24 23:34:56 +00003183// Set lowest element and zero upper elements.
Evan Cheng7a831ce2007-12-15 03:00:47 +00003184let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00003185def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng7a831ce2007-12-15 03:00:47 +00003186 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengd880b972008-05-09 21:53:03 +00003187def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengfd17f422008-05-08 22:35:02 +00003188 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengcdfc3c82006-04-17 22:45:49 +00003189
Evan Cheng2c3ae372006-04-12 21:21:57 +00003190// Some special case pandn patterns.
3191def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3192 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003193 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003194def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3195 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003196 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003197def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3198 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003199 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003200
Evan Cheng2c3ae372006-04-12 21:21:57 +00003201def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003202 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003203 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003204def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003205 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003206 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003207def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003208 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003209 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng206ee9d2006-07-07 08:33:52 +00003210
Nate Begemanb348d182007-11-17 03:58:34 +00003211// vector -> vector casts
3212def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3213 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3214def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3215 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedmand0c0fae2008-09-05 23:07:03 +00003216def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3217 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3218def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3219 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb348d182007-11-17 03:58:34 +00003220
Evan Chengb4162fd2007-07-20 00:27:43 +00003221// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohmand3006222007-07-27 17:16:43 +00003222def : Pat<(alignedloadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003223 (MOVAPSrm addr:$src)>;
Dan Gohmand3006222007-07-27 17:16:43 +00003224def : Pat<(loadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003225 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003226def : Pat<(alignedloadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003227 (MOVAPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003228def : Pat<(loadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003229 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003230
3231def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003232 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003233def : Pat<(alignedstore (v4i32 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 (v8i16 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 (v16i8 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<(store (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003240 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003241def : Pat<(store (v4i32 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 (v8i16 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 (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003246 (MOVUPSmr addr:$dst, VR128:$src)>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003247
Nate Begeman63ec90a2008-02-03 07:18:54 +00003248//===----------------------------------------------------------------------===//
3249// SSE4.1 Instructions
3250//===----------------------------------------------------------------------===//
3251
Dale Johannesene397acc2008-10-10 23:51:03 +00003252multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003253 string OpcodeStr,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003254 Intrinsic V4F32Int,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003255 Intrinsic V2F64Int> {
Nate Begeman63ec90a2008-02-03 07:18:54 +00003256 // Intrinsic operation, reg.
Nate Begeman63ec90a2008-02-03 07:18:54 +00003257 // Vector intrinsic operation, reg
Eric Christopher44b93ff2009-07-31 20:07:27 +00003258 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003259 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003260 !strconcat(OpcodeStr,
3261 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003262 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3263 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003264
3265 // Vector intrinsic operation, mem
Evan Cheng400073d2009-12-18 07:40:29 +00003266 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003267 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003268 !strconcat(OpcodeStr,
3269 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003270 [(set VR128:$dst,
3271 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Cheng400073d2009-12-18 07:40:29 +00003272 TA, OpSize,
Evan Chengb1f49812009-12-22 17:47:23 +00003273 Requires<[HasSSE41]>;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003274
Nate Begeman63ec90a2008-02-03 07:18:54 +00003275 // Vector intrinsic operation, reg
Evan Cheng172b7942008-03-14 07:39:27 +00003276 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003277 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003278 !strconcat(OpcodeStr,
3279 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003280 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3281 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003282
3283 // Vector intrinsic operation, mem
Evan Cheng172b7942008-03-14 07:39:27 +00003284 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003285 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003286 !strconcat(OpcodeStr,
3287 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003288 [(set VR128:$dst,
3289 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003290 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003291}
3292
Dale Johannesene397acc2008-10-10 23:51:03 +00003293let Constraints = "$src1 = $dst" in {
3294multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3295 string OpcodeStr,
3296 Intrinsic F32Int,
3297 Intrinsic F64Int> {
3298 // Intrinsic operation, reg.
3299 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003300 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003301 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3302 !strconcat(OpcodeStr,
3303 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003304 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003305 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3306 OpSize;
3307
3308 // Intrinsic operation, mem.
Eric Christopher44b93ff2009-07-31 20:07:27 +00003309 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3310 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003311 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003312 !strconcat(OpcodeStr,
Dale Johannesene397acc2008-10-10 23:51:03 +00003313 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003314 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003315 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3316 OpSize;
3317
3318 // Intrinsic operation, reg.
3319 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003320 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003321 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3322 !strconcat(OpcodeStr,
3323 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003324 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003325 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3326 OpSize;
3327
3328 // Intrinsic operation, mem.
3329 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003330 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003331 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3332 !strconcat(OpcodeStr,
3333 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003334 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003335 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3336 OpSize;
3337}
3338}
3339
Nate Begeman63ec90a2008-02-03 07:18:54 +00003340// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesene397acc2008-10-10 23:51:03 +00003341defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3342 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3343defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3344 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003345
3346// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3347multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3348 Intrinsic IntId128> {
3349 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3350 (ins VR128:$src),
3351 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3352 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3353 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3354 (ins i128mem:$src),
3355 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3356 [(set VR128:$dst,
3357 (IntId128
3358 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3359}
3360
3361defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3362 int_x86_sse41_phminposuw>;
3363
3364/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003365let Constraints = "$src1 = $dst" in {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003366 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3367 Intrinsic IntId128, bit Commutable = 0> {
Nate Begemanfea2be52008-02-09 23:46:37 +00003368 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3369 (ins VR128:$src1, VR128:$src2),
3370 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3371 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3372 OpSize {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003373 let isCommutable = Commutable;
3374 }
Nate Begemanfea2be52008-02-09 23:46:37 +00003375 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3376 (ins VR128:$src1, i128mem:$src2),
3377 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3378 [(set VR128:$dst,
3379 (IntId128 VR128:$src1,
3380 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003381 }
3382}
3383
3384defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3385 int_x86_sse41_pcmpeqq, 1>;
3386defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3387 int_x86_sse41_packusdw, 0>;
3388defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3389 int_x86_sse41_pminsb, 1>;
3390defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3391 int_x86_sse41_pminsd, 1>;
3392defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3393 int_x86_sse41_pminud, 1>;
3394defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3395 int_x86_sse41_pminuw, 1>;
3396defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3397 int_x86_sse41_pmaxsb, 1>;
3398defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3399 int_x86_sse41_pmaxsd, 1>;
3400defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3401 int_x86_sse41_pmaxud, 1>;
3402defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3403 int_x86_sse41_pmaxuw, 1>;
Nate Begeman204e84e2008-02-04 06:00:24 +00003404
Mon P Wangaf9b9522008-12-18 21:42:19 +00003405defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3406
Nate Begeman30a0de92008-07-17 16:51:19 +00003407def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3408 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3409def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3410 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3411
Nate Begeman1426d522008-02-09 01:38:08 +00003412/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003413let Constraints = "$src1 = $dst" in {
Dan Gohman0b924dc2008-05-23 17:49:40 +00003414 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3415 SDNode OpNode, Intrinsic IntId128,
3416 bit Commutable = 0> {
Nate Begeman1426d522008-02-09 01:38:08 +00003417 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3418 (ins VR128:$src1, VR128:$src2),
3419 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman0b924dc2008-05-23 17:49:40 +00003420 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3421 VR128:$src2))]>, OpSize {
Nate Begeman1426d522008-02-09 01:38:08 +00003422 let isCommutable = Commutable;
3423 }
3424 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3425 (ins VR128:$src1, VR128:$src2),
3426 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3427 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3428 OpSize {
3429 let isCommutable = Commutable;
3430 }
3431 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3432 (ins VR128:$src1, i128mem:$src2),
3433 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3434 [(set VR128:$dst,
Chris Lattner1a7d0872010-02-18 06:33:42 +00003435 (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003436 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3437 (ins VR128:$src1, i128mem:$src2),
3438 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3439 [(set VR128:$dst,
Evan Chengb1938262008-05-23 00:37:07 +00003440 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman1426d522008-02-09 01:38:08 +00003441 OpSize;
3442 }
3443}
Dan Gohman0b924dc2008-05-23 17:49:40 +00003444defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman1426d522008-02-09 01:38:08 +00003445 int_x86_sse41_pmulld, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003446
Evan Cheng172b7942008-03-14 07:39:27 +00003447/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Chenge9083d62008-03-05 08:19:16 +00003448let Constraints = "$src1 = $dst" in {
Nate Begeman204e84e2008-02-04 06:00:24 +00003449 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3450 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng172b7942008-03-14 07:39:27 +00003451 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003452 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003453 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003454 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003455 [(set VR128:$dst,
Nate Begemanfea2be52008-02-09 23:46:37 +00003456 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3457 OpSize {
Nate Begeman204e84e2008-02-04 06:00:24 +00003458 let isCommutable = Commutable;
3459 }
Evan Cheng172b7942008-03-14 07:39:27 +00003460 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003461 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3462 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003463 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begemanfea2be52008-02-09 23:46:37 +00003464 [(set VR128:$dst,
3465 (IntId128 VR128:$src1,
3466 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3467 OpSize;
Nate Begeman204e84e2008-02-04 06:00:24 +00003468 }
3469}
3470
3471defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3472 int_x86_sse41_blendps, 0>;
3473defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3474 int_x86_sse41_blendpd, 0>;
3475defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3476 int_x86_sse41_pblendw, 0>;
3477defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3478 int_x86_sse41_dpps, 1>;
3479defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3480 int_x86_sse41_dppd, 1>;
3481defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng35b9a772008-06-16 20:25:59 +00003482 int_x86_sse41_mpsadbw, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003483
Nate Begemanfea2be52008-02-09 23:46:37 +00003484
Evan Cheng172b7942008-03-14 07:39:27 +00003485/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003486let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanab5d56c2008-02-10 18:47:57 +00003487 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3488 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3489 (ins VR128:$src1, VR128:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003490 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003491 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3492 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3493 OpSize;
3494
3495 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3496 (ins VR128:$src1, i128mem:$src2),
3497 !strconcat(OpcodeStr,
3498 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3499 [(set VR128:$dst,
3500 (IntId VR128:$src1,
3501 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3502 }
3503}
3504
3505defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3506defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3507defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3508
3509
Nate Begemanfea2be52008-02-09 23:46:37 +00003510multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3511 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3512 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3513 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3514
3515 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3516 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003517 [(set VR128:$dst,
3518 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3519 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003520}
3521
3522defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3523defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3524defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3525defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3526defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3527defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3528
Evan Chengca57f782008-09-24 23:27:55 +00003529// Common patterns involving scalar load.
3530def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3531 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3532def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3533 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3534
3535def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3536 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3537def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3538 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3539
3540def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3541 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3542def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3543 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3544
3545def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3546 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3547def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3548 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3549
3550def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3551 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3552def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3553 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3554
3555def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3556 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3557def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3558 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3559
3560
Nate Begemanfea2be52008-02-09 23:46:37 +00003561multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3562 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3563 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3564 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3565
3566 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3567 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003568 [(set VR128:$dst,
3569 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3570 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003571}
3572
3573defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3574defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3575defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3576defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3577
Evan Chengca57f782008-09-24 23:27:55 +00003578// Common patterns involving scalar load
3579def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003580 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003581def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003582 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003583
3584def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003585 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003586def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003587 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003588
3589
Nate Begemanfea2be52008-02-09 23:46:37 +00003590multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3591 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3592 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3593 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3594
Evan Chengca57f782008-09-24 23:27:55 +00003595 // Expecting a i16 load any extended to i32 value.
Nate Begemanfea2be52008-02-09 23:46:37 +00003596 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3597 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003598 [(set VR128:$dst, (IntId (bitconvert
3599 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3600 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003601}
3602
3603defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman9d47b8d2009-06-06 05:55:37 +00003604defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begemanfea2be52008-02-09 23:46:37 +00003605
Evan Chengca57f782008-09-24 23:27:55 +00003606// Common patterns involving scalar load
3607def : Pat<(int_x86_sse41_pmovsxbq
3608 (bitconvert (v4i32 (X86vzmovl
3609 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003610 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003611
3612def : Pat<(int_x86_sse41_pmovzxbq
3613 (bitconvert (v4i32 (X86vzmovl
3614 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003615 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003616
Nate Begemanfea2be52008-02-09 23:46:37 +00003617
Nate Begeman14d12ca2008-02-11 04:19:36 +00003618/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3619multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003620 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003621 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003622 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003623 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003624 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3625 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003626 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003627 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003628 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003629 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003630 []>, OpSize;
3631// FIXME:
3632// There's an AssertZext in the way of writing the store pattern
3633// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begemanfea2be52008-02-09 23:46:37 +00003634}
3635
Nate Begeman14d12ca2008-02-11 04:19:36 +00003636defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003637
Nate Begeman14d12ca2008-02-11 04:19:36 +00003638
3639/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3640multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003641 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003642 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003643 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003644 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3645 []>, OpSize;
3646// FIXME:
3647// There's an AssertZext in the way of writing the store pattern
3648// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3649}
3650
3651defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3652
3653
3654/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3655multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003656 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003657 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003658 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003659 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3660 [(set GR32:$dst,
3661 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003662 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003663 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003664 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003665 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3666 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3667 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003668}
3669
Nate Begeman14d12ca2008-02-11 04:19:36 +00003670defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman1426d522008-02-09 01:38:08 +00003671
Nate Begeman14d12ca2008-02-11 04:19:36 +00003672
Evan Cheng62a3f152008-03-24 21:52:23 +00003673/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3674/// destination
Nate Begeman14d12ca2008-02-11 04:19:36 +00003675multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003676 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003677 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003678 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003679 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman171c11e2008-04-16 02:32:24 +00003680 [(set GR32:$dst,
3681 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng62a3f152008-03-24 21:52:23 +00003682 OpSize;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003683 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003684 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003685 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003686 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng62a3f152008-03-24 21:52:23 +00003687 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begemanfea2be52008-02-09 23:46:37 +00003688 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003689}
3690
Nate Begeman14d12ca2008-02-11 04:19:36 +00003691defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003692
Dan Gohmand9ced092008-08-08 18:30:21 +00003693// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3694def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3695 imm:$src2))),
3696 addr:$dst),
3697 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3698 Requires<[HasSSE41]>;
3699
Evan Chenge9083d62008-03-05 08:19:16 +00003700let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003701 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003702 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003703 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003704 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003705 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003706 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003707 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003708 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003709 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3710 !strconcat(OpcodeStr,
3711 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003712 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003713 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3714 imm:$src3))]>, OpSize;
3715 }
3716}
3717
3718defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3719
Evan Chenge9083d62008-03-05 08:19:16 +00003720let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003721 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003722 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003723 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003724 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003725 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003726 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003727 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3728 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003729 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003730 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3731 !strconcat(OpcodeStr,
3732 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003733 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003734 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3735 imm:$src3)))]>, OpSize;
3736 }
3737}
3738
3739defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3740
Eric Christopher1e5cdea2009-07-23 02:22:41 +00003741// insertps has a few different modes, there's the first two here below which
3742// are optimized inserts that won't zero arbitrary elements in the destination
3743// vector. The next one matches the intrinsic and could zero arbitrary elements
3744// in the target vector.
Evan Chenge9083d62008-03-05 08:19:16 +00003745let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003746 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherfbd66872009-07-24 00:33:09 +00003747 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3748 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003749 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003750 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003751 [(set VR128:$dst,
3752 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003753 OpSize;
Eric Christopherfbd66872009-07-24 00:33:09 +00003754 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003755 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3756 !strconcat(OpcodeStr,
3757 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003758 [(set VR128:$dst,
Eric Christopherfbd66872009-07-24 00:33:09 +00003759 (X86insrtps VR128:$src1,
3760 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003761 imm:$src3))]>, OpSize;
3762 }
3763}
3764
Evan Cheng7aae8762008-03-26 08:11:49 +00003765defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003766
Eric Christopherfbd66872009-07-24 00:33:09 +00003767def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3768 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3769
Eric Christopher71c67532009-07-29 00:28:05 +00003770// ptest instruction we'll lower to this in X86ISelLowering primarily from
3771// the intel intrinsic that corresponds to this.
Nate Begemanbc4efb82008-03-16 21:14:46 +00003772let Defs = [EFLAGS] in {
3773def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003774 "ptest \t{$src2, $src1|$src1, $src2}",
3775 [(X86ptest VR128:$src1, VR128:$src2),
3776 (implicit EFLAGS)]>, OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003777def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003778 "ptest \t{$src2, $src1|$src1, $src2}",
3779 [(X86ptest VR128:$src1, (load addr:$src2)),
3780 (implicit EFLAGS)]>, OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003781}
3782
3783def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3784 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderby40fe18f2010-02-10 00:10:31 +00003785 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3786 OpSize;
Nate Begeman30a0de92008-07-17 16:51:19 +00003787
Eric Christopherb120ab42009-08-18 22:50:32 +00003788
3789//===----------------------------------------------------------------------===//
3790// SSE4.2 Instructions
3791//===----------------------------------------------------------------------===//
3792
Nate Begeman30a0de92008-07-17 16:51:19 +00003793/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3794let Constraints = "$src1 = $dst" in {
3795 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3796 Intrinsic IntId128, bit Commutable = 0> {
3797 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3798 (ins VR128:$src1, VR128:$src2),
3799 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3800 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3801 OpSize {
3802 let isCommutable = Commutable;
3803 }
3804 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3805 (ins VR128:$src1, i128mem:$src2),
3806 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3807 [(set VR128:$dst,
3808 (IntId128 VR128:$src1,
3809 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3810 }
3811}
3812
Nate Begemane99b2552008-07-17 17:04:58 +00003813defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman30a0de92008-07-17 16:51:19 +00003814
3815def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3816 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3817def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3818 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003819
3820// crc intrinsic instruction
3821// This set of instructions are only rm, the only difference is the size
3822// of r and m.
3823let Constraints = "$src1 = $dst" in {
Eric Christopher027c2b12009-08-10 21:48:58 +00003824 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003825 (ins GR32:$src1, i8mem:$src2),
3826 "crc32 \t{$src2, $src1|$src1, $src2}",
3827 [(set GR32:$dst,
3828 (int_x86_sse42_crc32_8 GR32:$src1,
3829 (load addr:$src2)))]>, OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003830 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003831 (ins GR32:$src1, GR8:$src2),
3832 "crc32 \t{$src2, $src1|$src1, $src2}",
3833 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003834 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003835 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003836 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003837 (ins GR32:$src1, i16mem:$src2),
3838 "crc32 \t{$src2, $src1|$src1, $src2}",
3839 [(set GR32:$dst,
3840 (int_x86_sse42_crc32_16 GR32:$src1,
3841 (load addr:$src2)))]>,
3842 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003843 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003844 (ins GR32:$src1, GR16:$src2),
3845 "crc32 \t{$src2, $src1|$src1, $src2}",
3846 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003847 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003848 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003849 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003850 (ins GR32:$src1, i32mem:$src2),
3851 "crc32 \t{$src2, $src1|$src1, $src2}",
3852 [(set GR32:$dst,
3853 (int_x86_sse42_crc32_32 GR32:$src1,
3854 (load addr:$src2)))]>, OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003855 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003856 (ins GR32:$src1, GR32:$src2),
3857 "crc32 \t{$src2, $src1|$src1, $src2}",
3858 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003859 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003860 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003861 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003862 (ins GR64:$src1, i64mem:$src2),
3863 "crc32 \t{$src2, $src1|$src1, $src2}",
3864 [(set GR64:$dst,
3865 (int_x86_sse42_crc32_64 GR64:$src1,
3866 (load addr:$src2)))]>,
3867 OpSize, REX_W;
Eric Christopher027c2b12009-08-10 21:48:58 +00003868 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003869 (ins GR64:$src1, GR64:$src2),
3870 "crc32 \t{$src2, $src1|$src1, $src2}",
3871 [(set GR64:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003872 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003873 OpSize, REX_W;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003874}
Eric Christopherb120ab42009-08-18 22:50:32 +00003875
3876// String/text processing instructions.
Dan Gohman533297b2009-10-29 18:10:34 +00003877let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003878def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003879 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3880 "#PCMPISTRM128rr PSEUDO!",
3881 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3882 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003883def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003884 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3885 "#PCMPISTRM128rm PSEUDO!",
3886 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3887 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003888}
3889
3890let Defs = [XMM0, EFLAGS] in {
3891def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003892 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3893 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003894def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003895 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3896 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003897}
3898
Sean Callanan108934c2009-12-18 00:01:26 +00003899let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003900def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003901 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3902 "#PCMPESTRM128rr PSEUDO!",
3903 [(set VR128:$dst,
3904 (int_x86_sse42_pcmpestrm128
3905 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3906
Eric Christopherb120ab42009-08-18 22:50:32 +00003907def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003908 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3909 "#PCMPESTRM128rm PSEUDO!",
3910 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3911 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3912 OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003913}
3914
3915let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callanan47234e62009-08-20 18:24:27 +00003916def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003917 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3918 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callanan47234e62009-08-20 18:24:27 +00003919def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003920 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3921 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003922}
3923
3924let Defs = [ECX, EFLAGS] in {
3925 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan108934c2009-12-18 00:01:26 +00003926 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3927 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3928 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3929 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3930 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003931 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003932 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3933 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3934 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3935 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003936 }
3937}
3938
3939defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3940defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3941defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3942defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3943defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3944defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3945
3946let Defs = [ECX, EFLAGS] in {
3947let Uses = [EAX, EDX] in {
3948 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3949 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003950 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3951 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3952 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3953 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003954 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003955 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3956 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3957 [(set ECX,
3958 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
3959 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003960 }
3961}
3962}
3963
3964defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3965defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3966defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3967defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3968defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3969defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;