blob: 5309ce50c9a3c1878c2a71e9f035d3ae03e8a68f [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Eric Christopher44b93ff2009-07-31 20:07:27 +00002//
Evan Chengffcb95b2006-02-21 19:13:53 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Eric Christopher44b93ff2009-07-31 20:07:27 +00007//
Evan Chengffcb95b2006-02-21 19:13:53 +00008//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 SSE instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Chris Lattner3a7cd952006-10-07 21:55:32 +000016
Evan Cheng4e4c71e2006-02-21 20:00:20 +000017//===----------------------------------------------------------------------===//
Evan Cheng2246f842006-03-18 01:23:20 +000018// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
Evan Cheng68c47cb2007-01-05 07:55:56 +000021def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
Nate Begeman30a0de92008-07-17 16:51:19 +000023def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000025
Evan Cheng8ca29322006-11-10 21:43:37 +000026def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
Evan Cheng6be2c582006-04-05 23:38:46 +000028def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
Evan Chengb9df0ca2006-03-22 02:53:00 +000029 [SDNPCommutative, SDNPAssociative]>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000030def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
Evan Cheng6be2c582006-04-05 23:38:46 +000032def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
Evan Chengb9df0ca2006-03-22 02:53:00 +000033 [SDNPCommutative, SDNPAssociative]>;
Dan Gohman20382522007-07-10 00:05:58 +000034def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
Evan Cheng68c47cb2007-01-05 07:55:56 +000036def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengfef922a2007-10-01 18:12:48 +000037def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Chenge5f62042007-09-29 00:00:36 +000038def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000039def X86pshufb : SDNode<"X86ISD::PSHUFB",
Nate Begemanb9a47b82009-02-23 08:49:38 +000040 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
41 SDTCisSameAs<0,2>]>>;
Nate Begeman14d12ca2008-02-11 04:19:36 +000042def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000046def X86pinsrb : SDNode<"X86ISD::PINSRB",
Nate Begeman14d12ca2008-02-11 04:19:36 +000047 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000049def X86pinsrw : SDNode<"X86ISD::PINSRW",
Nate Begeman14d12ca2008-02-11 04:19:36 +000050 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher44b93ff2009-07-31 20:07:27 +000052def X86insrtps : SDNode<"X86ISD::INSERTPS",
Nate Begeman14d12ca2008-02-11 04:19:36 +000053 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
Eric Christopherfbd66872009-07-24 00:33:09 +000054 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
Evan Chengd880b972008-05-09 21:53:03 +000055def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
Evan Chengf26ffe92008-05-29 08:22:04 +000059def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
Nate Begeman30a0de92008-07-17 16:51:19 +000061def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
Evan Chengc60bd972006-03-25 09:37:23 +000071
Chris Lattnerd486d772010-03-28 05:07:17 +000072def SDTX86CmpPTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>,
73 SDTCisVT<1, v4f32>,
74 SDTCisVT<2, v4f32>]>;
Eric Christopher71c67532009-07-29 00:28:05 +000075def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
76
Evan Cheng2246f842006-03-18 01:23:20 +000077//===----------------------------------------------------------------------===//
Chris Lattner3a7cd952006-10-07 21:55:32 +000078// SSE Complex Patterns
79//===----------------------------------------------------------------------===//
80
81// These are 'extloads' from a scalar to the low element of a vector, zeroing
82// the top elements. These are used for the SSE 'ss' and 'sd' instruction
83// forms.
Rafael Espindola094fad32009-04-08 21:14:34 +000084def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000085 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindola094fad32009-04-08 21:14:34 +000086def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000087 [SDNPHasChain, SDNPMayLoad]>;
Chris Lattner3a7cd952006-10-07 21:55:32 +000088
89def ssmem : Operand<v4f32> {
90 let PrintMethod = "printf32mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000091 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000092 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000093}
94def sdmem : Operand<v2f64> {
95 let PrintMethod = "printf64mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000096 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000097 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000098}
99
100//===----------------------------------------------------------------------===//
Evan Cheng06a8aa12006-03-17 19:55:52 +0000101// SSE pattern fragments
102//===----------------------------------------------------------------------===//
103
Evan Cheng2246f842006-03-18 01:23:20 +0000104def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
105def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
Dan Gohman01976302007-06-25 15:19:03 +0000106def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
Evan Cheng24dc1f52006-03-23 07:44:07 +0000107def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000108
Dan Gohmand3006222007-07-27 17:16:43 +0000109// Like 'store', but always requires vector alignment.
Dan Gohman4106f372007-07-18 20:23:34 +0000110def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000111 (store node:$val, node:$ptr), [{
112 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000113}]>;
114
Dan Gohmand3006222007-07-27 17:16:43 +0000115// Like 'load', but always requires vector alignment.
Dan Gohman33586292008-10-15 06:50:19 +0000116def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
117 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000118}]>;
119
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000120def alignedloadfsf32 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000121 (f32 (alignedload node:$ptr))>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000122def alignedloadfsf64 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000123 (f64 (alignedload node:$ptr))>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000124def alignedloadv4f32 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000125 (v4f32 (alignedload node:$ptr))>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000126def alignedloadv2f64 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000127 (v2f64 (alignedload node:$ptr))>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000128def alignedloadv4i32 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000129 (v4i32 (alignedload node:$ptr))>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000130def alignedloadv2i64 : PatFrag<(ops node:$ptr),
Sean Callanan108934c2009-12-18 00:01:26 +0000131 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000132
133// Like 'load', but uses special alignment checks suitable for use in
134// memory operands in most SSE instructions, which are required to
David Greene95eb2ee2010-01-11 16:29:42 +0000135// be naturally aligned on some targets but not on others. If the subtarget
136// allows unaligned accesses, match any load, though this may require
137// setting a feature bit in the processor (on startup, for example).
138// Opteron 10h and later implement such a feature.
Dan Gohman33586292008-10-15 06:50:19 +0000139def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
David Greene95eb2ee2010-01-11 16:29:42 +0000140 return Subtarget->hasVectorUAMem()
141 || cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000142}]>;
143
Dan Gohmand3006222007-07-27 17:16:43 +0000144def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
145def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000146def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
147def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
148def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
149def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begemanfea2be52008-02-09 23:46:37 +0000150def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000151
Bill Wendling01284b42007-08-11 09:52:53 +0000152// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
153// 16-byte boundary.
Nate Begemanfea2be52008-02-09 23:46:37 +0000154// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohmana7250dd2008-10-16 00:03:00 +0000155def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman33586292008-10-15 06:50:19 +0000156 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling01284b42007-08-11 09:52:53 +0000157}]>;
158
159def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling01284b42007-08-11 09:52:53 +0000160def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
161def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
162def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
163
David Greene8939b0d2010-02-16 20:50:18 +0000164// MOVNT Support
165// Like 'store', but requires the non-temporal bit to be set
166def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
167 (st node:$val, node:$ptr), [{
168 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
169 return ST->isNonTemporal();
170 return false;
171}]>;
172
173def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
174 (st node:$val, node:$ptr), [{
175 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
176 return ST->isNonTemporal() && !ST->isTruncatingStore() &&
177 ST->getAddressingMode() == ISD::UNINDEXED &&
178 ST->getAlignment() >= 16;
179 return false;
180}]>;
181
182def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
183 (st node:$val, node:$ptr), [{
184 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
185 return ST->isNonTemporal() &&
186 ST->getAlignment() < 16;
187 return false;
188}]>;
189
Evan Cheng1b32f222006-03-30 07:33:32 +0000190def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
191def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
Evan Cheng506d3df2006-03-29 23:07:14 +0000192def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
193def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
Evan Cheng5aa97b22006-03-29 18:47:40 +0000194def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
195def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
196
Evan Chengca57f782008-09-24 23:27:55 +0000197def vzmovl_v2i64 : PatFrag<(ops node:$src),
198 (bitconvert (v2i64 (X86vzmovl
199 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
200def vzmovl_v4i32 : PatFrag<(ops node:$src),
201 (bitconvert (v4i32 (X86vzmovl
202 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
203
204def vzload_v2i64 : PatFrag<(ops node:$src),
205 (bitconvert (v2i64 (X86vzload node:$src)))>;
206
207
Evan Cheng386031a2006-03-24 07:29:27 +0000208def fp32imm0 : PatLeaf<(f32 fpimm), [{
209 return N->isExactlyValue(+0.0);
210}]>;
211
Evan Cheng89321162009-10-28 06:30:34 +0000212// BYTE_imm - Transform bit immediates into byte immediates.
213def BYTE_imm : SDNodeXForm<imm, [{
Evan Chengff65e382006-04-04 21:49:39 +0000214 // Transformation function: imm >> 3
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000215 return getI32Imm(N->getZExtValue() >> 3);
Evan Chengff65e382006-04-04 21:49:39 +0000216}]>;
217
Evan Cheng63d33002006-03-22 08:01:21 +0000218// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
219// SHUFP* etc. imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000220def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng63d33002006-03-22 08:01:21 +0000221 return getI8Imm(X86::getShuffleSHUFImmediate(N));
Evan Chengb9df0ca2006-03-22 02:53:00 +0000222}]>;
223
Eric Christopher44b93ff2009-07-31 20:07:27 +0000224// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000225// PSHUFHW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000226def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000227 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
228}]>;
229
Eric Christopher44b93ff2009-07-31 20:07:27 +0000230// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000231// PSHUFLW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000232def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000233 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
234}]>;
235
Nate Begemana09008b2009-10-19 02:17:23 +0000236// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
237// a PALIGNR imm.
238def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
239 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
240}]>;
241
Nate Begeman9008ca62009-04-27 18:41:29 +0000242def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
243 (vector_shuffle node:$lhs, node:$rhs), [{
244 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
245 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
246}]>;
247
248def movddup : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
251}]>;
252
253def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
254 (vector_shuffle node:$lhs, node:$rhs), [{
255 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
256}]>;
257
258def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
259 (vector_shuffle node:$lhs, node:$rhs), [{
260 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
261}]>;
262
Nate Begeman0b10b912009-11-07 23:17:15 +0000263def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
264 (vector_shuffle node:$lhs, node:$rhs), [{
265 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman9008ca62009-04-27 18:41:29 +0000266}]>;
267
268def movlp : PatFrag<(ops node:$lhs, node:$rhs),
269 (vector_shuffle node:$lhs, node:$rhs), [{
270 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
271}]>;
272
273def movl : PatFrag<(ops node:$lhs, node:$rhs),
274 (vector_shuffle node:$lhs, node:$rhs), [{
275 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
276}]>;
277
278def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
279 (vector_shuffle node:$lhs, node:$rhs), [{
280 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
281}]>;
282
283def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
284 (vector_shuffle node:$lhs, node:$rhs), [{
285 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
286}]>;
287
288def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
289 (vector_shuffle node:$lhs, node:$rhs), [{
290 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
291}]>;
292
293def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
294 (vector_shuffle node:$lhs, node:$rhs), [{
295 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
296}]>;
297
298def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
299 (vector_shuffle node:$lhs, node:$rhs), [{
300 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
301}]>;
302
303def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
304 (vector_shuffle node:$lhs, node:$rhs), [{
305 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
306}]>;
307
308def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
309 (vector_shuffle node:$lhs, node:$rhs), [{
310 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng691c9232006-03-29 19:02:40 +0000311}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000312
Nate Begeman9008ca62009-04-27 18:41:29 +0000313def shufp : PatFrag<(ops node:$lhs, node:$rhs),
314 (vector_shuffle node:$lhs, node:$rhs), [{
315 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng14aed5e2006-03-24 01:18:28 +0000316}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000317
Nate Begeman9008ca62009-04-27 18:41:29 +0000318def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
319 (vector_shuffle node:$lhs, node:$rhs), [{
320 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000321}], SHUFFLE_get_pshufhw_imm>;
322
Nate Begeman9008ca62009-04-27 18:41:29 +0000323def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
324 (vector_shuffle node:$lhs, node:$rhs), [{
325 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000326}], SHUFFLE_get_pshuflw_imm>;
327
Nate Begemana09008b2009-10-19 02:17:23 +0000328def palign : PatFrag<(ops node:$lhs, node:$rhs),
329 (vector_shuffle node:$lhs, node:$rhs), [{
330 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
331}], SHUFFLE_get_palign_imm>;
332
Evan Cheng06a8aa12006-03-17 19:55:52 +0000333//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000334// SSE scalar FP Instructions
335//===----------------------------------------------------------------------===//
336
Dan Gohman533297b2009-10-29 18:10:34 +0000337// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
338// instruction selection into a branch sequence.
339let Uses = [EFLAGS], usesCustomInserter = 1 in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000340 def CMOV_FR32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000341 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000342 "#CMOV_FR32 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000343 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
344 EFLAGS))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000345 def CMOV_FR64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000346 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000347 "#CMOV_FR64 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000348 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
349 EFLAGS))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000350 def CMOV_V4F32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000351 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000352 "#CMOV_V4F32 PSEUDO!",
353 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000354 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
355 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000356 def CMOV_V2F64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000357 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000358 "#CMOV_V2F64 PSEUDO!",
359 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000360 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
361 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000362 def CMOV_V2I64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000363 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000364 "#CMOV_V2I64 PSEUDO!",
365 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000366 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng0488db92007-09-25 01:57:46 +0000367 EFLAGS)))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000368}
369
Bill Wendlingddd35322007-05-02 23:11:52 +0000370//===----------------------------------------------------------------------===//
371// SSE1 Instructions
372//===----------------------------------------------------------------------===//
373
Dan Gohman874cada2010-02-28 00:17:42 +0000374// Move Instructions. Register-to-register movss is not used for FR32
375// register copies because it's a partial register update; FsMOVAPSrr is
376// used instead. Register-to-register movss is not modeled as an INSERT_SUBREG
377// because INSERT_SUBREG requires that the insert be implementable in terms of
378// a copy, and just mentioned, we don't use movss for copies.
379let Constraints = "$src1 = $dst" in
380def MOVSSrr : SSI<0x10, MRMSrcReg,
381 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
382 "movss\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +0000383 [(set (v4f32 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +0000384 (movl VR128:$src1, (scalar_to_vector FR32:$src2)))]>;
385
386// Extract the low 32-bit value from one vector and insert it into another.
387let AddedComplexity = 15 in
388def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +0000389 (MOVSSrr (v4f32 VR128:$src1),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000390 (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_ss))>;
Dan Gohman874cada2010-02-28 00:17:42 +0000391
392// Implicitly promote a 32-bit scalar to a vector.
393def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000394 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, sub_ss)>;
Dan Gohman874cada2010-02-28 00:17:42 +0000395
396// Loading from memory automatically zeroing upper bits.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000397let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000398def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000399 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000400 [(set FR32:$dst, (loadf32 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +0000401
402// MOVSSrm zeros the high parts of the register; represent this
403// with SUBREG_TO_REG.
404let AddedComplexity = 20 in {
405def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000406 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
Dan Gohman874cada2010-02-28 00:17:42 +0000407def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000408 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
Dan Gohman874cada2010-02-28 00:17:42 +0000409def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000410 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
Dan Gohman874cada2010-02-28 00:17:42 +0000411}
412
413// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +0000414def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000415 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000416 [(store FR32:$src, addr:$dst)]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000417
Dan Gohman874cada2010-02-28 00:17:42 +0000418// Extract and store.
419def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
420 addr:$dst),
421 (MOVSSmr addr:$dst,
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +0000422 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
Dan Gohman874cada2010-02-28 00:17:42 +0000423
Evan Chengc46349d2006-03-28 23:51:43 +0000424// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +0000425def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000426 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000427 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000428def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000429 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000430 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000431def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000432 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000433 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000434def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000435 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000436 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
Evan Chengc46349d2006-03-28 23:51:43 +0000437
Evan Chengd2a6d542006-04-12 23:42:44 +0000438// Match intrinsics which expect XMM operand(s).
Sean Callanan108934c2009-12-18 00:01:26 +0000439def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
440 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
441def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
442 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
443
Evan Cheng64d80e32007-07-19 01:14:50 +0000444def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000445 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000446 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000447def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000448 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000449 [(set GR32:$dst, (int_x86_sse_cvtss2si
450 (load addr:$src)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000451
Dan Gohmand9c2af52010-05-26 18:03:53 +0000452// Match intrinsics which expect MM and XMM operand(s).
Dale Johannesenc7842082007-10-30 22:15:38 +0000453def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
454 "cvtps2pi\t{$src, $dst|$dst, $src}",
455 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
456def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
457 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000458 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000459 (load addr:$src)))]>;
460def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
461 "cvttps2pi\t{$src, $dst|$dst, $src}",
462 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
463def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
464 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000465 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000466 (load addr:$src)))]>;
Evan Chenge9083d62008-03-05 08:19:16 +0000467let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000468 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesenc7842082007-10-30 22:15:38 +0000469 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
470 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
471 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
472 VR64:$src2))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000473 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesenc7842082007-10-30 22:15:38 +0000474 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
475 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000476 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesenc7842082007-10-30 22:15:38 +0000477 (load addr:$src2)))]>;
478}
479
Evan Chengd2a6d542006-04-12 23:42:44 +0000480// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +0000481def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000482 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000483 [(set GR32:$dst,
484 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000485def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000486 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000487 [(set GR32:$dst,
488 (int_x86_sse_cvttss2si(load addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +0000489
Evan Chenge9083d62008-03-05 08:19:16 +0000490let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000491 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000492 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000493 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000494 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
495 GR32:$src2))]>;
496 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000497 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000498 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000499 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
500 (loadi32 addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000501}
Evan Chengd03db7a2006-04-12 05:20:24 +0000502
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000503// Comparison instructions
Dan Gohmanb1347092009-01-09 02:27:34 +0000504let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000505 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000506 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000507 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000508let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +0000509 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000510 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000511 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Daniel Dunbar79373682010-05-25 18:40:53 +0000512
513 // Accept explicit immediate argument form instead of comparison code.
514let isAsmParserOnly = 1 in {
515 def CMPSSrr_alt : SSIi8<0xC2, MRMSrcReg,
516 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, i8imm:$src2),
517 "cmpss\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
518let mayLoad = 1 in
519 def CMPSSrm_alt : SSIi8<0xC2, MRMSrcMem,
520 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, i8imm:$src2),
521 "cmpss\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
522}
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000523}
524
Evan Cheng24f2ea32007-09-14 21:48:26 +0000525let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000526def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000527 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000528 [(set EFLAGS, (X86cmp FR32:$src1, FR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000529def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000530 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000531 [(set EFLAGS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000532
Sean Callanan108934c2009-12-18 00:01:26 +0000533def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
534 "comiss\t{$src2, $src1|$src1, $src2}", []>;
535def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
536 "comiss\t{$src2, $src1|$src1, $src2}", []>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000537
Evan Cheng24f2ea32007-09-14 21:48:26 +0000538} // Defs = [EFLAGS]
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000539
Evan Cheng0876aa52006-03-30 06:21:22 +0000540// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +0000541let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000542 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000543 (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +0000544 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000545 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000546 [(set VR128:$dst, (int_x86_sse_cmp_ss
Sean Callanan108934c2009-12-18 00:01:26 +0000547 VR128:$src1,
548 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000549 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Eric Christopher7e2f5aa2010-05-25 17:33:22 +0000550 (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +0000551 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000552 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000553 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
554 (load addr:$src), imm:$cc))]>;
Evan Cheng0876aa52006-03-30 06:21:22 +0000555}
556
Evan Cheng24f2ea32007-09-14 21:48:26 +0000557let Defs = [EFLAGS] in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000558def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000559 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000560 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
561 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000562def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000563 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000564 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
565 (load addr:$src2)))]>;
Evan Cheng0488db92007-09-25 01:57:46 +0000566
Dan Gohmanb1347092009-01-09 02:27:34 +0000567def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000568 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000569 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
570 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000571def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000572 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000573 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
574 (load addr:$src2)))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000575} // Defs = [EFLAGS]
Evan Cheng0876aa52006-03-30 06:21:22 +0000576
Eric Christopher44b93ff2009-07-31 20:07:27 +0000577// Aliases of packed SSE1 instructions for scalar use. These all have names
578// that start with 'Fs'.
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000579
580// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +0000581let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
582 canFoldAsLoad = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +0000583 // FIXME: Set encoding to pseudo!
Chris Lattnerbe1778f2010-02-05 21:34:18 +0000584def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
585 [(set FR32:$dst, fp32imm0)]>,
586 Requires<[HasSSE1]>, TB, OpSize;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000587
Bill Wendlingddd35322007-05-02 23:11:52 +0000588// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
589// disregarded.
Eric Christopher44b93ff2009-07-31 20:07:27 +0000590let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000591def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000592 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000593
Bill Wendlingddd35322007-05-02 23:11:52 +0000594// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
595// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000596let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000597def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000598 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +0000599 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000600
601// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +0000602let Constraints = "$src1 = $dst" in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000603let isCommutable = 1 in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000604 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
605 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000606 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000607 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000608 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
609 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000610 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000611 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000612 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
613 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000614 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000615 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000616}
Bill Wendlingddd35322007-05-02 23:11:52 +0000617
Dan Gohmanb1347092009-01-09 02:27:34 +0000618def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
619 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000620 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000621 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000622 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000623def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
624 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000625 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000626 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000627 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000628def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
629 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000630 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000631 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000632 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000633
Chris Lattnerba7e7562008-01-10 07:59:24 +0000634let neverHasSideEffects = 1 in {
Dan Gohman32791e02007-06-25 15:44:19 +0000635def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000636 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000637 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000638let mayLoad = 1 in
Dan Gohman32791e02007-06-25 15:44:19 +0000639def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000640 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000641 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000642}
Chris Lattnerba7e7562008-01-10 07:59:24 +0000643}
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000644
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000645/// basic_sse12_fp_binop_rm - SSE 1 & 2 binops come in both scalar and
646/// vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000647///
Dan Gohman20382522007-07-10 00:05:58 +0000648/// In addition, we also have a special variant of the scalar form here to
649/// represent the associated intrinsic operation. This form is unlike the
650/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +0000651/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +0000652///
653/// These three forms can each be reg+reg or reg+mem, so there are a total of
654/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +0000655///
Evan Chenge9083d62008-03-05 08:19:16 +0000656let Constraints = "$src1 = $dst" in {
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000657multiclass basic_sse12_fp_binop_rm<bits<8> opc, string OpcodeStr,
658 SDNode OpNode, bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000659 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000660 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000661 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman32791e02007-06-25 15:44:19 +0000662 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000663 let isCommutable = Commutable;
664 }
665
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000666 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
667 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
668 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
669 let isCommutable = Commutable;
670 }
671
Bill Wendlingddd35322007-05-02 23:11:52 +0000672 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000673 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
674 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000675 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000676 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000677
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000678 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
679 (ins FR64:$src1, f64mem:$src2),
680 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
681 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
682
Dan Gohman20382522007-07-10 00:05:58 +0000683 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000684 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
685 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000686 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000687 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
688 let isCommutable = Commutable;
689 }
690
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000691 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
692 (ins VR128:$src1, VR128:$src2),
693 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
694 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
695 let isCommutable = Commutable;
696 }
697
Dan Gohman20382522007-07-10 00:05:58 +0000698 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000699 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
700 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000701 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000702 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000703
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000704 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
705 (ins VR128:$src1, f128mem:$src2),
706 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
707 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
708
Dan Gohman20382522007-07-10 00:05:58 +0000709 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000710 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
711 (ins VR128:$src1, VR128:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000712 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
713 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
714 !strconcat(OpcodeStr, "_ss")) VR128:$src1,
715 VR128:$src2))]>;
716 // int_x86_sse_xxx_ss
717
718 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
719 (ins VR128:$src1, VR128:$src2),
720 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
721 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
722 !strconcat(OpcodeStr, "_sd")) VR128:$src1,
723 VR128:$src2))]>;
724 // int_x86_sse2_xxx_sd
Bill Wendlingddd35322007-05-02 23:11:52 +0000725
Dan Gohman20382522007-07-10 00:05:58 +0000726 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000727 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
728 (ins VR128:$src1, ssmem:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000729 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
730 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
731 !strconcat(OpcodeStr, "_ss")) VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +0000732 sse_load_f32:$src2))]>;
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000733 // int_x86_sse_xxx_ss
734
735 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
736 (ins VR128:$src1, sdmem:$src2),
737 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
738 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
739 !strconcat(OpcodeStr, "_sd")) VR128:$src1,
740 sse_load_f64:$src2))]>;
741 // int_x86_sse2_xxx_sd
Bill Wendlingddd35322007-05-02 23:11:52 +0000742}
743}
744
745// Arithmetic instructions
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000746defm ADD : basic_sse12_fp_binop_rm<0x58, "add", fadd, 1>;
747defm MUL : basic_sse12_fp_binop_rm<0x59, "mul", fmul, 1>;
748defm SUB : basic_sse12_fp_binop_rm<0x5C, "sub", fsub>;
749defm DIV : basic_sse12_fp_binop_rm<0x5E, "div", fdiv>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000750
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000751/// sse12_fp_binop_rm - Other SSE 1 & 2 binops
Dan Gohman20382522007-07-10 00:05:58 +0000752///
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000753/// This multiclass is like basic_sse12_fp_binop_rm, with the addition of
Dan Gohman20382522007-07-10 00:05:58 +0000754/// instructions for a full-vector intrinsic form. Operations that map
755/// onto C operators don't use this form since they just use the plain
756/// vector form instead of having a separate vector intrinsic form.
757///
758/// This provides a total of eight "instructions".
759///
Evan Chenge9083d62008-03-05 08:19:16 +0000760let Constraints = "$src1 = $dst" in {
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000761multiclass sse12_fp_binop_rm<bits<8> opc, string OpcodeStr,
762 SDNode OpNode, bit Commutable = 0> {
Dan Gohman20382522007-07-10 00:05:58 +0000763
764 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000765 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000766 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000767 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
768 let isCommutable = Commutable;
769 }
770
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000771 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
772 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
773 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
774 let isCommutable = Commutable;
775 }
776
Dan Gohman20382522007-07-10 00:05:58 +0000777 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000778 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
779 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000780 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000781 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000782
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000783 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
784 (ins FR64:$src1, f64mem:$src2),
785 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
786 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
787
Dan Gohman20382522007-07-10 00:05:58 +0000788 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000789 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
790 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000791 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000792 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
793 let isCommutable = Commutable;
794 }
795
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000796 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
797 (ins VR128:$src1, VR128:$src2),
798 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
799 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
800 let isCommutable = Commutable;
801 }
802
Dan Gohman20382522007-07-10 00:05:58 +0000803 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000804 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
805 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000806 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000807 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000808
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000809 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
810 (ins VR128:$src1, f128mem:$src2),
811 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
812 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
813
Dan Gohman20382522007-07-10 00:05:58 +0000814 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000815 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
816 (ins VR128:$src1, VR128:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000817 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
818 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
819 !strconcat(OpcodeStr, "_ss")) VR128:$src1,
820 VR128:$src2))]> {
821 // int_x86_sse_xxx_ss
822 let isCommutable = Commutable;
823 }
824
825 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
826 (ins VR128:$src1, VR128:$src2),
827 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
828 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
829 !strconcat(OpcodeStr, "_sd")) VR128:$src1,
830 VR128:$src2))]> {
831 // int_x86_sse2_xxx_sd
Dan Gohman20382522007-07-10 00:05:58 +0000832 let isCommutable = Commutable;
833 }
834
835 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000836 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
837 (ins VR128:$src1, ssmem:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000838 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
839 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
840 !strconcat(OpcodeStr, "_ss")) VR128:$src1,
Dan Gohman20382522007-07-10 00:05:58 +0000841 sse_load_f32:$src2))]>;
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000842 // int_x86_sse_xxx_ss
843
844 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
845 (ins VR128:$src1, sdmem:$src2),
846 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
847 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
848 !strconcat(OpcodeStr, "_sd")) VR128:$src1,
849 sse_load_f64:$src2))]>;
850 // int_x86_sse2_xxx_sd
Dan Gohman20382522007-07-10 00:05:58 +0000851
852 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000853 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
854 (ins VR128:$src1, VR128:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000855 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
856 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
857 !strconcat(OpcodeStr, "_ps")) VR128:$src1,
858 VR128:$src2))]> {
859 // int_x86_sse_xxx_ps
860 let isCommutable = Commutable;
861 }
862
863 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
864 (ins VR128:$src1, VR128:$src2),
865 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
866 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
867 !strconcat(OpcodeStr, "_pd")) VR128:$src1,
868 VR128:$src2))]> {
869 // int_x86_sse2_xxx_pd
Dan Gohman20382522007-07-10 00:05:58 +0000870 let isCommutable = Commutable;
871 }
872
873 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000874 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
875 (ins VR128:$src1, f128mem:$src2),
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000876 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
877 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse_",
878 !strconcat(OpcodeStr, "_ps")) VR128:$src1,
879 (memopv4f32 addr:$src2)))]>;
880 // int_x86_sse_xxx_ps
881
882 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
883 (ins VR128:$src1, f128mem:$src2),
884 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
885 [(set VR128:$dst, (!nameconcat<Intrinsic>("int_x86_sse2_",
886 !strconcat(OpcodeStr, "_pd")) VR128:$src1,
887 (memopv2f64 addr:$src2)))]>;
888 // int_x86_sse2_xxx_pd
Dan Gohman20382522007-07-10 00:05:58 +0000889}
890}
891
Bruno Cardoso Lopesaa02ff12010-05-27 18:17:40 +0000892defm MAX : sse12_fp_binop_rm<0x5F, "max", X86fmax>;
893defm MIN : sse12_fp_binop_rm<0x5D, "min", X86fmin>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000894
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000895//===----------------------------------------------------------------------===//
Evan Cheng9ab1ac52006-04-14 23:32:40 +0000896// SSE packed FP Instructions
Evan Chengc12e6c42006-03-19 09:38:54 +0000897
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000898// Move Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +0000899let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000900def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000901 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000902let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000903def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000904 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000905 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000906
Evan Cheng64d80e32007-07-19 01:14:50 +0000907def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000908 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000909 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000910
Chris Lattnerf77e0372008-01-11 06:59:07 +0000911let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000912def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000913 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000914let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000915def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000916 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000917 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000918def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000919 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000920 [(store (v4f32 VR128:$src), addr:$dst)]>;
921
922// Intrinsic forms of MOVUPS load and store
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000923let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000924def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000925 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000926 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000927def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000928 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000929 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000930
Evan Chenge9083d62008-03-05 08:19:16 +0000931let Constraints = "$src1 = $dst" in {
Dan Gohman32791e02007-06-25 15:44:19 +0000932 let AddedComplexity = 20 in {
933 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000934 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000935 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000936 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000937 (movlp VR128:$src1,
938 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000939 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000940 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000941 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000942 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000943 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +0000944 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000945 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000946} // Constraints = "$src1 = $dst"
Evan Cheng4fcb9222006-03-28 02:43:26 +0000947
Evan Chengb70ea0b2008-05-10 00:59:18 +0000948
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000949def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
Chris Lattner3485b512010-03-08 18:57:56 +0000950 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000951
Evan Cheng64d80e32007-07-19 01:14:50 +0000952def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000953 "movlps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000954 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
Evan Cheng015188f2006-06-15 08:14:54 +0000955 (iPTR 0))), addr:$dst)]>;
Evan Cheng9bbfd4f2006-03-28 07:01:28 +0000956
Evan Cheng664ade72006-04-07 21:20:58 +0000957// v2f64 extract element 1 is always custom lowered to unpack high to low
958// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +0000959def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000960 "movhps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000961 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +0000962 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
963 (undef)), (iPTR 0))), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000964
Evan Chenge9083d62008-03-05 08:19:16 +0000965let Constraints = "$src1 = $dst" in {
Evan Chengb7a75a52008-09-26 23:41:32 +0000966let AddedComplexity = 20 in {
Evan Cheng0af934e2009-05-12 20:17:52 +0000967def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
968 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000969 "movlhps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000970 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000971 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2c0dbd02006-03-24 02:58:06 +0000972
Evan Cheng0af934e2009-05-12 20:17:52 +0000973def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
974 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000975 "movhlps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000976 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000977 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2dadaea2006-04-19 20:37:34 +0000978} // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000979} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +0000980
Nate Begemanec8eee22009-04-29 22:47:44 +0000981let AddedComplexity = 20 in {
Nate Begeman9008ca62009-04-27 18:41:29 +0000982def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000983 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000984def : Pat<(v2i64 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000985 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000986}
Evan Cheng0b457f02008-09-25 20:50:48 +0000987
Bill Wendlingddd35322007-05-02 23:11:52 +0000988
989
Dan Gohman20382522007-07-10 00:05:58 +0000990// Arithmetic
991
992/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000993///
Dan Gohman20382522007-07-10 00:05:58 +0000994/// In addition, we also have a special variant of the scalar form here to
995/// represent the associated intrinsic operation. This form is unlike the
996/// plain scalar form, in that it takes an entire vector (instead of a
997/// scalar) and leaves the top elements undefined.
998///
999/// And, we have a special variant form for a full-vector intrinsic form.
1000///
1001/// These four forms can each have a reg or a mem operand, so there are a
1002/// total of eight "instructions".
1003///
1004multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
1005 SDNode OpNode,
1006 Intrinsic F32Int,
1007 Intrinsic V4F32Int,
1008 bit Commutable = 0> {
1009 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001010 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001011 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001012 [(set FR32:$dst, (OpNode FR32:$src))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +00001013 let isCommutable = Commutable;
1014 }
1015
Dan Gohman20382522007-07-10 00:05:58 +00001016 // Scalar operation, mem.
Evan Cheng400073d2009-12-18 07:40:29 +00001017 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001018 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Cheng400073d2009-12-18 07:40:29 +00001019 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +00001020 Requires<[HasSSE1, OptForSize]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001021
Dan Gohman20382522007-07-10 00:05:58 +00001022 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001023 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001024 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001025 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
1026 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001027 }
1028
Dan Gohman20382522007-07-10 00:05:58 +00001029 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001030 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001031 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001032 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001033
1034 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001035 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001036 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001037 [(set VR128:$dst, (F32Int VR128:$src))]> {
1038 let isCommutable = Commutable;
1039 }
1040
1041 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001042 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001043 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001044 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
1045
1046 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001047 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001048 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001049 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
1050 let isCommutable = Commutable;
1051 }
1052
1053 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001054 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001055 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001056 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001057}
1058
Dan Gohman20382522007-07-10 00:05:58 +00001059// Square root.
1060defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
1061 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
1062
1063// Reciprocal approximations. Note that these typically require refinement
1064// in order to obtain suitable precision.
1065defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
1066 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
1067defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
1068 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
1069
Bill Wendlingddd35322007-05-02 23:11:52 +00001070// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001071let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001072 let isCommutable = 1 in {
1073 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001074 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001075 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001076 [(set VR128:$dst, (v2i64
1077 (and VR128:$src1, VR128:$src2)))]>;
1078 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001079 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001080 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001081 [(set VR128:$dst, (v2i64
1082 (or VR128:$src1, VR128:$src2)))]>;
1083 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001084 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001085 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001086 [(set VR128:$dst, (v2i64
1087 (xor VR128:$src1, VR128:$src2)))]>;
1088 }
1089
1090 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001091 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001092 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +00001093 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
1094 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001095 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001096 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001097 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +00001098 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
1099 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001100 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001101 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001102 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +00001103 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
1104 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001105 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001106 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001107 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001108 [(set VR128:$dst,
1109 (v2i64 (and (xor VR128:$src1,
1110 (bc_v2i64 (v4i32 immAllOnesV))),
1111 VR128:$src2)))]>;
1112 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001113 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001114 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001115 [(set VR128:$dst,
Evan Cheng31d3a652007-07-19 23:34:10 +00001116 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Bill Wendlingddd35322007-05-02 23:11:52 +00001117 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001118 (memopv2i64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001119}
1120
Evan Chenge9083d62008-03-05 08:19:16 +00001121let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001122 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begemanc2616e42008-05-12 20:34:32 +00001123 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1124 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1125 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
1126 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001127 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begemanc2616e42008-05-12 20:34:32 +00001128 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1129 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1130 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001131 (memop addr:$src), imm:$cc))]>;
Daniel Dunbar79373682010-05-25 18:40:53 +00001132
1133 // Accept explicit immediate argument form instead of comparison code.
1134let isAsmParserOnly = 1 in {
1135 def CMPPSrri_alt : PSIi8<0xC2, MRMSrcReg,
1136 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, i8imm:$src2),
1137 "cmpps\t{$src2, $src, $dst|$dst, $src, $src}", []>;
1138 def CMPPSrmi_alt : PSIi8<0xC2, MRMSrcMem,
1139 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, i8imm:$src2),
1140 "cmpps\t{$src2, $src, $dst|$dst, $src, $src}", []>;
1141}
Bill Wendlingddd35322007-05-02 23:11:52 +00001142}
Nate Begeman30a0de92008-07-17 16:51:19 +00001143def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001144 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00001145def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001146 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001147
1148// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001149let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001150 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher44b93ff2009-07-31 20:07:27 +00001151 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001152 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001153 VR128:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001154 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001155 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001156 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001157 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001158 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001159 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001160 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001161 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001162 (v4f32 (shufp:$src3
1163 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001164
1165 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001166 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001167 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001168 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001169 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001170 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001171 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001172 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001173 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001174 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001175 (v4f32 (unpckh VR128:$src1,
1176 (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001177
Eric Christopher44b93ff2009-07-31 20:07:27 +00001178 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001179 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001180 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001181 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001182 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001183 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001184 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001185 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001186 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001187 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001188 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001189} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001190
1191// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00001192def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001193 "movmskps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001194 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Cheng8a0b2da2009-05-28 18:55:28 +00001195def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001196 "movmskpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001197 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1198
Evan Cheng27b7db52008-03-08 00:58:38 +00001199// Prefetch intrinsic.
1200def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1201 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1202def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1203 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1204def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1205 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1206def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1207 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001208
1209// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00001210def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001211 "movntps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001212 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1213
David Greene8939b0d2010-02-16 20:50:18 +00001214let AddedComplexity = 400 in { // Prefer non-temporal versions
1215def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1216 "movntps\t{$src, $dst|$dst, $src}",
1217 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1218
1219def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1220 "movntdq\t{$src, $dst|$dst, $src}",
1221 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
1222
David Greene8939b0d2010-02-16 20:50:18 +00001223def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1224 "movnti\t{$src, $dst|$dst, $src}",
1225 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
1226 TB, Requires<[HasSSE2]>;
1227
1228def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
1229 "movnti\t{$src, $dst|$dst, $src}",
1230 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
1231 TB, Requires<[HasSSE2]>;
1232}
1233
Bill Wendlingddd35322007-05-02 23:11:52 +00001234// Load, store, and memory fence
Dan Gohmanee5673b2010-05-20 01:23:41 +00001235def SFENCE : I<0xAE, MRM_F8, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>,
1236 TB, Requires<[HasSSE1]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001237
1238// MXCSR register
Evan Cheng64d80e32007-07-19 01:14:50 +00001239def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001240 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001241def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001242 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001243
1244// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00001245// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00001246// load of an all-zeros value if folding it would be beneficial.
Chris Lattner28c1d292010-02-05 21:30:49 +00001247// FIXME: Change encoding to pseudo!
Daniel Dunbar7417b762009-08-11 22:17:52 +00001248let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00001249 isCodeGenOnly = 1 in {
1250def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
1251 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
1252def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
1253 [(set VR128:$dst, (v2f64 immAllZerosV))]>;
1254let ExeDomain = SSEPackedInt in
1255def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00001256 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00001257}
Bill Wendlingddd35322007-05-02 23:11:52 +00001258
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00001259def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>;
1260def : Pat<(v8i16 immAllZerosV), (V_SET0PI)>;
1261def : Pat<(v16i8 immAllZerosV), (V_SET0PI)>;
Evan Chengc8e3b142008-03-12 07:02:50 +00001262
Dan Gohman874cada2010-02-28 00:17:42 +00001263def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001264 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001265
Eric Christopher44b93ff2009-07-31 20:07:27 +00001266//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001267// SSE2 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00001268//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001269
Dan Gohman874cada2010-02-28 00:17:42 +00001270// Move Instructions. Register-to-register movsd is not used for FR64
1271// register copies because it's a partial register update; FsMOVAPDrr is
1272// used instead. Register-to-register movsd is not modeled as an INSERT_SUBREG
1273// because INSERT_SUBREG requires that the insert be implementable in terms of
1274// a copy, and just mentioned, we don't use movsd for copies.
1275let Constraints = "$src1 = $dst" in
1276def MOVSDrr : SDI<0x10, MRMSrcReg,
1277 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
1278 "movsd\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +00001279 [(set (v2f64 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +00001280 (movl VR128:$src1, (scalar_to_vector FR64:$src2)))]>;
1281
1282// Extract the low 64-bit value from one vector and insert it into another.
1283let AddedComplexity = 15 in
1284def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +00001285 (MOVSDrr (v2f64 VR128:$src1),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001286 (EXTRACT_SUBREG (v2f64 VR128:$src2), sub_sd))>;
Dan Gohman874cada2010-02-28 00:17:42 +00001287
1288// Implicitly promote a 64-bit scalar to a vector.
1289def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001290 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001291
1292// Loading from memory automatically zeroing upper bits.
1293let canFoldAsLoad = 1, isReMaterializable = 1, AddedComplexity = 20 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001294def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001295 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001296 [(set FR64:$dst, (loadf64 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +00001297
1298// MOVSDrm zeros the high parts of the register; represent this
1299// with SUBREG_TO_REG.
1300let AddedComplexity = 20 in {
1301def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001302 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001303def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001304 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001305def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001306 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001307def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001308 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001309def : Pat<(v2f64 (X86vzload addr:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001310 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
Dan Gohman874cada2010-02-28 00:17:42 +00001311}
1312
1313// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +00001314def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001315 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001316 [(store FR64:$src, addr:$dst)]>;
1317
Dan Gohman874cada2010-02-28 00:17:42 +00001318// Extract and store.
1319def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
1320 addr:$dst),
1321 (MOVSDmr addr:$dst,
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00001322 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
Dan Gohman874cada2010-02-28 00:17:42 +00001323
Bill Wendlingddd35322007-05-02 23:11:52 +00001324// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00001325def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001326 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001327 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001328def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001329 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001330 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001331def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001332 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001333 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001334def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Cheng400073d2009-12-18 07:40:29 +00001336 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengb1f49812009-12-22 17:47:23 +00001337 Requires<[HasSSE2, OptForSize]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001338def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001339 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001340 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001341def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001342 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001343 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1344
Sean Callanan5ab94032009-09-16 01:13:52 +00001345def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1346 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1347def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1348 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1349def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1350 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1351def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1352 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1353def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1354 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1355def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1356 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1357def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1358 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1359def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1360 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1361def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1362 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1363def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1364 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1365
Bill Wendlingddd35322007-05-02 23:11:52 +00001366// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001367def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001368 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001369 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1370 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001371def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001372 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001373 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +00001374 Requires<[HasSSE2, OptForSize]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001375
1376def : Pat<(extloadf32 addr:$src),
Dan Gohman874cada2010-02-28 00:17:42 +00001377 (CVTSS2SDrr (MOVSSrm addr:$src))>,
1378 Requires<[HasSSE2, OptForSpeed]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001379
1380// Match intrinsics which expect XMM operand(s).
Evan Cheng64d80e32007-07-19 01:14:50 +00001381def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001382 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001383 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001384def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001385 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001386 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1387 (load addr:$src)))]>;
1388
Dan Gohmand9c2af52010-05-26 18:03:53 +00001389// Match intrinsics which expect MM and XMM operand(s).
Dale Johannesenc7842082007-10-30 22:15:38 +00001390def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1391 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1392 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1393def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1394 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001395 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001396 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001397def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1398 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1399 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1400def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1401 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001402 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001403 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001404def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1405 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1406 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1407def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1408 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001409 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesenc7842082007-10-30 22:15:38 +00001410 (load addr:$src)))]>;
1411
Bill Wendlingddd35322007-05-02 23:11:52 +00001412// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +00001413def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001414 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001415 [(set GR32:$dst,
1416 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001417def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001418 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001419 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1420 (load addr:$src)))]>;
1421
1422// Comparison instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001423let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001424 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001425 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001426 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001427let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +00001428 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001429 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001430 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Daniel Dunbar79373682010-05-25 18:40:53 +00001431
1432 // Accept explicit immediate argument form instead of comparison code.
1433let isAsmParserOnly = 1 in {
1434 def CMPSDrr_alt : SDIi8<0xC2, MRMSrcReg,
1435 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, i8imm:$src2),
1436 "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
1437let mayLoad = 1 in
1438 def CMPSDrm_alt : SDIi8<0xC2, MRMSrcMem,
1439 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, i8imm:$src2),
1440 "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
1441}
Bill Wendlingddd35322007-05-02 23:11:52 +00001442}
1443
Evan Cheng0488db92007-09-25 01:57:46 +00001444let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001445def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001446 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001447 [(set EFLAGS, (X86cmp FR64:$src1, FR64:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001448def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001450 [(set EFLAGS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001451} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001452
Bill Wendlingddd35322007-05-02 23:11:52 +00001453// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +00001454let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001455 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00001456 (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001457 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001458 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001459 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1460 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001461 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00001462 (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001463 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001464 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001465 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1466 (load addr:$src), imm:$cc))]>;
1467}
1468
Evan Cheng0488db92007-09-25 01:57:46 +00001469let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001470def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001471 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001472 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1473 VR128:$src2))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00001474def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001475 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001476 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1477 (load addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001478
Evan Cheng64d80e32007-07-19 01:14:50 +00001479def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001480 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001481 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1482 VR128:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001483def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001484 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001485 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1486 (load addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001487} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001488
Eric Christopher44b93ff2009-07-31 20:07:27 +00001489// Aliases of packed SSE2 instructions for scalar use. These all have names
1490// that start with 'Fs'.
Bill Wendlingddd35322007-05-02 23:11:52 +00001491
1492// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +00001493let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1494 canFoldAsLoad = 1 in
Chris Lattnerbe1778f2010-02-05 21:34:18 +00001495def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1496 [(set FR64:$dst, fpimm0)]>,
Bill Wendlingddd35322007-05-02 23:11:52 +00001497 Requires<[HasSSE2]>, TB, OpSize;
1498
Dan Gohman32791e02007-06-25 15:44:19 +00001499// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001500// disregarded.
Chris Lattnerba7e7562008-01-10 07:59:24 +00001501let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001502def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001503 "movapd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001504
Dan Gohman32791e02007-06-25 15:44:19 +00001505// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001506// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001507let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001508def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001509 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +00001510 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001511
1512// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +00001513let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001514let isCommutable = 1 in {
Evan Chengb6093392008-05-02 07:53:32 +00001515 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1516 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001518 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001519 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1520 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001521 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001522 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001523 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1524 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001525 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001526 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1527}
1528
Evan Chengb6093392008-05-02 07:53:32 +00001529def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1530 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001531 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001532 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001533 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001534def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1535 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001536 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001537 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001538 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001539def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1540 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001541 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001542 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001543 (memopfsf64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001544
Chris Lattnerba7e7562008-01-10 07:59:24 +00001545let neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001546def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001547 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001548 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001549let mayLoad = 1 in
Bill Wendlingddd35322007-05-02 23:11:52 +00001550def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001551 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001552 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001553}
Chris Lattnerba7e7562008-01-10 07:59:24 +00001554}
Bill Wendlingddd35322007-05-02 23:11:52 +00001555
Eric Christopher44b93ff2009-07-31 20:07:27 +00001556//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001557// SSE packed FP Instructions
1558
1559// Move Instructions
Chris Lattnerba7e7562008-01-10 07:59:24 +00001560let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001561def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001562 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001563let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001564def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001565 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001566 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001567
Evan Cheng64d80e32007-07-19 01:14:50 +00001568def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001569 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001570 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001571
Chris Lattnerf77e0372008-01-11 06:59:07 +00001572let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001573def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001574 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001575let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001576def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001577 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001578 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001579def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001580 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001581 [(store (v2f64 VR128:$src), addr:$dst)]>;
1582
1583// Intrinsic forms of MOVUPD load and store
Evan Cheng64d80e32007-07-19 01:14:50 +00001584def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001586 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001587def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001588 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001589 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001590
Evan Chenge9083d62008-03-05 08:19:16 +00001591let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001592 let AddedComplexity = 20 in {
1593 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001594 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001595 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001596 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001597 (v2f64 (movlp VR128:$src1,
1598 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001599 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001600 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001601 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001602 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +00001603 (v2f64 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001604 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001605 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001606} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001607
Evan Cheng64d80e32007-07-19 01:14:50 +00001608def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001609 "movlpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001610 [(store (f64 (vector_extract (v2f64 VR128:$src),
1611 (iPTR 0))), addr:$dst)]>;
1612
1613// v2f64 extract element 1 is always custom lowered to unpack high to low
1614// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +00001615def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001616 "movhpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001617 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +00001618 (v2f64 (unpckh VR128:$src, (undef))),
1619 (iPTR 0))), addr:$dst)]>;
Evan Chengd9539472006-04-14 21:59:03 +00001620
Evan Cheng470a6ad2006-02-22 02:26:30 +00001621// SSE2 instructions without OpSize prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001622def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001623 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001624 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1625 TB, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001626def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001627 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1628 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1629 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001630 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001631
1632// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001633def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001634 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001635 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1636 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001637def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001638 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1639 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1640 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001641 XS, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001642
Evan Cheng64d80e32007-07-19 01:14:50 +00001643def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001644 "cvtps2dq\t{$src, $dst|$dst, $src}",
1645 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001646def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001647 "cvtps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001648 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001649 (memop addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001650// SSE2 packed instructions with XS prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001651def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1652 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1653def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1654 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1655
Evan Cheng64d80e32007-07-19 01:14:50 +00001656def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001657 "cvttps2dq\t{$src, $dst|$dst, $src}",
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00001658 [(set VR128:$dst,
Sean Callanan108934c2009-12-18 00:01:26 +00001659 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001660 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001661def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001662 "cvttps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001663 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001664 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001665 XS, Requires<[HasSSE2]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001666
Evan Cheng470a6ad2006-02-22 02:26:30 +00001667// SSE2 packed instructions with XD prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001668def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001669 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001670 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1671 XD, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001672def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001673 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001674 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001675 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001676 XD, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001677
Evan Cheng64d80e32007-07-19 01:14:50 +00001678def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001679 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001680 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng029d9da2008-03-14 07:46:48 +00001681def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001682 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001683 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001684 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001685
1686// SSE2 instructions without OpSize prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001687def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1688 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1689def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1690 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1691
Evan Cheng64d80e32007-07-19 01:14:50 +00001692def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001693 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001694 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1695 TB, Requires<[HasSSE2]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001696def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001697 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001698 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
Chris Lattner15258d52006-10-07 06:17:43 +00001699 (load addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001700 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001701
Sean Callanan108934c2009-12-18 00:01:26 +00001702def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1703 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1704def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1705 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1706
1707
Evan Cheng64d80e32007-07-19 01:14:50 +00001708def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001709 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001710 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001711def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001712 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001713 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Chengb1938262008-05-23 00:37:07 +00001714 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001715
Evan Chengd2a6d542006-04-12 23:42:44 +00001716// Match intrinsics which expect XMM operand(s).
1717// Aliases for intrinsics
Evan Chenge9083d62008-03-05 08:19:16 +00001718let Constraints = "$src1 = $dst" in {
Evan Chengd2a6d542006-04-12 23:42:44 +00001719def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001720 (outs VR128:$dst), (ins VR128:$src1, GR32:$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,
Evan Cheng069287d2006-05-16 07:21:53 +00001723 GR32:$src2))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001724def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001725 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001726 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001727 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1728 (loadi32 addr:$src2)))]>;
1729def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001730 (outs VR128:$dst), (ins VR128:$src1, VR128:$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,
1733 VR128:$src2))]>;
1734def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00001735 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001736 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001737 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001738 (load addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001739def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001740 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001741 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001742 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1743 VR128:$src2))]>, XS,
1744 Requires<[HasSSE2]>;
1745def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001746 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001747 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001748 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001749 (load addr:$src2)))]>, XS,
Evan Chengd2a6d542006-04-12 23:42:44 +00001750 Requires<[HasSSE2]>;
1751}
1752
Dan Gohman20382522007-07-10 00:05:58 +00001753// Arithmetic
1754
1755/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
Chris Lattner6f987732006-10-07 21:17:13 +00001756///
Dan Gohman20382522007-07-10 00:05:58 +00001757/// In addition, we also have a special variant of the scalar form here to
1758/// represent the associated intrinsic operation. This form is unlike the
1759/// plain scalar form, in that it takes an entire vector (instead of a
1760/// scalar) and leaves the top elements undefined.
1761///
1762/// And, we have a special variant form for a full-vector intrinsic form.
1763///
1764/// These four forms can each have a reg or a mem operand, so there are a
1765/// total of eight "instructions".
1766///
1767multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1768 SDNode OpNode,
1769 Intrinsic F64Int,
1770 Intrinsic V2F64Int,
1771 bit Commutable = 0> {
1772 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001773 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001774 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001775 [(set FR64:$dst, (OpNode FR64:$src))]> {
Chris Lattner6f987732006-10-07 21:17:13 +00001776 let isCommutable = Commutable;
1777 }
Bill Wendlingddd35322007-05-02 23:11:52 +00001778
Dan Gohman20382522007-07-10 00:05:58 +00001779 // Scalar operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001780 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001781 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001782 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001783
Dan Gohman20382522007-07-10 00:05:58 +00001784 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001785 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001786 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001787 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1788 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001789 }
1790
Dan Gohman20382522007-07-10 00:05:58 +00001791 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001792 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001794 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001795
1796 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001797 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001798 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001799 [(set VR128:$dst, (F64Int VR128:$src))]> {
1800 let isCommutable = Commutable;
1801 }
1802
1803 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001804 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001805 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001806 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1807
1808 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001809 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001810 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001811 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1812 let isCommutable = Commutable;
1813 }
1814
1815 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001816 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001817 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001818 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Evan Cheng97ac5fa2006-04-03 23:49:17 +00001819}
Evan Chengffcb95b2006-02-21 19:13:53 +00001820
Dan Gohman20382522007-07-10 00:05:58 +00001821// Square root.
1822defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1823 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1824
1825// There is no f64 version of the reciprocal approximation instructions.
1826
Evan Chengffcb95b2006-02-21 19:13:53 +00001827// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001828let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001829 let isCommutable = 1 in {
1830 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001831 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001832 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001833 [(set VR128:$dst,
1834 (and (bc_v2i64 (v2f64 VR128:$src1)),
Chris Lattner3b57a832006-10-07 06:27:03 +00001835 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001836 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001837 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001838 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001839 [(set VR128:$dst,
1840 (or (bc_v2i64 (v2f64 VR128:$src1)),
1841 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1842 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001843 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001844 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001845 [(set VR128:$dst,
1846 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1847 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1848 }
1849
1850 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001851 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001852 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001853 [(set VR128:$dst,
1854 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001855 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001856 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001857 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001858 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001859 [(set VR128:$dst,
1860 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001861 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001862 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001863 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001864 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001865 [(set VR128:$dst,
1866 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001867 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001868 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001869 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001870 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001871 [(set VR128:$dst,
1872 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Chris Lattner3b57a832006-10-07 06:27:03 +00001873 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001874 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001875 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001876 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001877 [(set VR128:$dst,
1878 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001879 (memopv2i64 addr:$src2)))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +00001880}
Evan Chengbf156d12006-02-21 19:26:52 +00001881
Evan Chenge9083d62008-03-05 08:19:16 +00001882let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001883 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001884 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1885 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1886 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begemanc2616e42008-05-12 20:34:32 +00001887 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001888 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng029d9da2008-03-14 07:46:48 +00001889 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1890 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1891 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001892 (memop addr:$src), imm:$cc))]>;
Daniel Dunbar79373682010-05-25 18:40:53 +00001893
1894 // Accept explicit immediate argument form instead of comparison code.
1895let isAsmParserOnly = 1 in {
1896 def CMPPDrri_alt : PDIi8<0xC2, MRMSrcReg,
1897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, i8imm:$src2),
1898 "cmppd\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
1899 def CMPPDrmi_alt : PDIi8<0xC2, MRMSrcMem,
1900 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, i8imm:$src2),
1901 "cmppd\t{$src2, $src, $dst|$dst, $src, $src2}", []>;
1902}
Evan Cheng470a6ad2006-02-22 02:26:30 +00001903}
Evan Chenge9d50352008-08-05 22:19:15 +00001904def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001905 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Chenge9d50352008-08-05 22:19:15 +00001906def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001907 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001908
1909// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001910let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001911 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001912 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1913 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman9008ca62009-04-27 18:41:29 +00001914 [(set VR128:$dst,
1915 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001916 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001917 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00001918 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001919 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001920 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001921 (v2f64 (shufp:$src3
1922 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001923
Bill Wendlingddd35322007-05-02 23:11:52 +00001924 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001925 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001926 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001928 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001929 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001930 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001931 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001933 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001934 (v2f64 (unpckh VR128:$src1,
1935 (memopv2f64 addr:$src2))))]>;
Evan Cheng4fcb9222006-03-28 02:43:26 +00001936
Eric Christopher44b93ff2009-07-31 20:07:27 +00001937 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001938 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001939 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001940 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001941 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001942 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001943 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001945 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001946 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001947 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001948} // Constraints = "$src1 = $dst"
Evan Cheng470a6ad2006-02-22 02:26:30 +00001949
Evan Cheng4b1734f2006-03-31 21:29:33 +00001950
Eric Christopher44b93ff2009-07-31 20:07:27 +00001951//===---------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001952// SSE integer instructions
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00001953let ExeDomain = SSEPackedInt in {
Evan Chengbf156d12006-02-21 19:26:52 +00001954
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001955// Move Instructions
Chris Lattnerf77e0372008-01-11 06:59:07 +00001956let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001957def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001959let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001960def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001962 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001963let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001964def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001966 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001967let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001968def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001969 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001970 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001971 XS, Requires<[HasSSE2]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001972let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001973def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001974 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001975 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001976 XS, Requires<[HasSSE2]>;
Evan Cheng24dc1f52006-03-23 07:44:07 +00001977
Dan Gohman4106f372007-07-18 20:23:34 +00001978// Intrinsic forms of MOVDQU load and store
Dan Gohman15511cf2008-12-03 18:15:48 +00001979let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001980def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001981 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001982 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1983 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001984def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001985 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001986 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1987 XS, Requires<[HasSSE2]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001988
Evan Chenge7b8a8b2008-03-05 08:11:27 +00001989let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001990
Chris Lattner45e123c2006-10-07 19:02:31 +00001991multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1992 bit Commutable = 0> {
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00001993 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001994 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001996 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1997 let isCommutable = Commutable;
1998 }
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00001999 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002000 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002001 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00002002 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002003 (bitconvert (memopv2i64
Sean Callanan108934c2009-12-18 00:01:26 +00002004 addr:$src2))))]>;
Chris Lattner8139e282006-10-07 18:39:00 +00002005}
Chris Lattner8139e282006-10-07 18:39:00 +00002006
Evan Cheng22b942a2008-05-03 00:52:09 +00002007multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
2008 string OpcodeStr,
2009 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002010 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002011 (ins VR128:$src1, VR128:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002012 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2013 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002014 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2015 (ins VR128:$src1, i128mem:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002016 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2017 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002018 (bitconvert (memopv2i64 addr:$src2))))]>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002019 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002020 (ins VR128:$src1, i32i8imm:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002021 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2022 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2023}
2024
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002025/// PDI_binop_rm - Simple SSE2 binary operator.
2026multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2027 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002028 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002029 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002030 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002031 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
2032 let isCommutable = Commutable;
2033 }
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002034 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002035 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002037 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002038 (bitconvert (memopv2i64 addr:$src2)))))]>;
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002039}
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002040
2041/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2042///
2043/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2044/// to collapse (bitconvert VT to VT) into its operand.
2045///
2046multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2047 bit Commutable = 0> {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002048 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002049 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002050 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002051 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
2052 let isCommutable = Commutable;
2053 }
Eric Christopher44b93ff2009-07-31 20:07:27 +00002054 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002055 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002056 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002057 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00002058 (memopv2i64 addr:$src2)))]>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002059}
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002060
Evan Chenge9083d62008-03-05 08:19:16 +00002061} // Constraints = "$src1 = $dst"
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002062} // ExeDomain = SSEPackedInt
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002063
2064// 128-bit Integer Arithmetic
2065
2066defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2067defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2068defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002069defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002070
Chris Lattner45e123c2006-10-07 19:02:31 +00002071defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2072defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2073defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2074defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002075
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002076defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2077defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2078defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002079defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002080
Chris Lattner45e123c2006-10-07 19:02:31 +00002081defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2082defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2083defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2084defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002085
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002086defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002087
Chris Lattner45e123c2006-10-07 19:02:31 +00002088defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2089defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2090defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002091
Chris Lattner45e123c2006-10-07 19:02:31 +00002092defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
Chris Lattner77337992006-10-07 07:06:17 +00002093
Chris Lattner45e123c2006-10-07 19:02:31 +00002094defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2095defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
Chris Lattner8139e282006-10-07 18:39:00 +00002096
Chris Lattner77337992006-10-07 07:06:17 +00002097
Chris Lattner45e123c2006-10-07 19:02:31 +00002098defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2099defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2100defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2101defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling3b1259b2009-05-28 02:04:00 +00002102defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Evan Chengc60bd972006-03-25 09:37:23 +00002103
Chris Lattner77337992006-10-07 07:06:17 +00002104
Evan Cheng22b942a2008-05-03 00:52:09 +00002105defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2106 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2107defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2108 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2109defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2110 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002111
Evan Cheng22b942a2008-05-03 00:52:09 +00002112defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2113 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2114defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2115 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begeman32097bd2008-05-13 17:52:09 +00002116defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Cheng22b942a2008-05-03 00:52:09 +00002117 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002118
Evan Cheng22b942a2008-05-03 00:52:09 +00002119defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2120 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemanc9bdb002008-05-13 01:47:52 +00002121defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Cheng22b942a2008-05-03 00:52:09 +00002122 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Chris Lattner77337992006-10-07 07:06:17 +00002123
Chris Lattner6970eda2006-10-07 19:49:05 +00002124// 128-bit logical shifts.
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002125let Constraints = "$src1 = $dst", neverHasSideEffects = 1,
2126 ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002127 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002128 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002129 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002130 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002131 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002132 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002133 // PSRADQri doesn't exist in SSE[1-3].
Evan Chengff65e382006-04-04 21:49:39 +00002134}
2135
Chris Lattner6970eda2006-10-07 19:49:05 +00002136let Predicates = [HasSSE2] in {
2137 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002138 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002139 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002140 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling5e249b42008-10-02 05:56:52 +00002141 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2142 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2143 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2144 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Evan Cheng68c47cb2007-01-05 07:55:56 +00002145 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng89321162009-10-28 06:30:34 +00002146 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002147
2148 // Shift up / down and insert zero's.
2149 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002150 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002151 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002152 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002153}
2154
Evan Cheng506d3df2006-03-29 23:07:14 +00002155// Logical
Chris Lattnera7ebe552006-10-07 19:37:30 +00002156defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2157defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2158defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2159
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002160let Constraints = "$src1 = $dst", ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002161 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002162 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002163 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002164 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2165 VR128:$src2)))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002166
Bill Wendlingddd35322007-05-02 23:11:52 +00002167 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002168 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002169 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002170 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7f55fcb2007-08-02 21:17:01 +00002171 (memopv2i64 addr:$src2))))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002172}
2173
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002174// SSE2 Integer comparison
Bill Wendlingddd35322007-05-02 23:11:52 +00002175defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2176defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2177defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2178defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2179defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2180defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002181
Nate Begeman30a0de92008-07-17 16:51:19 +00002182def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002183 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002184def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002185 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002186def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002187 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002188def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002189 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002190def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002191 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002192def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002193 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2194
Nate Begeman30a0de92008-07-17 16:51:19 +00002195def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002196 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002197def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002198 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002199def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002200 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002201def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002202 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002203def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002204 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002205def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002206 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2207
2208
Evan Cheng506d3df2006-03-29 23:07:14 +00002209// Pack instructions
Chris Lattner45e123c2006-10-07 19:02:31 +00002210defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2211defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2212defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002213
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002214let ExeDomain = SSEPackedInt in {
2215
Evan Cheng506d3df2006-03-29 23:07:14 +00002216// Shuffle and unpack instructions
Nate Begemana09008b2009-10-19 02:17:23 +00002217let AddedComplexity = 5 in {
Evan Cheng8703be42006-04-04 19:12:30 +00002218def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002219 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002221 [(set VR128:$dst, (v4i32 (pshufd:$src2
2222 VR128:$src1, (undef))))]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002223def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002224 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002225 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002226 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chengc3630942009-12-09 21:00:30 +00002227 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002228 (undef))))]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002229}
Evan Cheng506d3df2006-03-29 23:07:14 +00002230
2231// SSE2 with ImmT == Imm8 and XS prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002232def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002233 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002234 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002235 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2236 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002237 XS, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002238def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002239 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002240 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002241 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher44b93ff2009-07-31 20:07:27 +00002242 (bc_v8i16 (memopv2i64 addr:$src1)),
2243 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002244 XS, Requires<[HasSSE2]>;
2245
2246// SSE2 with ImmT == Imm8 and XD prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002247def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman9008ca62009-04-27 18:41:29 +00002248 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002249 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002250 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2251 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002252 XD, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002253def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman9008ca62009-04-27 18:41:29 +00002254 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002255 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002256 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2257 (bc_v8i16 (memopv2i64 addr:$src1)),
2258 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002259 XD, Requires<[HasSSE2]>;
2260
Evan Chengc60bd972006-03-25 09:37:23 +00002261
Evan Chenge9083d62008-03-05 08:19:16 +00002262let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002263 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002264 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002265 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002266 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002267 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002268 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002269 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002271 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002272 (unpckl VR128:$src1,
2273 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002274 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002275 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002276 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002277 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002278 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002279 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002280 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002282 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002283 (unpckl VR128:$src1,
2284 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002285 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002286 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002287 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002288 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002289 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002290 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002291 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002292 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002293 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002294 (unpckl VR128:$src1,
2295 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002296 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002297 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002298 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002299 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002300 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002301 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002302 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002303 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002304 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002305 (v2i64 (unpckl VR128:$src1,
2306 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002307
2308 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002309 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002310 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002311 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002312 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002313 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002314 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002315 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002316 [(set VR128:$dst,
2317 (unpckh VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00002318 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002319 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002320 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002321 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002322 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002323 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002324 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002325 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002326 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002327 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002328 (unpckh VR128:$src1,
2329 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002330 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002331 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002332 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002333 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002334 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002335 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002336 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002337 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002338 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002339 (unpckh VR128:$src1,
2340 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002341 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002342 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002343 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002344 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002345 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002346 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002347 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002348 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002349 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002350 (v2i64 (unpckh VR128:$src1,
2351 (memopv2i64 addr:$src2))))]>;
Evan Chenga971f6f2006-03-23 01:57:24 +00002352}
Evan Cheng82521dd2006-03-21 07:09:35 +00002353
Evan Chengb067a1e2006-03-31 19:22:53 +00002354// Extract / Insert
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002355def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002356 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002357 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002358 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begeman14d12ca2008-02-11 04:19:36 +00002359 imm:$src2))]>;
Evan Chenge9083d62008-03-05 08:19:16 +00002360let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002361 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002362 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002363 GR32:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002364 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002365 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002366 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002367 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002368 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002369 i16mem:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002370 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002371 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002372 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2373 imm:$src3))]>;
Evan Chengb067a1e2006-03-31 19:22:53 +00002374}
2375
Evan Chengc5fb2b12006-03-30 00:33:26 +00002376// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00002377def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002378 "pmovmskb\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002379 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
Evan Chengc5fb2b12006-03-30 00:33:26 +00002380
Evan Chengfcf5e212006-04-11 06:57:30 +00002381// Conditional store
Evan Cheng071a2792007-09-11 19:55:27 +00002382let Uses = [EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +00002383def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002384 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng071a2792007-09-11 19:55:27 +00002385 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Evan Chengfcf5e212006-04-11 06:57:30 +00002386
Evan Cheng1d768642009-02-10 22:06:28 +00002387let Uses = [RDI] in
2388def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2389 "maskmovdqu\t{$mask, $src|$src, $mask}",
2390 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2391
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002392} // ExeDomain = SSEPackedInt
2393
Evan Chengecac9cb2006-03-25 06:03:26 +00002394// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00002395def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2396 "movntpd\t{$src, $dst|$dst, $src}",
2397 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002398let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002399def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2400 "movntdq\t{$src, $dst|$dst, $src}",
2401 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2402def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002403 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002404 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Evan Chengfcf5e212006-04-11 06:57:30 +00002405 TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002406
David Greene8939b0d2010-02-16 20:50:18 +00002407let AddedComplexity = 400 in { // Prefer non-temporal versions
2408def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2409 "movntpd\t{$src, $dst|$dst, $src}",
2410 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2411
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002412let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002413def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2414 "movntdq\t{$src, $dst|$dst, $src}",
2415 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
David Greene8939b0d2010-02-16 20:50:18 +00002416}
2417
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002418// Flush cache
Evan Cheng64d80e32007-07-19 01:14:50 +00002419def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002420 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002421 TB, Requires<[HasSSE2]>;
2422
2423// Load, store, and memory fence
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002424def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002425 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002426def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002427 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002428
Dan Gohman14aaeac2010-05-20 01:35:50 +00002429// Pause. This "instruction" is encoded as "rep; nop", so even though it
Dan Gohmand9c2af52010-05-26 18:03:53 +00002430// was introduced with SSE2, it's backward compatible.
Dan Gohman14aaeac2010-05-20 01:35:50 +00002431def PAUSE : I<0x90, RawFrm, (outs), (ins), "pause", []>, REP;
2432
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002433//TODO: custom lower this so as to never even generate the noop
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002434def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002435 (i8 0)), (NOOP)>;
2436def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2437def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002438def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002439 (i8 1)), (MFENCE)>;
2440
Evan Chengffea91e2006-03-26 09:53:12 +00002441// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00002442// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00002443// load of an all-ones value if folding it would be beneficial.
Daniel Dunbar7417b762009-08-11 22:17:52 +00002444let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
Jakob Stoklund Olesen428e1522010-03-30 22:46:55 +00002445 isCodeGenOnly = 1, ExeDomain = SSEPackedInt in
Chris Lattner28c1d292010-02-05 21:30:49 +00002446 // FIXME: Change encoding to pseudo.
2447 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00002448 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Evan Cheng386031a2006-03-24 07:29:27 +00002449
Evan Cheng64d80e32007-07-19 01:14:50 +00002450def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002451 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002452 [(set VR128:$dst,
Evan Cheng069287d2006-05-16 07:21:53 +00002453 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002454def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002455 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002456 [(set VR128:$dst,
2457 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Evan Chengebf01d62006-11-16 23:33:25 +00002458
Evan Cheng64d80e32007-07-19 01:14:50 +00002459def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002460 "movd\t{$src, $dst|$dst, $src}",
Chris Lattnerf3597a12006-12-05 18:45:06 +00002461 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2462
Evan Cheng64d80e32007-07-19 01:14:50 +00002463def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002464 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002465 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002466
Evan Cheng11e15b32006-04-03 20:53:28 +00002467// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00002468def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002469 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002470 [(set VR128:$dst,
2471 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2472 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002473def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "movq\t{$src, $dst|$dst, $src}",
Evan Chengebf01d62006-11-16 23:33:25 +00002475 [(store (i64 (vector_extract (v2i64 VR128:$src),
2476 (iPTR 0))), addr:$dst)]>;
2477
Dan Gohman874cada2010-02-28 00:17:42 +00002478def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00002479 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
Dan Gohman874cada2010-02-28 00:17:42 +00002480
Evan Cheng64d80e32007-07-19 01:14:50 +00002481def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002483 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002484 (iPTR 0)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002485def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002486 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002487 [(store (i32 (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002488 (iPTR 0))), addr:$dst)]>;
Evan Cheng11e15b32006-04-03 20:53:28 +00002489
Evan Cheng64d80e32007-07-19 01:14:50 +00002490def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002491 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002492 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002493def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002494 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002495 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002496
Evan Cheng397edef2006-04-11 22:28:25 +00002497// Store / copy lower 64-bits of a XMM register.
Evan Cheng64d80e32007-07-19 01:14:50 +00002498def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002499 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng397edef2006-04-11 22:28:25 +00002500 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2501
Evan Cheng017dcc62006-04-21 01:05:10 +00002502// movd / movq to XMM register zero-extends
Evan Cheng7a831ce2007-12-15 03:00:47 +00002503let AddedComplexity = 15 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002504def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002505 "movd\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002506 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002507 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002508// This is X86-64 only.
2509def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2510 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002511 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002512 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002513}
2514
2515let AddedComplexity = 20 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002516def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002517 "movd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002518 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002519 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002520 (loadi32 addr:$src))))))]>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002521
2522def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2523 (MOVZDI2PDIrm addr:$src)>;
2524def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2525 (MOVZDI2PDIrm addr:$src)>;
Duncan Sandsd4b9c172008-06-13 19:07:40 +00002526def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2527 (MOVZDI2PDIrm addr:$src)>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002528
Evan Cheng64d80e32007-07-19 01:14:50 +00002529def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002530 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng7a831ce2007-12-15 03:00:47 +00002531 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002532 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002533 (loadi64 addr:$src))))))]>, XS,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002534 Requires<[HasSSE2]>;
Evan Cheng48090aa2006-03-21 23:01:21 +00002535
Evan Chengc36c0ab2008-05-22 18:56:56 +00002536def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2537 (MOVZQI2PQIrm addr:$src)>;
2538def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2539 (MOVZQI2PQIrm addr:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00002540def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengb70ea0b2008-05-10 00:59:18 +00002541}
Evan Chengd880b972008-05-09 21:53:03 +00002542
Evan Cheng7a831ce2007-12-15 03:00:47 +00002543// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2544// IA32 document. movq xmm1, xmm2 does clear the high bits.
2545let AddedComplexity = 15 in
2546def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2547 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002548 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002549 XS, Requires<[HasSSE2]>;
2550
Evan Cheng8e8de682008-05-20 18:24:47 +00002551let AddedComplexity = 20 in {
Evan Cheng7a831ce2007-12-15 03:00:47 +00002552def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2553 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002554 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng8e8de682008-05-20 18:24:47 +00002555 (loadv2i64 addr:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002556 XS, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002557
Evan Cheng8e8de682008-05-20 18:24:47 +00002558def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2559 (MOVZPQILo2PQIrm addr:$src)>;
2560}
2561
Sean Callanan108934c2009-12-18 00:01:26 +00002562// Instructions for the disassembler
2563// xr = XMM register
2564// xm = mem64
2565
2566def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2567 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2568
Eric Christopher44b93ff2009-07-31 20:07:27 +00002569//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002570// SSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002571//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002572
Bill Wendlingddd35322007-05-02 23:11:52 +00002573// Move Instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00002574def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002575 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002576 [(set VR128:$dst, (v4f32 (movshdup
2577 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002578def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002579 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002580 [(set VR128:$dst, (movshdup
2581 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002582
Evan Cheng64d80e32007-07-19 01:14:50 +00002583def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002584 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002585 [(set VR128:$dst, (v4f32 (movsldup
2586 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002587def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002588 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002589 [(set VR128:$dst, (movsldup
2590 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002591
Evan Cheng64d80e32007-07-19 01:14:50 +00002592def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002593 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002594 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002595def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002596 "movddup\t{$src, $dst|$dst, $src}",
Evan Cheng0b457f02008-09-25 20:50:48 +00002597 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002598 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2599 (undef))))]>;
Evan Cheng0b457f02008-09-25 20:50:48 +00002600
Nate Begeman9008ca62009-04-27 18:41:29 +00002601def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2602 (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002603 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002604
2605let AddedComplexity = 5 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00002606def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002607 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002608def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2609 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2610def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2611 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2612def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2613 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2614}
Bill Wendlingddd35322007-05-02 23:11:52 +00002615
2616// Arithmetic
Evan Chenge9083d62008-03-05 08:19:16 +00002617let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002618 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002619 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002620 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002621 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2622 VR128:$src2))]>;
2623 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002624 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002625 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002626 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002627 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002628 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002629 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002630 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002631 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2632 VR128:$src2))]>;
2633 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002634 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002635 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002636 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002637 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002638}
2639
Evan Cheng64d80e32007-07-19 01:14:50 +00002640def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002641 "lddqu\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002642 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2643
2644// Horizontal ops
2645class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002646 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002647 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002648 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2649class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002650 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002651 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002652 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002653class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002654 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002655 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002656 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2657class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002658 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002659 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002660 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002661
Evan Chenge9083d62008-03-05 08:19:16 +00002662let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002663 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2664 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2665 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2666 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2667 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2668 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2669 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2670 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2671}
2672
2673// Thread synchronization
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002674def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
Bill Wendlingddd35322007-05-02 23:11:52 +00002675 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002676def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
Bill Wendlingddd35322007-05-02 23:11:52 +00002677 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2678
2679// vector_shuffle v1, <undef> <1, 1, 3, 3>
2680let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002681def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002682 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2683let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002684def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002685 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2686
2687// vector_shuffle v1, <undef> <0, 0, 2, 2>
2688let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002689 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002690 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2691let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002692 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002693 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2694
Eric Christopher44b93ff2009-07-31 20:07:27 +00002695//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002696// SSSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002697//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002698
Bill Wendling76d708b2007-08-10 06:22:27 +00002699/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begemanfea2be52008-02-09 23:46:37 +00002700multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2701 Intrinsic IntId64, Intrinsic IntId128> {
2702 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2703 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2704 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002705
Nate Begemanfea2be52008-02-09 23:46:37 +00002706 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2707 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2708 [(set VR64:$dst,
2709 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2710
2711 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2712 (ins VR128:$src),
2713 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2714 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2715 OpSize;
2716
2717 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2718 (ins i128mem:$src),
2719 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2720 [(set VR128:$dst,
2721 (IntId128
2722 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Bill Wendlingddd35322007-05-02 23:11:52 +00002723}
2724
Bill Wendling76d708b2007-08-10 06:22:27 +00002725/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begemanfea2be52008-02-09 23:46:37 +00002726multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2727 Intrinsic IntId64, Intrinsic IntId128> {
2728 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2729 (ins VR64:$src),
2730 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2731 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002732
Nate Begemanfea2be52008-02-09 23:46:37 +00002733 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2734 (ins i64mem:$src),
2735 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2736 [(set VR64:$dst,
2737 (IntId64
2738 (bitconvert (memopv4i16 addr:$src))))]>;
2739
2740 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2741 (ins VR128:$src),
2742 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2743 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2744 OpSize;
2745
2746 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2747 (ins i128mem:$src),
2748 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2749 [(set VR128:$dst,
2750 (IntId128
2751 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002752}
2753
2754/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begemanfea2be52008-02-09 23:46:37 +00002755multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2756 Intrinsic IntId64, Intrinsic IntId128> {
2757 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2758 (ins VR64:$src),
2759 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2760 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002761
Nate Begemanfea2be52008-02-09 23:46:37 +00002762 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2763 (ins i64mem:$src),
2764 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2765 [(set VR64:$dst,
2766 (IntId64
2767 (bitconvert (memopv2i32 addr:$src))))]>;
2768
2769 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2770 (ins VR128:$src),
2771 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2772 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2773 OpSize;
2774
2775 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2776 (ins i128mem:$src),
2777 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2778 [(set VR128:$dst,
2779 (IntId128
2780 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002781}
2782
2783defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2784 int_x86_ssse3_pabs_b,
2785 int_x86_ssse3_pabs_b_128>;
2786defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2787 int_x86_ssse3_pabs_w,
2788 int_x86_ssse3_pabs_w_128>;
2789defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2790 int_x86_ssse3_pabs_d,
2791 int_x86_ssse3_pabs_d_128>;
2792
2793/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Chenge9083d62008-03-05 08:19:16 +00002794let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002795 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2796 Intrinsic IntId64, Intrinsic IntId128,
2797 bit Commutable = 0> {
2798 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2799 (ins VR64:$src1, VR64:$src2),
2800 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2801 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2802 let isCommutable = Commutable;
2803 }
2804 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2805 (ins VR64:$src1, i64mem:$src2),
2806 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2807 [(set VR64:$dst,
2808 (IntId64 VR64:$src1,
2809 (bitconvert (memopv8i8 addr:$src2))))]>;
2810
2811 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2812 (ins VR128:$src1, VR128:$src2),
2813 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2814 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2815 OpSize {
2816 let isCommutable = Commutable;
2817 }
2818 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2819 (ins VR128:$src1, i128mem:$src2),
2820 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2821 [(set VR128:$dst,
2822 (IntId128 VR128:$src1,
2823 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2824 }
2825}
2826
2827/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Chenge9083d62008-03-05 08:19:16 +00002828let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002829 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2830 Intrinsic IntId64, Intrinsic IntId128,
2831 bit Commutable = 0> {
2832 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2833 (ins VR64:$src1, VR64:$src2),
2834 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2835 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2836 let isCommutable = Commutable;
2837 }
2838 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2839 (ins VR64:$src1, i64mem:$src2),
2840 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2841 [(set VR64:$dst,
2842 (IntId64 VR64:$src1,
2843 (bitconvert (memopv4i16 addr:$src2))))]>;
2844
2845 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2846 (ins VR128:$src1, VR128:$src2),
2847 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2848 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2849 OpSize {
2850 let isCommutable = Commutable;
2851 }
2852 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2853 (ins VR128:$src1, i128mem:$src2),
2854 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2855 [(set VR128:$dst,
2856 (IntId128 VR128:$src1,
2857 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2858 }
2859}
2860
2861/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Chenge9083d62008-03-05 08:19:16 +00002862let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002863 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2864 Intrinsic IntId64, Intrinsic IntId128,
2865 bit Commutable = 0> {
2866 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2867 (ins VR64:$src1, VR64:$src2),
2868 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2869 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2870 let isCommutable = Commutable;
2871 }
2872 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2873 (ins VR64:$src1, i64mem:$src2),
2874 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2875 [(set VR64:$dst,
2876 (IntId64 VR64:$src1,
2877 (bitconvert (memopv2i32 addr:$src2))))]>;
2878
2879 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2880 (ins VR128:$src1, VR128:$src2),
2881 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2882 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2883 OpSize {
2884 let isCommutable = Commutable;
2885 }
2886 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2887 (ins VR128:$src1, i128mem:$src2),
2888 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2889 [(set VR128:$dst,
2890 (IntId128 VR128:$src1,
2891 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2892 }
2893}
2894
Chris Lattner65de1b92010-04-17 07:38:24 +00002895let ImmT = NoImm in { // None of these have i8 immediate fields.
Bill Wendling76d708b2007-08-10 06:22:27 +00002896defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2897 int_x86_ssse3_phadd_w,
Evan Cheng4e444432008-06-16 21:16:24 +00002898 int_x86_ssse3_phadd_w_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002899defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2900 int_x86_ssse3_phadd_d,
Evan Cheng4e444432008-06-16 21:16:24 +00002901 int_x86_ssse3_phadd_d_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002902defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2903 int_x86_ssse3_phadd_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002904 int_x86_ssse3_phadd_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002905defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2906 int_x86_ssse3_phsub_w,
2907 int_x86_ssse3_phsub_w_128>;
2908defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2909 int_x86_ssse3_phsub_d,
2910 int_x86_ssse3_phsub_d_128>;
2911defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2912 int_x86_ssse3_phsub_sw,
2913 int_x86_ssse3_phsub_sw_128>;
2914defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2915 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002916 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002917defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2918 int_x86_ssse3_pmul_hr_sw,
2919 int_x86_ssse3_pmul_hr_sw_128, 1>;
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00002920
Bill Wendling76d708b2007-08-10 06:22:27 +00002921defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2922 int_x86_ssse3_pshuf_b,
2923 int_x86_ssse3_pshuf_b_128>;
2924defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2925 int_x86_ssse3_psign_b,
2926 int_x86_ssse3_psign_b_128>;
2927defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2928 int_x86_ssse3_psign_w,
2929 int_x86_ssse3_psign_w_128>;
Evan Chenged7f56b2009-05-28 18:48:53 +00002930defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling76d708b2007-08-10 06:22:27 +00002931 int_x86_ssse3_psign_d,
2932 int_x86_ssse3_psign_d_128>;
Chris Lattner65de1b92010-04-17 07:38:24 +00002933}
Bill Wendling76d708b2007-08-10 06:22:27 +00002934
Eric Christophercff6f852010-04-15 01:40:20 +00002935// palignr patterns.
Evan Chenge9083d62008-03-05 08:19:16 +00002936let Constraints = "$src1 = $dst" in {
Bill Wendlingae9671b2007-08-10 09:00:17 +00002937 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002938 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002939 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002940 []>;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002941 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002942 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002943 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002944 []>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002945
Bill Wendlingae9671b2007-08-10 09:00:17 +00002946 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002947 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002948 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002949 []>, OpSize;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002950 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002951 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002952 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002953 []>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002954}
Bill Wendlingddd35322007-05-02 23:11:52 +00002955
Eric Christopher6d972fd2010-04-20 00:59:54 +00002956let AddedComplexity = 5 in {
2957
Eric Christophercff6f852010-04-15 01:40:20 +00002958def : Pat<(v1i64 (palign:$src3 VR64:$src1, VR64:$src2)),
2959 (PALIGNR64rr VR64:$src2, VR64:$src1,
2960 (SHUFFLE_get_palign_imm VR64:$src3))>,
2961 Requires<[HasSSSE3]>;
2962def : Pat<(v2i32 (palign:$src3 VR64:$src1, VR64:$src2)),
2963 (PALIGNR64rr VR64:$src2, VR64:$src1,
2964 (SHUFFLE_get_palign_imm VR64:$src3))>,
2965 Requires<[HasSSSE3]>;
2966def : Pat<(v2f32 (palign:$src3 VR64:$src1, VR64:$src2)),
2967 (PALIGNR64rr VR64:$src2, VR64:$src1,
2968 (SHUFFLE_get_palign_imm VR64:$src3))>,
2969 Requires<[HasSSSE3]>;
2970def : Pat<(v4i16 (palign:$src3 VR64:$src1, VR64:$src2)),
2971 (PALIGNR64rr VR64:$src2, VR64:$src1,
2972 (SHUFFLE_get_palign_imm VR64:$src3))>,
2973 Requires<[HasSSSE3]>;
2974def : Pat<(v8i8 (palign:$src3 VR64:$src1, VR64:$src2)),
2975 (PALIGNR64rr VR64:$src2, VR64:$src1,
2976 (SHUFFLE_get_palign_imm VR64:$src3))>,
2977 Requires<[HasSSSE3]>;
Evan Cheng89321162009-10-28 06:30:34 +00002978
Nate Begemana09008b2009-10-19 02:17:23 +00002979def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2980 (PALIGNR128rr VR128:$src2, VR128:$src1,
2981 (SHUFFLE_get_palign_imm VR128:$src3))>,
2982 Requires<[HasSSSE3]>;
2983def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2984 (PALIGNR128rr VR128:$src2, VR128:$src1,
2985 (SHUFFLE_get_palign_imm VR128:$src3))>,
2986 Requires<[HasSSSE3]>;
2987def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2988 (PALIGNR128rr VR128:$src2, VR128:$src1,
2989 (SHUFFLE_get_palign_imm VR128:$src3))>,
2990 Requires<[HasSSSE3]>;
2991def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2992 (PALIGNR128rr VR128:$src2, VR128:$src1,
2993 (SHUFFLE_get_palign_imm VR128:$src3))>,
2994 Requires<[HasSSSE3]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002995}
Nate Begemana09008b2009-10-19 02:17:23 +00002996
Nate Begemanb9a47b82009-02-23 08:49:38 +00002997def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2998 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2999def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
3000 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
3001
Eric Christopher44b93ff2009-07-31 20:07:27 +00003002//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00003003// Non-Instruction Patterns
Eric Christopher44b93ff2009-07-31 20:07:27 +00003004//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00003005
Eric Christopher44b93ff2009-07-31 20:07:27 +00003006// extload f32 -> f64. This matches load+fextend because we have a hack in
3007// the isel (PreprocessForFPConvert) that can introduce loads after dag
3008// combine.
Chris Lattnerd43d00c2008-01-24 08:07:48 +00003009// Since these loads aren't folded into the fextend, we have to match it
3010// explicitly here.
3011let Predicates = [HasSSE2] in
3012 def : Pat<(fextend (loadf32 addr:$src)),
3013 (CVTSS2SDrm addr:$src)>;
3014
Evan Cheng2c0dbd02006-03-24 02:58:06 +00003015// bit_convert
Chris Lattner4cc84ed2006-10-07 04:52:09 +00003016let Predicates = [HasSSE2] in {
3017 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
3018 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
3019 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
3020 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
3021 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
3022 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
3023 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
3024 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
3025 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
3026 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
3027 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
3028 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
3029 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
3030 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
3031 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
3032 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3033 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3034 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3035 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3036 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3037 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3038 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3039 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3040 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3041 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3042 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3043 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3044 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3045 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3046 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3047}
Evan Chengb9df0ca2006-03-22 02:53:00 +00003048
Evan Cheng017dcc62006-04-21 01:05:10 +00003049// Move scalar to XMM zero-extended
3050// movd to XMM register zero-extends
Evan Chengf2ea84a2006-10-09 21:42:15 +00003051let AddedComplexity = 15 in {
Evan Cheng017dcc62006-04-21 01:05:10 +00003052// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chengd880b972008-05-09 21:53:03 +00003053def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00003054 (MOVSDrr (v2f64 (V_SET0PS)), FR64:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00003055def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00003056 (MOVSSrr (v4f32 (V_SET0PS)), FR32:$src)>;
Evan Cheng23573e52008-05-09 23:37:55 +00003057def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00003058 (MOVSSrr (v4f32 (V_SET0PS)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003059 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss)))>;
Evan Cheng331e2bd2008-07-10 01:08:23 +00003060def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Jakob Stoklund Olesend363b4e2010-03-31 00:40:13 +00003061 (MOVSSrr (v4i32 (V_SET0PI)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003062 (EXTRACT_SUBREG (v4i32 VR128:$src), sub_ss))>;
Evan Cheng017dcc62006-04-21 01:05:10 +00003063}
Evan Chengbc4832b2006-03-24 23:15:12 +00003064
Evan Chengb9df0ca2006-03-22 02:53:00 +00003065// Splat v2f64 / v2i64
Evan Chengfd111b52006-04-19 21:15:24 +00003066let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003067def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003068 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003069def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003070 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003071def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003072 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003073def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003074 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengfd111b52006-04-19 21:15:24 +00003075}
Evan Cheng475aecf2006-03-29 03:04:49 +00003076
Evan Chengb7a5c522006-04-18 21:55:35 +00003077// Special unary SHUFPSrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003078def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3079 (SHUFPSrri VR128:$src1, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003080 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003081let AddedComplexity = 5 in
3082def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3083 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3084 Requires<[HasSSE2]>;
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003085// Special unary SHUFPDrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003086def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003087 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003088 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3089 Requires<[HasSSE2]>;
3090// Special unary SHUFPDrri case.
3091def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003092 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003093 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003094 Requires<[HasSSE2]>;
Evan Cheng3d60df42006-04-10 22:35:16 +00003095// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman9008ca62009-04-27 18:41:29 +00003096def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3097 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng7d9061e2006-03-30 19:54:57 +00003098 Requires<[HasSSE2]>;
Evan Chengb7a75a52008-09-26 23:41:32 +00003099
Evan Cheng3d60df42006-04-10 22:35:16 +00003100// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman9008ca62009-04-27 18:41:29 +00003101def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003102 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003103 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003104 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003105def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003106 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003107 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003108 Requires<[HasSSE2]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00003109// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman9008ca62009-04-27 18:41:29 +00003110def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003111 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003112 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00003113 Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003114
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003115// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003116let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003117def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3118 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003119 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003120def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3121 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003122 Requires<[OptForSpeed, HasSSE2]>;
3123}
Evan Chengfd111b52006-04-19 21:15:24 +00003124let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003125def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003126 (UNPCKLPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003127def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003128 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003129def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003130 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003131def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003132 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
Evan Chengfd111b52006-04-19 21:15:24 +00003133}
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003134
Evan Cheng174f8032007-05-17 18:44:37 +00003135// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003136let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003137def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3138 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003139 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003140def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3141 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003142 Requires<[OptForSpeed, HasSSE2]>;
3143}
Evan Cheng174f8032007-05-17 18:44:37 +00003144let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003145def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003146 (UNPCKHPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003147def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003148 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003149def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003150 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003151def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003152 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
Evan Cheng174f8032007-05-17 18:44:37 +00003153}
3154
Evan Chengb7a75a52008-09-26 23:41:32 +00003155let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003156// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman0b10b912009-11-07 23:17:15 +00003157def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003158 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003159
3160// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003161def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003162 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003163
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003164// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003165def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003166 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003167def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003168 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003169}
Evan Cheng9d09b892006-05-31 00:51:37 +00003170
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003171let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003172// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003173def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003174 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003175def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003176 (MOVLPDrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003177def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003178 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003179def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003180 (MOVLPDrm VR128:$src1, addr:$src2)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003181}
Evan Cheng64e97692006-04-24 21:58:20 +00003182
Evan Chengcd0baf22008-05-23 21:23:16 +00003183// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003184def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003185 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003186def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003187 (MOVLPDmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003188def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3189 addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003190 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003191def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003192 (MOVLPDmr addr:$src1, VR128:$src2)>;
Evan Chengcd0baf22008-05-23 21:23:16 +00003193
Evan Chengf2ea84a2006-10-09 21:42:15 +00003194let AddedComplexity = 15 in {
Evan Cheng64e97692006-04-24 21:58:20 +00003195// Setting the lowest element in the vector.
Nate Begeman9008ca62009-04-27 18:41:29 +00003196def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003197 (MOVSSrr (v4i32 VR128:$src1),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003198 (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_ss))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003199def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003200 (MOVSDrr (v2i64 VR128:$src1),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003201 (EXTRACT_SUBREG (v2i64 VR128:$src2), sub_sd))>;
Evan Chenga7fc6422006-04-24 23:34:56 +00003202
Dan Gohman874cada2010-02-28 00:17:42 +00003203// vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
Nate Begeman9008ca62009-04-27 18:41:29 +00003204def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003205 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
Dan Gohman874cada2010-02-28 00:17:42 +00003206 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003207def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00003208 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
Dan Gohman874cada2010-02-28 00:17:42 +00003209 Requires<[HasSSE2]>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003210}
Evan Cheng9e062ed2006-05-03 20:32:03 +00003211
Eli Friedman7e2242b2009-06-19 07:00:55 +00003212// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3213// fall back to this for SSE1)
3214def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003215 (SHUFPSrri VR128:$src2, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003216 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Eli Friedman7e2242b2009-06-19 07:00:55 +00003217
Evan Chenga7fc6422006-04-24 23:34:56 +00003218// Set lowest element and zero upper elements.
Evan Chengd880b972008-05-09 21:53:03 +00003219def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengfd17f422008-05-08 22:35:02 +00003220 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengcdfc3c82006-04-17 22:45:49 +00003221
Evan Cheng2c3ae372006-04-12 21:21:57 +00003222// Some special case pandn patterns.
3223def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3224 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003225 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003226def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3227 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003228 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003229def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3230 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003231 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003232
Evan Cheng2c3ae372006-04-12 21:21:57 +00003233def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003234 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003235 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003236def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003237 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003238 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003239def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003240 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003241 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng206ee9d2006-07-07 08:33:52 +00003242
Nate Begemanb348d182007-11-17 03:58:34 +00003243// vector -> vector casts
3244def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3245 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3246def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3247 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedmand0c0fae2008-09-05 23:07:03 +00003248def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3249 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3250def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3251 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb348d182007-11-17 03:58:34 +00003252
Evan Chengb4162fd2007-07-20 00:27:43 +00003253// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohmand3006222007-07-27 17:16:43 +00003254def : Pat<(alignedloadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003255 (MOVAPSrm addr:$src)>;
Dan Gohmand3006222007-07-27 17:16:43 +00003256def : Pat<(loadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003257 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003258def : Pat<(alignedloadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003259 (MOVAPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003260def : Pat<(loadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003261 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003262
3263def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003264 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003265def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003266 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003267def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003268 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003269def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003270 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003271def : Pat<(store (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003272 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003273def : Pat<(store (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003274 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003275def : Pat<(store (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003276 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003277def : Pat<(store (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003278 (MOVUPSmr addr:$dst, VR128:$src)>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003279
Nate Begeman63ec90a2008-02-03 07:18:54 +00003280//===----------------------------------------------------------------------===//
3281// SSE4.1 Instructions
3282//===----------------------------------------------------------------------===//
3283
Dale Johannesene397acc2008-10-10 23:51:03 +00003284multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003285 string OpcodeStr,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003286 Intrinsic V4F32Int,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003287 Intrinsic V2F64Int> {
Nate Begeman63ec90a2008-02-03 07:18:54 +00003288 // Intrinsic operation, reg.
Nate Begeman63ec90a2008-02-03 07:18:54 +00003289 // Vector intrinsic operation, reg
Eric Christopher44b93ff2009-07-31 20:07:27 +00003290 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003291 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003292 !strconcat(OpcodeStr,
3293 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003294 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3295 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003296
3297 // Vector intrinsic operation, mem
Evan Cheng400073d2009-12-18 07:40:29 +00003298 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003299 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003300 !strconcat(OpcodeStr,
3301 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003302 [(set VR128:$dst,
3303 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Cheng400073d2009-12-18 07:40:29 +00003304 TA, OpSize,
Evan Chengb1f49812009-12-22 17:47:23 +00003305 Requires<[HasSSE41]>;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003306
Nate Begeman63ec90a2008-02-03 07:18:54 +00003307 // Vector intrinsic operation, reg
Evan Cheng172b7942008-03-14 07:39:27 +00003308 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003309 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003310 !strconcat(OpcodeStr,
3311 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003312 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3313 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003314
3315 // Vector intrinsic operation, mem
Evan Cheng172b7942008-03-14 07:39:27 +00003316 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003317 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003318 !strconcat(OpcodeStr,
3319 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003320 [(set VR128:$dst,
3321 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003322 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003323}
3324
Dale Johannesene397acc2008-10-10 23:51:03 +00003325let Constraints = "$src1 = $dst" in {
3326multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3327 string OpcodeStr,
3328 Intrinsic F32Int,
3329 Intrinsic F64Int> {
3330 // Intrinsic operation, reg.
3331 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003332 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003333 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3334 !strconcat(OpcodeStr,
3335 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003336 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003337 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3338 OpSize;
3339
3340 // Intrinsic operation, mem.
Eric Christopher44b93ff2009-07-31 20:07:27 +00003341 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3342 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003343 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003344 !strconcat(OpcodeStr,
Dale Johannesene397acc2008-10-10 23:51:03 +00003345 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003346 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003347 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3348 OpSize;
3349
3350 // Intrinsic operation, reg.
3351 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003352 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003353 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3354 !strconcat(OpcodeStr,
3355 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003356 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003357 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3358 OpSize;
3359
3360 // Intrinsic operation, mem.
3361 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003362 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003363 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3364 !strconcat(OpcodeStr,
3365 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003366 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003367 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3368 OpSize;
3369}
3370}
3371
Nate Begeman63ec90a2008-02-03 07:18:54 +00003372// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesene397acc2008-10-10 23:51:03 +00003373defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3374 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3375defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3376 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003377
3378// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3379multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3380 Intrinsic IntId128> {
3381 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3382 (ins VR128:$src),
3383 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3384 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3385 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3386 (ins i128mem:$src),
3387 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3388 [(set VR128:$dst,
3389 (IntId128
3390 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3391}
3392
3393defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3394 int_x86_sse41_phminposuw>;
3395
3396/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003397let Constraints = "$src1 = $dst" in {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003398 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3399 Intrinsic IntId128, bit Commutable = 0> {
Nate Begemanfea2be52008-02-09 23:46:37 +00003400 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3401 (ins VR128:$src1, VR128:$src2),
3402 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3403 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3404 OpSize {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003405 let isCommutable = Commutable;
3406 }
Nate Begemanfea2be52008-02-09 23:46:37 +00003407 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3408 (ins VR128:$src1, i128mem:$src2),
3409 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3410 [(set VR128:$dst,
3411 (IntId128 VR128:$src1,
3412 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003413 }
3414}
3415
3416defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3417 int_x86_sse41_pcmpeqq, 1>;
3418defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3419 int_x86_sse41_packusdw, 0>;
3420defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3421 int_x86_sse41_pminsb, 1>;
3422defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3423 int_x86_sse41_pminsd, 1>;
3424defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3425 int_x86_sse41_pminud, 1>;
3426defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3427 int_x86_sse41_pminuw, 1>;
3428defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3429 int_x86_sse41_pmaxsb, 1>;
3430defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3431 int_x86_sse41_pmaxsd, 1>;
3432defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3433 int_x86_sse41_pmaxud, 1>;
3434defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3435 int_x86_sse41_pmaxuw, 1>;
Nate Begeman204e84e2008-02-04 06:00:24 +00003436
Mon P Wangaf9b9522008-12-18 21:42:19 +00003437defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3438
Nate Begeman30a0de92008-07-17 16:51:19 +00003439def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3440 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3441def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3442 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3443
Nate Begeman1426d522008-02-09 01:38:08 +00003444/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003445let Constraints = "$src1 = $dst" in {
Dan Gohman0b924dc2008-05-23 17:49:40 +00003446 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3447 SDNode OpNode, Intrinsic IntId128,
3448 bit Commutable = 0> {
Nate Begeman1426d522008-02-09 01:38:08 +00003449 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3450 (ins VR128:$src1, VR128:$src2),
3451 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman0b924dc2008-05-23 17:49:40 +00003452 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3453 VR128:$src2))]>, OpSize {
Nate Begeman1426d522008-02-09 01:38:08 +00003454 let isCommutable = Commutable;
3455 }
3456 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3457 (ins VR128:$src1, VR128:$src2),
3458 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3459 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3460 OpSize {
3461 let isCommutable = Commutable;
3462 }
3463 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3464 (ins VR128:$src1, i128mem:$src2),
3465 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3466 [(set VR128:$dst,
Chris Lattner1a7d0872010-02-18 06:33:42 +00003467 (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003468 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3469 (ins VR128:$src1, i128mem:$src2),
3470 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3471 [(set VR128:$dst,
Evan Chengb1938262008-05-23 00:37:07 +00003472 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman1426d522008-02-09 01:38:08 +00003473 OpSize;
3474 }
3475}
Eric Christopher8258d0b2010-03-30 18:49:01 +00003476
3477/// SS48I_binop_rm - Simple SSE41 binary operator.
3478let Constraints = "$src1 = $dst" in {
3479multiclass SS48I_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
3480 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00003481 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
Eric Christopher8258d0b2010-03-30 18:49:01 +00003482 (ins VR128:$src1, VR128:$src2),
3483 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3484 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>,
3485 OpSize {
3486 let isCommutable = Commutable;
3487 }
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00003488 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
Eric Christopher8258d0b2010-03-30 18:49:01 +00003489 (ins VR128:$src1, i128mem:$src2),
3490 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3491 [(set VR128:$dst, (OpNode VR128:$src1,
3492 (bc_v4i32 (memopv2i64 addr:$src2))))]>,
3493 OpSize;
3494}
3495}
3496
3497defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003498
Evan Cheng172b7942008-03-14 07:39:27 +00003499/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Chenge9083d62008-03-05 08:19:16 +00003500let Constraints = "$src1 = $dst" in {
Nate Begeman204e84e2008-02-04 06:00:24 +00003501 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3502 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng172b7942008-03-14 07:39:27 +00003503 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003504 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003505 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003506 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003507 [(set VR128:$dst,
Nate Begemanfea2be52008-02-09 23:46:37 +00003508 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3509 OpSize {
Nate Begeman204e84e2008-02-04 06:00:24 +00003510 let isCommutable = Commutable;
3511 }
Evan Cheng172b7942008-03-14 07:39:27 +00003512 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003513 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3514 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003515 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begemanfea2be52008-02-09 23:46:37 +00003516 [(set VR128:$dst,
3517 (IntId128 VR128:$src1,
3518 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3519 OpSize;
Nate Begeman204e84e2008-02-04 06:00:24 +00003520 }
3521}
3522
3523defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3524 int_x86_sse41_blendps, 0>;
3525defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3526 int_x86_sse41_blendpd, 0>;
3527defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3528 int_x86_sse41_pblendw, 0>;
3529defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3530 int_x86_sse41_dpps, 1>;
3531defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3532 int_x86_sse41_dppd, 1>;
3533defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Eric Christopher419e2232010-04-08 00:52:02 +00003534 int_x86_sse41_mpsadbw, 0>;
Nate Begeman1426d522008-02-09 01:38:08 +00003535
Nate Begemanfea2be52008-02-09 23:46:37 +00003536
Evan Cheng172b7942008-03-14 07:39:27 +00003537/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003538let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanab5d56c2008-02-10 18:47:57 +00003539 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3540 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3541 (ins VR128:$src1, VR128:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003542 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003543 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3544 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3545 OpSize;
3546
3547 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3548 (ins VR128:$src1, i128mem:$src2),
3549 !strconcat(OpcodeStr,
3550 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3551 [(set VR128:$dst,
3552 (IntId VR128:$src1,
3553 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3554 }
3555}
3556
3557defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3558defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3559defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3560
3561
Nate Begemanfea2be52008-02-09 23:46:37 +00003562multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3563 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3564 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3565 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3566
3567 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3568 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003569 [(set VR128:$dst,
3570 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3571 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003572}
3573
3574defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3575defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3576defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3577defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3578defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3579defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3580
Evan Chengca57f782008-09-24 23:27:55 +00003581// Common patterns involving scalar load.
3582def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3583 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3584def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3585 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3586
3587def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3588 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3589def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3590 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3591
3592def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3593 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3594def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3595 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3596
3597def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3598 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3599def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3600 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3601
3602def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3603 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3604def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3605 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3606
3607def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3608 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3609def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3610 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3611
3612
Nate Begemanfea2be52008-02-09 23:46:37 +00003613multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3614 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3615 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3616 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3617
3618 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3619 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003620 [(set VR128:$dst,
3621 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3622 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003623}
3624
3625defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3626defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3627defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3628defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3629
Evan Chengca57f782008-09-24 23:27:55 +00003630// Common patterns involving scalar load
3631def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003632 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003633def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003634 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003635
3636def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003637 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003638def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003639 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003640
3641
Nate Begemanfea2be52008-02-09 23:46:37 +00003642multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3643 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3644 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3645 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3646
Evan Chengca57f782008-09-24 23:27:55 +00003647 // Expecting a i16 load any extended to i32 value.
Nate Begemanfea2be52008-02-09 23:46:37 +00003648 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3649 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003650 [(set VR128:$dst, (IntId (bitconvert
3651 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3652 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003653}
3654
3655defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman9d47b8d2009-06-06 05:55:37 +00003656defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begemanfea2be52008-02-09 23:46:37 +00003657
Evan Chengca57f782008-09-24 23:27:55 +00003658// Common patterns involving scalar load
3659def : Pat<(int_x86_sse41_pmovsxbq
3660 (bitconvert (v4i32 (X86vzmovl
3661 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003662 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003663
3664def : Pat<(int_x86_sse41_pmovzxbq
3665 (bitconvert (v4i32 (X86vzmovl
3666 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003667 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003668
Nate Begemanfea2be52008-02-09 23:46:37 +00003669
Nate Begeman14d12ca2008-02-11 04:19:36 +00003670/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3671multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003672 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003673 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003674 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003675 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003676 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3677 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003678 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003679 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003680 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003681 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003682 []>, OpSize;
3683// FIXME:
3684// There's an AssertZext in the way of writing the store pattern
3685// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begemanfea2be52008-02-09 23:46:37 +00003686}
3687
Nate Begeman14d12ca2008-02-11 04:19:36 +00003688defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003689
Nate Begeman14d12ca2008-02-11 04:19:36 +00003690
3691/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3692multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003693 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003694 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003695 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003696 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3697 []>, OpSize;
3698// FIXME:
3699// There's an AssertZext in the way of writing the store pattern
3700// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3701}
3702
3703defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3704
3705
3706/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3707multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003708 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003709 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003710 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003711 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3712 [(set GR32:$dst,
3713 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003714 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003715 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003716 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003717 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3718 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3719 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003720}
3721
Nate Begeman14d12ca2008-02-11 04:19:36 +00003722defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman1426d522008-02-09 01:38:08 +00003723
Nate Begeman14d12ca2008-02-11 04:19:36 +00003724
Evan Cheng62a3f152008-03-24 21:52:23 +00003725/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3726/// destination
Nate Begeman14d12ca2008-02-11 04:19:36 +00003727multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003728 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003729 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003730 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003731 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman171c11e2008-04-16 02:32:24 +00003732 [(set GR32:$dst,
3733 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng62a3f152008-03-24 21:52:23 +00003734 OpSize;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003735 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003736 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003737 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003738 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng62a3f152008-03-24 21:52:23 +00003739 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begemanfea2be52008-02-09 23:46:37 +00003740 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003741}
3742
Nate Begeman14d12ca2008-02-11 04:19:36 +00003743defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003744
Dan Gohmand9ced092008-08-08 18:30:21 +00003745// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3746def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3747 imm:$src2))),
3748 addr:$dst),
3749 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3750 Requires<[HasSSE41]>;
3751
Evan Chenge9083d62008-03-05 08:19:16 +00003752let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003753 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003754 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003755 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003756 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003757 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003758 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003759 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003760 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003761 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3762 !strconcat(OpcodeStr,
3763 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003764 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003765 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3766 imm:$src3))]>, OpSize;
3767 }
3768}
3769
3770defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3771
Evan Chenge9083d62008-03-05 08:19:16 +00003772let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003773 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003774 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003775 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003776 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003777 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003778 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003779 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3780 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003781 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003782 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3783 !strconcat(OpcodeStr,
3784 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003785 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003786 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3787 imm:$src3)))]>, OpSize;
3788 }
3789}
3790
3791defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3792
Eric Christopher1e5cdea2009-07-23 02:22:41 +00003793// insertps has a few different modes, there's the first two here below which
3794// are optimized inserts that won't zero arbitrary elements in the destination
3795// vector. The next one matches the intrinsic and could zero arbitrary elements
3796// in the target vector.
Evan Chenge9083d62008-03-05 08:19:16 +00003797let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003798 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherfbd66872009-07-24 00:33:09 +00003799 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3800 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003801 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003802 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003803 [(set VR128:$dst,
3804 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003805 OpSize;
Eric Christopherfbd66872009-07-24 00:33:09 +00003806 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003807 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3808 !strconcat(OpcodeStr,
3809 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003810 [(set VR128:$dst,
Eric Christopherfbd66872009-07-24 00:33:09 +00003811 (X86insrtps VR128:$src1,
3812 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003813 imm:$src3))]>, OpSize;
3814 }
3815}
3816
Evan Cheng7aae8762008-03-26 08:11:49 +00003817defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003818
Eric Christopherfbd66872009-07-24 00:33:09 +00003819def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3820 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3821
Eric Christopher71c67532009-07-29 00:28:05 +00003822// ptest instruction we'll lower to this in X86ISelLowering primarily from
3823// the intel intrinsic that corresponds to this.
Nate Begemanbc4efb82008-03-16 21:14:46 +00003824let Defs = [EFLAGS] in {
3825def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003826 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003827 [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>,
3828 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003829def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003830 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003831 [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>,
3832 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003833}
3834
3835def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3836 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderby40fe18f2010-02-10 00:10:31 +00003837 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3838 OpSize;
Nate Begeman30a0de92008-07-17 16:51:19 +00003839
Eric Christopherb120ab42009-08-18 22:50:32 +00003840
3841//===----------------------------------------------------------------------===//
3842// SSE4.2 Instructions
3843//===----------------------------------------------------------------------===//
3844
Nate Begeman30a0de92008-07-17 16:51:19 +00003845/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3846let Constraints = "$src1 = $dst" in {
3847 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3848 Intrinsic IntId128, bit Commutable = 0> {
3849 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3850 (ins VR128:$src1, VR128:$src2),
3851 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3852 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3853 OpSize {
3854 let isCommutable = Commutable;
3855 }
3856 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3857 (ins VR128:$src1, i128mem:$src2),
3858 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3859 [(set VR128:$dst,
3860 (IntId128 VR128:$src1,
3861 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3862 }
3863}
3864
Nate Begemane99b2552008-07-17 17:04:58 +00003865defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman30a0de92008-07-17 16:51:19 +00003866
3867def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3868 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3869def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3870 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003871
3872// crc intrinsic instruction
3873// This set of instructions are only rm, the only difference is the size
3874// of r and m.
3875let Constraints = "$src1 = $dst" in {
Eric Christopher027c2b12009-08-10 21:48:58 +00003876 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003877 (ins GR32:$src1, i8mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003878 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003879 [(set GR32:$dst,
3880 (int_x86_sse42_crc32_8 GR32:$src1,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003881 (load addr:$src2)))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003882 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003883 (ins GR32:$src1, GR8:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003884 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003885 [(set GR32:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003886 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003887 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003888 (ins GR32:$src1, i16mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003889 "crc32{w} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003890 [(set GR32:$dst,
3891 (int_x86_sse42_crc32_16 GR32:$src1,
3892 (load addr:$src2)))]>,
3893 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003894 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003895 (ins GR32:$src1, GR16:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003896 "crc32{w} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003897 [(set GR32:$dst,
Eric Christopher027c2b12009-08-10 21:48:58 +00003898 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003899 OpSize;
Eric Christopher027c2b12009-08-10 21:48:58 +00003900 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003901 (ins GR32:$src1, i32mem:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003902 "crc32{l} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003903 [(set GR32:$dst,
3904 (int_x86_sse42_crc32_32 GR32:$src1,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003905 (load addr:$src2)))]>;
Eric Christopher027c2b12009-08-10 21:48:58 +00003906 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003907 (ins GR32:$src1, GR32:$src2),
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003908 "crc32{l} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003909 [(set GR32:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003910 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>;
3911 def CRC64m8 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
3912 (ins GR64:$src1, i8mem:$src2),
3913 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003914 [(set GR64:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003915 (int_x86_sse42_crc64_8 GR64:$src1,
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003916 (load addr:$src2)))]>,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003917 REX_W;
3918 def CRC64r8 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
3919 (ins GR64:$src1, GR8:$src2),
3920 "crc32{b} \t{$src2, $src1|$src1, $src2}",
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003921 [(set GR64:$dst,
Kevin Enderbyb46b03b2010-03-19 20:04:42 +00003922 (int_x86_sse42_crc64_8 GR64:$src1, GR8:$src2))]>,
3923 REX_W;
3924 def CRC64m64 : SS42FI<0xF1, MRMSrcMem, (outs GR64:$dst),
3925 (ins GR64:$src1, i64mem:$src2),
3926 "crc32{q} \t{$src2, $src1|$src1, $src2}",
3927 [(set GR64:$dst,
3928 (int_x86_sse42_crc64_64 GR64:$src1,
3929 (load addr:$src2)))]>,
3930 REX_W;
3931 def CRC64r64 : SS42FI<0xF1, MRMSrcReg, (outs GR64:$dst),
3932 (ins GR64:$src1, GR64:$src2),
3933 "crc32{q} \t{$src2, $src1|$src1, $src2}",
3934 [(set GR64:$dst,
3935 (int_x86_sse42_crc64_64 GR64:$src1, GR64:$src2))]>,
3936 REX_W;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003937}
Eric Christopherb120ab42009-08-18 22:50:32 +00003938
3939// String/text processing instructions.
Dan Gohman533297b2009-10-29 18:10:34 +00003940let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003941def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003942 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3943 "#PCMPISTRM128rr PSEUDO!",
3944 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3945 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003946def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003947 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3948 "#PCMPISTRM128rm PSEUDO!",
3949 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3950 imm:$src3))]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003951}
3952
3953let Defs = [XMM0, EFLAGS] in {
3954def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003955 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3956 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003957def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003958 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3959 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003960}
3961
Sean Callanan108934c2009-12-18 00:01:26 +00003962let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopherb120ab42009-08-18 22:50:32 +00003963def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003964 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3965 "#PCMPESTRM128rr PSEUDO!",
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00003966 [(set VR128:$dst,
3967 (int_x86_sse42_pcmpestrm128
Sean Callanan108934c2009-12-18 00:01:26 +00003968 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3969
Eric Christopherb120ab42009-08-18 22:50:32 +00003970def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00003971 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3972 "#PCMPESTRM128rm PSEUDO!",
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00003973 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3974 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003975 OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003976}
3977
3978let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callanan47234e62009-08-20 18:24:27 +00003979def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003980 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3981 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callanan47234e62009-08-20 18:24:27 +00003982def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003983 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3984 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003985}
3986
3987let Defs = [ECX, EFLAGS] in {
3988 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00003989 def rr : SS42AI<0x63, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003990 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3991 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3992 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3993 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003994 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00003995 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3996 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3997 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3998 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00003999 }
4000}
4001
4002defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
4003defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
4004defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
4005defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
4006defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
4007defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
4008
4009let Defs = [ECX, EFLAGS] in {
4010let Uses = [EAX, EDX] in {
4011 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
4012 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00004013 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4014 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
4015 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
4016 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004017 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan108934c2009-12-18 00:01:26 +00004018 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4019 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00004020 [(set ECX,
Sean Callanan108934c2009-12-18 00:01:26 +00004021 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
4022 (implicit EFLAGS)]>, OpSize;
Eric Christopherb120ab42009-08-18 22:50:32 +00004023 }
4024}
4025}
4026
4027defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
4028defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
4029defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
4030defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
4031defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
4032defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004033
4034//===----------------------------------------------------------------------===//
4035// AES-NI Instructions
4036//===----------------------------------------------------------------------===//
4037
4038let Constraints = "$src1 = $dst" in {
4039 multiclass AESI_binop_rm_int<bits<8> opc, string OpcodeStr,
4040 Intrinsic IntId128, bit Commutable = 0> {
4041 def rr : AES8I<opc, MRMSrcReg, (outs VR128:$dst),
4042 (ins VR128:$src1, VR128:$src2),
4043 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4044 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
4045 OpSize {
4046 let isCommutable = Commutable;
4047 }
4048 def rm : AES8I<opc, MRMSrcMem, (outs VR128:$dst),
4049 (ins VR128:$src1, i128mem:$src2),
4050 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4051 [(set VR128:$dst,
4052 (IntId128 VR128:$src1,
4053 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4054 }
4055}
4056
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004057defm AESENC : AESI_binop_rm_int<0xDC, "aesenc",
4058 int_x86_aesni_aesenc>;
4059defm AESENCLAST : AESI_binop_rm_int<0xDD, "aesenclast",
4060 int_x86_aesni_aesenclast>;
4061defm AESDEC : AESI_binop_rm_int<0xDE, "aesdec",
4062 int_x86_aesni_aesdec>;
4063defm AESDECLAST : AESI_binop_rm_int<0xDF, "aesdeclast",
4064 int_x86_aesni_aesdeclast>;
4065
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004066def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, VR128:$src2)),
4067 (AESENCrr VR128:$src1, VR128:$src2)>;
4068def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, (memop addr:$src2))),
4069 (AESENCrm VR128:$src1, addr:$src2)>;
4070def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, VR128:$src2)),
4071 (AESENCLASTrr VR128:$src1, VR128:$src2)>;
4072def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, (memop addr:$src2))),
4073 (AESENCLASTrm VR128:$src1, addr:$src2)>;
4074def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, VR128:$src2)),
4075 (AESDECrr VR128:$src1, VR128:$src2)>;
4076def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, (memop addr:$src2))),
4077 (AESDECrm VR128:$src1, addr:$src2)>;
4078def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, VR128:$src2)),
4079 (AESDECLASTrr VR128:$src1, VR128:$src2)>;
4080def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, (memop addr:$src2))),
4081 (AESDECLASTrm VR128:$src1, addr:$src2)>;
4082
Eric Christopherb3500fd2010-04-02 23:48:33 +00004083def AESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst),
4084 (ins VR128:$src1),
4085 "aesimc\t{$src1, $dst|$dst, $src1}",
4086 [(set VR128:$dst,
4087 (int_x86_aesni_aesimc VR128:$src1))]>,
4088 OpSize;
4089
4090def AESIMCrm : AES8I<0xDB, MRMSrcMem, (outs VR128:$dst),
4091 (ins i128mem:$src1),
4092 "aesimc\t{$src1, $dst|$dst, $src1}",
4093 [(set VR128:$dst,
4094 (int_x86_aesni_aesimc (bitconvert (memopv2i64 addr:$src1))))]>,
4095 OpSize;
4096
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004097def AESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst),
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00004098 (ins VR128:$src1, i8imm:$src2),
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004099 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4100 [(set VR128:$dst,
4101 (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>,
4102 OpSize;
4103def AESKEYGENASSIST128rm : AESAI<0xDF, MRMSrcMem, (outs VR128:$dst),
Eric Christopher7e2f5aa2010-05-25 17:33:22 +00004104 (ins i128mem:$src1, i8imm:$src2),
Eric Christopher6d1cd1c2010-04-02 21:54:27 +00004105 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4106 [(set VR128:$dst,
4107 (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)),
4108 imm:$src2))]>,
4109 OpSize;