blob: 0e6a4f9701f4abab78c183e557019a4e8bdf8aad [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
Bob Wilson86afec72010-03-25 16:36:14 +000072def X86aesimc : SDNode<"X86ISD::AESIMC", SDTIntBinOp>;
73def X86aesenc : SDNode<"X86ISD::AESENC", SDTIntBinOp>;
74def X86aesenclast : SDNode<"X86ISD::AESENCLAST", SDTIntBinOp>;
75def X86aesdec : SDNode<"X86ISD::AESDEC", SDTIntBinOp>;
76def X86aesdeclast : SDNode<"X86ISD::AESDECLAST", SDTIntBinOp>;
77
Chris Lattnerd486d772010-03-28 05:07:17 +000078def SDTX86CmpPTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>,
79 SDTCisVT<1, v4f32>,
80 SDTCisVT<2, v4f32>]>;
Eric Christopher71c67532009-07-29 00:28:05 +000081def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
82
Evan Cheng2246f842006-03-18 01:23:20 +000083//===----------------------------------------------------------------------===//
Chris Lattner3a7cd952006-10-07 21:55:32 +000084// SSE Complex Patterns
85//===----------------------------------------------------------------------===//
86
87// These are 'extloads' from a scalar to the low element of a vector, zeroing
88// the top elements. These are used for the SSE 'ss' and 'sd' instruction
89// forms.
Rafael Espindola094fad32009-04-08 21:14:34 +000090def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000091 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindola094fad32009-04-08 21:14:34 +000092def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerba7e7562008-01-10 07:59:24 +000093 [SDNPHasChain, SDNPMayLoad]>;
Chris Lattner3a7cd952006-10-07 21:55:32 +000094
95def ssmem : Operand<v4f32> {
96 let PrintMethod = "printf32mem";
Dan Gohmana4714e02009-07-30 01:56:29 +000097 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +000098 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +000099}
100def sdmem : Operand<v2f64> {
101 let PrintMethod = "printf64mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000102 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000103 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner3a7cd952006-10-07 21:55:32 +0000104}
105
106//===----------------------------------------------------------------------===//
Evan Cheng06a8aa12006-03-17 19:55:52 +0000107// SSE pattern fragments
108//===----------------------------------------------------------------------===//
109
Evan Cheng2246f842006-03-18 01:23:20 +0000110def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
111def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
Dan Gohman01976302007-06-25 15:19:03 +0000112def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
Evan Cheng24dc1f52006-03-23 07:44:07 +0000113def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000114
Dan Gohmand3006222007-07-27 17:16:43 +0000115// Like 'store', but always requires vector alignment.
Dan Gohman4106f372007-07-18 20:23:34 +0000116def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman33586292008-10-15 06:50:19 +0000117 (store node:$val, node:$ptr), [{
118 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000119}]>;
120
Dan Gohmand3006222007-07-27 17:16:43 +0000121// Like 'load', but always requires vector alignment.
Dan Gohman33586292008-10-15 06:50:19 +0000122def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
123 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000124}]>;
125
Sean Callanan108934c2009-12-18 00:01:26 +0000126def alignedloadfsf32 : PatFrag<(ops node:$ptr),
127 (f32 (alignedload node:$ptr))>;
128def alignedloadfsf64 : PatFrag<(ops node:$ptr),
129 (f64 (alignedload node:$ptr))>;
130def alignedloadv4f32 : PatFrag<(ops node:$ptr),
131 (v4f32 (alignedload node:$ptr))>;
132def alignedloadv2f64 : PatFrag<(ops node:$ptr),
133 (v2f64 (alignedload node:$ptr))>;
134def alignedloadv4i32 : PatFrag<(ops node:$ptr),
135 (v4i32 (alignedload node:$ptr))>;
136def alignedloadv2i64 : PatFrag<(ops node:$ptr),
137 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000138
139// Like 'load', but uses special alignment checks suitable for use in
140// memory operands in most SSE instructions, which are required to
David Greene95eb2ee2010-01-11 16:29:42 +0000141// be naturally aligned on some targets but not on others. If the subtarget
142// allows unaligned accesses, match any load, though this may require
143// setting a feature bit in the processor (on startup, for example).
144// Opteron 10h and later implement such a feature.
Dan Gohman33586292008-10-15 06:50:19 +0000145def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
David Greene95eb2ee2010-01-11 16:29:42 +0000146 return Subtarget->hasVectorUAMem()
147 || cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4106f372007-07-18 20:23:34 +0000148}]>;
149
Dan Gohmand3006222007-07-27 17:16:43 +0000150def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
151def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000152def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
153def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
154def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
155def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begemanfea2be52008-02-09 23:46:37 +0000156def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4106f372007-07-18 20:23:34 +0000157
Bill Wendling01284b42007-08-11 09:52:53 +0000158// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
159// 16-byte boundary.
Nate Begemanfea2be52008-02-09 23:46:37 +0000160// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohmana7250dd2008-10-16 00:03:00 +0000161def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman33586292008-10-15 06:50:19 +0000162 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling01284b42007-08-11 09:52:53 +0000163}]>;
164
165def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling01284b42007-08-11 09:52:53 +0000166def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
167def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
168def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
169
David Greene8939b0d2010-02-16 20:50:18 +0000170// MOVNT Support
171// Like 'store', but requires the non-temporal bit to be set
172def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
173 (st node:$val, node:$ptr), [{
174 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
175 return ST->isNonTemporal();
176 return false;
177}]>;
178
179def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
180 (st node:$val, node:$ptr), [{
181 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
182 return ST->isNonTemporal() && !ST->isTruncatingStore() &&
183 ST->getAddressingMode() == ISD::UNINDEXED &&
184 ST->getAlignment() >= 16;
185 return false;
186}]>;
187
188def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
189 (st node:$val, node:$ptr), [{
190 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
191 return ST->isNonTemporal() &&
192 ST->getAlignment() < 16;
193 return false;
194}]>;
195
Evan Cheng1b32f222006-03-30 07:33:32 +0000196def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
197def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
Evan Cheng506d3df2006-03-29 23:07:14 +0000198def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
199def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
Evan Cheng5aa97b22006-03-29 18:47:40 +0000200def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
201def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
202
Evan Chengca57f782008-09-24 23:27:55 +0000203def vzmovl_v2i64 : PatFrag<(ops node:$src),
204 (bitconvert (v2i64 (X86vzmovl
205 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
206def vzmovl_v4i32 : PatFrag<(ops node:$src),
207 (bitconvert (v4i32 (X86vzmovl
208 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
209
210def vzload_v2i64 : PatFrag<(ops node:$src),
211 (bitconvert (v2i64 (X86vzload node:$src)))>;
212
213
Evan Cheng386031a2006-03-24 07:29:27 +0000214def fp32imm0 : PatLeaf<(f32 fpimm), [{
215 return N->isExactlyValue(+0.0);
216}]>;
217
Evan Cheng89321162009-10-28 06:30:34 +0000218// BYTE_imm - Transform bit immediates into byte immediates.
219def BYTE_imm : SDNodeXForm<imm, [{
Evan Chengff65e382006-04-04 21:49:39 +0000220 // Transformation function: imm >> 3
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000221 return getI32Imm(N->getZExtValue() >> 3);
Evan Chengff65e382006-04-04 21:49:39 +0000222}]>;
223
Evan Cheng63d33002006-03-22 08:01:21 +0000224// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
225// SHUFP* etc. imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000226def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng63d33002006-03-22 08:01:21 +0000227 return getI8Imm(X86::getShuffleSHUFImmediate(N));
Evan Chengb9df0ca2006-03-22 02:53:00 +0000228}]>;
229
Eric Christopher44b93ff2009-07-31 20:07:27 +0000230// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000231// PSHUFHW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000232def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000233 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
234}]>;
235
Eric Christopher44b93ff2009-07-31 20:07:27 +0000236// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Evan Cheng506d3df2006-03-29 23:07:14 +0000237// PSHUFLW imm.
Nate Begeman9008ca62009-04-27 18:41:29 +0000238def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Evan Cheng506d3df2006-03-29 23:07:14 +0000239 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
240}]>;
241
Nate Begemana09008b2009-10-19 02:17:23 +0000242// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
243// a PALIGNR imm.
244def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
245 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
246}]>;
247
Nate Begeman9008ca62009-04-27 18:41:29 +0000248def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
251 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
252}]>;
253
254def movddup : PatFrag<(ops node:$lhs, node:$rhs),
255 (vector_shuffle node:$lhs, node:$rhs), [{
256 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
257}]>;
258
259def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
260 (vector_shuffle node:$lhs, node:$rhs), [{
261 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
262}]>;
263
264def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
265 (vector_shuffle node:$lhs, node:$rhs), [{
266 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
267}]>;
268
Nate Begeman0b10b912009-11-07 23:17:15 +0000269def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
270 (vector_shuffle node:$lhs, node:$rhs), [{
271 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman9008ca62009-04-27 18:41:29 +0000272}]>;
273
274def movlp : PatFrag<(ops node:$lhs, node:$rhs),
275 (vector_shuffle node:$lhs, node:$rhs), [{
276 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
277}]>;
278
279def movl : PatFrag<(ops node:$lhs, node:$rhs),
280 (vector_shuffle node:$lhs, node:$rhs), [{
281 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
282}]>;
283
284def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
285 (vector_shuffle node:$lhs, node:$rhs), [{
286 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
287}]>;
288
289def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
290 (vector_shuffle node:$lhs, node:$rhs), [{
291 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
292}]>;
293
294def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
295 (vector_shuffle node:$lhs, node:$rhs), [{
296 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
297}]>;
298
299def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
300 (vector_shuffle node:$lhs, node:$rhs), [{
301 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
302}]>;
303
304def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
305 (vector_shuffle node:$lhs, node:$rhs), [{
306 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
307}]>;
308
309def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
310 (vector_shuffle node:$lhs, node:$rhs), [{
311 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
312}]>;
313
314def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
315 (vector_shuffle node:$lhs, node:$rhs), [{
316 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng691c9232006-03-29 19:02:40 +0000317}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000318
Nate Begeman9008ca62009-04-27 18:41:29 +0000319def shufp : PatFrag<(ops node:$lhs, node:$rhs),
320 (vector_shuffle node:$lhs, node:$rhs), [{
321 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng14aed5e2006-03-24 01:18:28 +0000322}], SHUFFLE_get_shuf_imm>;
Evan Cheng0188ecb2006-03-22 18:59:22 +0000323
Nate Begeman9008ca62009-04-27 18:41:29 +0000324def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
325 (vector_shuffle node:$lhs, node:$rhs), [{
326 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000327}], SHUFFLE_get_pshufhw_imm>;
328
Nate Begeman9008ca62009-04-27 18:41:29 +0000329def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
330 (vector_shuffle node:$lhs, node:$rhs), [{
331 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Evan Cheng506d3df2006-03-29 23:07:14 +0000332}], SHUFFLE_get_pshuflw_imm>;
333
Nate Begemana09008b2009-10-19 02:17:23 +0000334def palign : PatFrag<(ops node:$lhs, node:$rhs),
335 (vector_shuffle node:$lhs, node:$rhs), [{
336 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
337}], SHUFFLE_get_palign_imm>;
338
Evan Cheng06a8aa12006-03-17 19:55:52 +0000339//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000340// SSE scalar FP Instructions
341//===----------------------------------------------------------------------===//
342
Dan Gohman533297b2009-10-29 18:10:34 +0000343// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
344// instruction selection into a branch sequence.
345let Uses = [EFLAGS], usesCustomInserter = 1 in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000346 def CMOV_FR32 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000347 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000348 "#CMOV_FR32 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000349 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
350 EFLAGS))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000351 def CMOV_FR64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000352 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000353 "#CMOV_FR64 PSEUDO!",
Evan Chenge5f62042007-09-29 00:00:36 +0000354 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
355 EFLAGS))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000356 def CMOV_V4F32 : 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_V4F32 PSEUDO!",
359 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000360 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
361 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000362 def CMOV_V2F64 : 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_V2F64 PSEUDO!",
365 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000366 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
367 EFLAGS)))]>;
Evan Chengf7c378e2006-04-10 07:23:14 +0000368 def CMOV_V2I64 : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +0000369 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Evan Chengf7c378e2006-04-10 07:23:14 +0000370 "#CMOV_V2I64 PSEUDO!",
371 [(set VR128:$dst,
Evan Chenge5f62042007-09-29 00:00:36 +0000372 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng0488db92007-09-25 01:57:46 +0000373 EFLAGS)))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000374}
375
Bill Wendlingddd35322007-05-02 23:11:52 +0000376//===----------------------------------------------------------------------===//
377// SSE1 Instructions
378//===----------------------------------------------------------------------===//
379
Dan Gohman874cada2010-02-28 00:17:42 +0000380// Move Instructions. Register-to-register movss is not used for FR32
381// register copies because it's a partial register update; FsMOVAPSrr is
382// used instead. Register-to-register movss is not modeled as an INSERT_SUBREG
383// because INSERT_SUBREG requires that the insert be implementable in terms of
384// a copy, and just mentioned, we don't use movss for copies.
385let Constraints = "$src1 = $dst" in
386def MOVSSrr : SSI<0x10, MRMSrcReg,
387 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
388 "movss\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +0000389 [(set (v4f32 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +0000390 (movl VR128:$src1, (scalar_to_vector FR32:$src2)))]>;
391
392// Extract the low 32-bit value from one vector and insert it into another.
393let AddedComplexity = 15 in
394def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +0000395 (MOVSSrr (v4f32 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +0000396 (EXTRACT_SUBREG (v4f32 VR128:$src2), x86_subreg_ss))>;
397
398// Implicitly promote a 32-bit scalar to a vector.
399def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
400 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, x86_subreg_ss)>;
401
402// Loading from memory automatically zeroing upper bits.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000403let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000404def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000405 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000406 [(set FR32:$dst, (loadf32 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +0000407
408// MOVSSrm zeros the high parts of the register; represent this
409// with SUBREG_TO_REG.
410let AddedComplexity = 20 in {
411def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
412 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
413def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
414 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
415def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
416 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), x86_subreg_ss)>;
417}
418
419// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +0000420def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000421 "movss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000422 [(store FR32:$src, addr:$dst)]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000423
Dan Gohman874cada2010-02-28 00:17:42 +0000424// Extract and store.
425def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
426 addr:$dst),
427 (MOVSSmr addr:$dst,
428 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
429
Evan Chengc46349d2006-03-28 23:51:43 +0000430// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +0000431def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000432 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000433 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000434def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000435 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000436 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000437def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000438 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000439 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000440def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000441 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000442 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
Evan Chengc46349d2006-03-28 23:51:43 +0000443
Evan Chengd2a6d542006-04-12 23:42:44 +0000444// Match intrinsics which expect XMM operand(s).
Sean Callanan108934c2009-12-18 00:01:26 +0000445def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
446 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
447def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
448 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
449
Evan Cheng64d80e32007-07-19 01:14:50 +0000450def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000451 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000452 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000453def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000454 "cvtss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000455 [(set GR32:$dst, (int_x86_sse_cvtss2si
456 (load addr:$src)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000457
Dale Johannesenc7842082007-10-30 22:15:38 +0000458// Match intrinisics which expect MM and XMM operand(s).
459def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
460 "cvtps2pi\t{$src, $dst|$dst, $src}",
461 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
462def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
463 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000464 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000465 (load addr:$src)))]>;
466def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
467 "cvttps2pi\t{$src, $dst|$dst, $src}",
468 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
469def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
470 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000471 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesenc7842082007-10-30 22:15:38 +0000472 (load addr:$src)))]>;
Evan Chenge9083d62008-03-05 08:19:16 +0000473let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000474 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesenc7842082007-10-30 22:15:38 +0000475 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
476 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
477 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
478 VR64:$src2))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000479 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesenc7842082007-10-30 22:15:38 +0000480 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
481 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000482 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesenc7842082007-10-30 22:15:38 +0000483 (load addr:$src2)))]>;
484}
485
Evan Chengd2a6d542006-04-12 23:42:44 +0000486// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +0000487def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000488 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000489 [(set GR32:$dst,
490 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000491def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000492 "cvttss2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000493 [(set GR32:$dst,
494 (int_x86_sse_cvttss2si(load addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +0000495
Evan Chenge9083d62008-03-05 08:19:16 +0000496let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000497 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000498 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000499 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000500 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
501 GR32:$src2))]>;
502 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000503 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000504 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000505 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
506 (loadi32 addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +0000507}
Evan Chengd03db7a2006-04-12 05:20:24 +0000508
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000509// Comparison instructions
Dan Gohmanb1347092009-01-09 02:27:34 +0000510let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000511 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000512 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000513 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000514let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +0000515 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000516 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000517 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000518}
519
Evan Cheng24f2ea32007-09-14 21:48:26 +0000520let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000521def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000522 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000523 [(set EFLAGS, (X86cmp FR32:$src1, FR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000524def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000525 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000526 [(set EFLAGS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000527
528def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
529 "comiss\t{$src2, $src1|$src1, $src2}", []>;
530def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
531 "comiss\t{$src2, $src1|$src1, $src2}", []>;
532
Evan Cheng24f2ea32007-09-14 21:48:26 +0000533} // Defs = [EFLAGS]
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000534
Evan Cheng0876aa52006-03-30 06:21:22 +0000535// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +0000536let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +0000537 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +0000538 (outs VR128:$dst),
539 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000540 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +0000541 [(set VR128:$dst, (int_x86_sse_cmp_ss
542 VR128:$src1,
543 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000544 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +0000545 (outs VR128:$dst),
546 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000547 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000548 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
549 (load addr:$src), imm:$cc))]>;
Evan Cheng0876aa52006-03-30 06:21:22 +0000550}
551
Evan Cheng24f2ea32007-09-14 21:48:26 +0000552let Defs = [EFLAGS] in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000553def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000554 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000555 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
556 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000557def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000558 "ucomiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000559 [(set EFLAGS, (X86ucomi (v4f32 VR128:$src1),
560 (load addr:$src2)))]>;
Evan Cheng0488db92007-09-25 01:57:46 +0000561
Dan Gohmanb1347092009-01-09 02:27:34 +0000562def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000563 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000564 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
565 VR128:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000566def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000567 "comiss\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +0000568 [(set EFLAGS, (X86comi (v4f32 VR128:$src1),
569 (load addr:$src2)))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000570} // Defs = [EFLAGS]
Evan Cheng0876aa52006-03-30 06:21:22 +0000571
Eric Christopher44b93ff2009-07-31 20:07:27 +0000572// Aliases of packed SSE1 instructions for scalar use. These all have names
573// that start with 'Fs'.
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000574
575// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +0000576let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
577 canFoldAsLoad = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +0000578 // FIXME: Set encoding to pseudo!
Chris Lattnerbe1778f2010-02-05 21:34:18 +0000579def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
580 [(set FR32:$dst, fp32imm0)]>,
581 Requires<[HasSSE1]>, TB, OpSize;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000582
Bill Wendlingddd35322007-05-02 23:11:52 +0000583// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
584// disregarded.
Eric Christopher44b93ff2009-07-31 20:07:27 +0000585let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000586def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000587 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000588
Bill Wendlingddd35322007-05-02 23:11:52 +0000589// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
590// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000591let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000592def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000593 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +0000594 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000595
596// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +0000597let Constraints = "$src1 = $dst" in {
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000598let isCommutable = 1 in {
Dan Gohmanb1347092009-01-09 02:27:34 +0000599 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
600 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000601 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000602 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000603 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
604 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000605 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000606 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000607 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
608 (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000609 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000610 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000611}
Bill Wendlingddd35322007-05-02 23:11:52 +0000612
Dan Gohmanb1347092009-01-09 02:27:34 +0000613def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
614 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000615 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000616 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000617 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000618def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
619 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000620 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000621 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000622 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000623def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
624 (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000625 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000626 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +0000627 (memopfsf32 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +0000628
Chris Lattnerba7e7562008-01-10 07:59:24 +0000629let neverHasSideEffects = 1 in {
Dan Gohman32791e02007-06-25 15:44:19 +0000630def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000631 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000632 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000633let mayLoad = 1 in
Dan Gohman32791e02007-06-25 15:44:19 +0000634def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000635 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000636 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000637}
Chris Lattnerba7e7562008-01-10 07:59:24 +0000638}
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000639
Dan Gohman20382522007-07-10 00:05:58 +0000640/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000641///
Dan Gohman20382522007-07-10 00:05:58 +0000642/// In addition, we also have a special variant of the scalar form here to
643/// represent the associated intrinsic operation. This form is unlike the
644/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +0000645/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +0000646///
647/// These three forms can each be reg+reg or reg+mem, so there are a total of
648/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +0000649///
Evan Chenge9083d62008-03-05 08:19:16 +0000650let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000651multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
652 SDNode OpNode, Intrinsic F32Int,
653 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000654 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000655 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000656 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman32791e02007-06-25 15:44:19 +0000657 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000658 let isCommutable = Commutable;
659 }
660
661 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000662 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
663 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000664 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000665 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000666
Dan Gohman20382522007-07-10 00:05:58 +0000667 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000668 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
669 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000670 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000671 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
672 let isCommutable = Commutable;
673 }
674
675 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000676 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
677 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000678 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000679 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000680
681 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000682 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
683 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000684 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +0000685 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000686
Dan Gohman20382522007-07-10 00:05:58 +0000687 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000688 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
689 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000690 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +0000691 [(set VR128:$dst, (F32Int VR128:$src1,
692 sse_load_f32:$src2))]>;
693}
694}
695
696// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +0000697defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
698defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
699defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
700defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000701
Dan Gohman20382522007-07-10 00:05:58 +0000702/// sse1_fp_binop_rm - Other SSE1 binops
703///
704/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
705/// instructions for a full-vector intrinsic form. Operations that map
706/// onto C operators don't use this form since they just use the plain
707/// vector form instead of having a separate vector intrinsic form.
708///
709/// This provides a total of eight "instructions".
710///
Evan Chenge9083d62008-03-05 08:19:16 +0000711let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +0000712multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
713 SDNode OpNode,
714 Intrinsic F32Int,
715 Intrinsic V4F32Int,
716 bit Commutable = 0> {
717
718 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000719 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000720 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000721 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
722 let isCommutable = Commutable;
723 }
724
725 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000726 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
727 (ins FR32:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000728 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000729 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000730
Dan Gohman20382522007-07-10 00:05:58 +0000731 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000732 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
733 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000734 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000735 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
736 let isCommutable = Commutable;
737 }
738
739 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000740 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
741 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000742 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000743 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000744
745 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000746 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
747 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000748 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000749 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
750 let isCommutable = Commutable;
751 }
752
753 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000754 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
755 (ins VR128:$src1, ssmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000756 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000757 [(set VR128:$dst, (F32Int VR128:$src1,
758 sse_load_f32:$src2))]>;
759
760 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +0000761 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
762 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000763 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +0000764 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
765 let isCommutable = Commutable;
766 }
767
768 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +0000769 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
770 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000771 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +0000772 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000773}
774}
775
776defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
777 int_x86_sse_max_ss, int_x86_sse_max_ps>;
778defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
779 int_x86_sse_min_ss, int_x86_sse_min_ps>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000780
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000781//===----------------------------------------------------------------------===//
Evan Cheng9ab1ac52006-04-14 23:32:40 +0000782// SSE packed FP Instructions
Evan Chengc12e6c42006-03-19 09:38:54 +0000783
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000784// Move Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +0000785let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000786def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000787 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000788let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000789def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000790 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000791 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000792
Evan Cheng64d80e32007-07-19 01:14:50 +0000793def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000794 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000795 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000796
Chris Lattnerf77e0372008-01-11 06:59:07 +0000797let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000798def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000799 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000800let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000801def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000802 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000803 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000804def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000805 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000806 [(store (v4f32 VR128:$src), addr:$dst)]>;
807
808// Intrinsic forms of MOVUPS load and store
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000809let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000810def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000811 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000812 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000813def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000814 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +0000815 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000816
Evan Chenge9083d62008-03-05 08:19:16 +0000817let Constraints = "$src1 = $dst" in {
Dan Gohman32791e02007-06-25 15:44:19 +0000818 let AddedComplexity = 20 in {
819 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000820 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000821 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000822 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000823 (movlp VR128:$src1,
824 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000825 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000826 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000827 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +0000828 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000829 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +0000830 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohman32791e02007-06-25 15:44:19 +0000831 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000832} // Constraints = "$src1 = $dst"
Evan Cheng4fcb9222006-03-28 02:43:26 +0000833
Evan Chengb70ea0b2008-05-10 00:59:18 +0000834
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000835def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
Chris Lattner3485b512010-03-08 18:57:56 +0000836 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
Nate Begeman7cdba6d2010-02-12 01:10:45 +0000837
Evan Cheng64d80e32007-07-19 01:14:50 +0000838def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000839 "movlps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000840 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
Evan Cheng015188f2006-06-15 08:14:54 +0000841 (iPTR 0))), addr:$dst)]>;
Evan Cheng9bbfd4f2006-03-28 07:01:28 +0000842
Evan Cheng664ade72006-04-07 21:20:58 +0000843// v2f64 extract element 1 is always custom lowered to unpack high to low
844// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +0000845def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000846 "movhps\t{$src, $dst|$dst, $src}",
Evan Cheng664ade72006-04-07 21:20:58 +0000847 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +0000848 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
849 (undef)), (iPTR 0))), addr:$dst)]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000850
Evan Chenge9083d62008-03-05 08:19:16 +0000851let Constraints = "$src1 = $dst" in {
Evan Chengb7a75a52008-09-26 23:41:32 +0000852let AddedComplexity = 20 in {
Evan Cheng0af934e2009-05-12 20:17:52 +0000853def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
854 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000855 "movlhps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000856 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +0000857 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2c0dbd02006-03-24 02:58:06 +0000858
Evan Cheng0af934e2009-05-12 20:17:52 +0000859def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
860 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000861 "movhlps\t{$src2, $dst|$dst, $src2}",
Evan Cheng4fcb9222006-03-28 02:43:26 +0000862 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +0000863 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Evan Cheng2dadaea2006-04-19 20:37:34 +0000864} // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +0000865} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +0000866
Nate Begemanec8eee22009-04-29 22:47:44 +0000867let AddedComplexity = 20 in {
Nate Begeman9008ca62009-04-27 18:41:29 +0000868def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000869 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000870def : Pat<(v2i64 (movddup VR128:$src, (undef))),
Chris Lattner3485b512010-03-08 18:57:56 +0000871 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
Nate Begemanec8eee22009-04-29 22:47:44 +0000872}
Evan Cheng0b457f02008-09-25 20:50:48 +0000873
Bill Wendlingddd35322007-05-02 23:11:52 +0000874
875
Dan Gohman20382522007-07-10 00:05:58 +0000876// Arithmetic
877
878/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +0000879///
Dan Gohman20382522007-07-10 00:05:58 +0000880/// In addition, we also have a special variant of the scalar form here to
881/// represent the associated intrinsic operation. This form is unlike the
882/// plain scalar form, in that it takes an entire vector (instead of a
883/// scalar) and leaves the top elements undefined.
884///
885/// And, we have a special variant form for a full-vector intrinsic form.
886///
887/// These four forms can each have a reg or a mem operand, so there are a
888/// total of eight "instructions".
889///
890multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
891 SDNode OpNode,
892 Intrinsic F32Int,
893 Intrinsic V4F32Int,
894 bit Commutable = 0> {
895 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000896 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000897 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000898 [(set FR32:$dst, (OpNode FR32:$src))]> {
Bill Wendlingddd35322007-05-02 23:11:52 +0000899 let isCommutable = Commutable;
900 }
901
Dan Gohman20382522007-07-10 00:05:58 +0000902 // Scalar operation, mem.
Evan Cheng400073d2009-12-18 07:40:29 +0000903 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000904 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Cheng400073d2009-12-18 07:40:29 +0000905 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +0000906 Requires<[HasSSE1, OptForSize]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +0000907
Dan Gohman20382522007-07-10 00:05:58 +0000908 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000909 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000910 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000911 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
912 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +0000913 }
914
Dan Gohman20382522007-07-10 00:05:58 +0000915 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000916 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000917 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +0000918 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +0000919
920 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +0000921 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000922 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000923 [(set VR128:$dst, (F32Int VR128:$src))]> {
924 let isCommutable = Commutable;
925 }
926
927 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +0000928 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000929 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000930 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
931
932 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +0000933 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000934 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +0000935 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
936 let isCommutable = Commutable;
937 }
938
939 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +0000940 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000941 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +0000942 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000943}
944
Dan Gohman20382522007-07-10 00:05:58 +0000945// Square root.
946defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
947 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
948
949// Reciprocal approximations. Note that these typically require refinement
950// in order to obtain suitable precision.
951defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
952 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
953defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
954 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
955
Bill Wendlingddd35322007-05-02 23:11:52 +0000956// Logical
Evan Chenge9083d62008-03-05 08:19:16 +0000957let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +0000958 let isCommutable = 1 in {
959 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000960 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000961 "andps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000962 [(set VR128:$dst, (v2i64
963 (and VR128:$src1, VR128:$src2)))]>;
964 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000965 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000966 "orps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000967 [(set VR128:$dst, (v2i64
968 (or VR128:$src1, VR128:$src2)))]>;
969 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000970 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000971 "xorps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000972 [(set VR128:$dst, (v2i64
973 (xor VR128:$src1, VR128:$src2)))]>;
974 }
975
976 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000977 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000978 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000979 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
980 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000981 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000982 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000983 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000984 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
985 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000986 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000987 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000988 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng31d3a652007-07-19 23:34:10 +0000989 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
990 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +0000991 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +0000992 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000993 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +0000994 [(set VR128:$dst,
995 (v2i64 (and (xor VR128:$src1,
996 (bc_v2i64 (v4i32 immAllOnesV))),
997 VR128:$src2)))]>;
998 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000999 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001000 "andnps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001001 [(set VR128:$dst,
Evan Cheng31d3a652007-07-19 23:34:10 +00001002 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Bill Wendlingddd35322007-05-02 23:11:52 +00001003 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001004 (memopv2i64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001005}
1006
Evan Chenge9083d62008-03-05 08:19:16 +00001007let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001008 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begemanc2616e42008-05-12 20:34:32 +00001009 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1010 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1011 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
1012 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001013 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begemanc2616e42008-05-12 20:34:32 +00001014 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1015 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1016 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001017 (memop addr:$src), imm:$cc))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001018}
Nate Begeman30a0de92008-07-17 16:51:19 +00001019def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001020 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00001021def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
Chris Lattner3485b512010-03-08 18:57:56 +00001022 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001023
1024// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001025let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001026 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher44b93ff2009-07-31 20:07:27 +00001027 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001028 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001029 VR128:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001030 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001031 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001032 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001033 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001034 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001035 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001036 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001037 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001038 (v4f32 (shufp:$src3
1039 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001040
1041 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001042 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001043 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001044 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001045 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001046 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001047 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001048 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001049 "unpckhps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001050 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001051 (v4f32 (unpckh VR128:$src1,
1052 (memopv4f32 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001053
Eric Christopher44b93ff2009-07-31 20:07:27 +00001054 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001055 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001056 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001057 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001058 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001059 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001060 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001061 "unpcklps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001062 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001063 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001064 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001065} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001066
1067// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00001068def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001069 "movmskps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001070 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Cheng8a0b2da2009-05-28 18:55:28 +00001071def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001072 "movmskpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001073 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1074
Evan Cheng27b7db52008-03-08 00:58:38 +00001075// Prefetch intrinsic.
1076def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1077 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1078def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1079 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1080def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1081 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1082def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1083 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001084
1085// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00001086def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001087 "movntps\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001088 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1089
David Greene8939b0d2010-02-16 20:50:18 +00001090let AddedComplexity = 400 in { // Prefer non-temporal versions
1091def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1092 "movntps\t{$src, $dst|$dst, $src}",
1093 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1094
1095def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1096 "movntdq\t{$src, $dst|$dst, $src}",
1097 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
1098
David Greene8939b0d2010-02-16 20:50:18 +00001099def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1100 "movnti\t{$src, $dst|$dst, $src}",
1101 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
1102 TB, Requires<[HasSSE2]>;
1103
1104def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
1105 "movnti\t{$src, $dst|$dst, $src}",
1106 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
1107 TB, Requires<[HasSSE2]>;
1108}
1109
Bill Wendlingddd35322007-05-02 23:11:52 +00001110// Load, store, and memory fence
Evan Chengbc9be212009-05-27 18:38:01 +00001111def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001112
1113// MXCSR register
Evan Cheng64d80e32007-07-19 01:14:50 +00001114def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001115 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001116def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001117 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001118
1119// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00001120// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00001121// load of an all-zeros value if folding it would be beneficial.
Chris Lattner28c1d292010-02-05 21:30:49 +00001122// FIXME: Change encoding to pseudo!
Daniel Dunbar7417b762009-08-11 22:17:52 +00001123let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1124 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00001125def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00001126 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001127
Dan Gohmane13709a2010-02-26 01:14:30 +00001128def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1129def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1130def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1131def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1132def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
Evan Chengc8e3b142008-03-12 07:02:50 +00001133
Dan Gohman874cada2010-02-28 00:17:42 +00001134def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1135 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001136
Eric Christopher44b93ff2009-07-31 20:07:27 +00001137//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001138// SSE2 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00001139//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001140
Dan Gohman874cada2010-02-28 00:17:42 +00001141// Move Instructions. Register-to-register movsd is not used for FR64
1142// register copies because it's a partial register update; FsMOVAPDrr is
1143// used instead. Register-to-register movsd is not modeled as an INSERT_SUBREG
1144// because INSERT_SUBREG requires that the insert be implementable in terms of
1145// a copy, and just mentioned, we don't use movsd for copies.
1146let Constraints = "$src1 = $dst" in
1147def MOVSDrr : SDI<0x10, MRMSrcReg,
1148 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
1149 "movsd\t{$src2, $dst|$dst, $src2}",
Chris Lattner3d005782010-03-15 05:53:30 +00001150 [(set (v2f64 VR128:$dst),
Dan Gohman874cada2010-02-28 00:17:42 +00001151 (movl VR128:$src1, (scalar_to_vector FR64:$src2)))]>;
1152
1153// Extract the low 64-bit value from one vector and insert it into another.
1154let AddedComplexity = 15 in
1155def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
Chris Lattner3485b512010-03-08 18:57:56 +00001156 (MOVSDrr (v2f64 VR128:$src1),
Dan Gohman874cada2010-02-28 00:17:42 +00001157 (EXTRACT_SUBREG (v2f64 VR128:$src2), x86_subreg_sd))>;
1158
1159// Implicitly promote a 64-bit scalar to a vector.
1160def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
1161 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, x86_subreg_sd)>;
1162
1163// Loading from memory automatically zeroing upper bits.
1164let canFoldAsLoad = 1, isReMaterializable = 1, AddedComplexity = 20 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001165def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001166 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001167 [(set FR64:$dst, (loadf64 addr:$src))]>;
Dan Gohman874cada2010-02-28 00:17:42 +00001168
1169// MOVSDrm zeros the high parts of the register; represent this
1170// with SUBREG_TO_REG.
1171let AddedComplexity = 20 in {
1172def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
1173 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1174def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
1175 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1176def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
1177 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1178def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
1179 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1180def : Pat<(v2f64 (X86vzload addr:$src)),
1181 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), x86_subreg_sd)>;
1182}
1183
1184// Store scalar value to memory.
Evan Cheng64d80e32007-07-19 01:14:50 +00001185def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001186 "movsd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001187 [(store FR64:$src, addr:$dst)]>;
1188
Dan Gohman874cada2010-02-28 00:17:42 +00001189// Extract and store.
1190def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
1191 addr:$dst),
1192 (MOVSDmr addr:$dst,
1193 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
1194
Bill Wendlingddd35322007-05-02 23:11:52 +00001195// Conversion instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00001196def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001197 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001198 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001199def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001200 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001201 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001202def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001203 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001204 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001205def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001206 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Cheng400073d2009-12-18 07:40:29 +00001207 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengb1f49812009-12-22 17:47:23 +00001208 Requires<[HasSSE2, OptForSize]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001209def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001210 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001211 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001212def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001213 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001214 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1215
Sean Callanan5ab94032009-09-16 01:13:52 +00001216def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1217 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1218def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1219 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1220def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1221 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1222def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1223 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1224def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1225 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1226def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1227 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1228def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1229 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1230def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1231 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1232def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1233 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1234def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1235 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1236
Bill Wendlingddd35322007-05-02 23:11:52 +00001237// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001238def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001239 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001240 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1241 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001242def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001243 "cvtss2sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001244 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengb1f49812009-12-22 17:47:23 +00001245 Requires<[HasSSE2, OptForSize]>;
Evan Cheng400073d2009-12-18 07:40:29 +00001246
1247def : Pat<(extloadf32 addr:$src),
Dan Gohman874cada2010-02-28 00:17:42 +00001248 (CVTSS2SDrr (MOVSSrm addr:$src))>,
1249 Requires<[HasSSE2, OptForSpeed]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001250
1251// Match intrinsics which expect XMM operand(s).
Evan Cheng64d80e32007-07-19 01:14:50 +00001252def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001253 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001254 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001255def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001256 "cvtsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001257 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1258 (load addr:$src)))]>;
1259
Dale Johannesenc7842082007-10-30 22:15:38 +00001260// Match intrinisics which expect MM and XMM operand(s).
1261def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1262 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1263 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1264def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1265 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001266 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001267 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001268def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1269 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1270 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1271def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1272 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001273 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Chengb1938262008-05-23 00:37:07 +00001274 (memop addr:$src)))]>;
Dale Johannesenc7842082007-10-30 22:15:38 +00001275def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1276 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1277 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1278def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1279 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001280 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesenc7842082007-10-30 22:15:38 +00001281 (load addr:$src)))]>;
1282
Bill Wendlingddd35322007-05-02 23:11:52 +00001283// Aliases for intrinsics
Evan Cheng64d80e32007-07-19 01:14:50 +00001284def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001285 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001286 [(set GR32:$dst,
1287 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001288def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001289 "cvttsd2si\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001290 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1291 (load addr:$src)))]>;
1292
1293// Comparison instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001294let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001295 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001296 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001297 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001298let mayLoad = 1 in
Eric Christopher44b93ff2009-07-31 20:07:27 +00001299 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001300 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001301 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001302}
1303
Evan Cheng0488db92007-09-25 01:57:46 +00001304let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001305def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001306 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001307 [(set EFLAGS, (X86cmp FR64:$src1, FR64:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001308def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001309 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001310 [(set EFLAGS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001311} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001312
Bill Wendlingddd35322007-05-02 23:11:52 +00001313// Aliases to match intrinsics which expect XMM operand(s).
Evan Chenge9083d62008-03-05 08:19:16 +00001314let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001315 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan108934c2009-12-18 00:01:26 +00001316 (outs VR128:$dst),
1317 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001318 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001319 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1320 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001321 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan108934c2009-12-18 00:01:26 +00001322 (outs VR128:$dst),
1323 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001324 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001325 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1326 (load addr:$src), imm:$cc))]>;
1327}
1328
Evan Cheng0488db92007-09-25 01:57:46 +00001329let Defs = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001330def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001331 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001332 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1333 VR128:$src2))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00001334def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335 "ucomisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001336 [(set EFLAGS, (X86ucomi (v2f64 VR128:$src1),
1337 (load addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001338
Evan Cheng64d80e32007-07-19 01:14:50 +00001339def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001340 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001341 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1342 VR128:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001343def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001344 "comisd\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00001345 [(set EFLAGS, (X86comi (v2f64 VR128:$src1),
1346 (load addr:$src2)))]>;
Dan Gohmanb1347092009-01-09 02:27:34 +00001347} // Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001348
Eric Christopher44b93ff2009-07-31 20:07:27 +00001349// Aliases of packed SSE2 instructions for scalar use. These all have names
1350// that start with 'Fs'.
Bill Wendlingddd35322007-05-02 23:11:52 +00001351
1352// Alias instructions that map fld0 to pxor for sse.
Dan Gohman4a0b3e12009-09-21 18:30:38 +00001353let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1354 canFoldAsLoad = 1 in
Chris Lattnerbe1778f2010-02-05 21:34:18 +00001355def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1356 [(set FR64:$dst, fpimm0)]>,
Bill Wendlingddd35322007-05-02 23:11:52 +00001357 Requires<[HasSSE2]>, TB, OpSize;
1358
Dan Gohman32791e02007-06-25 15:44:19 +00001359// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001360// disregarded.
Chris Lattnerba7e7562008-01-10 07:59:24 +00001361let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001362def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001363 "movapd\t{$src, $dst|$dst, $src}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001364
Dan Gohman32791e02007-06-25 15:44:19 +00001365// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
Bill Wendlingddd35322007-05-02 23:11:52 +00001366// disregarded.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001367let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001368def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001369 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohmand3006222007-07-27 17:16:43 +00001370 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001371
1372// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Chenge9083d62008-03-05 08:19:16 +00001373let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001374let isCommutable = 1 in {
Evan Chengb6093392008-05-02 07:53:32 +00001375 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1376 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001377 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001378 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001379 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1380 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001381 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001382 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001383 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1384 (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001385 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001386 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1387}
1388
Evan Chengb6093392008-05-02 07:53:32 +00001389def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1390 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001391 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001392 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001393 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001394def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1395 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001397 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001398 (memopfsf64 addr:$src2)))]>;
Evan Chengb6093392008-05-02 07:53:32 +00001399def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1400 (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001401 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001402 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohmand3006222007-07-27 17:16:43 +00001403 (memopfsf64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001404
Chris Lattnerba7e7562008-01-10 07:59:24 +00001405let neverHasSideEffects = 1 in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001406def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001407 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001408 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001409let mayLoad = 1 in
Bill Wendlingddd35322007-05-02 23:11:52 +00001410def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001411 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001412 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001413}
Chris Lattnerba7e7562008-01-10 07:59:24 +00001414}
Bill Wendlingddd35322007-05-02 23:11:52 +00001415
Dan Gohman20382522007-07-10 00:05:58 +00001416/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
Bill Wendlingddd35322007-05-02 23:11:52 +00001417///
Dan Gohman20382522007-07-10 00:05:58 +00001418/// In addition, we also have a special variant of the scalar form here to
1419/// represent the associated intrinsic operation. This form is unlike the
1420/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng236aa8a2009-02-26 03:12:02 +00001421/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohman20382522007-07-10 00:05:58 +00001422///
1423/// These three forms can each be reg+reg or reg+mem, so there are a total of
1424/// six "instructions".
Bill Wendlingddd35322007-05-02 23:11:52 +00001425///
Evan Chenge9083d62008-03-05 08:19:16 +00001426let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001427multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1428 SDNode OpNode, Intrinsic F64Int,
1429 bit Commutable = 0> {
Bill Wendlingddd35322007-05-02 23:11:52 +00001430 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001431 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001432 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001433 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1434 let isCommutable = Commutable;
1435 }
1436
1437 // Scalar operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001438 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1439 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001440 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001441 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001442
Dan Gohman20382522007-07-10 00:05:58 +00001443 // Vector operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001444 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1445 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001446 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001447 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1448 let isCommutable = Commutable;
1449 }
1450
1451 // Vector operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001452 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1453 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001454 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanb1347092009-01-09 02:27:34 +00001455 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001456
1457 // Intrinsic operation, reg+reg.
Dan Gohmanb1347092009-01-09 02:27:34 +00001458 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1459 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001460 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng236aa8a2009-02-26 03:12:02 +00001461 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001462
Dan Gohman20382522007-07-10 00:05:58 +00001463 // Intrinsic operation, reg+mem.
Dan Gohmanb1347092009-01-09 02:27:34 +00001464 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1465 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001466 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00001467 [(set VR128:$dst, (F64Int VR128:$src1,
1468 sse_load_f64:$src2))]>;
1469}
1470}
1471
1472// Arithmetic instructions
Dan Gohman20382522007-07-10 00:05:58 +00001473defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1474defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1475defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1476defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001477
Dan Gohman20382522007-07-10 00:05:58 +00001478/// sse2_fp_binop_rm - Other SSE2 binops
1479///
1480/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1481/// instructions for a full-vector intrinsic form. Operations that map
1482/// onto C operators don't use this form since they just use the plain
1483/// vector form instead of having a separate vector intrinsic form.
1484///
1485/// This provides a total of eight "instructions".
1486///
Evan Chenge9083d62008-03-05 08:19:16 +00001487let Constraints = "$src1 = $dst" in {
Dan Gohman20382522007-07-10 00:05:58 +00001488multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1489 SDNode OpNode,
1490 Intrinsic F64Int,
1491 Intrinsic V2F64Int,
1492 bit Commutable = 0> {
1493
1494 // Scalar operation, reg+reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001495 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001496 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001497 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1498 let isCommutable = Commutable;
1499 }
1500
1501 // Scalar operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001502 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1503 (ins FR64:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001504 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001505 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001506
Dan Gohman20382522007-07-10 00:05:58 +00001507 // Vector operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001508 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1509 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001510 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001511 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1512 let isCommutable = Commutable;
1513 }
1514
1515 // Vector operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001516 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1517 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001518 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001519 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001520
1521 // Intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001522 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1523 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001524 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001525 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1526 let isCommutable = Commutable;
1527 }
1528
1529 // Intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001530 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1531 (ins VR128:$src1, sdmem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001532 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001533 [(set VR128:$dst, (F64Int VR128:$src1,
1534 sse_load_f64:$src2))]>;
1535
1536 // Vector intrinsic operation, reg+reg.
Evan Chengb1938262008-05-23 00:37:07 +00001537 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1538 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001539 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman20382522007-07-10 00:05:58 +00001540 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1541 let isCommutable = Commutable;
1542 }
1543
1544 // Vector intrinsic operation, reg+mem.
Evan Chengb1938262008-05-23 00:37:07 +00001545 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1546 (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001547 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00001548 [(set VR128:$dst, (V2F64Int VR128:$src1,
1549 (memopv2f64 addr:$src2)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001550}
1551}
1552
1553defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1554 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1555defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1556 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001557
Eric Christopher44b93ff2009-07-31 20:07:27 +00001558//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00001559// SSE packed FP Instructions
1560
1561// Move Instructions
Chris Lattnerba7e7562008-01-10 07:59:24 +00001562let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001563def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001564 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001565let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001566def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001567 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001568 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001569
Evan Cheng64d80e32007-07-19 01:14:50 +00001570def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001571 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001572 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001573
Chris Lattnerf77e0372008-01-11 06:59:07 +00001574let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001575def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001576 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001577let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001578def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001579 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001580 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001581def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001582 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001583 [(store (v2f64 VR128:$src), addr:$dst)]>;
1584
1585// Intrinsic forms of MOVUPD load and store
Evan Cheng64d80e32007-07-19 01:14:50 +00001586def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001587 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001588 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001589def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001591 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001592
Evan Chenge9083d62008-03-05 08:19:16 +00001593let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001594 let AddedComplexity = 20 in {
1595 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001596 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001597 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001598 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001599 (v2f64 (movlp VR128:$src1,
1600 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001601 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001602 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001603 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00001604 [(set VR128:$dst,
Nate Begeman0b10b912009-11-07 23:17:15 +00001605 (v2f64 (movlhps VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00001606 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001607 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001608} // Constraints = "$src1 = $dst"
Bill Wendlingddd35322007-05-02 23:11:52 +00001609
Evan Cheng64d80e32007-07-19 01:14:50 +00001610def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001611 "movlpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001612 [(store (f64 (vector_extract (v2f64 VR128:$src),
1613 (iPTR 0))), addr:$dst)]>;
1614
1615// v2f64 extract element 1 is always custom lowered to unpack high to low
1616// and extract element 0 so the non-store version isn't too horrible.
Evan Cheng64d80e32007-07-19 01:14:50 +00001617def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001618 "movhpd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001619 [(store (f64 (vector_extract
Nate Begeman9008ca62009-04-27 18:41:29 +00001620 (v2f64 (unpckh VR128:$src, (undef))),
1621 (iPTR 0))), addr:$dst)]>;
Evan Chengd9539472006-04-14 21:59:03 +00001622
Evan Cheng470a6ad2006-02-22 02:26:30 +00001623// SSE2 instructions without OpSize prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001624def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001625 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001626 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1627 TB, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001628def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001629 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1630 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1631 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001632 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001633
1634// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001635def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001636 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001637 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1638 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001639def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001640 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1641 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1642 (bitconvert (memopv2i64 addr:$src))))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001643 XS, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001644
Evan Cheng64d80e32007-07-19 01:14:50 +00001645def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng029d9da2008-03-14 07:46:48 +00001646 "cvtps2dq\t{$src, $dst|$dst, $src}",
1647 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001648def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001649 "cvtps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001650 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001651 (memop addr:$src)))]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001652// SSE2 packed instructions with XS prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001653def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1654 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1655def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1656 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1657
Evan Cheng64d80e32007-07-19 01:14:50 +00001658def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan108934c2009-12-18 00:01:26 +00001660 [(set VR128:$dst,
1661 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001662 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001663def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001664 "cvttps2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001665 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Chengb1938262008-05-23 00:37:07 +00001666 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001667 XS, Requires<[HasSSE2]>;
Evan Chengd03db7a2006-04-12 05:20:24 +00001668
Evan Cheng470a6ad2006-02-22 02:26:30 +00001669// SSE2 packed instructions with XD prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00001670def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001671 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001672 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1673 XD, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001674def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001676 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001677 (memop addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001678 XD, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001679
Evan Cheng64d80e32007-07-19 01:14:50 +00001680def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001681 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001682 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng029d9da2008-03-14 07:46:48 +00001683def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001685 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Chengb1938262008-05-23 00:37:07 +00001686 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001687
1688// SSE2 instructions without OpSize prefix
Sean Callanan108934c2009-12-18 00:01:26 +00001689def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1690 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1691def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1692 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1693
Evan Cheng64d80e32007-07-19 01:14:50 +00001694def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001695 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001696 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1697 TB, Requires<[HasSSE2]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001698def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001699 "cvtps2pd\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001700 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
Chris Lattner15258d52006-10-07 06:17:43 +00001701 (load addr:$src)))]>,
Evan Cheng190717d2006-05-31 19:00:07 +00001702 TB, Requires<[HasSSE2]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001703
Sean Callanan108934c2009-12-18 00:01:26 +00001704def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1705 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1706def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1707 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1708
1709
Evan Cheng64d80e32007-07-19 01:14:50 +00001710def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001711 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001712 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangbfbbd4d2008-05-28 00:42:27 +00001713def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001714 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Evan Cheng190717d2006-05-31 19:00:07 +00001715 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Chengb1938262008-05-23 00:37:07 +00001716 (memop addr:$src)))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001717
Evan Chengd2a6d542006-04-12 23:42:44 +00001718// Match intrinsics which expect XMM operand(s).
1719// Aliases for intrinsics
Evan Chenge9083d62008-03-05 08:19:16 +00001720let Constraints = "$src1 = $dst" in {
Evan Chengd2a6d542006-04-12 23:42:44 +00001721def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001722 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001724 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
Evan Cheng069287d2006-05-16 07:21:53 +00001725 GR32:$src2))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001726def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001727 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001728 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001729 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1730 (loadi32 addr:$src2)))]>;
1731def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001732 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001733 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001734 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1735 VR128:$src2))]>;
1736def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00001737 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001738 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001739 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001740 (load addr:$src2)))]>;
Evan Chengd2a6d542006-04-12 23:42:44 +00001741def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001742 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001743 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001744 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1745 VR128:$src2))]>, XS,
1746 Requires<[HasSSE2]>;
1747def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001748 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001749 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Evan Chengd2a6d542006-04-12 23:42:44 +00001750 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
Chris Lattner15258d52006-10-07 06:17:43 +00001751 (load addr:$src2)))]>, XS,
Evan Chengd2a6d542006-04-12 23:42:44 +00001752 Requires<[HasSSE2]>;
1753}
1754
Dan Gohman20382522007-07-10 00:05:58 +00001755// Arithmetic
1756
1757/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
Chris Lattner6f987732006-10-07 21:17:13 +00001758///
Dan Gohman20382522007-07-10 00:05:58 +00001759/// In addition, we also have a special variant of the scalar form here to
1760/// represent the associated intrinsic operation. This form is unlike the
1761/// plain scalar form, in that it takes an entire vector (instead of a
1762/// scalar) and leaves the top elements undefined.
1763///
1764/// And, we have a special variant form for a full-vector intrinsic form.
1765///
1766/// These four forms can each have a reg or a mem operand, so there are a
1767/// total of eight "instructions".
1768///
1769multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1770 SDNode OpNode,
1771 Intrinsic F64Int,
1772 Intrinsic V2F64Int,
1773 bit Commutable = 0> {
1774 // Scalar operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001775 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001776 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001777 [(set FR64:$dst, (OpNode FR64:$src))]> {
Chris Lattner6f987732006-10-07 21:17:13 +00001778 let isCommutable = Commutable;
1779 }
Bill Wendlingddd35322007-05-02 23:11:52 +00001780
Dan Gohman20382522007-07-10 00:05:58 +00001781 // Scalar operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001782 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001783 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001784 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001785
Dan Gohman20382522007-07-10 00:05:58 +00001786 // Vector operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001787 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001789 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1790 let isCommutable = Commutable;
Bill Wendlingddd35322007-05-02 23:11:52 +00001791 }
1792
Dan Gohman20382522007-07-10 00:05:58 +00001793 // Vector operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001794 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001795 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4106f372007-07-18 20:23:34 +00001796 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohman20382522007-07-10 00:05:58 +00001797
1798 // Intrinsic operation, reg.
Evan Cheng64d80e32007-07-19 01:14:50 +00001799 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001800 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001801 [(set VR128:$dst, (F64Int VR128:$src))]> {
1802 let isCommutable = Commutable;
1803 }
1804
1805 // Intrinsic operation, mem.
Evan Cheng64d80e32007-07-19 01:14:50 +00001806 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001807 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001808 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1809
1810 // Vector intrinsic operation, reg
Evan Cheng64d80e32007-07-19 01:14:50 +00001811 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001812 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman20382522007-07-10 00:05:58 +00001813 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1814 let isCommutable = Commutable;
1815 }
1816
1817 // Vector intrinsic operation, mem
Dan Gohmanf3372d12007-08-02 21:06:40 +00001818 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001819 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Chengb1938262008-05-23 00:37:07 +00001820 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Evan Cheng97ac5fa2006-04-03 23:49:17 +00001821}
Evan Chengffcb95b2006-02-21 19:13:53 +00001822
Dan Gohman20382522007-07-10 00:05:58 +00001823// Square root.
1824defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1825 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1826
1827// There is no f64 version of the reciprocal approximation instructions.
1828
Evan Chengffcb95b2006-02-21 19:13:53 +00001829// Logical
Evan Chenge9083d62008-03-05 08:19:16 +00001830let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001831 let isCommutable = 1 in {
1832 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001835 [(set VR128:$dst,
1836 (and (bc_v2i64 (v2f64 VR128:$src1)),
Chris Lattner3b57a832006-10-07 06:27:03 +00001837 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001838 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001839 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001840 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001841 [(set VR128:$dst,
1842 (or (bc_v2i64 (v2f64 VR128:$src1)),
1843 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1844 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001845 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001846 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001847 [(set VR128:$dst,
1848 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1849 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1850 }
1851
1852 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001853 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001854 "andpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001855 [(set VR128:$dst,
1856 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001857 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001858 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001859 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001860 "orpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001861 [(set VR128:$dst,
1862 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001863 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001864 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001865 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001866 "xorpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001867 [(set VR128:$dst,
1868 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng31d3a652007-07-19 23:34:10 +00001869 (memopv2i64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001870 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001871 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001872 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001873 [(set VR128:$dst,
1874 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Chris Lattner3b57a832006-10-07 06:27:03 +00001875 (bc_v2i64 (v2f64 VR128:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001876 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001877 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001878 "andnpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001879 [(set VR128:$dst,
1880 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng31d3a652007-07-19 23:34:10 +00001881 (memopv2i64 addr:$src2)))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +00001882}
Evan Chengbf156d12006-02-21 19:26:52 +00001883
Evan Chenge9083d62008-03-05 08:19:16 +00001884let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001885 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001886 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1887 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1888 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begemanc2616e42008-05-12 20:34:32 +00001889 VR128:$src, imm:$cc))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001890 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng029d9da2008-03-14 07:46:48 +00001891 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1892 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1893 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00001894 (memop addr:$src), imm:$cc))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001895}
Evan Chenge9d50352008-08-05 22:19:15 +00001896def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001897 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Chenge9d50352008-08-05 22:19:15 +00001898def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman30a0de92008-07-17 16:51:19 +00001899 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001900
1901// Shuffle and unpack instructions
Evan Chenge9083d62008-03-05 08:19:16 +00001902let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001903 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng029d9da2008-03-14 07:46:48 +00001904 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1905 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman9008ca62009-04-27 18:41:29 +00001906 [(set VR128:$dst,
1907 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001908 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001909 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00001910 f128mem:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001912 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001913 (v2f64 (shufp:$src3
1914 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Evan Cheng470a6ad2006-02-22 02:26:30 +00001915
Bill Wendlingddd35322007-05-02 23:11:52 +00001916 let AddedComplexity = 10 in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00001917 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001918 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001919 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001920 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001921 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001922 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001923 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001924 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001925 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001926 (v2f64 (unpckh VR128:$src1,
1927 (memopv2f64 addr:$src2))))]>;
Evan Cheng4fcb9222006-03-28 02:43:26 +00001928
Eric Christopher44b93ff2009-07-31 20:07:27 +00001929 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001930 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001932 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001933 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00001934 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001935 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00001937 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00001938 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00001939 } // AddedComplexity
Evan Chenge9083d62008-03-05 08:19:16 +00001940} // Constraints = "$src1 = $dst"
Evan Cheng470a6ad2006-02-22 02:26:30 +00001941
Evan Cheng4b1734f2006-03-31 21:29:33 +00001942
Eric Christopher44b93ff2009-07-31 20:07:27 +00001943//===---------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001944// SSE integer instructions
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00001945let ExeDomain = SSEPackedInt in {
Evan Chengbf156d12006-02-21 19:26:52 +00001946
Evan Cheng4e4c71e2006-02-21 20:00:20 +00001947// Move Instructions
Chris Lattnerf77e0372008-01-11 06:59:07 +00001948let neverHasSideEffects = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001949def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001950 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001951let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001952def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001953 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001954 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001955let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001956def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "movdqa\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001958 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman15511cf2008-12-03 18:15:48 +00001959let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001960def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001962 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001963 XS, Requires<[HasSSE2]>;
Chris Lattnerf77e0372008-01-11 06:59:07 +00001964let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001965def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001966 "movdqu\t{$src, $dst|$dst, $src}",
Evan Chengb4162fd2007-07-20 00:27:43 +00001967 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Evan Cheng9ab1ac52006-04-14 23:32:40 +00001968 XS, Requires<[HasSSE2]>;
Evan Cheng24dc1f52006-03-23 07:44:07 +00001969
Dan Gohman4106f372007-07-18 20:23:34 +00001970// Intrinsic forms of MOVDQU load and store
Dan Gohman15511cf2008-12-03 18:15:48 +00001971let canFoldAsLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +00001972def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001973 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001974 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1975 XS, Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001976def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001977 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4106f372007-07-18 20:23:34 +00001978 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1979 XS, Requires<[HasSSE2]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001980
Evan Chenge7b8a8b2008-03-05 08:11:27 +00001981let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00001982
Chris Lattner45e123c2006-10-07 19:02:31 +00001983multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1984 bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00001985 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1986 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001987 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001988 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1989 let isCommutable = Commutable;
1990 }
Sean Callanan108934c2009-12-18 00:01:26 +00001991 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1992 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001993 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner8139e282006-10-07 18:39:00 +00001994 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00001995 (bitconvert (memopv2i64
1996 addr:$src2))))]>;
Chris Lattner8139e282006-10-07 18:39:00 +00001997}
Chris Lattner8139e282006-10-07 18:39:00 +00001998
Evan Cheng22b942a2008-05-03 00:52:09 +00001999multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
2000 string OpcodeStr,
2001 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan108934c2009-12-18 00:01:26 +00002002 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2003 (ins VR128:$src1, VR128:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002004 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2005 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002006 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2007 (ins VR128:$src1, i128mem:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002008 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2009 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002010 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002011 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
2012 (ins VR128:$src1, i32i8imm:$src2),
Evan Cheng22b942a2008-05-03 00:52:09 +00002013 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2014 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2015}
2016
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002017/// PDI_binop_rm - Simple SSE2 binary operator.
2018multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2019 ValueType OpVT, bit Commutable = 0> {
Sean Callanan108934c2009-12-18 00:01:26 +00002020 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2021 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002022 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002023 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
2024 let isCommutable = Commutable;
2025 }
Sean Callanan108934c2009-12-18 00:01:26 +00002026 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2027 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002028 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002029 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher44b93ff2009-07-31 20:07:27 +00002030 (bitconvert (memopv2i64 addr:$src2)))))]>;
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002031}
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002032
2033/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2034///
2035/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2036/// to collapse (bitconvert VT to VT) into its operand.
2037///
2038multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2039 bit Commutable = 0> {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002040 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002041 (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002042 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002043 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
2044 let isCommutable = Commutable;
2045 }
Eric Christopher44b93ff2009-07-31 20:07:27 +00002046 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002047 (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002048 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002049 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan108934c2009-12-18 00:01:26 +00002050 (memopv2i64 addr:$src2)))]>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002051}
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002052
Evan Chenge9083d62008-03-05 08:19:16 +00002053} // Constraints = "$src1 = $dst"
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002054} // ExeDomain = SSEPackedInt
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002055
2056// 128-bit Integer Arithmetic
2057
2058defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2059defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2060defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002061defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002062
Chris Lattner45e123c2006-10-07 19:02:31 +00002063defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2064defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2065defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2066defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002067
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002068defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2069defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2070defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
Chris Lattner70f4f2e2006-10-07 19:34:33 +00002071defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002072
Chris Lattner45e123c2006-10-07 19:02:31 +00002073defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2074defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2075defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2076defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
Evan Cheng49ac1bf2006-04-13 00:43:35 +00002077
Chris Lattner7c47f9a2006-10-07 19:14:49 +00002078defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002079
Chris Lattner45e123c2006-10-07 19:02:31 +00002080defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2081defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2082defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
Evan Cheng00586942006-04-13 06:11:45 +00002083
Chris Lattner45e123c2006-10-07 19:02:31 +00002084defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
Chris Lattner77337992006-10-07 07:06:17 +00002085
Chris Lattner45e123c2006-10-07 19:02:31 +00002086defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2087defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
Chris Lattner8139e282006-10-07 18:39:00 +00002088
Chris Lattner77337992006-10-07 07:06:17 +00002089
Chris Lattner45e123c2006-10-07 19:02:31 +00002090defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2091defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2092defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2093defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling3b1259b2009-05-28 02:04:00 +00002094defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Evan Chengc60bd972006-03-25 09:37:23 +00002095
Chris Lattner77337992006-10-07 07:06:17 +00002096
Evan Cheng22b942a2008-05-03 00:52:09 +00002097defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2098 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2099defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2100 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2101defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2102 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002103
Evan Cheng22b942a2008-05-03 00:52:09 +00002104defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2105 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2106defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2107 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begeman32097bd2008-05-13 17:52:09 +00002108defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Cheng22b942a2008-05-03 00:52:09 +00002109 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Chris Lattner77337992006-10-07 07:06:17 +00002110
Evan Cheng22b942a2008-05-03 00:52:09 +00002111defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2112 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemanc9bdb002008-05-13 01:47:52 +00002113defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Cheng22b942a2008-05-03 00:52:09 +00002114 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Chris Lattner77337992006-10-07 07:06:17 +00002115
Chris Lattner6970eda2006-10-07 19:49:05 +00002116// 128-bit logical shifts.
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002117let Constraints = "$src1 = $dst", neverHasSideEffects = 1,
2118 ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002119 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002120 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002121 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002122 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002123 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002124 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002125 // PSRADQri doesn't exist in SSE[1-3].
Evan Chengff65e382006-04-04 21:49:39 +00002126}
2127
Chris Lattner6970eda2006-10-07 19:49:05 +00002128let Predicates = [HasSSE2] in {
2129 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002130 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002131 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng89321162009-10-28 06:30:34 +00002132 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling5e249b42008-10-02 05:56:52 +00002133 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2134 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2135 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2136 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Evan Cheng68c47cb2007-01-05 07:55:56 +00002137 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng89321162009-10-28 06:30:34 +00002138 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002139
2140 // Shift up / down and insert zero's.
2141 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002142 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengf26ffe92008-05-29 08:22:04 +00002143 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng89321162009-10-28 06:30:34 +00002144 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Chris Lattner6970eda2006-10-07 19:49:05 +00002145}
2146
Evan Cheng506d3df2006-03-29 23:07:14 +00002147// Logical
Chris Lattnera7ebe552006-10-07 19:37:30 +00002148defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2149defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2150defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2151
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002152let Constraints = "$src1 = $dst", ExeDomain = SSEPackedInt in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002153 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002154 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002155 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002156 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2157 VR128:$src2)))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002158
Bill Wendlingddd35322007-05-02 23:11:52 +00002159 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002160 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002161 "pandn\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002162 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7f55fcb2007-08-02 21:17:01 +00002163 (memopv2i64 addr:$src2))))]>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002164}
2165
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002166// SSE2 Integer comparison
Bill Wendlingddd35322007-05-02 23:11:52 +00002167defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2168defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2169defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2170defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2171defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2172defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002173
Nate Begeman30a0de92008-07-17 16:51:19 +00002174def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002175 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002176def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002177 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002178def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002179 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002180def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002181 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002182def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002183 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002184def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002185 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2186
Nate Begeman30a0de92008-07-17 16:51:19 +00002187def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002188 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002189def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002190 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002191def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002192 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002193def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002194 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002195def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002196 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman30a0de92008-07-17 16:51:19 +00002197def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman0d1704b2008-05-12 23:09:43 +00002198 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2199
2200
Evan Cheng506d3df2006-03-29 23:07:14 +00002201// Pack instructions
Chris Lattner45e123c2006-10-07 19:02:31 +00002202defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2203defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2204defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
Evan Cheng506d3df2006-03-29 23:07:14 +00002205
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002206let ExeDomain = SSEPackedInt in {
2207
Evan Cheng506d3df2006-03-29 23:07:14 +00002208// Shuffle and unpack instructions
Nate Begemana09008b2009-10-19 02:17:23 +00002209let AddedComplexity = 5 in {
Evan Cheng8703be42006-04-04 19:12:30 +00002210def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002211 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002212 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002213 [(set VR128:$dst, (v4i32 (pshufd:$src2
2214 VR128:$src1, (undef))))]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002215def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002216 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002217 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002218 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chengc3630942009-12-09 21:00:30 +00002219 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00002220 (undef))))]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002221}
Evan Cheng506d3df2006-03-29 23:07:14 +00002222
2223// SSE2 with ImmT == Imm8 and XS prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002224def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002225 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002226 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002227 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2228 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002229 XS, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002230def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002231 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002232 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002233 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher44b93ff2009-07-31 20:07:27 +00002234 (bc_v8i16 (memopv2i64 addr:$src1)),
2235 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002236 XS, Requires<[HasSSE2]>;
2237
2238// SSE2 with ImmT == Imm8 and XD prefix.
Evan Cheng8703be42006-04-04 19:12:30 +00002239def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman9008ca62009-04-27 18:41:29 +00002240 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002242 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2243 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002244 XD, Requires<[HasSSE2]>;
Evan Cheng8703be42006-04-04 19:12:30 +00002245def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman9008ca62009-04-27 18:41:29 +00002246 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002247 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002248 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2249 (bc_v8i16 (memopv2i64 addr:$src1)),
2250 (undef))))]>,
Evan Cheng506d3df2006-03-29 23:07:14 +00002251 XD, Requires<[HasSSE2]>;
2252
Evan Chengc60bd972006-03-25 09:37:23 +00002253
Evan Chenge9083d62008-03-05 08:19:16 +00002254let Constraints = "$src1 = $dst" in {
Eric Christopher44b93ff2009-07-31 20:07:27 +00002255 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002256 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002257 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002258 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002259 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002260 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002261 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002262 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002263 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002264 (unpckl VR128:$src1,
2265 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002266 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002267 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002268 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002269 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002270 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002271 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002272 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002273 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002274 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002275 (unpckl VR128:$src1,
2276 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002277 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002278 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002280 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002281 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002282 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002283 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002284 "punpckldq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002285 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002286 (unpckl VR128:$src1,
2287 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002288 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002289 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002290 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002291 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002292 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002293 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002294 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002296 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002297 (v2i64 (unpckl VR128:$src1,
2298 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002299
2300 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002301 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002302 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002303 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002304 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002305 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002306 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002307 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002308 [(set VR128:$dst,
2309 (unpckh VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00002310 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002311 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002312 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002313 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002314 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002315 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002316 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002317 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002318 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002319 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002320 (unpckh VR128:$src1,
2321 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002322 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002323 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002324 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002325 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002326 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002327 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002328 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002329 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002330 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002331 (unpckh VR128:$src1,
2332 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002333 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002334 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002336 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002337 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00002338 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002339 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002340 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002341 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002342 (v2i64 (unpckh VR128:$src1,
2343 (memopv2i64 addr:$src2))))]>;
Evan Chenga971f6f2006-03-23 01:57:24 +00002344}
Evan Cheng82521dd2006-03-21 07:09:35 +00002345
Evan Chengb067a1e2006-03-31 19:22:53 +00002346// Extract / Insert
Evan Cheng9ab1ac52006-04-14 23:32:40 +00002347def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002348 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002349 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002350 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begeman14d12ca2008-02-11 04:19:36 +00002351 imm:$src2))]>;
Evan Chenge9083d62008-03-05 08:19:16 +00002352let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002353 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002354 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002355 GR32:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002356 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002357 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002358 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002359 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002360 (outs VR128:$dst), (ins VR128:$src1,
Bill Wendlingddd35322007-05-02 23:11:52 +00002361 i16mem:$src2, i32i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002362 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002363 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00002364 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2365 imm:$src3))]>;
Evan Chengb067a1e2006-03-31 19:22:53 +00002366}
2367
Evan Chengc5fb2b12006-03-30 00:33:26 +00002368// Mask creation
Evan Cheng64d80e32007-07-19 01:14:50 +00002369def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002370 "pmovmskb\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002371 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
Evan Chengc5fb2b12006-03-30 00:33:26 +00002372
Evan Chengfcf5e212006-04-11 06:57:30 +00002373// Conditional store
Evan Cheng071a2792007-09-11 19:55:27 +00002374let Uses = [EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +00002375def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002376 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng071a2792007-09-11 19:55:27 +00002377 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Evan Chengfcf5e212006-04-11 06:57:30 +00002378
Evan Cheng1d768642009-02-10 22:06:28 +00002379let Uses = [RDI] in
2380def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2381 "maskmovdqu\t{$mask, $src|$src, $mask}",
2382 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2383
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002384} // ExeDomain = SSEPackedInt
2385
Evan Chengecac9cb2006-03-25 06:03:26 +00002386// Non-temporal stores
David Greene8939b0d2010-02-16 20:50:18 +00002387def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2388 "movntpd\t{$src, $dst|$dst, $src}",
2389 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002390let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002391def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2392 "movntdq\t{$src, $dst|$dst, $src}",
2393 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2394def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002395 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher44b93ff2009-07-31 20:07:27 +00002396 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Evan Chengfcf5e212006-04-11 06:57:30 +00002397 TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002398
David Greene8939b0d2010-02-16 20:50:18 +00002399let AddedComplexity = 400 in { // Prefer non-temporal versions
2400def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2401 "movntpd\t{$src, $dst|$dst, $src}",
2402 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2403
Jakob Stoklund Olesen4a2a6e72010-03-25 18:52:04 +00002404let ExeDomain = SSEPackedInt in
David Greene8939b0d2010-02-16 20:50:18 +00002405def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2406 "movntdq\t{$src, $dst|$dst, $src}",
2407 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
David Greene8939b0d2010-02-16 20:50:18 +00002408}
2409
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002410// Flush cache
Evan Cheng64d80e32007-07-19 01:14:50 +00002411def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002412 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002413 TB, Requires<[HasSSE2]>;
2414
2415// Load, store, and memory fence
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002416def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002417 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002418def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
Evan Chengf3e1b1d2006-04-14 07:43:12 +00002419 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengecac9cb2006-03-25 06:03:26 +00002420
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002421//TODO: custom lower this so as to never even generate the noop
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002422def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002423 (i8 0)), (NOOP)>;
2424def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2425def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00002426def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
Andrew Lenharth22c5c1b2008-02-16 01:24:58 +00002427 (i8 1)), (MFENCE)>;
2428
Evan Chengffea91e2006-03-26 09:53:12 +00002429// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman15511cf2008-12-03 18:15:48 +00002430// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman62c939d2008-12-03 05:21:24 +00002431// load of an all-ones value if folding it would be beneficial.
Daniel Dunbar7417b762009-08-11 22:17:52 +00002432let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2433 isCodeGenOnly = 1 in
Chris Lattner28c1d292010-02-05 21:30:49 +00002434 // FIXME: Change encoding to pseudo.
2435 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattner8a594482007-11-25 00:24:49 +00002436 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Evan Cheng386031a2006-03-24 07:29:27 +00002437
Evan Cheng64d80e32007-07-19 01:14:50 +00002438def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002439 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002440 [(set VR128:$dst,
Evan Cheng069287d2006-05-16 07:21:53 +00002441 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002442def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002443 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002444 [(set VR128:$dst,
2445 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Evan Chengebf01d62006-11-16 23:33:25 +00002446
Evan Cheng64d80e32007-07-19 01:14:50 +00002447def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002448 "movd\t{$src, $dst|$dst, $src}",
Chris Lattnerf3597a12006-12-05 18:45:06 +00002449 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2450
Evan Cheng64d80e32007-07-19 01:14:50 +00002451def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002452 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002453 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002454
Evan Cheng11e15b32006-04-03 20:53:28 +00002455// SSE2 instructions with XS prefix
Evan Cheng64d80e32007-07-19 01:14:50 +00002456def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002457 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002458 [(set VR128:$dst,
2459 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2460 Requires<[HasSSE2]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "movq\t{$src, $dst|$dst, $src}",
Evan Chengebf01d62006-11-16 23:33:25 +00002463 [(store (i64 (vector_extract (v2i64 VR128:$src),
2464 (iPTR 0))), addr:$dst)]>;
2465
Dan Gohman874cada2010-02-28 00:17:42 +00002466def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
2467 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), x86_subreg_sd))>;
2468
Evan Cheng64d80e32007-07-19 01:14:50 +00002469def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002470 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002471 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002472 (iPTR 0)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002473def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng11e15b32006-04-03 20:53:28 +00002475 [(store (i32 (vector_extract (v4i32 VR128:$src),
Evan Cheng015188f2006-06-15 08:14:54 +00002476 (iPTR 0))), addr:$dst)]>;
Evan Cheng11e15b32006-04-03 20:53:28 +00002477
Evan Cheng64d80e32007-07-19 01:14:50 +00002478def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002479 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002480 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002481def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "movd\t{$src, $dst|$dst, $src}",
Evan Chengc9f09232006-12-14 19:43:11 +00002483 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
Chris Lattnerf3597a12006-12-05 18:45:06 +00002484
Evan Cheng397edef2006-04-11 22:28:25 +00002485// Store / copy lower 64-bits of a XMM register.
Evan Cheng64d80e32007-07-19 01:14:50 +00002486def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002487 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng397edef2006-04-11 22:28:25 +00002488 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2489
Evan Cheng017dcc62006-04-21 01:05:10 +00002490// movd / movq to XMM register zero-extends
Evan Cheng7a831ce2007-12-15 03:00:47 +00002491let AddedComplexity = 15 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002492def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002493 "movd\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002494 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002495 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002496// This is X86-64 only.
2497def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2498 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002499 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng7e2ff772008-05-08 00:57:18 +00002500 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00002501}
2502
2503let AddedComplexity = 20 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002504def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002505 "movd\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002506 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002507 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002508 (loadi32 addr:$src))))))]>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002509
2510def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2511 (MOVZDI2PDIrm addr:$src)>;
2512def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2513 (MOVZDI2PDIrm addr:$src)>;
Duncan Sandsd4b9c172008-06-13 19:07:40 +00002514def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2515 (MOVZDI2PDIrm addr:$src)>;
Evan Chengc36c0ab2008-05-22 18:56:56 +00002516
Evan Cheng64d80e32007-07-19 01:14:50 +00002517def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002518 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng7a831ce2007-12-15 03:00:47 +00002519 [(set VR128:$dst,
Evan Chengd880b972008-05-09 21:53:03 +00002520 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng7e2ff772008-05-08 00:57:18 +00002521 (loadi64 addr:$src))))))]>, XS,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002522 Requires<[HasSSE2]>;
Evan Cheng48090aa2006-03-21 23:01:21 +00002523
Evan Chengc36c0ab2008-05-22 18:56:56 +00002524def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2525 (MOVZQI2PQIrm addr:$src)>;
2526def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2527 (MOVZQI2PQIrm addr:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00002528def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengb70ea0b2008-05-10 00:59:18 +00002529}
Evan Chengd880b972008-05-09 21:53:03 +00002530
Evan Cheng7a831ce2007-12-15 03:00:47 +00002531// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2532// IA32 document. movq xmm1, xmm2 does clear the high bits.
2533let AddedComplexity = 15 in
2534def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2535 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002536 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002537 XS, Requires<[HasSSE2]>;
2538
Evan Cheng8e8de682008-05-20 18:24:47 +00002539let AddedComplexity = 20 in {
Evan Cheng7a831ce2007-12-15 03:00:47 +00002540def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2541 "movq\t{$src, $dst|$dst, $src}",
Evan Chengd880b972008-05-09 21:53:03 +00002542 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng8e8de682008-05-20 18:24:47 +00002543 (loadv2i64 addr:$src))))]>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00002544 XS, Requires<[HasSSE2]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002545
Evan Cheng8e8de682008-05-20 18:24:47 +00002546def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2547 (MOVZPQILo2PQIrm addr:$src)>;
2548}
2549
Sean Callanan108934c2009-12-18 00:01:26 +00002550// Instructions for the disassembler
2551// xr = XMM register
2552// xm = mem64
2553
2554def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2555 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2556
Eric Christopher44b93ff2009-07-31 20:07:27 +00002557//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002558// SSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002559//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002560
Bill Wendlingddd35322007-05-02 23:11:52 +00002561// Move Instructions
Evan Cheng64d80e32007-07-19 01:14:50 +00002562def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002563 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002564 [(set VR128:$dst, (v4f32 (movshdup
2565 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002566def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002567 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002568 [(set VR128:$dst, (movshdup
2569 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002570
Evan Cheng64d80e32007-07-19 01:14:50 +00002571def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002572 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002573 [(set VR128:$dst, (v4f32 (movsldup
2574 VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002575def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002576 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002577 [(set VR128:$dst, (movsldup
2578 (memopv4f32 addr:$src), (undef)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002579
Evan Cheng64d80e32007-07-19 01:14:50 +00002580def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002581 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman9008ca62009-04-27 18:41:29 +00002582 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002583def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002584 "movddup\t{$src, $dst|$dst, $src}",
Evan Cheng0b457f02008-09-25 20:50:48 +00002585 [(set VR128:$dst,
Nate Begeman9008ca62009-04-27 18:41:29 +00002586 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2587 (undef))))]>;
Evan Cheng0b457f02008-09-25 20:50:48 +00002588
Nate Begeman9008ca62009-04-27 18:41:29 +00002589def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2590 (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002591 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002592
2593let AddedComplexity = 5 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00002594def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Cheng0b457f02008-09-25 20:50:48 +00002595 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanec8eee22009-04-29 22:47:44 +00002596def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2597 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2598def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2599 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2600def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2601 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2602}
Bill Wendlingddd35322007-05-02 23:11:52 +00002603
2604// Arithmetic
Evan Chenge9083d62008-03-05 08:19:16 +00002605let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002606 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002607 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002608 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002609 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2610 VR128:$src2))]>;
2611 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002612 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002613 "addsubps\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002614 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002615 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002616 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002617 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002618 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002619 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2620 VR128:$src2))]>;
2621 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002622 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 "addsubpd\t{$src2, $dst|$dst, $src2}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002624 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Chengb1938262008-05-23 00:37:07 +00002625 (memop addr:$src2)))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002626}
2627
Evan Cheng64d80e32007-07-19 01:14:50 +00002628def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002629 "lddqu\t{$src, $dst|$dst, $src}",
Bill Wendlingddd35322007-05-02 23:11:52 +00002630 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2631
2632// Horizontal ops
2633class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002634 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002635 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002636 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2637class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002638 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002639 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002640 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002641class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002642 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002643 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Bill Wendlingddd35322007-05-02 23:11:52 +00002644 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2645class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Cheng64d80e32007-07-19 01:14:50 +00002646 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002647 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00002648 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Bill Wendlingddd35322007-05-02 23:11:52 +00002649
Evan Chenge9083d62008-03-05 08:19:16 +00002650let Constraints = "$src1 = $dst" in {
Bill Wendlingddd35322007-05-02 23:11:52 +00002651 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2652 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2653 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2654 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2655 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2656 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2657 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2658 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2659}
2660
2661// Thread synchronization
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002662def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
Bill Wendlingddd35322007-05-02 23:11:52 +00002663 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Chris Lattnereaca5fa2010-02-12 23:54:57 +00002664def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
Bill Wendlingddd35322007-05-02 23:11:52 +00002665 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2666
2667// vector_shuffle v1, <undef> <1, 1, 3, 3>
2668let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002669def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002670 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2671let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002672def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002673 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2674
2675// vector_shuffle v1, <undef> <0, 0, 2, 2>
2676let AddedComplexity = 15 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002677 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002678 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2679let AddedComplexity = 20 in
Nate Begeman9008ca62009-04-27 18:41:29 +00002680 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Bill Wendlingddd35322007-05-02 23:11:52 +00002681 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2682
Eric Christopher44b93ff2009-07-31 20:07:27 +00002683//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002684// SSSE3 Instructions
Eric Christopher44b93ff2009-07-31 20:07:27 +00002685//===---------------------------------------------------------------------===//
Bill Wendlingddd35322007-05-02 23:11:52 +00002686
Bill Wendling76d708b2007-08-10 06:22:27 +00002687/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begemanfea2be52008-02-09 23:46:37 +00002688multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2689 Intrinsic IntId64, Intrinsic IntId128> {
2690 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2691 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2692 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002693
Nate Begemanfea2be52008-02-09 23:46:37 +00002694 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2695 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2696 [(set VR64:$dst,
2697 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2698
2699 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2700 (ins VR128:$src),
2701 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2702 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2703 OpSize;
2704
2705 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2706 (ins i128mem:$src),
2707 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2708 [(set VR128:$dst,
2709 (IntId128
2710 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Bill Wendlingddd35322007-05-02 23:11:52 +00002711}
2712
Bill Wendling76d708b2007-08-10 06:22:27 +00002713/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begemanfea2be52008-02-09 23:46:37 +00002714multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2715 Intrinsic IntId64, Intrinsic IntId128> {
2716 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2717 (ins VR64:$src),
2718 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2719 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002720
Nate Begemanfea2be52008-02-09 23:46:37 +00002721 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2722 (ins i64mem:$src),
2723 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2724 [(set VR64:$dst,
2725 (IntId64
2726 (bitconvert (memopv4i16 addr:$src))))]>;
2727
2728 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2729 (ins VR128:$src),
2730 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2731 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2732 OpSize;
2733
2734 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2735 (ins i128mem:$src),
2736 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2737 [(set VR128:$dst,
2738 (IntId128
2739 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002740}
2741
2742/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begemanfea2be52008-02-09 23:46:37 +00002743multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2744 Intrinsic IntId64, Intrinsic IntId128> {
2745 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2746 (ins VR64:$src),
2747 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2748 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002749
Nate Begemanfea2be52008-02-09 23:46:37 +00002750 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2751 (ins i64mem:$src),
2752 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2753 [(set VR64:$dst,
2754 (IntId64
2755 (bitconvert (memopv2i32 addr:$src))))]>;
2756
2757 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2758 (ins VR128:$src),
2759 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2760 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2761 OpSize;
2762
2763 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2764 (ins i128mem:$src),
2765 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2766 [(set VR128:$dst,
2767 (IntId128
2768 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002769}
2770
2771defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2772 int_x86_ssse3_pabs_b,
2773 int_x86_ssse3_pabs_b_128>;
2774defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2775 int_x86_ssse3_pabs_w,
2776 int_x86_ssse3_pabs_w_128>;
2777defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2778 int_x86_ssse3_pabs_d,
2779 int_x86_ssse3_pabs_d_128>;
2780
2781/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Chenge9083d62008-03-05 08:19:16 +00002782let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002783 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2784 Intrinsic IntId64, Intrinsic IntId128,
2785 bit Commutable = 0> {
2786 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2787 (ins VR64:$src1, VR64:$src2),
2788 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2789 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2790 let isCommutable = Commutable;
2791 }
2792 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2793 (ins VR64:$src1, i64mem:$src2),
2794 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2795 [(set VR64:$dst,
2796 (IntId64 VR64:$src1,
2797 (bitconvert (memopv8i8 addr:$src2))))]>;
2798
2799 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2800 (ins VR128:$src1, VR128:$src2),
2801 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2802 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2803 OpSize {
2804 let isCommutable = Commutable;
2805 }
2806 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2807 (ins VR128:$src1, i128mem:$src2),
2808 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2809 [(set VR128:$dst,
2810 (IntId128 VR128:$src1,
2811 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2812 }
2813}
2814
2815/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Chenge9083d62008-03-05 08:19:16 +00002816let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002817 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2818 Intrinsic IntId64, Intrinsic IntId128,
2819 bit Commutable = 0> {
2820 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2821 (ins VR64:$src1, VR64:$src2),
2822 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2823 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2824 let isCommutable = Commutable;
2825 }
2826 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2827 (ins VR64:$src1, i64mem:$src2),
2828 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2829 [(set VR64:$dst,
2830 (IntId64 VR64:$src1,
2831 (bitconvert (memopv4i16 addr:$src2))))]>;
2832
2833 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2834 (ins VR128:$src1, VR128:$src2),
2835 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2836 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2837 OpSize {
2838 let isCommutable = Commutable;
2839 }
2840 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2841 (ins VR128:$src1, i128mem:$src2),
2842 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2843 [(set VR128:$dst,
2844 (IntId128 VR128:$src1,
2845 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2846 }
2847}
2848
2849/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Chenge9083d62008-03-05 08:19:16 +00002850let Constraints = "$src1 = $dst" in {
Bill Wendling76d708b2007-08-10 06:22:27 +00002851 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2852 Intrinsic IntId64, Intrinsic IntId128,
2853 bit Commutable = 0> {
2854 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2855 (ins VR64:$src1, VR64:$src2),
2856 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2857 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2858 let isCommutable = Commutable;
2859 }
2860 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2861 (ins VR64:$src1, i64mem:$src2),
2862 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2863 [(set VR64:$dst,
2864 (IntId64 VR64:$src1,
2865 (bitconvert (memopv2i32 addr:$src2))))]>;
2866
2867 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2868 (ins VR128:$src1, VR128:$src2),
2869 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2870 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2871 OpSize {
2872 let isCommutable = Commutable;
2873 }
2874 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2875 (ins VR128:$src1, i128mem:$src2),
2876 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2877 [(set VR128:$dst,
2878 (IntId128 VR128:$src1,
2879 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2880 }
2881}
2882
2883defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2884 int_x86_ssse3_phadd_w,
Evan Cheng4e444432008-06-16 21:16:24 +00002885 int_x86_ssse3_phadd_w_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002886defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2887 int_x86_ssse3_phadd_d,
Evan Cheng4e444432008-06-16 21:16:24 +00002888 int_x86_ssse3_phadd_d_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002889defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2890 int_x86_ssse3_phadd_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002891 int_x86_ssse3_phadd_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002892defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2893 int_x86_ssse3_phsub_w,
2894 int_x86_ssse3_phsub_w_128>;
2895defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2896 int_x86_ssse3_phsub_d,
2897 int_x86_ssse3_phsub_d_128>;
2898defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2899 int_x86_ssse3_phsub_sw,
2900 int_x86_ssse3_phsub_sw_128>;
2901defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2902 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng4e444432008-06-16 21:16:24 +00002903 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002904defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2905 int_x86_ssse3_pmul_hr_sw,
2906 int_x86_ssse3_pmul_hr_sw_128, 1>;
2907defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2908 int_x86_ssse3_pshuf_b,
2909 int_x86_ssse3_pshuf_b_128>;
2910defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2911 int_x86_ssse3_psign_b,
2912 int_x86_ssse3_psign_b_128>;
2913defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2914 int_x86_ssse3_psign_w,
2915 int_x86_ssse3_psign_w_128>;
Evan Chenged7f56b2009-05-28 18:48:53 +00002916defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling76d708b2007-08-10 06:22:27 +00002917 int_x86_ssse3_psign_d,
2918 int_x86_ssse3_psign_d_128>;
2919
Evan Chenge9083d62008-03-05 08:19:16 +00002920let Constraints = "$src1 = $dst" in {
Bill Wendlingae9671b2007-08-10 09:00:17 +00002921 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002922 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002923 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002924 []>;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002925 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002926 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002927 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002928 []>;
Bill Wendling76d708b2007-08-10 06:22:27 +00002929
Bill Wendlingae9671b2007-08-10 09:00:17 +00002930 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002931 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002932 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002933 []>, OpSize;
Dan Gohmanc2ecdc52008-05-28 01:50:19 +00002934 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb9e6b342009-11-20 22:28:42 +00002935 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen83e105c2007-10-11 20:58:37 +00002936 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng89321162009-10-28 06:30:34 +00002937 []>, OpSize;
Bill Wendling76d708b2007-08-10 06:22:27 +00002938}
Bill Wendlingddd35322007-05-02 23:11:52 +00002939
Nate Begemana09008b2009-10-19 02:17:23 +00002940// palignr patterns.
Sean Callananb9e6b342009-11-20 22:28:42 +00002941def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002942 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2943 Requires<[HasSSSE3]>;
2944def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2945 (memop64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002946 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002947 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2948 Requires<[HasSSSE3]>;
2949
Sean Callananb9e6b342009-11-20 22:28:42 +00002950def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002951 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2952 Requires<[HasSSSE3]>;
2953def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2954 (memopv2i64 addr:$src2),
Sean Callananb9e6b342009-11-20 22:28:42 +00002955 (i8 imm:$src3)),
Evan Cheng89321162009-10-28 06:30:34 +00002956 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2957 Requires<[HasSSSE3]>;
2958
Nate Begemana09008b2009-10-19 02:17:23 +00002959let AddedComplexity = 5 in {
2960def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2961 (PALIGNR128rr VR128:$src2, VR128:$src1,
2962 (SHUFFLE_get_palign_imm VR128:$src3))>,
2963 Requires<[HasSSSE3]>;
2964def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2965 (PALIGNR128rr VR128:$src2, VR128:$src1,
2966 (SHUFFLE_get_palign_imm VR128:$src3))>,
2967 Requires<[HasSSSE3]>;
2968def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2969 (PALIGNR128rr VR128:$src2, VR128:$src1,
2970 (SHUFFLE_get_palign_imm VR128:$src3))>,
2971 Requires<[HasSSSE3]>;
2972def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2973 (PALIGNR128rr VR128:$src2, VR128:$src1,
2974 (SHUFFLE_get_palign_imm VR128:$src3))>,
2975 Requires<[HasSSSE3]>;
Eric Christopher761411c2009-11-07 08:45:53 +00002976}
Nate Begemana09008b2009-10-19 02:17:23 +00002977
Nate Begemanb9a47b82009-02-23 08:49:38 +00002978def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2979 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2980def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2981 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2982
Eric Christopher44b93ff2009-07-31 20:07:27 +00002983//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002984// Non-Instruction Patterns
Eric Christopher44b93ff2009-07-31 20:07:27 +00002985//===---------------------------------------------------------------------===//
Evan Cheng48090aa2006-03-21 23:01:21 +00002986
Eric Christopher44b93ff2009-07-31 20:07:27 +00002987// extload f32 -> f64. This matches load+fextend because we have a hack in
2988// the isel (PreprocessForFPConvert) that can introduce loads after dag
2989// combine.
Chris Lattnerd43d00c2008-01-24 08:07:48 +00002990// Since these loads aren't folded into the fextend, we have to match it
2991// explicitly here.
2992let Predicates = [HasSSE2] in
2993 def : Pat<(fextend (loadf32 addr:$src)),
2994 (CVTSS2SDrm addr:$src)>;
2995
Evan Cheng2c0dbd02006-03-24 02:58:06 +00002996// bit_convert
Chris Lattner4cc84ed2006-10-07 04:52:09 +00002997let Predicates = [HasSSE2] in {
2998 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2999 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
3000 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
3001 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
3002 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
3003 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
3004 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
3005 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
3006 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
3007 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
3008 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
3009 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
3010 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
3011 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
3012 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
3013 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3014 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3015 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3016 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3017 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3018 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3019 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3020 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3021 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3022 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3023 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3024 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3025 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3026 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3027 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3028}
Evan Chengb9df0ca2006-03-22 02:53:00 +00003029
Evan Cheng017dcc62006-04-21 01:05:10 +00003030// Move scalar to XMM zero-extended
3031// movd to XMM register zero-extends
Evan Chengf2ea84a2006-10-09 21:42:15 +00003032let AddedComplexity = 15 in {
Evan Cheng017dcc62006-04-21 01:05:10 +00003033// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chengd880b972008-05-09 21:53:03 +00003034def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003035 (MOVSDrr (v2f64 (V_SET0)), FR64:$src)>;
Evan Chengd880b972008-05-09 21:53:03 +00003036def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Dan Gohman874cada2010-02-28 00:17:42 +00003037 (MOVSSrr (v4f32 (V_SET0)), FR32:$src)>;
Evan Cheng23573e52008-05-09 23:37:55 +00003038def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003039 (MOVSSrr (v4f32 (V_SET0)),
3040 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss)))>;
Evan Cheng331e2bd2008-07-10 01:08:23 +00003041def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Dan Gohman874cada2010-02-28 00:17:42 +00003042 (MOVSSrr (v4i32 (V_SET0)),
3043 (EXTRACT_SUBREG (v4i32 VR128:$src), x86_subreg_ss))>;
Evan Cheng017dcc62006-04-21 01:05:10 +00003044}
Evan Chengbc4832b2006-03-24 23:15:12 +00003045
Evan Chengb9df0ca2006-03-22 02:53:00 +00003046// Splat v2f64 / v2i64
Evan Chengfd111b52006-04-19 21:15:24 +00003047let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003048def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003049 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003050def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003051 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003052def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003053 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003054def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Evan Chengf686d9b2006-10-27 21:08:32 +00003055 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengfd111b52006-04-19 21:15:24 +00003056}
Evan Cheng475aecf2006-03-29 03:04:49 +00003057
Evan Chengb7a5c522006-04-18 21:55:35 +00003058// Special unary SHUFPSrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003059def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3060 (SHUFPSrri VR128:$src1, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003061 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003062let AddedComplexity = 5 in
3063def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3064 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3065 Requires<[HasSSE2]>;
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003066// Special unary SHUFPDrri case.
Nate Begeman9008ca62009-04-27 18:41:29 +00003067def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003068 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003069 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3070 Requires<[HasSSE2]>;
3071// Special unary SHUFPDrri case.
3072def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003073 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman9008ca62009-04-27 18:41:29 +00003074 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7f55fcb2007-08-02 21:17:01 +00003075 Requires<[HasSSE2]>;
Evan Cheng3d60df42006-04-10 22:35:16 +00003076// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman9008ca62009-04-27 18:41:29 +00003077def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3078 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng7d9061e2006-03-30 19:54:57 +00003079 Requires<[HasSSE2]>;
Evan Chengb7a75a52008-09-26 23:41:32 +00003080
Evan Cheng3d60df42006-04-10 22:35:16 +00003081// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman9008ca62009-04-27 18:41:29 +00003082def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003083 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003084 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003085 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003086def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003087 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003088 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Chris Lattner30da68a2006-06-20 00:25:29 +00003089 Requires<[HasSSE2]>;
Evan Cheng7a831ce2007-12-15 03:00:47 +00003090// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman9008ca62009-04-27 18:41:29 +00003091def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003092 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman9008ca62009-04-27 18:41:29 +00003093 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng7a831ce2007-12-15 03:00:47 +00003094 Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003095
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003096// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003097let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003098def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3099 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003100 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003101def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3102 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003103 Requires<[OptForSpeed, HasSSE2]>;
3104}
Evan Chengfd111b52006-04-19 21:15:24 +00003105let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003106def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003107 (UNPCKLPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003108def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003109 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003110def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003111 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003112def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003113 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
Evan Chengfd111b52006-04-19 21:15:24 +00003114}
Evan Cheng1d5a8cc2006-04-05 07:20:06 +00003115
Evan Cheng174f8032007-05-17 18:44:37 +00003116// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Chengb7a75a52008-09-26 23:41:32 +00003117let AddedComplexity = 15 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003118def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3119 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003120 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003121def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3122 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Chengb7a75a52008-09-26 23:41:32 +00003123 Requires<[OptForSpeed, HasSSE2]>;
3124}
Evan Cheng174f8032007-05-17 18:44:37 +00003125let AddedComplexity = 10 in {
Nate Begeman9008ca62009-04-27 18:41:29 +00003126def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003127 (UNPCKHPSrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003128def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003129 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003130def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003131 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003132def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003133 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
Evan Cheng174f8032007-05-17 18:44:37 +00003134}
3135
Evan Chengb7a75a52008-09-26 23:41:32 +00003136let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003137// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman0b10b912009-11-07 23:17:15 +00003138def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003139 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003140
3141// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003142def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003143 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
Evan Cheng2dadaea2006-04-19 20:37:34 +00003144
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003145// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003146def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003147 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003148def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003149 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003150}
Evan Cheng9d09b892006-05-31 00:51:37 +00003151
Evan Cheng6e56e2c2006-11-07 22:14:24 +00003152let AddedComplexity = 20 in {
Evan Cheng2dadaea2006-04-19 20:37:34 +00003153// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003154def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003155 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003156def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003157 (MOVLPDrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003158def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003159 (MOVLPSrm VR128:$src1, addr:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003160def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmane13709a2010-02-26 01:14:30 +00003161 (MOVLPDrm VR128:$src1, addr:$src2)>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003162}
Evan Cheng64e97692006-04-24 21:58:20 +00003163
Evan Chengcd0baf22008-05-23 21:23:16 +00003164// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman9008ca62009-04-27 18:41:29 +00003165def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003166 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003167def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003168 (MOVLPDmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003169def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3170 addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003171 (MOVLPSmr addr:$src1, VR128:$src2)>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003172def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Dan Gohmane13709a2010-02-26 01:14:30 +00003173 (MOVLPDmr addr:$src1, VR128:$src2)>;
Evan Chengcd0baf22008-05-23 21:23:16 +00003174
Evan Chengf2ea84a2006-10-09 21:42:15 +00003175let AddedComplexity = 15 in {
Evan Cheng64e97692006-04-24 21:58:20 +00003176// Setting the lowest element in the vector.
Nate Begeman9008ca62009-04-27 18:41:29 +00003177def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003178 (MOVSSrr (v4i32 VR128:$src1),
3179 (EXTRACT_SUBREG (v4i32 VR128:$src2), x86_subreg_ss))>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003180def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003181 (MOVSDrr (v2i64 VR128:$src1),
3182 (EXTRACT_SUBREG (v2i64 VR128:$src2), x86_subreg_sd))>;
Evan Chenga7fc6422006-04-24 23:34:56 +00003183
Dan Gohman874cada2010-02-28 00:17:42 +00003184// vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
Nate Begeman9008ca62009-04-27 18:41:29 +00003185def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003186 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3187 Requires<[HasSSE2]>;
Nate Begeman9008ca62009-04-27 18:41:29 +00003188def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohman874cada2010-02-28 00:17:42 +00003189 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, x86_subreg_sd))>,
3190 Requires<[HasSSE2]>;
Evan Chengf2ea84a2006-10-09 21:42:15 +00003191}
Evan Cheng9e062ed2006-05-03 20:32:03 +00003192
Eli Friedman7e2242b2009-06-19 07:00:55 +00003193// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3194// fall back to this for SSE1)
3195def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003196 (SHUFPSrri VR128:$src2, VR128:$src1,
Dan Gohmane13709a2010-02-26 01:14:30 +00003197 (SHUFFLE_get_shuf_imm VR128:$src3))>;
Eli Friedman7e2242b2009-06-19 07:00:55 +00003198
Evan Chenga7fc6422006-04-24 23:34:56 +00003199// Set lowest element and zero upper elements.
Evan Chengd880b972008-05-09 21:53:03 +00003200def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengfd17f422008-05-08 22:35:02 +00003201 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chengcdfc3c82006-04-17 22:45:49 +00003202
Evan Cheng2c3ae372006-04-12 21:21:57 +00003203// Some special case pandn patterns.
3204def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3205 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003206 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003207def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3208 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003209 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003210def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3211 VR128:$src2)),
Chris Lattner30da68a2006-06-20 00:25:29 +00003212 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng1b32f222006-03-30 07:33:32 +00003213
Evan Cheng2c3ae372006-04-12 21:21:57 +00003214def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003215 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003216 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003217def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003218 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003219 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2c3ae372006-04-12 21:21:57 +00003220def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Chengb1938262008-05-23 00:37:07 +00003221 (memop addr:$src2))),
Chris Lattner30da68a2006-06-20 00:25:29 +00003222 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Evan Cheng206ee9d2006-07-07 08:33:52 +00003223
Nate Begemanb348d182007-11-17 03:58:34 +00003224// vector -> vector casts
3225def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3226 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3227def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3228 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedmand0c0fae2008-09-05 23:07:03 +00003229def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3230 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3231def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3232 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb348d182007-11-17 03:58:34 +00003233
Evan Chengb4162fd2007-07-20 00:27:43 +00003234// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohmand3006222007-07-27 17:16:43 +00003235def : Pat<(alignedloadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003236 (MOVAPSrm addr:$src)>;
Dan Gohmand3006222007-07-27 17:16:43 +00003237def : Pat<(loadv4i32 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003238 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003239def : Pat<(alignedloadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003240 (MOVAPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003241def : Pat<(loadv2i64 addr:$src),
Dan Gohmane13709a2010-02-26 01:14:30 +00003242 (MOVUPSrm addr:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003243
3244def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003245 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003246def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003247 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003248def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003249 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003250def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003251 (MOVAPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003252def : Pat<(store (v2i64 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003253 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003254def : Pat<(store (v4i32 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003255 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003256def : Pat<(store (v8i16 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003257 (MOVUPSmr addr:$dst, VR128:$src)>;
Evan Chengb4162fd2007-07-20 00:27:43 +00003258def : Pat<(store (v16i8 VR128:$src), addr:$dst),
Dan Gohmane13709a2010-02-26 01:14:30 +00003259 (MOVUPSmr addr:$dst, VR128:$src)>;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003260
Nate Begeman63ec90a2008-02-03 07:18:54 +00003261//===----------------------------------------------------------------------===//
3262// SSE4.1 Instructions
3263//===----------------------------------------------------------------------===//
3264
Dale Johannesene397acc2008-10-10 23:51:03 +00003265multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003266 string OpcodeStr,
Nate Begeman63ec90a2008-02-03 07:18:54 +00003267 Intrinsic V4F32Int,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003268 Intrinsic V2F64Int> {
Nate Begeman63ec90a2008-02-03 07:18:54 +00003269 // Intrinsic operation, reg.
Nate Begeman63ec90a2008-02-03 07:18:54 +00003270 // Vector intrinsic operation, reg
Eric Christopher44b93ff2009-07-31 20:07:27 +00003271 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003272 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003273 !strconcat(OpcodeStr,
3274 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003275 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3276 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003277
3278 // Vector intrinsic operation, mem
Evan Cheng400073d2009-12-18 07:40:29 +00003279 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003280 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003281 !strconcat(OpcodeStr,
3282 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003283 [(set VR128:$dst,
3284 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Cheng400073d2009-12-18 07:40:29 +00003285 TA, OpSize,
Evan Chengb1f49812009-12-22 17:47:23 +00003286 Requires<[HasSSE41]>;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003287
Nate Begeman63ec90a2008-02-03 07:18:54 +00003288 // Vector intrinsic operation, reg
Evan Cheng172b7942008-03-14 07:39:27 +00003289 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman204e84e2008-02-04 06:00:24 +00003290 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003291 !strconcat(OpcodeStr,
3292 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003293 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3294 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003295
3296 // Vector intrinsic operation, mem
Evan Cheng172b7942008-03-14 07:39:27 +00003297 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman204e84e2008-02-04 06:00:24 +00003298 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begeman63ec90a2008-02-03 07:18:54 +00003299 !strconcat(OpcodeStr,
3300 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Chengb1938262008-05-23 00:37:07 +00003301 [(set VR128:$dst,
3302 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003303 OpSize;
Nate Begeman63ec90a2008-02-03 07:18:54 +00003304}
3305
Dale Johannesene397acc2008-10-10 23:51:03 +00003306let Constraints = "$src1 = $dst" in {
3307multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3308 string OpcodeStr,
3309 Intrinsic F32Int,
3310 Intrinsic F64Int> {
3311 // Intrinsic operation, reg.
3312 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003313 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003314 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3315 !strconcat(OpcodeStr,
3316 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003317 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003318 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3319 OpSize;
3320
3321 // Intrinsic operation, mem.
Eric Christopher44b93ff2009-07-31 20:07:27 +00003322 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3323 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003324 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003325 !strconcat(OpcodeStr,
Dale Johannesene397acc2008-10-10 23:51:03 +00003326 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003327 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003328 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3329 OpSize;
3330
3331 // Intrinsic operation, reg.
3332 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003333 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003334 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3335 !strconcat(OpcodeStr,
3336 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003337 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003338 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3339 OpSize;
3340
3341 // Intrinsic operation, mem.
3342 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher44b93ff2009-07-31 20:07:27 +00003343 (outs VR128:$dst),
Dale Johannesene397acc2008-10-10 23:51:03 +00003344 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3345 !strconcat(OpcodeStr,
3346 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003347 [(set VR128:$dst,
Dale Johannesene397acc2008-10-10 23:51:03 +00003348 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3349 OpSize;
3350}
3351}
3352
Nate Begeman63ec90a2008-02-03 07:18:54 +00003353// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesene397acc2008-10-10 23:51:03 +00003354defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3355 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3356defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3357 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003358
3359// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3360multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3361 Intrinsic IntId128> {
3362 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3363 (ins VR128:$src),
3364 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3365 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3366 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3367 (ins i128mem:$src),
3368 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3369 [(set VR128:$dst,
3370 (IntId128
3371 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3372}
3373
3374defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3375 int_x86_sse41_phminposuw>;
3376
3377/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003378let Constraints = "$src1 = $dst" in {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003379 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3380 Intrinsic IntId128, bit Commutable = 0> {
Nate Begemanfea2be52008-02-09 23:46:37 +00003381 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3382 (ins VR128:$src1, VR128:$src2),
3383 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3384 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3385 OpSize {
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003386 let isCommutable = Commutable;
3387 }
Nate Begemanfea2be52008-02-09 23:46:37 +00003388 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3389 (ins VR128:$src1, i128mem:$src2),
3390 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3391 [(set VR128:$dst,
3392 (IntId128 VR128:$src1,
3393 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begeman2f6f1c02008-02-04 05:34:34 +00003394 }
3395}
3396
3397defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3398 int_x86_sse41_pcmpeqq, 1>;
3399defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3400 int_x86_sse41_packusdw, 0>;
3401defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3402 int_x86_sse41_pminsb, 1>;
3403defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3404 int_x86_sse41_pminsd, 1>;
3405defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3406 int_x86_sse41_pminud, 1>;
3407defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3408 int_x86_sse41_pminuw, 1>;
3409defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3410 int_x86_sse41_pmaxsb, 1>;
3411defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3412 int_x86_sse41_pmaxsd, 1>;
3413defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3414 int_x86_sse41_pmaxud, 1>;
3415defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3416 int_x86_sse41_pmaxuw, 1>;
Nate Begeman204e84e2008-02-04 06:00:24 +00003417
Mon P Wangaf9b9522008-12-18 21:42:19 +00003418defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3419
Nate Begeman30a0de92008-07-17 16:51:19 +00003420def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3421 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3422def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3423 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3424
Nate Begeman1426d522008-02-09 01:38:08 +00003425/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003426let Constraints = "$src1 = $dst" in {
Dan Gohman0b924dc2008-05-23 17:49:40 +00003427 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3428 SDNode OpNode, Intrinsic IntId128,
3429 bit Commutable = 0> {
Nate Begeman1426d522008-02-09 01:38:08 +00003430 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3431 (ins VR128:$src1, VR128:$src2),
3432 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman0b924dc2008-05-23 17:49:40 +00003433 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3434 VR128:$src2))]>, OpSize {
Nate Begeman1426d522008-02-09 01:38:08 +00003435 let isCommutable = Commutable;
3436 }
3437 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3438 (ins VR128:$src1, VR128:$src2),
3439 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3440 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3441 OpSize {
3442 let isCommutable = Commutable;
3443 }
3444 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3445 (ins VR128:$src1, i128mem:$src2),
3446 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3447 [(set VR128:$dst,
Chris Lattner1a7d0872010-02-18 06:33:42 +00003448 (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003449 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3450 (ins VR128:$src1, i128mem:$src2),
3451 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3452 [(set VR128:$dst,
Evan Chengb1938262008-05-23 00:37:07 +00003453 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman1426d522008-02-09 01:38:08 +00003454 OpSize;
3455 }
3456}
Dan Gohman0b924dc2008-05-23 17:49:40 +00003457defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman1426d522008-02-09 01:38:08 +00003458 int_x86_sse41_pmulld, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003459
Evan Cheng172b7942008-03-14 07:39:27 +00003460/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Chenge9083d62008-03-05 08:19:16 +00003461let Constraints = "$src1 = $dst" in {
Nate Begeman204e84e2008-02-04 06:00:24 +00003462 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3463 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng172b7942008-03-14 07:39:27 +00003464 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003465 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003466 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003467 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003468 [(set VR128:$dst,
Nate Begemanfea2be52008-02-09 23:46:37 +00003469 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3470 OpSize {
Nate Begeman204e84e2008-02-04 06:00:24 +00003471 let isCommutable = Commutable;
3472 }
Evan Cheng172b7942008-03-14 07:39:27 +00003473 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003474 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3475 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003476 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begemanfea2be52008-02-09 23:46:37 +00003477 [(set VR128:$dst,
3478 (IntId128 VR128:$src1,
3479 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3480 OpSize;
Nate Begeman204e84e2008-02-04 06:00:24 +00003481 }
3482}
3483
3484defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3485 int_x86_sse41_blendps, 0>;
3486defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3487 int_x86_sse41_blendpd, 0>;
3488defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3489 int_x86_sse41_pblendw, 0>;
3490defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3491 int_x86_sse41_dpps, 1>;
3492defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3493 int_x86_sse41_dppd, 1>;
3494defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng35b9a772008-06-16 20:25:59 +00003495 int_x86_sse41_mpsadbw, 1>;
Nate Begeman1426d522008-02-09 01:38:08 +00003496
Nate Begemanfea2be52008-02-09 23:46:37 +00003497
Evan Cheng172b7942008-03-14 07:39:27 +00003498/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Chenge9083d62008-03-05 08:19:16 +00003499let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanab5d56c2008-02-10 18:47:57 +00003500 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3501 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3502 (ins VR128:$src1, VR128:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003503 !strconcat(OpcodeStr,
Nate Begemanab5d56c2008-02-10 18:47:57 +00003504 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3505 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3506 OpSize;
3507
3508 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3509 (ins VR128:$src1, i128mem:$src2),
3510 !strconcat(OpcodeStr,
3511 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3512 [(set VR128:$dst,
3513 (IntId VR128:$src1,
3514 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3515 }
3516}
3517
3518defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3519defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3520defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3521
3522
Nate Begemanfea2be52008-02-09 23:46:37 +00003523multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3524 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3525 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3526 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3527
3528 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3529 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003530 [(set VR128:$dst,
3531 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3532 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003533}
3534
3535defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3536defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3537defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3538defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3539defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3540defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3541
Evan Chengca57f782008-09-24 23:27:55 +00003542// Common patterns involving scalar load.
3543def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3544 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3545def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3546 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3547
3548def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3549 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3550def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3551 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3552
3553def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3554 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3555def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3556 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3557
3558def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3559 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3560def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3561 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3562
3563def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3564 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3565def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3566 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3567
3568def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3569 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3570def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3571 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3572
3573
Nate Begemanfea2be52008-02-09 23:46:37 +00003574multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3575 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3576 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3577 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3578
3579 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3580 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003581 [(set VR128:$dst,
3582 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3583 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003584}
3585
3586defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3587defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3588defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3589defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3590
Evan Chengca57f782008-09-24 23:27:55 +00003591// Common patterns involving scalar load
3592def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003593 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003594def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003595 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003596
3597def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003598 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003599def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng89d4a282008-09-25 00:49:51 +00003600 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003601
3602
Nate Begemanfea2be52008-02-09 23:46:37 +00003603multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3604 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3605 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3606 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3607
Evan Chengca57f782008-09-24 23:27:55 +00003608 // Expecting a i16 load any extended to i32 value.
Nate Begemanfea2be52008-02-09 23:46:37 +00003609 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3610 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Chengca57f782008-09-24 23:27:55 +00003611 [(set VR128:$dst, (IntId (bitconvert
3612 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3613 OpSize;
Nate Begemanfea2be52008-02-09 23:46:37 +00003614}
3615
3616defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman9d47b8d2009-06-06 05:55:37 +00003617defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begemanfea2be52008-02-09 23:46:37 +00003618
Evan Chengca57f782008-09-24 23:27:55 +00003619// Common patterns involving scalar load
3620def : Pat<(int_x86_sse41_pmovsxbq
3621 (bitconvert (v4i32 (X86vzmovl
3622 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003623 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003624
3625def : Pat<(int_x86_sse41_pmovzxbq
3626 (bitconvert (v4i32 (X86vzmovl
3627 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng89d4a282008-09-25 00:49:51 +00003628 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Chengca57f782008-09-24 23:27:55 +00003629
Nate Begemanfea2be52008-02-09 23:46:37 +00003630
Nate Begeman14d12ca2008-02-11 04:19:36 +00003631/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3632multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003633 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003634 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003635 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003636 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003637 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3638 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003639 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003640 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003641 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003642 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003643 []>, OpSize;
3644// FIXME:
3645// There's an AssertZext in the way of writing the store pattern
3646// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begemanfea2be52008-02-09 23:46:37 +00003647}
3648
Nate Begeman14d12ca2008-02-11 04:19:36 +00003649defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003650
Nate Begeman14d12ca2008-02-11 04:19:36 +00003651
3652/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3653multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003654 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003655 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003656 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003657 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3658 []>, OpSize;
3659// FIXME:
3660// There's an AssertZext in the way of writing the store pattern
3661// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3662}
3663
3664defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3665
3666
3667/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3668multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003669 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003670 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003671 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003672 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3673 [(set GR32:$dst,
3674 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003675 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003676 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003677 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003678 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3679 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3680 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003681}
3682
Nate Begeman14d12ca2008-02-11 04:19:36 +00003683defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman1426d522008-02-09 01:38:08 +00003684
Nate Begeman14d12ca2008-02-11 04:19:36 +00003685
Evan Cheng62a3f152008-03-24 21:52:23 +00003686/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3687/// destination
Nate Begeman14d12ca2008-02-11 04:19:36 +00003688multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Cheng7aae8762008-03-26 08:11:49 +00003689 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begemanfea2be52008-02-09 23:46:37 +00003690 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003691 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003692 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman171c11e2008-04-16 02:32:24 +00003693 [(set GR32:$dst,
3694 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng62a3f152008-03-24 21:52:23 +00003695 OpSize;
Eric Christopher44b93ff2009-07-31 20:07:27 +00003696 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemanfea2be52008-02-09 23:46:37 +00003697 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003698 !strconcat(OpcodeStr,
Nate Begemanfea2be52008-02-09 23:46:37 +00003699 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng62a3f152008-03-24 21:52:23 +00003700 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begemanfea2be52008-02-09 23:46:37 +00003701 addr:$dst)]>, OpSize;
Nate Begeman1426d522008-02-09 01:38:08 +00003702}
3703
Nate Begeman14d12ca2008-02-11 04:19:36 +00003704defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begemanfea2be52008-02-09 23:46:37 +00003705
Dan Gohmand9ced092008-08-08 18:30:21 +00003706// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3707def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3708 imm:$src2))),
3709 addr:$dst),
3710 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3711 Requires<[HasSSE41]>;
3712
Evan Chenge9083d62008-03-05 08:19:16 +00003713let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003714 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003715 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003716 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003717 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003718 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003719 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003720 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003721 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003722 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3723 !strconcat(OpcodeStr,
3724 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003725 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003726 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3727 imm:$src3))]>, OpSize;
3728 }
3729}
3730
3731defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3732
Evan Chenge9083d62008-03-05 08:19:16 +00003733let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003734 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng172b7942008-03-14 07:39:27 +00003735 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003736 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003737 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003738 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003739 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003740 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3741 OpSize;
Evan Cheng172b7942008-03-14 07:39:27 +00003742 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003743 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3744 !strconcat(OpcodeStr,
3745 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003746 [(set VR128:$dst,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003747 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3748 imm:$src3)))]>, OpSize;
3749 }
3750}
3751
3752defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3753
Eric Christopher1e5cdea2009-07-23 02:22:41 +00003754// insertps has a few different modes, there's the first two here below which
3755// are optimized inserts that won't zero arbitrary elements in the destination
3756// vector. The next one matches the intrinsic and could zero arbitrary elements
3757// in the target vector.
Evan Chenge9083d62008-03-05 08:19:16 +00003758let Constraints = "$src1 = $dst" in {
Nate Begeman14d12ca2008-02-11 04:19:36 +00003759 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherfbd66872009-07-24 00:33:09 +00003760 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3761 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003762 !strconcat(OpcodeStr,
Nate Begeman14d12ca2008-02-11 04:19:36 +00003763 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003764 [(set VR128:$dst,
3765 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan108934c2009-12-18 00:01:26 +00003766 OpSize;
Eric Christopherfbd66872009-07-24 00:33:09 +00003767 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003768 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3769 !strconcat(OpcodeStr,
3770 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher44b93ff2009-07-31 20:07:27 +00003771 [(set VR128:$dst,
Eric Christopherfbd66872009-07-24 00:33:09 +00003772 (X86insrtps VR128:$src1,
3773 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begeman14d12ca2008-02-11 04:19:36 +00003774 imm:$src3))]>, OpSize;
3775 }
3776}
3777
Evan Cheng7aae8762008-03-26 08:11:49 +00003778defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003779
Eric Christopherfbd66872009-07-24 00:33:09 +00003780def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3781 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3782
Eric Christopher71c67532009-07-29 00:28:05 +00003783// ptest instruction we'll lower to this in X86ISelLowering primarily from
3784// the intel intrinsic that corresponds to this.
Nate Begemanbc4efb82008-03-16 21:14:46 +00003785let Defs = [EFLAGS] in {
3786def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003787 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003788 [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>,
3789 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003790def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher71c67532009-07-29 00:28:05 +00003791 "ptest \t{$src2, $src1|$src1, $src2}",
Chris Lattnerd486d772010-03-28 05:07:17 +00003792 [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>,
3793 OpSize;
Nate Begemanbc4efb82008-03-16 21:14:46 +00003794}
3795
3796def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3797 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderby40fe18f2010-02-10 00:10:31 +00003798 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3799 OpSize;
Nate Begeman30a0de92008-07-17 16:51:19 +00003800
Eric Christopherb120ab42009-08-18 22:50:32 +00003801
3802//===----------------------------------------------------------------------===//
3803// SSE4.2 Instructions
3804//===----------------------------------------------------------------------===//
3805
Nate Begeman30a0de92008-07-17 16:51:19 +00003806/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3807let Constraints = "$src1 = $dst" in {
3808 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3809 Intrinsic IntId128, bit Commutable = 0> {
3810 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3811 (ins VR128:$src1, VR128:$src2),
3812 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3813 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3814 OpSize {
3815 let isCommutable = Commutable;
3816 }
3817 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3818 (ins VR128:$src1, i128mem:$src2),
3819 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3820 [(set VR128:$dst,
3821 (IntId128 VR128:$src1,
3822 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3823 }
3824}
3825
Nate Begemane99b2552008-07-17 17:04:58 +00003826defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman30a0de92008-07-17 16:51:19 +00003827
3828def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3829 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3830def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3831 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003832
Bob Wilson86afec72010-03-25 16:36:14 +00003833defm AESIMC : SS42I_binop_rm_int<0xDB, "aesimc",
3834 int_x86_sse42_aesimc>;
3835defm AESENC : SS42I_binop_rm_int<0xDC, "aesenc",
3836 int_x86_sse42_aesenc>;
3837defm AESENCLAST : SS42I_binop_rm_int<0xDD, "aesenclast",
3838 int_x86_sse42_aesenclast>;
3839defm AESDEC : SS42I_binop_rm_int<0xDE, "aesdec",
3840 int_x86_sse42_aesdec>;
3841defm AESDECLAST : SS42I_binop_rm_int<0xDF, "aesdeclast",
3842 int_x86_sse42_aesdeclast>;
3843
3844def : Pat<(v2i64 (X86aesimc VR128:$src1, VR128:$src2)),
3845 (AESIMCrr VR128:$src1, VR128:$src2)>;
3846def : Pat<(v2i64 (X86aesimc VR128:$src1, (memop addr:$src2))),
3847 (AESIMCrm VR128:$src1, addr:$src2)>;
3848def : Pat<(v2i64 (X86aesenc VR128:$src1, VR128:$src2)),
3849 (AESENCrr VR128:$src1, VR128:$src2)>;
3850def : Pat<(v2i64 (X86aesenc VR128:$src1, (memop addr:$src2))),
3851 (AESENCrm VR128:$src1, addr:$src2)>;
3852def : Pat<(v2i64 (X86aesenclast VR128:$src1, VR128:$src2)),
3853 (AESENCLASTrr VR128:$src1, VR128:$src2)>;
3854def : Pat<(v2i64 (X86aesenclast VR128:$src1, (memop addr:$src2))),
3855 (AESENCLASTrm VR128:$src1, addr:$src2)>;
3856def : Pat<(v2i64 (X86aesdec VR128:$src1, VR128:$src2)),
3857 (AESDECrr VR128:$src1, VR128:$src2)>;
3858def : Pat<(v2i64 (X86aesdec VR128:$src1, (memop addr:$src2))),
3859 (AESDECrm VR128:$src1, addr:$src2)>;
3860def : Pat<(v2i64 (X86aesdeclast VR128:$src1, VR128:$src2)),
3861 (AESDECLASTrr VR128:$src1, VR128:$src2)>;
3862def : Pat<(v2i64 (X86aesdeclast VR128:$src1, (memop addr:$src2))),
3863 (AESDECLASTrm VR128:$src1, addr:$src2)>;
3864
3865def AESKEYGENASSIST128rr : SS42AI<0xDF, MRMSrcReg, (outs),
3866 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3867 "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
3868def AESKEYGENASSIST128rm : SS42AI<0xDF, MRMSrcMem, (outs),
3869 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3870 "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
3871
Eric Christopherb4dc13c2009-08-08 21:55:08 +00003872// 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!",
3966 [(set VR128:$dst,
3967 (int_x86_sse42_pcmpestrm128
3968 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!",
3973 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3974 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3975 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> {
Sean Callanan108934c2009-12-18 00:01:26 +00003989 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3990 (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}",
4020 [(set ECX,
4021 (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>;