1 //===- PPCInstrAltivec.td - The PowerPC Altivec Extension --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Altivec extension to the PowerPC instruction set.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Altivec transformation functions and pattern fragments.
18 /// VPKUHUM_shuffle_mask/VPKUWUM_shuffle_mask - Return true if this is a valid
19 /// shuffle mask for the VPKUHUM or VPKUWUM instructions.
20 def VPKUHUM_shuffle_mask : PatLeaf<(build_vector), [{
21 return PPC::isVPKUHUMShuffleMask(N, false);
23 def VPKUWUM_shuffle_mask : PatLeaf<(build_vector), [{
24 return PPC::isVPKUWUMShuffleMask(N, false);
27 def VPKUHUM_unary_shuffle_mask : PatLeaf<(build_vector), [{
28 return PPC::isVPKUHUMShuffleMask(N, true);
30 def VPKUWUM_unary_shuffle_mask : PatLeaf<(build_vector), [{
31 return PPC::isVPKUWUMShuffleMask(N, true);
35 def VMRGLB_shuffle_mask : PatLeaf<(build_vector), [{
36 return PPC::isVMRGLShuffleMask(N, 1, false);
38 def VMRGLH_shuffle_mask : PatLeaf<(build_vector), [{
39 return PPC::isVMRGLShuffleMask(N, 2, false);
41 def VMRGLW_shuffle_mask : PatLeaf<(build_vector), [{
42 return PPC::isVMRGLShuffleMask(N, 4, false);
44 def VMRGHB_shuffle_mask : PatLeaf<(build_vector), [{
45 return PPC::isVMRGHShuffleMask(N, 1, false);
47 def VMRGHH_shuffle_mask : PatLeaf<(build_vector), [{
48 return PPC::isVMRGHShuffleMask(N, 2, false);
50 def VMRGHW_shuffle_mask : PatLeaf<(build_vector), [{
51 return PPC::isVMRGHShuffleMask(N, 4, false);
54 def VMRGLB_unary_shuffle_mask : PatLeaf<(build_vector), [{
55 return PPC::isVMRGLShuffleMask(N, 1, true);
57 def VMRGLH_unary_shuffle_mask : PatLeaf<(build_vector), [{
58 return PPC::isVMRGLShuffleMask(N, 2, true);
60 def VMRGLW_unary_shuffle_mask : PatLeaf<(build_vector), [{
61 return PPC::isVMRGLShuffleMask(N, 4, true);
63 def VMRGHB_unary_shuffle_mask : PatLeaf<(build_vector), [{
64 return PPC::isVMRGHShuffleMask(N, 1, true);
66 def VMRGHH_unary_shuffle_mask : PatLeaf<(build_vector), [{
67 return PPC::isVMRGHShuffleMask(N, 2, true);
69 def VMRGHW_unary_shuffle_mask : PatLeaf<(build_vector), [{
70 return PPC::isVMRGHShuffleMask(N, 4, true);
73 def VSLDOI_get_imm : SDNodeXForm<build_vector, [{
74 return getI32Imm(PPC::isVSLDOIShuffleMask(N, false));
76 def VSLDOI_shuffle_mask : PatLeaf<(build_vector), [{
77 return PPC::isVSLDOIShuffleMask(N, false) != -1;
80 /// VSLDOI_unary* - These are used to match vsldoi(X,X), which is turned into
81 /// vector_shuffle(X,undef,mask) by the dag combiner.
82 def VSLDOI_unary_get_imm : SDNodeXForm<build_vector, [{
83 return getI32Imm(PPC::isVSLDOIShuffleMask(N, true));
85 def VSLDOI_unary_shuffle_mask : PatLeaf<(build_vector), [{
86 return PPC::isVSLDOIShuffleMask(N, true) != -1;
87 }], VSLDOI_unary_get_imm>;
90 // VSPLT*_get_imm xform function: convert vector_shuffle mask to VSPLT* imm.
91 def VSPLTB_get_imm : SDNodeXForm<build_vector, [{
92 return getI32Imm(PPC::getVSPLTImmediate(N, 1));
94 def VSPLTB_shuffle_mask : PatLeaf<(build_vector), [{
95 return PPC::isSplatShuffleMask(N, 1);
97 def VSPLTH_get_imm : SDNodeXForm<build_vector, [{
98 return getI32Imm(PPC::getVSPLTImmediate(N, 2));
100 def VSPLTH_shuffle_mask : PatLeaf<(build_vector), [{
101 return PPC::isSplatShuffleMask(N, 2);
103 def VSPLTW_get_imm : SDNodeXForm<build_vector, [{
104 return getI32Imm(PPC::getVSPLTImmediate(N, 4));
106 def VSPLTW_shuffle_mask : PatLeaf<(build_vector), [{
107 return PPC::isSplatShuffleMask(N, 4);
111 // VSPLTISB_get_imm xform function: convert build_vector to VSPLTISB imm.
112 def VSPLTISB_get_imm : SDNodeXForm<build_vector, [{
113 return PPC::get_VSPLTI_elt(N, 1, *CurDAG);
115 def vecspltisb : PatLeaf<(build_vector), [{
116 return PPC::get_VSPLTI_elt(N, 1, *CurDAG).getNode() != 0;
117 }], VSPLTISB_get_imm>;
119 // VSPLTISH_get_imm xform function: convert build_vector to VSPLTISH imm.
120 def VSPLTISH_get_imm : SDNodeXForm<build_vector, [{
121 return PPC::get_VSPLTI_elt(N, 2, *CurDAG);
123 def vecspltish : PatLeaf<(build_vector), [{
124 return PPC::get_VSPLTI_elt(N, 2, *CurDAG).getNode() != 0;
125 }], VSPLTISH_get_imm>;
127 // VSPLTISW_get_imm xform function: convert build_vector to VSPLTISW imm.
128 def VSPLTISW_get_imm : SDNodeXForm<build_vector, [{
129 return PPC::get_VSPLTI_elt(N, 4, *CurDAG);
131 def vecspltisw : PatLeaf<(build_vector), [{
132 return PPC::get_VSPLTI_elt(N, 4, *CurDAG).getNode() != 0;
133 }], VSPLTISW_get_imm>;
135 def V_immneg0 : PatLeaf<(build_vector), [{
136 return PPC::isAllNegativeZeroVector(N);
139 //===----------------------------------------------------------------------===//
140 // Helpers for defining instructions that directly correspond to intrinsics.
142 // VA1a_Int - A VAForm_1a intrinsic definition.
143 class VA1a_Int<bits<6> xo, string opc, Intrinsic IntID>
144 : VAForm_1a<xo, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB, VRRC:$vC),
145 !strconcat(opc, " $vD, $vA, $vB, $vC"), VecFP,
146 [(set VRRC:$vD, (IntID VRRC:$vA, VRRC:$vB, VRRC:$vC))]>;
148 // VX1_Int - A VXForm_1 intrinsic definition.
149 class VX1_Int<bits<11> xo, string opc, Intrinsic IntID>
150 : VXForm_1<xo, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
151 !strconcat(opc, " $vD, $vA, $vB"), VecFP,
152 [(set VRRC:$vD, (IntID VRRC:$vA, VRRC:$vB))]>;
154 // VX2_Int - A VXForm_2 intrinsic definition.
155 class VX2_Int<bits<11> xo, string opc, Intrinsic IntID>
156 : VXForm_2<xo, (outs VRRC:$vD), (ins VRRC:$vB),
157 !strconcat(opc, " $vD, $vB"), VecFP,
158 [(set VRRC:$vD, (IntID VRRC:$vB))]>;
160 //===----------------------------------------------------------------------===//
161 // Instruction Definitions.
163 def DSS : DSS_Form<822, (outs),
164 (ins u5imm:$ZERO0, u5imm:$STRM,u5imm:$ZERO1,u5imm:$ZERO2),
165 "dss $STRM", LdStGeneral /*FIXME*/, []>;
166 def DSSALL : DSS_Form<822, (outs),
167 (ins u5imm:$ONE, u5imm:$ZERO0,u5imm:$ZERO1,u5imm:$ZERO2),
168 "dssall", LdStGeneral /*FIXME*/, []>;
169 def DST : DSS_Form<342, (outs),
170 (ins u5imm:$ZERO, u5imm:$STRM, GPRC:$rA, GPRC:$rB),
171 "dst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
172 def DSTT : DSS_Form<342, (outs),
173 (ins u5imm:$ONE, u5imm:$STRM, GPRC:$rA, GPRC:$rB),
174 "dstt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
175 def DSTST : DSS_Form<374, (outs),
176 (ins u5imm:$ZERO, u5imm:$STRM, GPRC:$rA, GPRC:$rB),
177 "dstst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
178 def DSTSTT : DSS_Form<374, (outs),
179 (ins u5imm:$ONE, u5imm:$STRM, GPRC:$rA, GPRC:$rB),
180 "dststt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
182 def DST64 : DSS_Form<342, (outs),
183 (ins u5imm:$ZERO, u5imm:$STRM, G8RC:$rA, GPRC:$rB),
184 "dst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
185 def DSTT64 : DSS_Form<342, (outs),
186 (ins u5imm:$ONE, u5imm:$STRM, G8RC:$rA, GPRC:$rB),
187 "dstt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
188 def DSTST64 : DSS_Form<374, (outs),
189 (ins u5imm:$ZERO, u5imm:$STRM, G8RC:$rA, GPRC:$rB),
190 "dstst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
191 def DSTSTT64 : DSS_Form<374, (outs),
192 (ins u5imm:$ONE, u5imm:$STRM, G8RC:$rA, GPRC:$rB),
193 "dststt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
195 def MFVSCR : VXForm_4<1540, (outs VRRC:$vD), (ins),
196 "mfvscr $vD", LdStGeneral,
197 [(set VRRC:$vD, (int_ppc_altivec_mfvscr))]>;
198 def MTVSCR : VXForm_5<1604, (outs), (ins VRRC:$vB),
199 "mtvscr $vB", LdStGeneral,
200 [(int_ppc_altivec_mtvscr VRRC:$vB)]>;
202 let canFoldAsLoad = 1, PPC970_Unit = 2 in { // Loads.
203 def LVEBX: XForm_1<31, 7, (outs VRRC:$vD), (ins memrr:$src),
204 "lvebx $vD, $src", LdStGeneral,
205 [(set VRRC:$vD, (int_ppc_altivec_lvebx xoaddr:$src))]>;
206 def LVEHX: XForm_1<31, 39, (outs VRRC:$vD), (ins memrr:$src),
207 "lvehx $vD, $src", LdStGeneral,
208 [(set VRRC:$vD, (int_ppc_altivec_lvehx xoaddr:$src))]>;
209 def LVEWX: XForm_1<31, 71, (outs VRRC:$vD), (ins memrr:$src),
210 "lvewx $vD, $src", LdStGeneral,
211 [(set VRRC:$vD, (int_ppc_altivec_lvewx xoaddr:$src))]>;
212 def LVX : XForm_1<31, 103, (outs VRRC:$vD), (ins memrr:$src),
213 "lvx $vD, $src", LdStGeneral,
214 [(set VRRC:$vD, (int_ppc_altivec_lvx xoaddr:$src))]>;
215 def LVXL : XForm_1<31, 359, (outs VRRC:$vD), (ins memrr:$src),
216 "lvxl $vD, $src", LdStGeneral,
217 [(set VRRC:$vD, (int_ppc_altivec_lvxl xoaddr:$src))]>;
220 def LVSL : XForm_1<31, 6, (outs VRRC:$vD), (ins memrr:$src),
221 "lvsl $vD, $src", LdStGeneral,
222 [(set VRRC:$vD, (int_ppc_altivec_lvsl xoaddr:$src))]>,
224 def LVSR : XForm_1<31, 38, (outs VRRC:$vD), (ins memrr:$src),
225 "lvsr $vD, $src", LdStGeneral,
226 [(set VRRC:$vD, (int_ppc_altivec_lvsr xoaddr:$src))]>,
229 let PPC970_Unit = 2 in { // Stores.
230 def STVEBX: XForm_8<31, 135, (outs), (ins VRRC:$rS, memrr:$dst),
231 "stvebx $rS, $dst", LdStGeneral,
232 [(int_ppc_altivec_stvebx VRRC:$rS, xoaddr:$dst)]>;
233 def STVEHX: XForm_8<31, 167, (outs), (ins VRRC:$rS, memrr:$dst),
234 "stvehx $rS, $dst", LdStGeneral,
235 [(int_ppc_altivec_stvehx VRRC:$rS, xoaddr:$dst)]>;
236 def STVEWX: XForm_8<31, 199, (outs), (ins VRRC:$rS, memrr:$dst),
237 "stvewx $rS, $dst", LdStGeneral,
238 [(int_ppc_altivec_stvewx VRRC:$rS, xoaddr:$dst)]>;
239 def STVX : XForm_8<31, 231, (outs), (ins VRRC:$rS, memrr:$dst),
240 "stvx $rS, $dst", LdStGeneral,
241 [(int_ppc_altivec_stvx VRRC:$rS, xoaddr:$dst)]>;
242 def STVXL : XForm_8<31, 487, (outs), (ins VRRC:$rS, memrr:$dst),
243 "stvxl $rS, $dst", LdStGeneral,
244 [(int_ppc_altivec_stvxl VRRC:$rS, xoaddr:$dst)]>;
247 let PPC970_Unit = 5 in { // VALU Operations.
248 // VA-Form instructions. 3-input AltiVec ops.
249 def VMADDFP : VAForm_1<46, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vC, VRRC:$vB),
250 "vmaddfp $vD, $vA, $vC, $vB", VecFP,
251 [(set VRRC:$vD, (fadd (fmul VRRC:$vA, VRRC:$vC),
253 Requires<[FPContractions]>;
254 def VNMSUBFP: VAForm_1<47, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vC, VRRC:$vB),
255 "vnmsubfp $vD, $vA, $vC, $vB", VecFP,
256 [(set VRRC:$vD, (fsub V_immneg0,
257 (fsub (fmul VRRC:$vA, VRRC:$vC),
259 Requires<[FPContractions]>;
261 def VMHADDSHS : VA1a_Int<32, "vmhaddshs", int_ppc_altivec_vmhaddshs>;
262 def VMHRADDSHS : VA1a_Int<33, "vmhraddshs", int_ppc_altivec_vmhraddshs>;
263 def VMLADDUHM : VA1a_Int<34, "vmladduhm", int_ppc_altivec_vmladduhm>;
264 def VPERM : VA1a_Int<43, "vperm", int_ppc_altivec_vperm>;
265 def VSEL : VA1a_Int<42, "vsel", int_ppc_altivec_vsel>;
268 def VSLDOI : VAForm_2<44, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB, u5imm:$SH),
269 "vsldoi $vD, $vA, $vB, $SH", VecFP,
271 (vector_shuffle (v16i8 VRRC:$vA), VRRC:$vB,
272 VSLDOI_shuffle_mask:$SH))]>;
274 // VX-Form instructions. AltiVec arithmetic ops.
275 def VADDFP : VXForm_1<10, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
276 "vaddfp $vD, $vA, $vB", VecFP,
277 [(set VRRC:$vD, (fadd VRRC:$vA, VRRC:$vB))]>;
279 def VADDUBM : VXForm_1<0, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
280 "vaddubm $vD, $vA, $vB", VecGeneral,
281 [(set VRRC:$vD, (add (v16i8 VRRC:$vA), VRRC:$vB))]>;
282 def VADDUHM : VXForm_1<64, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
283 "vadduhm $vD, $vA, $vB", VecGeneral,
284 [(set VRRC:$vD, (add (v8i16 VRRC:$vA), VRRC:$vB))]>;
285 def VADDUWM : VXForm_1<128, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
286 "vadduwm $vD, $vA, $vB", VecGeneral,
287 [(set VRRC:$vD, (add (v4i32 VRRC:$vA), VRRC:$vB))]>;
289 def VADDCUW : VX1_Int<384, "vaddcuw", int_ppc_altivec_vaddcuw>;
290 def VADDSBS : VX1_Int<768, "vaddsbs", int_ppc_altivec_vaddsbs>;
291 def VADDSHS : VX1_Int<832, "vaddshs", int_ppc_altivec_vaddshs>;
292 def VADDSWS : VX1_Int<896, "vaddsws", int_ppc_altivec_vaddsws>;
293 def VADDUBS : VX1_Int<512, "vaddubs", int_ppc_altivec_vaddubs>;
294 def VADDUHS : VX1_Int<576, "vadduhs", int_ppc_altivec_vadduhs>;
295 def VADDUWS : VX1_Int<640, "vadduws", int_ppc_altivec_vadduws>;
298 def VAND : VXForm_1<1028, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
299 "vand $vD, $vA, $vB", VecFP,
300 [(set VRRC:$vD, (and (v4i32 VRRC:$vA), VRRC:$vB))]>;
301 def VANDC : VXForm_1<1092, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
302 "vandc $vD, $vA, $vB", VecFP,
303 [(set VRRC:$vD, (and (v4i32 VRRC:$vA), (vnot VRRC:$vB)))]>;
305 def VCFSX : VXForm_1<842, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
306 "vcfsx $vD, $vB, $UIMM", VecFP,
308 (int_ppc_altivec_vcfsx VRRC:$vB, imm:$UIMM))]>;
309 def VCFUX : VXForm_1<778, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
310 "vcfux $vD, $vB, $UIMM", VecFP,
312 (int_ppc_altivec_vcfux VRRC:$vB, imm:$UIMM))]>;
313 def VCTSXS : VXForm_1<970, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
314 "vctsxs $vD, $vB, $UIMM", VecFP,
316 (int_ppc_altivec_vctsxs VRRC:$vB, imm:$UIMM))]>;
317 def VCTUXS : VXForm_1<906, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
318 "vctuxs $vD, $vB, $UIMM", VecFP,
320 (int_ppc_altivec_vctuxs VRRC:$vB, imm:$UIMM))]>;
321 def VEXPTEFP : VX2_Int<394, "vexptefp", int_ppc_altivec_vexptefp>;
322 def VLOGEFP : VX2_Int<458, "vlogefp", int_ppc_altivec_vlogefp>;
324 def VAVGSB : VX1_Int<1282, "vavgsb", int_ppc_altivec_vavgsb>;
325 def VAVGSH : VX1_Int<1346, "vavgsh", int_ppc_altivec_vavgsh>;
326 def VAVGSW : VX1_Int<1410, "vavgsw", int_ppc_altivec_vavgsw>;
327 def VAVGUB : VX1_Int<1026, "vavgub", int_ppc_altivec_vavgub>;
328 def VAVGUH : VX1_Int<1090, "vavguh", int_ppc_altivec_vavguh>;
329 def VAVGUW : VX1_Int<1154, "vavguw", int_ppc_altivec_vavguw>;
331 def VMAXFP : VX1_Int<1034, "vmaxfp", int_ppc_altivec_vmaxfp>;
332 def VMAXSB : VX1_Int< 258, "vmaxsb", int_ppc_altivec_vmaxsb>;
333 def VMAXSH : VX1_Int< 322, "vmaxsh", int_ppc_altivec_vmaxsh>;
334 def VMAXSW : VX1_Int< 386, "vmaxsw", int_ppc_altivec_vmaxsw>;
335 def VMAXUB : VX1_Int< 2, "vmaxub", int_ppc_altivec_vmaxub>;
336 def VMAXUH : VX1_Int< 66, "vmaxuh", int_ppc_altivec_vmaxuh>;
337 def VMAXUW : VX1_Int< 130, "vmaxuw", int_ppc_altivec_vmaxuw>;
338 def VMINFP : VX1_Int<1098, "vminfp", int_ppc_altivec_vminfp>;
339 def VMINSB : VX1_Int< 770, "vminsb", int_ppc_altivec_vminsb>;
340 def VMINSH : VX1_Int< 834, "vminsh", int_ppc_altivec_vminsh>;
341 def VMINSW : VX1_Int< 898, "vminsw", int_ppc_altivec_vminsw>;
342 def VMINUB : VX1_Int< 514, "vminub", int_ppc_altivec_vminub>;
343 def VMINUH : VX1_Int< 578, "vminuh", int_ppc_altivec_vminuh>;
344 def VMINUW : VX1_Int< 642, "vminuw", int_ppc_altivec_vminuw>;
346 def VMRGHB : VXForm_1< 12, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
347 "vmrghb $vD, $vA, $vB", VecFP,
348 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
349 VRRC:$vB, VMRGHB_shuffle_mask))]>;
350 def VMRGHH : VXForm_1< 76, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
351 "vmrghh $vD, $vA, $vB", VecFP,
352 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
353 VRRC:$vB, VMRGHH_shuffle_mask))]>;
354 def VMRGHW : VXForm_1<140, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
355 "vmrghw $vD, $vA, $vB", VecFP,
356 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
357 VRRC:$vB, VMRGHW_shuffle_mask))]>;
358 def VMRGLB : VXForm_1<268, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
359 "vmrglb $vD, $vA, $vB", VecFP,
360 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
361 VRRC:$vB, VMRGLB_shuffle_mask))]>;
362 def VMRGLH : VXForm_1<332, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
363 "vmrglh $vD, $vA, $vB", VecFP,
364 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
365 VRRC:$vB, VMRGLH_shuffle_mask))]>;
366 def VMRGLW : VXForm_1<396, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
367 "vmrglw $vD, $vA, $vB", VecFP,
368 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
369 VRRC:$vB, VMRGLW_shuffle_mask))]>;
371 def VMSUMMBM : VA1a_Int<37, "vmsummbm", int_ppc_altivec_vmsummbm>;
372 def VMSUMSHM : VA1a_Int<40, "vmsumshm", int_ppc_altivec_vmsumshm>;
373 def VMSUMSHS : VA1a_Int<41, "vmsumshs", int_ppc_altivec_vmsumshs>;
374 def VMSUMUBM : VA1a_Int<36, "vmsumubm", int_ppc_altivec_vmsumubm>;
375 def VMSUMUHM : VA1a_Int<38, "vmsumuhm", int_ppc_altivec_vmsumuhm>;
376 def VMSUMUHS : VA1a_Int<39, "vmsumuhs", int_ppc_altivec_vmsumuhs>;
378 def VMULESB : VX1_Int<776, "vmulesb", int_ppc_altivec_vmulesb>;
379 def VMULESH : VX1_Int<840, "vmulesh", int_ppc_altivec_vmulesh>;
380 def VMULEUB : VX1_Int<520, "vmuleub", int_ppc_altivec_vmuleub>;
381 def VMULEUH : VX1_Int<584, "vmuleuh", int_ppc_altivec_vmuleuh>;
382 def VMULOSB : VX1_Int<264, "vmulosb", int_ppc_altivec_vmulosb>;
383 def VMULOSH : VX1_Int<328, "vmulosh", int_ppc_altivec_vmulosh>;
384 def VMULOUB : VX1_Int< 8, "vmuloub", int_ppc_altivec_vmuloub>;
385 def VMULOUH : VX1_Int< 72, "vmulouh", int_ppc_altivec_vmulouh>;
387 def VREFP : VX2_Int<266, "vrefp", int_ppc_altivec_vrefp>;
388 def VRFIM : VX2_Int<714, "vrfim", int_ppc_altivec_vrfim>;
389 def VRFIN : VX2_Int<522, "vrfin", int_ppc_altivec_vrfin>;
390 def VRFIP : VX2_Int<650, "vrfip", int_ppc_altivec_vrfip>;
391 def VRFIZ : VX2_Int<586, "vrfiz", int_ppc_altivec_vrfiz>;
392 def VRSQRTEFP : VX2_Int<330, "vrsqrtefp", int_ppc_altivec_vrsqrtefp>;
394 def VSUBCUW : VX1_Int<74, "vsubcuw", int_ppc_altivec_vsubcuw>;
396 def VSUBFP : VXForm_1<74, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
397 "vsubfp $vD, $vA, $vB", VecGeneral,
398 [(set VRRC:$vD, (fsub VRRC:$vA, VRRC:$vB))]>;
399 def VSUBUBM : VXForm_1<1024, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
400 "vsububm $vD, $vA, $vB", VecGeneral,
401 [(set VRRC:$vD, (sub (v16i8 VRRC:$vA), VRRC:$vB))]>;
402 def VSUBUHM : VXForm_1<1088, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
403 "vsubuhm $vD, $vA, $vB", VecGeneral,
404 [(set VRRC:$vD, (sub (v8i16 VRRC:$vA), VRRC:$vB))]>;
405 def VSUBUWM : VXForm_1<1152, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
406 "vsubuwm $vD, $vA, $vB", VecGeneral,
407 [(set VRRC:$vD, (sub (v4i32 VRRC:$vA), VRRC:$vB))]>;
409 def VSUBSBS : VX1_Int<1792, "vsubsbs" , int_ppc_altivec_vsubsbs>;
410 def VSUBSHS : VX1_Int<1856, "vsubshs" , int_ppc_altivec_vsubshs>;
411 def VSUBSWS : VX1_Int<1920, "vsubsws" , int_ppc_altivec_vsubsws>;
412 def VSUBUBS : VX1_Int<1536, "vsububs" , int_ppc_altivec_vsububs>;
413 def VSUBUHS : VX1_Int<1600, "vsubuhs" , int_ppc_altivec_vsubuhs>;
414 def VSUBUWS : VX1_Int<1664, "vsubuws" , int_ppc_altivec_vsubuws>;
415 def VSUMSWS : VX1_Int<1928, "vsumsws" , int_ppc_altivec_vsumsws>;
416 def VSUM2SWS: VX1_Int<1672, "vsum2sws", int_ppc_altivec_vsum2sws>;
417 def VSUM4SBS: VX1_Int<1672, "vsum4sbs", int_ppc_altivec_vsum4sbs>;
418 def VSUM4SHS: VX1_Int<1608, "vsum4shs", int_ppc_altivec_vsum4shs>;
419 def VSUM4UBS: VX1_Int<1544, "vsum4ubs", int_ppc_altivec_vsum4ubs>;
421 def VNOR : VXForm_1<1284, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
422 "vnor $vD, $vA, $vB", VecFP,
423 [(set VRRC:$vD, (vnot (or (v4i32 VRRC:$vA), VRRC:$vB)))]>;
424 def VOR : VXForm_1<1156, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
425 "vor $vD, $vA, $vB", VecFP,
426 [(set VRRC:$vD, (or (v4i32 VRRC:$vA), VRRC:$vB))]>;
427 def VXOR : VXForm_1<1220, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
428 "vxor $vD, $vA, $vB", VecFP,
429 [(set VRRC:$vD, (xor (v4i32 VRRC:$vA), VRRC:$vB))]>;
431 def VRLB : VX1_Int< 4, "vrlb", int_ppc_altivec_vrlb>;
432 def VRLH : VX1_Int< 68, "vrlh", int_ppc_altivec_vrlh>;
433 def VRLW : VX1_Int< 132, "vrlw", int_ppc_altivec_vrlw>;
435 def VSL : VX1_Int< 452, "vsl" , int_ppc_altivec_vsl >;
436 def VSLO : VX1_Int<1036, "vslo", int_ppc_altivec_vslo>;
437 def VSLB : VX1_Int< 260, "vslb", int_ppc_altivec_vslb>;
438 def VSLH : VX1_Int< 324, "vslh", int_ppc_altivec_vslh>;
439 def VSLW : VX1_Int< 388, "vslw", int_ppc_altivec_vslw>;
441 def VSPLTB : VXForm_1<524, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
442 "vspltb $vD, $vB, $UIMM", VecPerm,
443 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vB), (undef),
444 VSPLTB_shuffle_mask:$UIMM))]>;
445 def VSPLTH : VXForm_1<588, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
446 "vsplth $vD, $vB, $UIMM", VecPerm,
447 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vB), (undef),
448 VSPLTH_shuffle_mask:$UIMM))]>;
449 def VSPLTW : VXForm_1<652, (outs VRRC:$vD), (ins u5imm:$UIMM, VRRC:$vB),
450 "vspltw $vD, $vB, $UIMM", VecPerm,
451 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vB), (undef),
452 VSPLTW_shuffle_mask:$UIMM))]>;
454 def VSR : VX1_Int< 708, "vsr" , int_ppc_altivec_vsr>;
455 def VSRO : VX1_Int<1100, "vsro" , int_ppc_altivec_vsro>;
456 def VSRAB : VX1_Int< 772, "vsrab", int_ppc_altivec_vsrab>;
457 def VSRAH : VX1_Int< 836, "vsrah", int_ppc_altivec_vsrah>;
458 def VSRAW : VX1_Int< 900, "vsraw", int_ppc_altivec_vsraw>;
459 def VSRB : VX1_Int< 516, "vsrb" , int_ppc_altivec_vsrb>;
460 def VSRH : VX1_Int< 580, "vsrh" , int_ppc_altivec_vsrh>;
461 def VSRW : VX1_Int< 644, "vsrw" , int_ppc_altivec_vsrw>;
464 def VSPLTISB : VXForm_3<780, (outs VRRC:$vD), (ins s5imm:$SIMM),
465 "vspltisb $vD, $SIMM", VecPerm,
466 [(set VRRC:$vD, (v16i8 vecspltisb:$SIMM))]>;
467 def VSPLTISH : VXForm_3<844, (outs VRRC:$vD), (ins s5imm:$SIMM),
468 "vspltish $vD, $SIMM", VecPerm,
469 [(set VRRC:$vD, (v8i16 vecspltish:$SIMM))]>;
470 def VSPLTISW : VXForm_3<908, (outs VRRC:$vD), (ins s5imm:$SIMM),
471 "vspltisw $vD, $SIMM", VecPerm,
472 [(set VRRC:$vD, (v4i32 vecspltisw:$SIMM))]>;
475 def VPKPX : VX1_Int<782, "vpkpx", int_ppc_altivec_vpkpx>;
476 def VPKSHSS : VX1_Int<398, "vpkshss", int_ppc_altivec_vpkshss>;
477 def VPKSHUS : VX1_Int<270, "vpkshus", int_ppc_altivec_vpkshus>;
478 def VPKSWSS : VX1_Int<462, "vpkswss", int_ppc_altivec_vpkswss>;
479 def VPKSWUS : VX1_Int<334, "vpkswus", int_ppc_altivec_vpkswus>;
480 def VPKUHUM : VXForm_1<14, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
481 "vpkuhum $vD, $vA, $vB", VecFP,
482 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
483 VRRC:$vB, VPKUHUM_shuffle_mask))]>;
484 def VPKUHUS : VX1_Int<142, "vpkuhus", int_ppc_altivec_vpkuhus>;
485 def VPKUWUM : VXForm_1<78, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),
486 "vpkuwum $vD, $vA, $vB", VecFP,
487 [(set VRRC:$vD, (vector_shuffle (v16i8 VRRC:$vA),
488 VRRC:$vB, VPKUWUM_shuffle_mask))]>;
489 def VPKUWUS : VX1_Int<206, "vpkuwus", int_ppc_altivec_vpkuwus>;
492 def VUPKHPX : VX2_Int<846, "vupkhpx", int_ppc_altivec_vupkhpx>;
493 def VUPKHSB : VX2_Int<526, "vupkhsb", int_ppc_altivec_vupkhsb>;
494 def VUPKHSH : VX2_Int<590, "vupkhsh", int_ppc_altivec_vupkhsh>;
495 def VUPKLPX : VX2_Int<974, "vupklpx", int_ppc_altivec_vupklpx>;
496 def VUPKLSB : VX2_Int<654, "vupklsb", int_ppc_altivec_vupklsb>;
497 def VUPKLSH : VX2_Int<718, "vupklsh", int_ppc_altivec_vupklsh>;
500 // Altivec Comparisons.
502 class VCMP<bits<10> xo, string asmstr, ValueType Ty>
503 : VXRForm_1<xo, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),asmstr,VecFPCompare,
504 [(set VRRC:$vD, (Ty (PPCvcmp VRRC:$vA, VRRC:$vB, xo)))]>;
505 class VCMPo<bits<10> xo, string asmstr, ValueType Ty>
506 : VXRForm_1<xo, (outs VRRC:$vD), (ins VRRC:$vA, VRRC:$vB),asmstr,VecFPCompare,
507 [(set VRRC:$vD, (Ty (PPCvcmp_o VRRC:$vA, VRRC:$vB, xo)))]> {
512 // f32 element comparisons.0
513 def VCMPBFP : VCMP <966, "vcmpbfp $vD, $vA, $vB" , v4f32>;
514 def VCMPBFPo : VCMPo<966, "vcmpbfp. $vD, $vA, $vB" , v4f32>;
515 def VCMPEQFP : VCMP <198, "vcmpeqfp $vD, $vA, $vB" , v4f32>;
516 def VCMPEQFPo : VCMPo<198, "vcmpeqfp. $vD, $vA, $vB", v4f32>;
517 def VCMPGEFP : VCMP <454, "vcmpgefp $vD, $vA, $vB" , v4f32>;
518 def VCMPGEFPo : VCMPo<454, "vcmpgefp. $vD, $vA, $vB", v4f32>;
519 def VCMPGTFP : VCMP <710, "vcmpgtfp $vD, $vA, $vB" , v4f32>;
520 def VCMPGTFPo : VCMPo<710, "vcmpgtfp. $vD, $vA, $vB", v4f32>;
522 // i8 element comparisons.
523 def VCMPEQUB : VCMP < 6, "vcmpequb $vD, $vA, $vB" , v16i8>;
524 def VCMPEQUBo : VCMPo< 6, "vcmpequb. $vD, $vA, $vB", v16i8>;
525 def VCMPGTSB : VCMP <774, "vcmpgtsb $vD, $vA, $vB" , v16i8>;
526 def VCMPGTSBo : VCMPo<774, "vcmpgtsb. $vD, $vA, $vB", v16i8>;
527 def VCMPGTUB : VCMP <518, "vcmpgtub $vD, $vA, $vB" , v16i8>;
528 def VCMPGTUBo : VCMPo<518, "vcmpgtub. $vD, $vA, $vB", v16i8>;
530 // i16 element comparisons.
531 def VCMPEQUH : VCMP < 70, "vcmpequh $vD, $vA, $vB" , v8i16>;
532 def VCMPEQUHo : VCMPo< 70, "vcmpequh. $vD, $vA, $vB", v8i16>;
533 def VCMPGTSH : VCMP <838, "vcmpgtsh $vD, $vA, $vB" , v8i16>;
534 def VCMPGTSHo : VCMPo<838, "vcmpgtsh. $vD, $vA, $vB", v8i16>;
535 def VCMPGTUH : VCMP <582, "vcmpgtuh $vD, $vA, $vB" , v8i16>;
536 def VCMPGTUHo : VCMPo<582, "vcmpgtuh. $vD, $vA, $vB", v8i16>;
538 // i32 element comparisons.
539 def VCMPEQUW : VCMP <134, "vcmpequw $vD, $vA, $vB" , v4i32>;
540 def VCMPEQUWo : VCMPo<134, "vcmpequw. $vD, $vA, $vB", v4i32>;
541 def VCMPGTSW : VCMP <902, "vcmpgtsw $vD, $vA, $vB" , v4i32>;
542 def VCMPGTSWo : VCMPo<902, "vcmpgtsw. $vD, $vA, $vB", v4i32>;
543 def VCMPGTUW : VCMP <646, "vcmpgtuw $vD, $vA, $vB" , v4i32>;
544 def VCMPGTUWo : VCMPo<646, "vcmpgtuw. $vD, $vA, $vB", v4i32>;
546 def V_SET0 : VXForm_setzero<1220, (outs VRRC:$vD), (ins),
547 "vxor $vD, $vD, $vD", VecFP,
548 [(set VRRC:$vD, (v4i32 immAllZerosV))]>;
551 //===----------------------------------------------------------------------===//
552 // Additional Altivec Patterns
556 def : Pat<(int_ppc_altivec_dssall), (DSSALL 1, 0, 0, 0)>;
557 def : Pat<(int_ppc_altivec_dss imm:$STRM), (DSS 0, imm:$STRM, 0, 0)>;
560 def : Pat<(int_ppc_altivec_dst GPRC:$rA, GPRC:$rB, imm:$STRM),
561 (DST 0, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
562 def : Pat<(int_ppc_altivec_dstt GPRC:$rA, GPRC:$rB, imm:$STRM),
563 (DSTT 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
564 def : Pat<(int_ppc_altivec_dstst GPRC:$rA, GPRC:$rB, imm:$STRM),
565 (DSTST 0, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
566 def : Pat<(int_ppc_altivec_dststt GPRC:$rA, GPRC:$rB, imm:$STRM),
567 (DSTSTT 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
570 def : Pat<(int_ppc_altivec_dst G8RC:$rA, GPRC:$rB, imm:$STRM),
571 (DST64 0, imm:$STRM, (i64 G8RC:$rA), GPRC:$rB)>;
572 def : Pat<(int_ppc_altivec_dstt G8RC:$rA, GPRC:$rB, imm:$STRM),
573 (DSTT64 1, imm:$STRM, (i64 G8RC:$rA), GPRC:$rB)>;
574 def : Pat<(int_ppc_altivec_dstst G8RC:$rA, GPRC:$rB, imm:$STRM),
575 (DSTST64 0, imm:$STRM, (i64 G8RC:$rA), GPRC:$rB)>;
576 def : Pat<(int_ppc_altivec_dststt G8RC:$rA, GPRC:$rB, imm:$STRM),
577 (DSTSTT64 1, imm:$STRM, (i64 G8RC:$rA), GPRC:$rB)>;
580 def : Pat<(v4i32 (load xoaddr:$src)), (LVX xoaddr:$src)>;
583 def : Pat<(store (v4i32 VRRC:$rS), xoaddr:$dst),
584 (STVX (v4i32 VRRC:$rS), xoaddr:$dst)>;
587 def : Pat<(v16i8 (bitconvert (v8i16 VRRC:$src))), (v16i8 VRRC:$src)>;
588 def : Pat<(v16i8 (bitconvert (v4i32 VRRC:$src))), (v16i8 VRRC:$src)>;
589 def : Pat<(v16i8 (bitconvert (v4f32 VRRC:$src))), (v16i8 VRRC:$src)>;
591 def : Pat<(v8i16 (bitconvert (v16i8 VRRC:$src))), (v8i16 VRRC:$src)>;
592 def : Pat<(v8i16 (bitconvert (v4i32 VRRC:$src))), (v8i16 VRRC:$src)>;
593 def : Pat<(v8i16 (bitconvert (v4f32 VRRC:$src))), (v8i16 VRRC:$src)>;
595 def : Pat<(v4i32 (bitconvert (v16i8 VRRC:$src))), (v4i32 VRRC:$src)>;
596 def : Pat<(v4i32 (bitconvert (v8i16 VRRC:$src))), (v4i32 VRRC:$src)>;
597 def : Pat<(v4i32 (bitconvert (v4f32 VRRC:$src))), (v4i32 VRRC:$src)>;
599 def : Pat<(v4f32 (bitconvert (v16i8 VRRC:$src))), (v4f32 VRRC:$src)>;
600 def : Pat<(v4f32 (bitconvert (v8i16 VRRC:$src))), (v4f32 VRRC:$src)>;
601 def : Pat<(v4f32 (bitconvert (v4i32 VRRC:$src))), (v4f32 VRRC:$src)>;
605 // Match vsldoi(x,x), vpkuwum(x,x), vpkuhum(x,x)
606 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VSLDOI_unary_shuffle_mask:$in),
607 (VSLDOI VRRC:$vA, VRRC:$vA, VSLDOI_unary_shuffle_mask:$in)>;
608 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef,VPKUWUM_unary_shuffle_mask:$in),
609 (VPKUWUM VRRC:$vA, VRRC:$vA)>;
610 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef,VPKUHUM_unary_shuffle_mask:$in),
611 (VPKUHUM VRRC:$vA, VRRC:$vA)>;
614 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGLB_unary_shuffle_mask:$in),
615 (VMRGLB VRRC:$vA, VRRC:$vA)>;
616 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGLH_unary_shuffle_mask:$in),
617 (VMRGLH VRRC:$vA, VRRC:$vA)>;
618 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGLW_unary_shuffle_mask:$in),
619 (VMRGLW VRRC:$vA, VRRC:$vA)>;
620 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGHB_unary_shuffle_mask:$in),
621 (VMRGHB VRRC:$vA, VRRC:$vA)>;
622 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGHH_unary_shuffle_mask:$in),
623 (VMRGHH VRRC:$vA, VRRC:$vA)>;
624 def:Pat<(vector_shuffle (v16i8 VRRC:$vA), undef, VMRGHW_unary_shuffle_mask:$in),
625 (VMRGHW VRRC:$vA, VRRC:$vA)>;
627 // Logical Operations
628 def : Pat<(v4i32 (vnot VRRC:$vA)), (VNOR VRRC:$vA, VRRC:$vA)>;
629 def : Pat<(v4i32 (vnot_conv VRRC:$vA)), (VNOR VRRC:$vA, VRRC:$vA)>;
631 def : Pat<(v4i32 (vnot_conv (or VRRC:$A, VRRC:$B))),
632 (VNOR VRRC:$A, VRRC:$B)>;
633 def : Pat<(v4i32 (and VRRC:$A, (vnot_conv VRRC:$B))),
634 (VANDC VRRC:$A, VRRC:$B)>;
636 def : Pat<(fmul VRRC:$vA, VRRC:$vB),
637 (VMADDFP VRRC:$vA, VRRC:$vB, (v4i32 (V_SET0)))>;
639 // Fused multiply add and multiply sub for packed float. These are represented
640 // separately from the real instructions above, for operations that must have
641 // the additional precision, such as Newton-Rhapson (used by divide, sqrt)
642 def : Pat<(PPCvmaddfp VRRC:$A, VRRC:$B, VRRC:$C),
643 (VMADDFP VRRC:$A, VRRC:$B, VRRC:$C)>;
644 def : Pat<(PPCvnmsubfp VRRC:$A, VRRC:$B, VRRC:$C),
645 (VNMSUBFP VRRC:$A, VRRC:$B, VRRC:$C)>;
647 def : Pat<(int_ppc_altivec_vmaddfp VRRC:$A, VRRC:$B, VRRC:$C),
648 (VMADDFP VRRC:$A, VRRC:$B, VRRC:$C)>;
649 def : Pat<(int_ppc_altivec_vnmsubfp VRRC:$A, VRRC:$B, VRRC:$C),
650 (VNMSUBFP VRRC:$A, VRRC:$B, VRRC:$C)>;
652 def : Pat<(PPCvperm (v16i8 VRRC:$vA), VRRC:$vB, VRRC:$vC),
653 (VPERM VRRC:$vA, VRRC:$vB, VRRC:$vC)>;