1 //====- X86InstrSSE.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // SSE specific DAG Nodes.
18 //===----------------------------------------------------------------------===//
20 def SDTX86Unpcklp : SDTypeProfile<1, 2,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>]>;
23 def X86loadp : SDNode<"X86ISD::LOAD_PACK", SDTLoad,
25 def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
26 [SDNPCommutative, SDNPAssociative]>;
27 def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
28 [SDNPCommutative, SDNPAssociative]>;
29 def X86s2vec : SDNode<"X86ISD::SCALAR_TO_VECTOR",
30 SDTypeProfile<1, 1, []>, []>;
31 def X86unpcklp : SDNode<"X86ISD::UNPCKLP",
34 //===----------------------------------------------------------------------===//
35 // SSE pattern fragments
36 //===----------------------------------------------------------------------===//
38 def X86loadpf32 : PatFrag<(ops node:$ptr), (f32 (X86loadp node:$ptr))>;
39 def X86loadpf64 : PatFrag<(ops node:$ptr), (f64 (X86loadp node:$ptr))>;
41 def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
42 def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
43 def loadv16i8 : PatFrag<(ops node:$ptr), (v16i8 (load node:$ptr))>;
44 def loadv8i16 : PatFrag<(ops node:$ptr), (v8i16 (load node:$ptr))>;
45 def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
46 def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
48 def fp32imm0 : PatLeaf<(f32 fpimm), [{
49 return N->isExactlyValue(+0.0);
52 def vecimm0 : PatLeaf<(build_vector), [{
53 return X86::isZeroVector(N);
56 // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
58 def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
59 return getI8Imm(X86::getShuffleSHUFImmediate(N));
62 def SHUFP_splat_mask : PatLeaf<(build_vector), [{
63 return X86::isSplatMask(N);
64 }], SHUFFLE_get_shuf_imm>;
66 def MOVLHPS_splat_mask : PatLeaf<(build_vector), [{
67 return X86::isSplatMask(N);
70 def MOVLHPSorUNPCKLPD_shuffle_mask : PatLeaf<(build_vector), [{
71 return X86::isMOVLHPSorUNPCKLPDMask(N);
72 }], SHUFFLE_get_shuf_imm>;
74 def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
75 return X86::isMOVHLPSMask(N);
76 }], SHUFFLE_get_shuf_imm>;
78 def UNPCKHPD_shuffle_mask : PatLeaf<(build_vector), [{
79 return X86::isUNPCKHPDMask(N);
80 }], SHUFFLE_get_shuf_imm>;
82 // Only use PSHUF if it is not a splat.
83 def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
84 return !X86::isSplatMask(N) && X86::isPSHUFDMask(N);
85 }], SHUFFLE_get_shuf_imm>;
87 def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
88 return X86::isSHUFPMask(N);
89 }], SHUFFLE_get_shuf_imm>;
91 //===----------------------------------------------------------------------===//
92 // SSE scalar FP Instructions
93 //===----------------------------------------------------------------------===//
95 // Instruction templates
96 // SSI - SSE1 instructions with XS prefix.
97 // SDI - SSE2 instructions with XD prefix.
98 // PSI - SSE1 instructions with TB prefix.
99 // PDI - SSE2 instructions with TB and OpSize prefixes.
100 // PSIi8 - SSE1 instructions with ImmT == Imm8 and TB prefix.
101 // PDIi8 - SSE2 instructions with ImmT == Imm8 and TB and OpSize prefixes.
102 class SSI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
103 : I<o, F, ops, asm, pattern>, XS, Requires<[HasSSE1]>;
104 class SDI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
105 : I<o, F, ops, asm, pattern>, XD, Requires<[HasSSE2]>;
106 class PSI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
107 : I<o, F, ops, asm, pattern>, TB, Requires<[HasSSE1]>;
108 class PDI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
109 : I<o, F, ops, asm, pattern>, TB, OpSize, Requires<[HasSSE2]>;
110 class PSIi8<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
111 : X86Inst<o, F, Imm8, ops, asm>, TB, Requires<[HasSSE1]> {
112 let Pattern = pattern;
114 class PDIi8<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
115 : X86Inst<o, F, Imm8, ops, asm>, TB, OpSize, Requires<[HasSSE2]> {
116 let Pattern = pattern;
119 // Some 'special' instructions
120 def IMPLICIT_DEF_FR32 : I<0, Pseudo, (ops FR32:$dst),
121 "#IMPLICIT_DEF $dst",
122 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
123 def IMPLICIT_DEF_FR64 : I<0, Pseudo, (ops FR64:$dst),
124 "#IMPLICIT_DEF $dst",
125 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
127 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
128 // scheduler into a branch sequence.
129 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
130 def CMOV_FR32 : I<0, Pseudo,
131 (ops FR32:$dst, FR32:$t, FR32:$f, i8imm:$cond),
132 "#CMOV_FR32 PSEUDO!",
133 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond))]>;
134 def CMOV_FR64 : I<0, Pseudo,
135 (ops FR64:$dst, FR64:$t, FR64:$f, i8imm:$cond),
136 "#CMOV_FR64 PSEUDO!",
137 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond))]>;
141 def MOVSSrr : SSI<0x10, MRMSrcReg, (ops FR32:$dst, FR32:$src),
142 "movss {$src, $dst|$dst, $src}", []>;
143 def MOVSSrm : SSI<0x10, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
144 "movss {$src, $dst|$dst, $src}",
145 [(set FR32:$dst, (loadf32 addr:$src))]>;
146 def MOVSDrr : SDI<0x10, MRMSrcReg, (ops FR64:$dst, FR64:$src),
147 "movsd {$src, $dst|$dst, $src}", []>;
148 def MOVSDrm : SDI<0x10, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
149 "movsd {$src, $dst|$dst, $src}",
150 [(set FR64:$dst, (loadf64 addr:$src))]>;
152 def MOVSSmr : SSI<0x11, MRMDestMem, (ops f32mem:$dst, FR32:$src),
153 "movss {$src, $dst|$dst, $src}",
154 [(store FR32:$src, addr:$dst)]>;
155 def MOVSDmr : SDI<0x11, MRMDestMem, (ops f64mem:$dst, FR64:$src),
156 "movsd {$src, $dst|$dst, $src}",
157 [(store FR64:$src, addr:$dst)]>;
159 // Conversion instructions
160 def CVTTSS2SIrr: SSI<0x2C, MRMSrcReg, (ops R32:$dst, FR32:$src),
161 "cvttss2si {$src, $dst|$dst, $src}",
162 [(set R32:$dst, (fp_to_sint FR32:$src))]>;
163 def CVTTSS2SIrm: SSI<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
164 "cvttss2si {$src, $dst|$dst, $src}",
165 [(set R32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
166 def CVTTSD2SIrr: SDI<0x2C, MRMSrcReg, (ops R32:$dst, FR64:$src),
167 "cvttsd2si {$src, $dst|$dst, $src}",
168 [(set R32:$dst, (fp_to_sint FR64:$src))]>;
169 def CVTTSD2SIrm: SDI<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
170 "cvttsd2si {$src, $dst|$dst, $src}",
171 [(set R32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
172 def CVTSD2SSrr: SDI<0x5A, MRMSrcReg, (ops FR32:$dst, FR64:$src),
173 "cvtsd2ss {$src, $dst|$dst, $src}",
174 [(set FR32:$dst, (fround FR64:$src))]>;
175 def CVTSD2SSrm: SDI<0x5A, MRMSrcMem, (ops FR32:$dst, f64mem:$src),
176 "cvtsd2ss {$src, $dst|$dst, $src}",
177 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
178 def CVTSI2SSrr: SSI<0x2A, MRMSrcReg, (ops FR32:$dst, R32:$src),
179 "cvtsi2ss {$src, $dst|$dst, $src}",
180 [(set FR32:$dst, (sint_to_fp R32:$src))]>;
181 def CVTSI2SSrm: SSI<0x2A, MRMSrcMem, (ops FR32:$dst, i32mem:$src),
182 "cvtsi2ss {$src, $dst|$dst, $src}",
183 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
184 def CVTSI2SDrr: SDI<0x2A, MRMSrcReg, (ops FR64:$dst, R32:$src),
185 "cvtsi2sd {$src, $dst|$dst, $src}",
186 [(set FR64:$dst, (sint_to_fp R32:$src))]>;
187 def CVTSI2SDrm: SDI<0x2A, MRMSrcMem, (ops FR64:$dst, i32mem:$src),
188 "cvtsi2sd {$src, $dst|$dst, $src}",
189 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
190 // SSE2 instructions with XS prefix
191 def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops FR64:$dst, FR32:$src),
192 "cvtss2sd {$src, $dst|$dst, $src}",
193 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
195 def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops FR64:$dst, f32mem:$src),
196 "cvtss2sd {$src, $dst|$dst, $src}",
197 [(set FR64:$dst, (fextend (loadf32 addr:$src)))]>, XS,
200 // Arithmetic instructions
201 let isTwoAddress = 1 in {
202 let isCommutable = 1 in {
203 def ADDSSrr : SSI<0x58, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
204 "addss {$src2, $dst|$dst, $src2}",
205 [(set FR32:$dst, (fadd FR32:$src1, FR32:$src2))]>;
206 def ADDSDrr : SDI<0x58, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
207 "addsd {$src2, $dst|$dst, $src2}",
208 [(set FR64:$dst, (fadd FR64:$src1, FR64:$src2))]>;
209 def MULSSrr : SSI<0x59, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
210 "mulss {$src2, $dst|$dst, $src2}",
211 [(set FR32:$dst, (fmul FR32:$src1, FR32:$src2))]>;
212 def MULSDrr : SDI<0x59, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
213 "mulsd {$src2, $dst|$dst, $src2}",
214 [(set FR64:$dst, (fmul FR64:$src1, FR64:$src2))]>;
217 def ADDSSrm : SSI<0x58, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
218 "addss {$src2, $dst|$dst, $src2}",
219 [(set FR32:$dst, (fadd FR32:$src1, (loadf32 addr:$src2)))]>;
220 def ADDSDrm : SDI<0x58, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
221 "addsd {$src2, $dst|$dst, $src2}",
222 [(set FR64:$dst, (fadd FR64:$src1, (loadf64 addr:$src2)))]>;
223 def MULSSrm : SSI<0x59, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
224 "mulss {$src2, $dst|$dst, $src2}",
225 [(set FR32:$dst, (fmul FR32:$src1, (loadf32 addr:$src2)))]>;
226 def MULSDrm : SDI<0x59, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
227 "mulsd {$src2, $dst|$dst, $src2}",
228 [(set FR64:$dst, (fmul FR64:$src1, (loadf64 addr:$src2)))]>;
230 def DIVSSrr : SSI<0x5E, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
231 "divss {$src2, $dst|$dst, $src2}",
232 [(set FR32:$dst, (fdiv FR32:$src1, FR32:$src2))]>;
233 def DIVSSrm : SSI<0x5E, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
234 "divss {$src2, $dst|$dst, $src2}",
235 [(set FR32:$dst, (fdiv FR32:$src1, (loadf32 addr:$src2)))]>;
236 def DIVSDrr : SDI<0x5E, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
237 "divsd {$src2, $dst|$dst, $src2}",
238 [(set FR64:$dst, (fdiv FR64:$src1, FR64:$src2))]>;
239 def DIVSDrm : SDI<0x5E, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
240 "divsd {$src2, $dst|$dst, $src2}",
241 [(set FR64:$dst, (fdiv FR64:$src1, (loadf64 addr:$src2)))]>;
243 def SUBSSrr : SSI<0x5C, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
244 "subss {$src2, $dst|$dst, $src2}",
245 [(set FR32:$dst, (fsub FR32:$src1, FR32:$src2))]>;
246 def SUBSSrm : SSI<0x5C, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
247 "subss {$src2, $dst|$dst, $src2}",
248 [(set FR32:$dst, (fsub FR32:$src1, (loadf32 addr:$src2)))]>;
249 def SUBSDrr : SDI<0x5C, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
250 "subsd {$src2, $dst|$dst, $src2}",
251 [(set FR64:$dst, (fsub FR64:$src1, FR64:$src2))]>;
252 def SUBSDrm : SDI<0x5C, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
253 "subsd {$src2, $dst|$dst, $src2}",
254 [(set FR64:$dst, (fsub FR64:$src1, (loadf64 addr:$src2)))]>;
257 def SQRTSSrr : SSI<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src),
258 "sqrtss {$src, $dst|$dst, $src}",
259 [(set FR32:$dst, (fsqrt FR32:$src))]>;
260 def SQRTSSrm : SSI<0x51, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
261 "sqrtss {$src, $dst|$dst, $src}",
262 [(set FR32:$dst, (fsqrt (loadf32 addr:$src)))]>;
263 def SQRTSDrr : SDI<0x51, MRMSrcReg, (ops FR64:$dst, FR64:$src),
264 "sqrtsd {$src, $dst|$dst, $src}",
265 [(set FR64:$dst, (fsqrt FR64:$src))]>;
266 def SQRTSDrm : SDI<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
267 "sqrtsd {$src, $dst|$dst, $src}",
268 [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>;
270 def RSQRTSSrr : SSI<0x52, MRMSrcReg, (ops FR32:$dst, FR32:$src),
271 "rsqrtss {$src, $dst|$dst, $src}", []>;
272 def RSQRTSSrm : SSI<0x52, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
273 "rsqrtss {$src, $dst|$dst, $src}", []>;
274 def RCPSSrr : SSI<0x53, MRMSrcReg, (ops FR32:$dst, FR32:$src),
275 "rcpss {$src, $dst|$dst, $src}", []>;
276 def RCPSSrm : SSI<0x53, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
277 "rcpss {$src, $dst|$dst, $src}", []>;
279 def MAXSSrr : SSI<0x5F, MRMSrcReg, (ops FR32:$dst, FR32:$src),
280 "maxss {$src, $dst|$dst, $src}", []>;
281 def MAXSSrm : SSI<0x5F, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
282 "maxss {$src, $dst|$dst, $src}", []>;
283 def MAXSDrr : SDI<0x5F, MRMSrcReg, (ops FR64:$dst, FR64:$src),
284 "maxsd {$src, $dst|$dst, $src}", []>;
285 def MAXSDrm : SDI<0x5F, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
286 "maxsd {$src, $dst|$dst, $src}", []>;
287 def MINSSrr : SSI<0x5D, MRMSrcReg, (ops FR32:$dst, FR32:$src),
288 "minss {$src, $dst|$dst, $src}", []>;
289 def MINSSrm : SSI<0x5D, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
290 "minss {$src, $dst|$dst, $src}", []>;
291 def MINSDrr : SDI<0x5D, MRMSrcReg, (ops FR64:$dst, FR64:$src),
292 "minsd {$src, $dst|$dst, $src}", []>;
293 def MINSDrm : SDI<0x5D, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
294 "minsd {$src, $dst|$dst, $src}", []>;
296 // Comparison instructions
297 let isTwoAddress = 1 in {
298 def CMPSSrr : SSI<0xC2, MRMSrcReg,
299 (ops FR32:$dst, FR32:$src1, FR32:$src, SSECC:$cc),
300 "cmp${cc}ss {$src, $dst|$dst, $src}", []>;
301 def CMPSSrm : SSI<0xC2, MRMSrcMem,
302 (ops FR32:$dst, FR32:$src1, f32mem:$src, SSECC:$cc),
303 "cmp${cc}ss {$src, $dst|$dst, $src}", []>;
304 def CMPSDrr : SDI<0xC2, MRMSrcReg,
305 (ops FR64:$dst, FR64:$src1, FR64:$src, SSECC:$cc),
306 "cmp${cc}sd {$src, $dst|$dst, $src}", []>;
307 def CMPSDrm : SDI<0xC2, MRMSrcMem,
308 (ops FR64:$dst, FR64:$src1, f64mem:$src, SSECC:$cc),
309 "cmp${cc}sd {$src, $dst|$dst, $src}", []>;
312 def UCOMISSrr: PSI<0x2E, MRMSrcReg, (ops FR32:$src1, FR32:$src2),
313 "ucomiss {$src2, $src1|$src1, $src2}",
314 [(X86cmp FR32:$src1, FR32:$src2)]>;
315 def UCOMISSrm: PSI<0x2E, MRMSrcMem, (ops FR32:$src1, f32mem:$src2),
316 "ucomiss {$src2, $src1|$src1, $src2}",
317 [(X86cmp FR32:$src1, (loadf32 addr:$src2))]>;
318 def UCOMISDrr: PDI<0x2E, MRMSrcReg, (ops FR64:$src1, FR64:$src2),
319 "ucomisd {$src2, $src1|$src1, $src2}",
320 [(X86cmp FR64:$src1, FR64:$src2)]>;
321 def UCOMISDrm: PDI<0x2E, MRMSrcMem, (ops FR64:$src1, f64mem:$src2),
322 "ucomisd {$src2, $src1|$src1, $src2}",
323 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
325 // Aliases of packed instructions for scalar use. These all have names that
328 // Alias instructions that map fld0 to pxor for sse.
329 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
330 def FsFLD0SS : I<0xEF, MRMInitReg, (ops FR32:$dst),
331 "pxor $dst, $dst", [(set FR32:$dst, fp32imm0)]>,
332 Requires<[HasSSE1]>, TB, OpSize;
333 def FsFLD0SD : I<0xEF, MRMInitReg, (ops FR64:$dst),
334 "pxor $dst, $dst", [(set FR64:$dst, fp64imm0)]>,
335 Requires<[HasSSE2]>, TB, OpSize;
337 // Alias instructions to do FR32 / FR64 reg-to-reg copy using movaps / movapd.
338 // Upper bits are disregarded.
339 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (ops FR32:$dst, FR32:$src),
340 "movaps {$src, $dst|$dst, $src}", []>;
341 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (ops FR64:$dst, FR64:$src),
342 "movapd {$src, $dst|$dst, $src}", []>;
344 // Alias instructions to load FR32 / FR64 from f128mem using movaps / movapd.
345 // Upper bits are disregarded.
346 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (ops FR32:$dst, f128mem:$src),
347 "movaps {$src, $dst|$dst, $src}",
348 [(set FR32:$dst, (X86loadpf32 addr:$src))]>;
349 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (ops FR64:$dst, f128mem:$src),
350 "movapd {$src, $dst|$dst, $src}",
351 [(set FR64:$dst, (X86loadpf64 addr:$src))]>;
353 // Alias bitwise logical operations using SSE logical ops on packed FP values.
354 let isTwoAddress = 1 in {
355 let isCommutable = 1 in {
356 def FsANDPSrr : PSI<0x54, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
357 "andps {$src2, $dst|$dst, $src2}",
358 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
359 def FsANDPDrr : PDI<0x54, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
360 "andpd {$src2, $dst|$dst, $src2}",
361 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
362 def FsORPSrr : PSI<0x56, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
363 "orps {$src2, $dst|$dst, $src2}", []>;
364 def FsORPDrr : PDI<0x56, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
365 "orpd {$src2, $dst|$dst, $src2}", []>;
366 def FsXORPSrr : PSI<0x57, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
367 "xorps {$src2, $dst|$dst, $src2}",
368 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
369 def FsXORPDrr : PDI<0x57, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
370 "xorpd {$src2, $dst|$dst, $src2}",
371 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
373 def FsANDPSrm : PSI<0x54, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f128mem:$src2),
374 "andps {$src2, $dst|$dst, $src2}",
375 [(set FR32:$dst, (X86fand FR32:$src1,
376 (X86loadpf32 addr:$src2)))]>;
377 def FsANDPDrm : PDI<0x54, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f128mem:$src2),
378 "andpd {$src2, $dst|$dst, $src2}",
379 [(set FR64:$dst, (X86fand FR64:$src1,
380 (X86loadpf64 addr:$src2)))]>;
381 def FsORPSrm : PSI<0x56, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f128mem:$src2),
382 "orps {$src2, $dst|$dst, $src2}", []>;
383 def FsORPDrm : PDI<0x56, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f128mem:$src2),
384 "orpd {$src2, $dst|$dst, $src2}", []>;
385 def FsXORPSrm : PSI<0x57, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f128mem:$src2),
386 "xorps {$src2, $dst|$dst, $src2}",
387 [(set FR32:$dst, (X86fxor FR32:$src1,
388 (X86loadpf32 addr:$src2)))]>;
389 def FsXORPDrm : PDI<0x57, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f128mem:$src2),
390 "xorpd {$src2, $dst|$dst, $src2}",
391 [(set FR64:$dst, (X86fxor FR64:$src1,
392 (X86loadpf64 addr:$src2)))]>;
394 def FsANDNPSrr : PSI<0x55, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
395 "andnps {$src2, $dst|$dst, $src2}", []>;
396 def FsANDNPSrm : PSI<0x55, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f128mem:$src2),
397 "andnps {$src2, $dst|$dst, $src2}", []>;
398 def FsANDNPDrr : PDI<0x55, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
399 "andnpd {$src2, $dst|$dst, $src2}", []>;
400 def FsANDNPDrm : PDI<0x55, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f128mem:$src2),
401 "andnpd {$src2, $dst|$dst, $src2}", []>;
404 //===----------------------------------------------------------------------===//
405 // SSE packed FP Instructions
406 //===----------------------------------------------------------------------===//
408 // Some 'special' instructions
409 def IMPLICIT_DEF_VR128 : I<0, Pseudo, (ops VR128:$dst),
410 "#IMPLICIT_DEF $dst",
411 [(set VR128:$dst, (v4f32 (undef)))]>,
415 def MOVAPSrr : PSI<0x28, MRMSrcReg, (ops VR128:$dst, VR128:$src),
416 "movaps {$src, $dst|$dst, $src}", []>;
417 def MOVAPSrm : PSI<0x28, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
418 "movaps {$src, $dst|$dst, $src}",
419 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
420 def MOVAPDrr : PDI<0x28, MRMSrcReg, (ops VR128:$dst, VR128:$src),
421 "movapd {$src, $dst|$dst, $src}", []>;
422 def MOVAPDrm : PDI<0x28, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
423 "movapd {$src, $dst|$dst, $src}",
424 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
426 def MOVAPSmr : PSI<0x29, MRMDestMem, (ops f128mem:$dst, VR128:$src),
427 "movaps {$src, $dst|$dst, $src}",
428 [(store (v4f32 VR128:$src), addr:$dst)]>;
429 def MOVAPDmr : PDI<0x29, MRMDestMem, (ops f128mem:$dst, VR128:$src),
430 "movapd {$src, $dst|$dst, $src}",
431 [(store (v2f64 VR128:$src), addr:$dst)]>;
433 def MOVUPSrr : PSI<0x10, MRMSrcReg, (ops VR128:$dst, VR128:$src),
434 "movups {$src, $dst|$dst, $src}", []>;
435 def MOVUPSrm : PSI<0x10, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
436 "movups {$src, $dst|$dst, $src}", []>;
437 def MOVUPSmr : PSI<0x11, MRMDestMem, (ops f128mem:$dst, VR128:$src),
438 "movups {$src, $dst|$dst, $src}", []>;
439 def MOVUPDrr : PDI<0x10, MRMSrcReg, (ops VR128:$dst, VR128:$src),
440 "movupd {$src, $dst|$dst, $src}", []>;
441 def MOVUPDrm : PDI<0x10, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
442 "movupd {$src, $dst|$dst, $src}", []>;
443 def MOVUPDmr : PDI<0x11, MRMDestMem, (ops f128mem:$dst, VR128:$src),
444 "movupd {$src, $dst|$dst, $src}", []>;
446 def MOVLPSrm : PSI<0x12, MRMSrcMem, (ops VR128:$dst, f64mem:$src),
447 "movlps {$src, $dst|$dst, $src}", []>;
448 def MOVLPSmr : PSI<0x13, MRMDestMem, (ops f64mem:$dst, VR128:$src),
449 "movlps {$src, $dst|$dst, $src}", []>;
450 def MOVLPDrm : PDI<0x12, MRMSrcMem, (ops VR128:$dst, f64mem:$src),
451 "movlpd {$src, $dst|$dst, $src}", []>;
452 def MOVLPDmr : PDI<0x13, MRMDestMem, (ops f64mem:$dst, VR128:$src),
453 "movlpd {$src, $dst|$dst, $src}", []>;
455 def MOVHPSrm : PSI<0x16, MRMSrcMem, (ops VR128:$dst, f64mem:$src),
456 "movhps {$src, $dst|$dst, $src}", []>;
457 def MOVHPSmr : PSI<0x17, MRMDestMem, (ops f64mem:$dst, VR128:$src),
458 "movhps {$src, $dst|$dst, $src}", []>;
459 def MOVHPDrm : PDI<0x16, MRMSrcMem, (ops VR128:$dst, f64mem:$src),
460 "movhpd {$src, $dst|$dst, $src}", []>;
461 def MOVHPDmr : PDI<0x17, MRMDestMem, (ops f64mem:$dst, VR128:$src),
462 "movhpd {$src, $dst|$dst, $src}", []>;
464 let isTwoAddress = 1 in {
465 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
466 "movlhps {$src2, $dst|$dst, $src2}", []>;
468 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
469 "movlhps {$src2, $dst|$dst, $src2}", []>;
472 def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (ops R32:$dst, VR128:$src),
473 "movmskps {$src, $dst|$dst, $src}", []>;
474 def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (ops R32:$dst, VR128:$src),
475 "movmskpd {$src, $dst|$dst, $src}", []>;
477 // Conversion instructions
478 def CVTPI2PSrr : PSI<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
479 "cvtpi2ps {$src, $dst|$dst, $src}", []>;
480 def CVTPI2PSrm : PSI<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
481 "cvtpi2ps {$src, $dst|$dst, $src}", []>;
482 def CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
483 "cvtpi2pd {$src, $dst|$dst, $src}", []>;
484 def CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
485 "cvtpi2pd {$src, $dst|$dst, $src}", []>;
487 // SSE2 instructions without OpSize prefix
488 def CVTDQ2PSrr : I<0x5B, MRMSrcReg, (ops VR128:$dst, VR128:$src),
489 "cvtdq2ps {$src, $dst|$dst, $src}", []>, TB,
491 def CVTDQ2PSrm : I<0x5B, MRMSrcMem, (ops VR128:$dst, i128mem:$src),
492 "cvtdq2ps {$src, $dst|$dst, $src}", []>, TB,
495 // SSE2 instructions with XS prefix
496 def CVTDQ2PDrr : I<0xE6, MRMSrcReg, (ops VR128:$dst, VR64:$src),
497 "cvtdq2pd {$src, $dst|$dst, $src}", []>,
498 XS, Requires<[HasSSE2]>;
499 def CVTDQ2PDrm : I<0xE6, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
500 "cvtdq2pd {$src, $dst|$dst, $src}", []>,
501 XS, Requires<[HasSSE2]>;
503 def CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
504 "cvtps2pi {$src, $dst|$dst, $src}", []>;
505 def CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
506 "cvtps2pi {$src, $dst|$dst, $src}", []>;
507 def CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
508 "cvtpd2pi {$src, $dst|$dst, $src}", []>;
509 def CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (ops VR64:$dst, f128mem:$src),
510 "cvtpd2pi {$src, $dst|$dst, $src}", []>;
512 def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (ops VR128:$dst, VR128:$src),
513 "cvtps2dq {$src, $dst|$dst, $src}", []>;
514 def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
515 "cvtps2dq {$src, $dst|$dst, $src}", []>;
516 // SSE2 packed instructions with XD prefix
517 def CVTPD2DQrr : SDI<0xE6, MRMSrcReg, (ops VR128:$dst, VR128:$src),
518 "cvtpd2dq {$src, $dst|$dst, $src}", []>;
519 def CVTPD2DQrm : SDI<0xE6, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
520 "cvtpd2dq {$src, $dst|$dst, $src}", []>;
522 // SSE2 instructions without OpSize prefix
523 def CVTPS2PDrr : I<0x5A, MRMSrcReg, (ops VR128:$dst, VR128:$src),
524 "cvtps2pd {$src, $dst|$dst, $src}", []>, TB,
526 def CVTPS2PDrm : I<0x5A, MRMSrcReg, (ops VR128:$dst, f64mem:$src),
527 "cvtps2pd {$src, $dst|$dst, $src}", []>, TB,
530 def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (ops VR128:$dst, VR128:$src),
531 "cvtpd2ps {$src, $dst|$dst, $src}", []>;
532 def CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (ops VR128:$dst, f128mem:$src),
533 "cvtpd2ps {$src, $dst|$dst, $src}", []>;
536 let isTwoAddress = 1 in {
537 let isCommutable = 1 in {
538 def ADDPSrr : PSI<0x58, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
539 "addps {$src2, $dst|$dst, $src2}",
540 [(set VR128:$dst, (v4f32 (fadd VR128:$src1, VR128:$src2)))]>;
541 def ADDPDrr : PDI<0x58, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
542 "addpd {$src2, $dst|$dst, $src2}",
543 [(set VR128:$dst, (v2f64 (fadd VR128:$src1, VR128:$src2)))]>;
544 def MULPSrr : PSI<0x59, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
545 "mulps {$src2, $dst|$dst, $src2}",
546 [(set VR128:$dst, (v4f32 (fmul VR128:$src1, VR128:$src2)))]>;
547 def MULPDrr : PDI<0x59, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
548 "mulpd {$src2, $dst|$dst, $src2}",
549 [(set VR128:$dst, (v2f64 (fmul VR128:$src1, VR128:$src2)))]>;
552 def ADDPSrm : PSI<0x58, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
553 "addps {$src2, $dst|$dst, $src2}",
554 [(set VR128:$dst, (v4f32 (fadd VR128:$src1,
555 (load addr:$src2))))]>;
556 def ADDPDrm : PDI<0x58, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
557 "addpd {$src2, $dst|$dst, $src2}",
558 [(set VR128:$dst, (v2f64 (fadd VR128:$src1,
559 (load addr:$src2))))]>;
560 def MULPSrm : PSI<0x59, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
561 "mulps {$src2, $dst|$dst, $src2}",
562 [(set VR128:$dst, (v4f32 (fmul VR128:$src1,
563 (load addr:$src2))))]>;
564 def MULPDrm : PDI<0x59, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
565 "mulpd {$src2, $dst|$dst, $src2}",
566 [(set VR128:$dst, (v2f64 (fmul VR128:$src1,
567 (load addr:$src2))))]>;
569 def DIVPSrr : PSI<0x5E, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
570 "divps {$src2, $dst|$dst, $src2}",
571 [(set VR128:$dst, (v4f32 (fdiv VR128:$src1, VR128:$src2)))]>;
572 def DIVPSrm : PSI<0x5E, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
573 "divps {$src2, $dst|$dst, $src2}",
574 [(set VR128:$dst, (v4f32 (fdiv VR128:$src1,
575 (load addr:$src2))))]>;
576 def DIVPDrr : PDI<0x5E, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
577 "divpd {$src2, $dst|$dst, $src2}",
578 [(set VR128:$dst, (v2f64 (fdiv VR128:$src1, VR128:$src2)))]>;
579 def DIVPDrm : PDI<0x5E, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
580 "divpd {$src2, $dst|$dst, $src2}",
581 [(set VR128:$dst, (v2f64 (fdiv VR128:$src1,
582 (load addr:$src2))))]>;
584 def SUBPSrr : PSI<0x5C, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
585 "subps {$src2, $dst|$dst, $src2}",
586 [(set VR128:$dst, (v4f32 (fsub VR128:$src1, VR128:$src2)))]>;
587 def SUBPSrm : PSI<0x5C, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
588 "subps {$src2, $dst|$dst, $src2}",
589 [(set VR128:$dst, (v4f32 (fsub VR128:$src1,
590 (load addr:$src2))))]>;
591 def SUBPDrr : PDI<0x5C, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
592 "subpd {$src2, $dst|$dst, $src2}",
593 [(set VR128:$dst, (v2f64 (fsub VR128:$src1, VR128:$src2)))]>;
594 def SUBPDrm : PDI<0x5C, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
595 "subpd {$src2, $dst|$dst, $src2}",
596 [(set VR128:$dst, (v2f64 (fsub VR128:$src1,
597 (load addr:$src2))))]>;
600 def SQRTPSrr : PSI<0x51, MRMSrcReg, (ops VR128:$dst, VR128:$src),
601 "sqrtps {$src, $dst|$dst, $src}",
602 [(set VR128:$dst, (v4f32 (fsqrt VR128:$src)))]>;
603 def SQRTPSrm : PSI<0x51, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
604 "sqrtps {$src, $dst|$dst, $src}",
605 [(set VR128:$dst, (v4f32 (fsqrt (load addr:$src))))]>;
606 def SQRTPDrr : PDI<0x51, MRMSrcReg, (ops VR128:$dst, VR128:$src),
607 "sqrtpd {$src, $dst|$dst, $src}",
608 [(set VR128:$dst, (v2f64 (fsqrt VR128:$src)))]>;
609 def SQRTPDrm : PDI<0x51, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
610 "sqrtpd {$src, $dst|$dst, $src}",
611 [(set VR128:$dst, (v2f64 (fsqrt (load addr:$src))))]>;
613 def RSQRTPSrr : PSI<0x52, MRMSrcReg, (ops VR128:$dst, VR128:$src),
614 "rsqrtps {$src, $dst|$dst, $src}", []>;
615 def RSQRTPSrm : PSI<0x52, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
616 "rsqrtps {$src, $dst|$dst, $src}", []>;
617 def RCPPSrr : PSI<0x53, MRMSrcReg, (ops VR128:$dst, VR128:$src),
618 "rcpps {$src, $dst|$dst, $src}", []>;
619 def RCPPSrm : PSI<0x53, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
620 "rcpps {$src, $dst|$dst, $src}", []>;
622 def MAXPSrr : PSI<0x5F, MRMSrcReg, (ops VR128:$dst, VR128:$src),
623 "maxps {$src, $dst|$dst, $src}", []>;
624 def MAXPSrm : PSI<0x5F, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
625 "maxps {$src, $dst|$dst, $src}", []>;
626 def MAXPDrr : PDI<0x5F, MRMSrcReg, (ops VR128:$dst, VR128:$src),
627 "maxpd {$src, $dst|$dst, $src}", []>;
628 def MAXPDrm : PDI<0x5F, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
629 "maxpd {$src, $dst|$dst, $src}", []>;
630 def MINPSrr : PSI<0x5D, MRMSrcReg, (ops VR128:$dst, VR128:$src),
631 "minps {$src, $dst|$dst, $src}", []>;
632 def MINPSrm : PSI<0x5D, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
633 "minps {$src, $dst|$dst, $src}", []>;
634 def MINPDrr : PDI<0x5D, MRMSrcReg, (ops VR128:$dst, VR128:$src),
635 "minpd {$src, $dst|$dst, $src}", []>;
636 def MINPDrm : PDI<0x5D, MRMSrcMem, (ops VR128:$dst, f128mem:$src),
637 "minpd {$src, $dst|$dst, $src}", []>;
640 let isTwoAddress = 1 in {
641 let isCommutable = 1 in {
642 def ANDPSrr : PSI<0x54, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
643 "andps {$src2, $dst|$dst, $src2}",
644 [(set VR128:$dst, (v4i32 (and VR128:$src1, VR128:$src2)))]>;
645 def ANDPDrr : PDI<0x54, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
646 "andpd {$src2, $dst|$dst, $src2}",
647 [(set VR128:$dst, (v2i64 (and VR128:$src1, VR128:$src2)))]>;
648 def ORPSrr : PSI<0x56, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
649 "orps {$src2, $dst|$dst, $src2}",
650 [(set VR128:$dst, (v4i32 (or VR128:$src1, VR128:$src2)))]>;
651 def ORPDrr : PDI<0x56, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
652 "orpd {$src2, $dst|$dst, $src2}",
653 [(set VR128:$dst, (v2i64 (or VR128:$src1, VR128:$src2)))]>;
654 def XORPSrr : PSI<0x57, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
655 "xorps {$src2, $dst|$dst, $src2}",
656 [(set VR128:$dst, (v4i32 (xor VR128:$src1, VR128:$src2)))]>;
657 def XORPDrr : PDI<0x57, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
658 "xorpd {$src2, $dst|$dst, $src2}",
659 [(set VR128:$dst, (v2i64 (xor VR128:$src1, VR128:$src2)))]>;
661 def ANDPSrm : PSI<0x54, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
662 "andps {$src2, $dst|$dst, $src2}",
663 [(set VR128:$dst, (v4i32 (and VR128:$src1,
664 (load addr:$src2))))]>;
665 def ANDPDrm : PDI<0x54, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
666 "andpd {$src2, $dst|$dst, $src2}",
667 [(set VR128:$dst, (v2i64 (and VR128:$src1,
668 (load addr:$src2))))]>;
669 def ORPSrm : PSI<0x56, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
670 "orps {$src2, $dst|$dst, $src2}",
671 [(set VR128:$dst, (v4i32 (or VR128:$src1,
672 (load addr:$src2))))]>;
673 def ORPDrm : PDI<0x56, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
674 "orpd {$src2, $dst|$dst, $src2}",
675 [(set VR128:$dst, (v2i64 (or VR128:$src1,
676 (load addr:$src2))))]>;
677 def XORPSrm : PSI<0x57, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
678 "xorps {$src2, $dst|$dst, $src2}",
679 [(set VR128:$dst, (v4i32 (xor VR128:$src1,
680 (load addr:$src2))))]>;
681 def XORPDrm : PDI<0x57, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
682 "xorpd {$src2, $dst|$dst, $src2}",
683 [(set VR128:$dst, (v2i64 (xor VR128:$src1,
684 (load addr:$src2))))]>;
685 def ANDNPSrr : PSI<0x55, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
686 "andnps {$src2, $dst|$dst, $src2}",
687 [(set VR128:$dst, (v4i32 (and (not VR128:$src1),
689 def ANDNPSrm : PSI<0x55, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
690 "andnps {$src2, $dst|$dst, $src2}",
691 [(set VR128:$dst, (v4i32 (and (not VR128:$src1),
692 (load addr:$src2))))]>;
693 def ANDNPDrr : PDI<0x55, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
694 "andnpd {$src2, $dst|$dst, $src2}",
695 [(set VR128:$dst, (v2i64 (and (not VR128:$src1),
698 def ANDNPDrm : PDI<0x55, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
699 "andnpd {$src2, $dst|$dst, $src2}",
700 [(set VR128:$dst, (v2i64 (and VR128:$src1,
701 (load addr:$src2))))]>;
704 let isTwoAddress = 1 in {
705 def CMPPSrr : PSI<0xC2, MRMSrcReg,
706 (ops VR128:$dst, VR128:$src1, VR128:$src, SSECC:$cc),
707 "cmp${cc}ps {$src, $dst|$dst, $src}", []>;
708 def CMPPSrm : PSI<0xC2, MRMSrcMem,
709 (ops VR128:$dst, VR128:$src1, f128mem:$src, SSECC:$cc),
710 "cmp${cc}ps {$src, $dst|$dst, $src}", []>;
711 def CMPPDrr : PDI<0xC2, MRMSrcReg,
712 (ops VR128:$dst, VR128:$src1, VR128:$src, SSECC:$cc),
713 "cmp${cc}pd {$src, $dst|$dst, $src}", []>;
714 def CMPPDrm : PDI<0xC2, MRMSrcMem,
715 (ops VR128:$dst, VR128:$src1, f128mem:$src, SSECC:$cc),
716 "cmp${cc}pd {$src, $dst|$dst, $src}", []>;
719 // Shuffle and unpack instructions
720 def PSHUFWrr : PSIi8<0x70, MRMDestReg,
721 (ops VR64:$dst, VR64:$src1, i8imm:$src2),
722 "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
723 def PSHUFWrm : PSIi8<0x70, MRMSrcMem,
724 (ops VR64:$dst, i64mem:$src1, i8imm:$src2),
725 "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
726 def PSHUFDrr : PDIi8<0x70, MRMDestReg,
727 (ops VR128:$dst, VR128:$src1, i8imm:$src2),
728 "pshufd {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
729 def PSHUFDrm : PDIi8<0x70, MRMSrcMem,
730 (ops VR128:$dst, i128mem:$src1, i8imm:$src2),
731 "pshufd {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
733 let isTwoAddress = 1 in {
734 def SHUFPSrr : PSIi8<0xC6, MRMSrcReg,
735 (ops VR128:$dst, VR128:$src1, VR128:$src2, i8imm:$src3),
736 "shufps {$src3, $src2, $dst|$dst, $src2, $src3}",
737 [(set VR128:$dst, (vector_shuffle
738 (v4f32 VR128:$src1), (v4f32 VR128:$src2),
739 SHUFP_shuffle_mask:$src3))]>;
740 def SHUFPSrm : PSIi8<0xC6, MRMSrcMem,
741 (ops VR128:$dst, VR128:$src1, f128mem:$src2, i8imm:$src3),
742 "shufps {$src3, $src2, $dst|$dst, $src2, $src3}", []>;
743 def SHUFPDrr : PDIi8<0xC6, MRMSrcReg,
744 (ops VR128:$dst, VR128:$src1, VR128:$src2, i8imm:$src3),
745 "shufpd {$src3, $src2, $dst|$dst, $src2, $src3}",
746 [(set VR128:$dst, (vector_shuffle
747 (v2f64 VR128:$src1), (v2f64 VR128:$src2),
748 SHUFP_shuffle_mask:$src3))]>;
749 def SHUFPDrm : PDIi8<0xC6, MRMSrcMem,
750 (ops VR128:$dst, VR128:$src1, f128mem:$src2, i8imm:$src3),
751 "shufpd {$src3, $src2, $dst|$dst, $src2, $src3}", []>;
753 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
754 (ops VR128:$dst, VR128:$src1, VR128:$src2),
755 "unpckhps {$src2, $dst|$dst, $src2}", []>;
756 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
757 (ops VR128:$dst, VR128:$src1, f128mem:$src2),
758 "unpckhps {$src2, $dst|$dst, $src2}", []>;
759 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
760 (ops VR128:$dst, VR128:$src1, VR128:$src2),
761 "unpckhpd {$src2, $dst|$dst, $src2}", []>;
762 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
763 (ops VR128:$dst, VR128:$src1, f128mem:$src2),
764 "unpckhpd {$src2, $dst|$dst, $src2}", []>;
765 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
766 (ops VR128:$dst, VR128:$src1, VR128:$src2),
767 "unpcklps {$src2, $dst|$dst, $src2}", []>;
768 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
769 (ops VR128:$dst, VR128:$src1, f128mem:$src2),
770 "unpcklps {$src2, $dst|$dst, $src2}", []>;
771 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
772 (ops VR128:$dst, VR128:$src1, VR128:$src2),
773 "unpcklpd {$src2, $dst|$dst, $src2}", []>;
774 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
775 (ops VR128:$dst, VR128:$src1, f128mem:$src2),
776 "unpcklpd {$src2, $dst|$dst, $src2}", []>;
779 //===----------------------------------------------------------------------===//
780 // SSE integer instructions
781 //===----------------------------------------------------------------------===//
784 def MOVD128rr : PDI<0x6E, MRMSrcReg, (ops VR128:$dst, R32:$src),
785 "movd {$src, $dst|$dst, $src}",
787 (v4i32 (scalar_to_vector R32:$src)))]>;
788 def MOVD128rm : PDI<0x6E, MRMSrcMem, (ops VR128:$dst, i32mem:$src),
789 "movd {$src, $dst|$dst, $src}", []>;
790 def MOVD128mr : PDI<0x7E, MRMDestMem, (ops i32mem:$dst, VR128:$src),
791 "movd {$src, $dst|$dst, $src}", []>;
793 def MOVDQArr : PDI<0x6F, MRMSrcReg, (ops VR128:$dst, VR128:$src),
794 "movdqa {$src, $dst|$dst, $src}", []>;
795 def MOVDQArm : PDI<0x6F, MRMSrcMem, (ops VR128:$dst, i128mem:$src),
796 "movdqa {$src, $dst|$dst, $src}",
797 [(set VR128:$dst, (loadv4i32 addr:$src))]>;
798 def MOVDQAmr : PDI<0x7F, MRMDestMem, (ops i128mem:$dst, VR128:$src),
799 "movdqa {$src, $dst|$dst, $src}",
800 [(store (v4i32 VR128:$src), addr:$dst)]>;
802 // SSE2 instructions with XS prefix
803 def MOVQ128rr : I<0x7E, MRMSrcReg, (ops VR128:$dst, VR64:$src),
804 "movq {$src, $dst|$dst, $src}",
806 (v2i64 (scalar_to_vector VR64:$src)))]>, XS,
808 def MOVQ128rm : I<0x7E, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
809 "movq {$src, $dst|$dst, $src}", []>, XS;
811 def MOVQ128mr : PDI<0xD6, MRMSrcMem, (ops i64mem:$dst, VR128:$src),
812 "movq {$src, $dst|$dst, $src}", []>;
814 // 128-bit Integer Arithmetic
815 let isTwoAddress = 1 in {
816 let isCommutable = 1 in {
817 def PADDBrr : PDI<0xFC, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
818 "paddb {$src2, $dst|$dst, $src2}",
819 [(set VR128:$dst, (v16i8 (add VR128:$src1, VR128:$src2)))]>;
820 def PADDWrr : PDI<0xFD, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
821 "paddw {$src2, $dst|$dst, $src2}",
822 [(set VR128:$dst, (v8i16 (add VR128:$src1, VR128:$src2)))]>;
823 def PADDDrr : PDI<0xFE, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2),
824 "paddd {$src2, $dst|$dst, $src2}",
825 [(set VR128:$dst, (v4i32 (add VR128:$src1, VR128:$src2)))]>;
827 def PADDBrm : PDI<0xFC, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
828 "paddb {$src2, $dst|$dst, $src2}",
829 [(set VR128:$dst, (v16i8 (add VR128:$src1,
830 (load addr:$src2))))]>;
831 def PADDWrm : PDI<0xFD, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
832 "paddw {$src2, $dst|$dst, $src2}",
833 [(set VR128:$dst, (v8i16 (add VR128:$src1,
834 (load addr:$src2))))]>;
835 def PADDDrm : PDI<0xFE, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f128mem:$src2),
836 "paddd {$src2, $dst|$dst, $src2}",
837 [(set VR128:$dst, (v4i32 (add VR128:$src1,
838 (load addr:$src2))))]>;
841 //===----------------------------------------------------------------------===//
842 // Alias Instructions
843 //===----------------------------------------------------------------------===//
845 // Alias instructions that map zero vector to xorp* for sse.
846 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
847 def VZEROv16i8 : I<0xEF, MRMInitReg, (ops VR128:$dst),
848 "pxor $dst, $dst", [(set VR128:$dst, (v16i8 vecimm0))]>,
849 Requires<[HasSSE2]>, TB, OpSize;
850 def VZEROv8i16 : I<0xEF, MRMInitReg, (ops VR128:$dst),
851 "pxor $dst, $dst", [(set VR128:$dst, (v8i16 vecimm0))]>,
852 Requires<[HasSSE2]>, TB, OpSize;
853 def VZEROv4i32 : I<0xEF, MRMInitReg, (ops VR128:$dst),
854 "pxor $dst, $dst", [(set VR128:$dst, (v4i32 vecimm0))]>,
855 Requires<[HasSSE2]>, TB, OpSize;
856 def VZEROv2i64 : I<0xEF, MRMInitReg, (ops VR128:$dst),
857 "pxor $dst, $dst", [(set VR128:$dst, (v2i64 vecimm0))]>,
858 Requires<[HasSSE2]>, TB, OpSize;
859 def VZEROv4f32 : PSI<0x57, MRMInitReg, (ops VR128:$dst),
860 "xorps $dst, $dst", [(set VR128:$dst, (v4f32 vecimm0))]>;
861 def VZEROv2f64 : PDI<0x57, MRMInitReg, (ops VR128:$dst),
862 "xorpd $dst, $dst", [(set VR128:$dst, (v2f64 vecimm0))]>;
864 def FR32ToV4F32 : PSI<0x28, MRMSrcReg, (ops VR128:$dst, FR32:$src),
865 "movaps {$src, $dst|$dst, $src}",
867 (v4f32 (scalar_to_vector FR32:$src)))]>;
869 def FR64ToV2F64 : PDI<0x28, MRMSrcReg, (ops VR128:$dst, FR64:$src),
870 "movapd {$src, $dst|$dst, $src}",
872 (v2f64 (scalar_to_vector FR64:$src)))]>;
874 //===----------------------------------------------------------------------===//
875 // Non-Instruction Patterns
876 //===----------------------------------------------------------------------===//
878 // 128-bit vector undef's.
879 def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
880 def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
881 def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
882 def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
883 def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
885 // Load 128-bit integer vector values.
886 def : Pat<(v16i8 (load addr:$src)), (MOVDQArm addr:$src)>,
888 def : Pat<(v8i16 (load addr:$src)), (MOVDQArm addr:$src)>,
890 def : Pat<(v4i32 (load addr:$src)), (MOVDQArm addr:$src)>,
892 def : Pat<(v2i64 (load addr:$src)), (MOVDQArm addr:$src)>,
895 // Store 128-bit integer vector values.
896 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
897 (MOVDQAmr addr:$dst, VR128:$src)>, Requires<[HasSSE1]>;
898 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
899 (MOVDQAmr addr:$dst, VR128:$src)>, Requires<[HasSSE1]>;
900 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
901 (MOVDQAmr addr:$dst, VR128:$src)>, Requires<[HasSSE1]>;
902 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
903 (MOVDQAmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
905 // Scalar to v8i16 / v16i8. The source may be a R32, but only the lower 8 or
907 def : Pat<(v8i16 (X86s2vec R32:$src)), (MOVD128rr R32:$src)>,
909 def : Pat<(v16i8 (X86s2vec R32:$src)), (MOVD128rr R32:$src)>,
913 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
914 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
916 // Splat v4f32 / v4i32
917 def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SHUFP_splat_mask:$sm),
918 (v4f32 (SHUFPSrr VR128:$src, VR128:$src, SHUFP_splat_mask:$sm))>,
920 def : Pat<(vector_shuffle (v4i32 VR128:$src), (undef), SHUFP_splat_mask:$sm),
921 (v4i32 (SHUFPSrr VR128:$src, VR128:$src, SHUFP_splat_mask:$sm))>,
924 // Splat v2f64 / v2i64
925 def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), MOVLHPS_splat_mask:$sm),
926 (v2f64 (MOVLHPSrr VR128:$src, VR128:$src))>, Requires<[HasSSE1]>;
927 def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), MOVLHPS_splat_mask:$sm),
928 (v2i64 (MOVLHPSrr VR128:$src, VR128:$src))>, Requires<[HasSSE1]>;
930 // Shuffle v4f32 / v4i32, undef. These should only match if splat cases do not.
931 def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), PSHUFD_shuffle_mask:$sm),
932 (v4f32 (PSHUFDrr VR128:$src, PSHUFD_shuffle_mask:$sm))>,
934 def : Pat<(vector_shuffle (v4i32 VR128:$src), (undef), PSHUFD_shuffle_mask:$sm),
935 (v4i32 (PSHUFDrr VR128:$src, PSHUFD_shuffle_mask:$sm))>,
938 // Shuffle v2f64 / v2i64
939 def : Pat<(vector_shuffle (v2f64 VR128:$src1), (v2f64 VR128:$src2),
940 MOVLHPSorUNPCKLPD_shuffle_mask:$sm),
941 (v2f64 (MOVLHPSrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE1]>;
942 def : Pat<(vector_shuffle (v2f64 VR128:$src1), (v2f64 VR128:$src2),
943 MOVHLPS_shuffle_mask:$sm),
944 (v2f64 (MOVHLPSrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE1]>;
945 def : Pat<(vector_shuffle (v2f64 VR128:$src1), (v2f64 VR128:$src2),
946 UNPCKHPD_shuffle_mask:$sm),
947 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
948 def : Pat<(vector_shuffle (v2f64 VR128:$src1), (loadv2f64 addr:$src2),
949 MOVLHPSorUNPCKLPD_shuffle_mask:$sm),
950 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
952 def : Pat<(vector_shuffle (v2i64 VR128:$src1), (v2i64 VR128:$src2),
953 MOVLHPSorUNPCKLPD_shuffle_mask:$sm),
954 (v2i64 (MOVLHPSrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE1]>;
955 def : Pat<(vector_shuffle (v2i64 VR128:$src1), (v2i64 VR128:$src2),
956 MOVHLPS_shuffle_mask:$sm),
957 (v2i64 (MOVHLPSrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE1]>;
958 def : Pat<(vector_shuffle (v2i64 VR128:$src1), (v2i64 VR128:$src2),
959 UNPCKHPD_shuffle_mask:$sm),
960 (v2i64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
961 def : Pat<(vector_shuffle (v2i64 VR128:$src1), (loadv2i64 addr:$src2),
962 MOVLHPSorUNPCKLPD_shuffle_mask:$sm),
963 (v2i64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;