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 // Since we canonicalize buildvectors to v16i8, all vnots "-1" operands will be
20 def vnot_ppc : PatFrag<(ops node:$in),
21 (xor node:$in, (bitconvert (v16i8 immAllOnesV)))>;
23 def vpkuhum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
24 (vector_shuffle node:$lhs, node:$rhs), [{
25 return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), false);
27 def vpkuwum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
28 (vector_shuffle node:$lhs, node:$rhs), [{
29 return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), false);
31 def vpkuhum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
32 (vector_shuffle node:$lhs, node:$rhs), [{
33 return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), true);
35 def vpkuwum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
36 (vector_shuffle node:$lhs, node:$rhs), [{
37 return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), true);
41 def vmrglb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
42 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
43 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, false);
45 def vmrglh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
46 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
47 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, false);
49 def vmrglw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
50 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
51 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, false);
53 def vmrghb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
54 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
55 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, false);
57 def vmrghh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
58 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
59 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, false);
61 def vmrghw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
62 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
63 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, false);
67 def vmrglb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
68 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
69 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, true);
71 def vmrglh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
72 (vector_shuffle node:$lhs, node:$rhs), [{
73 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, true);
75 def vmrglw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
76 (vector_shuffle node:$lhs, node:$rhs), [{
77 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, true);
79 def vmrghb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
80 (vector_shuffle node:$lhs, node:$rhs), [{
81 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, true);
83 def vmrghh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
84 (vector_shuffle node:$lhs, node:$rhs), [{
85 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, true);
87 def vmrghw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
88 (vector_shuffle node:$lhs, node:$rhs), [{
89 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, true);
93 def VSLDOI_get_imm : SDNodeXForm<vector_shuffle, [{
94 return getI32Imm(PPC::isVSLDOIShuffleMask(N, false));
96 def vsldoi_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
97 (vector_shuffle node:$lhs, node:$rhs), [{
98 return PPC::isVSLDOIShuffleMask(N, false) != -1;
102 /// VSLDOI_unary* - These are used to match vsldoi(X,X), which is turned into
103 /// vector_shuffle(X,undef,mask) by the dag combiner.
104 def VSLDOI_unary_get_imm : SDNodeXForm<vector_shuffle, [{
105 return getI32Imm(PPC::isVSLDOIShuffleMask(N, true));
107 def vsldoi_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
108 (vector_shuffle node:$lhs, node:$rhs), [{
109 return PPC::isVSLDOIShuffleMask(N, true) != -1;
110 }], VSLDOI_unary_get_imm>;
113 // VSPLT*_get_imm xform function: convert vector_shuffle mask to VSPLT* imm.
114 def VSPLTB_get_imm : SDNodeXForm<vector_shuffle, [{
115 return getI32Imm(PPC::getVSPLTImmediate(N, 1));
117 def vspltb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
118 (vector_shuffle node:$lhs, node:$rhs), [{
119 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 1);
121 def VSPLTH_get_imm : SDNodeXForm<vector_shuffle, [{
122 return getI32Imm(PPC::getVSPLTImmediate(N, 2));
124 def vsplth_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
125 (vector_shuffle node:$lhs, node:$rhs), [{
126 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 2);
128 def VSPLTW_get_imm : SDNodeXForm<vector_shuffle, [{
129 return getI32Imm(PPC::getVSPLTImmediate(N, 4));
131 def vspltw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
132 (vector_shuffle node:$lhs, node:$rhs), [{
133 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 4);
137 // VSPLTISB_get_imm xform function: convert build_vector to VSPLTISB imm.
138 def VSPLTISB_get_imm : SDNodeXForm<build_vector, [{
139 return PPC::get_VSPLTI_elt(N, 1, *CurDAG);
141 def vecspltisb : PatLeaf<(build_vector), [{
142 return PPC::get_VSPLTI_elt(N, 1, *CurDAG).getNode() != 0;
143 }], VSPLTISB_get_imm>;
145 // VSPLTISH_get_imm xform function: convert build_vector to VSPLTISH imm.
146 def VSPLTISH_get_imm : SDNodeXForm<build_vector, [{
147 return PPC::get_VSPLTI_elt(N, 2, *CurDAG);
149 def vecspltish : PatLeaf<(build_vector), [{
150 return PPC::get_VSPLTI_elt(N, 2, *CurDAG).getNode() != 0;
151 }], VSPLTISH_get_imm>;
153 // VSPLTISW_get_imm xform function: convert build_vector to VSPLTISW imm.
154 def VSPLTISW_get_imm : SDNodeXForm<build_vector, [{
155 return PPC::get_VSPLTI_elt(N, 4, *CurDAG);
157 def vecspltisw : PatLeaf<(build_vector), [{
158 return PPC::get_VSPLTI_elt(N, 4, *CurDAG).getNode() != 0;
159 }], VSPLTISW_get_imm>;
161 //===----------------------------------------------------------------------===//
162 // Helpers for defining instructions that directly correspond to intrinsics.
164 // VA1a_Int_Ty - A VAForm_1a intrinsic definition of specific type.
165 class VA1a_Int_Ty<bits<6> xo, string opc, Intrinsic IntID, ValueType Ty>
166 : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
167 !strconcat(opc, " $vD, $vA, $vB, $vC"), IIC_VecFP,
168 [(set Ty:$vD, (IntID Ty:$vA, Ty:$vB, Ty:$vC))]>;
170 // VA1a_Int_Ty2 - A VAForm_1a intrinsic definition where the type of the
171 // inputs doesn't match the type of the output.
172 class VA1a_Int_Ty2<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
174 : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
175 !strconcat(opc, " $vD, $vA, $vB, $vC"), IIC_VecFP,
176 [(set OutTy:$vD, (IntID InTy:$vA, InTy:$vB, InTy:$vC))]>;
178 // VA1a_Int_Ty3 - A VAForm_1a intrinsic definition where there are two
179 // input types and an output type.
180 class VA1a_Int_Ty3<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
181 ValueType In1Ty, ValueType In2Ty>
182 : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
183 !strconcat(opc, " $vD, $vA, $vB, $vC"), IIC_VecFP,
185 (IntID In1Ty:$vA, In1Ty:$vB, In2Ty:$vC))]>;
187 // VX1_Int_Ty - A VXForm_1 intrinsic definition of specific type.
188 class VX1_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
189 : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
190 !strconcat(opc, " $vD, $vA, $vB"), IIC_VecFP,
191 [(set Ty:$vD, (IntID Ty:$vA, Ty:$vB))]>;
193 // VX1_Int_Ty2 - A VXForm_1 intrinsic definition where the type of the
194 // inputs doesn't match the type of the output.
195 class VX1_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
197 : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
198 !strconcat(opc, " $vD, $vA, $vB"), IIC_VecFP,
199 [(set OutTy:$vD, (IntID InTy:$vA, InTy:$vB))]>;
201 // VX1_Int_Ty3 - A VXForm_1 intrinsic definition where there are two
202 // input types and an output type.
203 class VX1_Int_Ty3<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
204 ValueType In1Ty, ValueType In2Ty>
205 : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
206 !strconcat(opc, " $vD, $vA, $vB"), IIC_VecFP,
207 [(set OutTy:$vD, (IntID In1Ty:$vA, In2Ty:$vB))]>;
209 // VX2_Int_SP - A VXForm_2 intrinsic definition of vector single-precision type.
210 class VX2_Int_SP<bits<11> xo, string opc, Intrinsic IntID>
211 : VXForm_2<xo, (outs vrrc:$vD), (ins vrrc:$vB),
212 !strconcat(opc, " $vD, $vB"), IIC_VecFP,
213 [(set v4f32:$vD, (IntID v4f32:$vB))]>;
215 // VX2_Int_Ty2 - A VXForm_2 intrinsic definition where the type of the
216 // inputs doesn't match the type of the output.
217 class VX2_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
219 : VXForm_2<xo, (outs vrrc:$vD), (ins vrrc:$vB),
220 !strconcat(opc, " $vD, $vB"), IIC_VecFP,
221 [(set OutTy:$vD, (IntID InTy:$vB))]>;
223 //===----------------------------------------------------------------------===//
224 // Instruction Definitions.
226 def HasAltivec : Predicate<"PPCSubTarget->hasAltivec()">;
227 let Predicates = [HasAltivec] in {
229 let isCodeGenOnly = 1 in {
230 def DSS : DSS_Form<822, (outs),
231 (ins u5imm:$ZERO0, u5imm:$STRM,u5imm:$ZERO1,u5imm:$ZERO2),
232 "dss $STRM", IIC_LdStLoad /*FIXME*/, []>,
233 Deprecated<DeprecatedDST>;
234 def DSSALL : DSS_Form<822, (outs),
235 (ins u5imm:$ONE, u5imm:$ZERO0,u5imm:$ZERO1,u5imm:$ZERO2),
236 "dssall", IIC_LdStLoad /*FIXME*/, []>,
237 Deprecated<DeprecatedDST>;
238 def DST : DSS_Form<342, (outs),
239 (ins u5imm:$ZERO, u5imm:$STRM, gprc:$rA, gprc:$rB),
240 "dst $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
241 Deprecated<DeprecatedDST>;
242 def DSTT : DSS_Form<342, (outs),
243 (ins u5imm:$ONE, u5imm:$STRM, gprc:$rA, gprc:$rB),
244 "dstt $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
245 Deprecated<DeprecatedDST>;
246 def DSTST : DSS_Form<374, (outs),
247 (ins u5imm:$ZERO, u5imm:$STRM, gprc:$rA, gprc:$rB),
248 "dstst $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
249 Deprecated<DeprecatedDST>;
250 def DSTSTT : DSS_Form<374, (outs),
251 (ins u5imm:$ONE, u5imm:$STRM, gprc:$rA, gprc:$rB),
252 "dststt $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
253 Deprecated<DeprecatedDST>;
255 def DST64 : DSS_Form<342, (outs),
256 (ins u5imm:$ZERO, u5imm:$STRM, g8rc:$rA, gprc:$rB),
257 "dst $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
258 Deprecated<DeprecatedDST>;
259 def DSTT64 : DSS_Form<342, (outs),
260 (ins u5imm:$ONE, u5imm:$STRM, g8rc:$rA, gprc:$rB),
261 "dstt $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
262 Deprecated<DeprecatedDST>;
263 def DSTST64 : DSS_Form<374, (outs),
264 (ins u5imm:$ZERO, u5imm:$STRM, g8rc:$rA, gprc:$rB),
265 "dstst $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
266 Deprecated<DeprecatedDST>;
267 def DSTSTT64 : DSS_Form<374, (outs),
268 (ins u5imm:$ONE, u5imm:$STRM, g8rc:$rA, gprc:$rB),
269 "dststt $rA, $rB, $STRM", IIC_LdStLoad /*FIXME*/, []>,
270 Deprecated<DeprecatedDST>;
273 def MFVSCR : VXForm_4<1540, (outs vrrc:$vD), (ins),
274 "mfvscr $vD", IIC_LdStStore,
275 [(set v8i16:$vD, (int_ppc_altivec_mfvscr))]>;
276 def MTVSCR : VXForm_5<1604, (outs), (ins vrrc:$vB),
277 "mtvscr $vB", IIC_LdStLoad,
278 [(int_ppc_altivec_mtvscr v4i32:$vB)]>;
280 let canFoldAsLoad = 1, PPC970_Unit = 2 in { // Loads.
281 def LVEBX: XForm_1<31, 7, (outs vrrc:$vD), (ins memrr:$src),
282 "lvebx $vD, $src", IIC_LdStLoad,
283 [(set v16i8:$vD, (int_ppc_altivec_lvebx xoaddr:$src))]>;
284 def LVEHX: XForm_1<31, 39, (outs vrrc:$vD), (ins memrr:$src),
285 "lvehx $vD, $src", IIC_LdStLoad,
286 [(set v8i16:$vD, (int_ppc_altivec_lvehx xoaddr:$src))]>;
287 def LVEWX: XForm_1<31, 71, (outs vrrc:$vD), (ins memrr:$src),
288 "lvewx $vD, $src", IIC_LdStLoad,
289 [(set v4i32:$vD, (int_ppc_altivec_lvewx xoaddr:$src))]>;
290 def LVX : XForm_1<31, 103, (outs vrrc:$vD), (ins memrr:$src),
291 "lvx $vD, $src", IIC_LdStLoad,
292 [(set v4i32:$vD, (int_ppc_altivec_lvx xoaddr:$src))]>;
293 def LVXL : XForm_1<31, 359, (outs vrrc:$vD), (ins memrr:$src),
294 "lvxl $vD, $src", IIC_LdStLoad,
295 [(set v4i32:$vD, (int_ppc_altivec_lvxl xoaddr:$src))]>;
298 def LVSL : XForm_1<31, 6, (outs vrrc:$vD), (ins memrr:$src),
299 "lvsl $vD, $src", IIC_LdStLoad,
300 [(set v16i8:$vD, (int_ppc_altivec_lvsl xoaddr:$src))]>,
302 def LVSR : XForm_1<31, 38, (outs vrrc:$vD), (ins memrr:$src),
303 "lvsr $vD, $src", IIC_LdStLoad,
304 [(set v16i8:$vD, (int_ppc_altivec_lvsr xoaddr:$src))]>,
307 let PPC970_Unit = 2 in { // Stores.
308 def STVEBX: XForm_8<31, 135, (outs), (ins vrrc:$rS, memrr:$dst),
309 "stvebx $rS, $dst", IIC_LdStStore,
310 [(int_ppc_altivec_stvebx v16i8:$rS, xoaddr:$dst)]>;
311 def STVEHX: XForm_8<31, 167, (outs), (ins vrrc:$rS, memrr:$dst),
312 "stvehx $rS, $dst", IIC_LdStStore,
313 [(int_ppc_altivec_stvehx v8i16:$rS, xoaddr:$dst)]>;
314 def STVEWX: XForm_8<31, 199, (outs), (ins vrrc:$rS, memrr:$dst),
315 "stvewx $rS, $dst", IIC_LdStStore,
316 [(int_ppc_altivec_stvewx v4i32:$rS, xoaddr:$dst)]>;
317 def STVX : XForm_8<31, 231, (outs), (ins vrrc:$rS, memrr:$dst),
318 "stvx $rS, $dst", IIC_LdStStore,
319 [(int_ppc_altivec_stvx v4i32:$rS, xoaddr:$dst)]>;
320 def STVXL : XForm_8<31, 487, (outs), (ins vrrc:$rS, memrr:$dst),
321 "stvxl $rS, $dst", IIC_LdStStore,
322 [(int_ppc_altivec_stvxl v4i32:$rS, xoaddr:$dst)]>;
325 let PPC970_Unit = 5 in { // VALU Operations.
326 // VA-Form instructions. 3-input AltiVec ops.
327 let isCommutable = 1 in {
328 def VMADDFP : VAForm_1<46, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vC, vrrc:$vB),
329 "vmaddfp $vD, $vA, $vC, $vB", IIC_VecFP,
331 (fma v4f32:$vA, v4f32:$vC, v4f32:$vB))]>;
333 // FIXME: The fma+fneg pattern won't match because fneg is not legal.
334 def VNMSUBFP: VAForm_1<47, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vC, vrrc:$vB),
335 "vnmsubfp $vD, $vA, $vC, $vB", IIC_VecFP,
336 [(set v4f32:$vD, (fneg (fma v4f32:$vA, v4f32:$vC,
337 (fneg v4f32:$vB))))]>;
339 def VMHADDSHS : VA1a_Int_Ty<32, "vmhaddshs", int_ppc_altivec_vmhaddshs, v8i16>;
340 def VMHRADDSHS : VA1a_Int_Ty<33, "vmhraddshs", int_ppc_altivec_vmhraddshs,
342 def VMLADDUHM : VA1a_Int_Ty<34, "vmladduhm", int_ppc_altivec_vmladduhm, v8i16>;
345 def VPERM : VA1a_Int_Ty3<43, "vperm", int_ppc_altivec_vperm,
346 v4i32, v4i32, v16i8>;
347 def VSEL : VA1a_Int_Ty<42, "vsel", int_ppc_altivec_vsel, v4i32>;
350 def VSLDOI : VAForm_2<44, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, u5imm:$SH),
351 "vsldoi $vD, $vA, $vB, $SH", IIC_VecFP,
353 (vsldoi_shuffle:$SH v16i8:$vA, v16i8:$vB))]>;
355 // VX-Form instructions. AltiVec arithmetic ops.
356 let isCommutable = 1 in {
357 def VADDFP : VXForm_1<10, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
358 "vaddfp $vD, $vA, $vB", IIC_VecFP,
359 [(set v4f32:$vD, (fadd v4f32:$vA, v4f32:$vB))]>;
361 def VADDUBM : VXForm_1<0, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
362 "vaddubm $vD, $vA, $vB", IIC_VecGeneral,
363 [(set v16i8:$vD, (add v16i8:$vA, v16i8:$vB))]>;
364 def VADDUHM : VXForm_1<64, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
365 "vadduhm $vD, $vA, $vB", IIC_VecGeneral,
366 [(set v8i16:$vD, (add v8i16:$vA, v8i16:$vB))]>;
367 def VADDUWM : VXForm_1<128, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
368 "vadduwm $vD, $vA, $vB", IIC_VecGeneral,
369 [(set v4i32:$vD, (add v4i32:$vA, v4i32:$vB))]>;
371 def VADDCUW : VX1_Int_Ty<384, "vaddcuw", int_ppc_altivec_vaddcuw, v4i32>;
372 def VADDSBS : VX1_Int_Ty<768, "vaddsbs", int_ppc_altivec_vaddsbs, v16i8>;
373 def VADDSHS : VX1_Int_Ty<832, "vaddshs", int_ppc_altivec_vaddshs, v8i16>;
374 def VADDSWS : VX1_Int_Ty<896, "vaddsws", int_ppc_altivec_vaddsws, v4i32>;
375 def VADDUBS : VX1_Int_Ty<512, "vaddubs", int_ppc_altivec_vaddubs, v16i8>;
376 def VADDUHS : VX1_Int_Ty<576, "vadduhs", int_ppc_altivec_vadduhs, v8i16>;
377 def VADDUWS : VX1_Int_Ty<640, "vadduws", int_ppc_altivec_vadduws, v4i32>;
380 let isCommutable = 1 in
381 def VAND : VXForm_1<1028, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
382 "vand $vD, $vA, $vB", IIC_VecFP,
383 [(set v4i32:$vD, (and v4i32:$vA, v4i32:$vB))]>;
384 def VANDC : VXForm_1<1092, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
385 "vandc $vD, $vA, $vB", IIC_VecFP,
386 [(set v4i32:$vD, (and v4i32:$vA,
387 (vnot_ppc v4i32:$vB)))]>;
389 def VCFSX : VXForm_1<842, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
390 "vcfsx $vD, $vB, $UIMM", IIC_VecFP,
392 (int_ppc_altivec_vcfsx v4i32:$vB, imm:$UIMM))]>;
393 def VCFUX : VXForm_1<778, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
394 "vcfux $vD, $vB, $UIMM", IIC_VecFP,
396 (int_ppc_altivec_vcfux v4i32:$vB, imm:$UIMM))]>;
397 def VCTSXS : VXForm_1<970, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
398 "vctsxs $vD, $vB, $UIMM", IIC_VecFP,
400 (int_ppc_altivec_vctsxs v4f32:$vB, imm:$UIMM))]>;
401 def VCTUXS : VXForm_1<906, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
402 "vctuxs $vD, $vB, $UIMM", IIC_VecFP,
404 (int_ppc_altivec_vctuxs v4f32:$vB, imm:$UIMM))]>;
406 // Defines with the UIM field set to 0 for floating-point
407 // to integer (fp_to_sint/fp_to_uint) conversions and integer
408 // to floating-point (sint_to_fp/uint_to_fp) conversions.
409 let isCodeGenOnly = 1, VA = 0 in {
410 def VCFSX_0 : VXForm_1<842, (outs vrrc:$vD), (ins vrrc:$vB),
411 "vcfsx $vD, $vB, 0", IIC_VecFP,
413 (int_ppc_altivec_vcfsx v4i32:$vB, 0))]>;
414 def VCTUXS_0 : VXForm_1<906, (outs vrrc:$vD), (ins vrrc:$vB),
415 "vctuxs $vD, $vB, 0", IIC_VecFP,
417 (int_ppc_altivec_vctuxs v4f32:$vB, 0))]>;
418 def VCFUX_0 : VXForm_1<778, (outs vrrc:$vD), (ins vrrc:$vB),
419 "vcfux $vD, $vB, 0", IIC_VecFP,
421 (int_ppc_altivec_vcfux v4i32:$vB, 0))]>;
422 def VCTSXS_0 : VXForm_1<970, (outs vrrc:$vD), (ins vrrc:$vB),
423 "vctsxs $vD, $vB, 0", IIC_VecFP,
425 (int_ppc_altivec_vctsxs v4f32:$vB, 0))]>;
427 def VEXPTEFP : VX2_Int_SP<394, "vexptefp", int_ppc_altivec_vexptefp>;
428 def VLOGEFP : VX2_Int_SP<458, "vlogefp", int_ppc_altivec_vlogefp>;
430 let isCommutable = 1 in {
431 def VAVGSB : VX1_Int_Ty<1282, "vavgsb", int_ppc_altivec_vavgsb, v16i8>;
432 def VAVGSH : VX1_Int_Ty<1346, "vavgsh", int_ppc_altivec_vavgsh, v8i16>;
433 def VAVGSW : VX1_Int_Ty<1410, "vavgsw", int_ppc_altivec_vavgsw, v4i32>;
434 def VAVGUB : VX1_Int_Ty<1026, "vavgub", int_ppc_altivec_vavgub, v16i8>;
435 def VAVGUH : VX1_Int_Ty<1090, "vavguh", int_ppc_altivec_vavguh, v8i16>;
436 def VAVGUW : VX1_Int_Ty<1154, "vavguw", int_ppc_altivec_vavguw, v4i32>;
438 def VMAXFP : VX1_Int_Ty<1034, "vmaxfp", int_ppc_altivec_vmaxfp, v4f32>;
439 def VMAXSB : VX1_Int_Ty< 258, "vmaxsb", int_ppc_altivec_vmaxsb, v16i8>;
440 def VMAXSH : VX1_Int_Ty< 322, "vmaxsh", int_ppc_altivec_vmaxsh, v8i16>;
441 def VMAXSW : VX1_Int_Ty< 386, "vmaxsw", int_ppc_altivec_vmaxsw, v4i32>;
442 def VMAXUB : VX1_Int_Ty< 2, "vmaxub", int_ppc_altivec_vmaxub, v16i8>;
443 def VMAXUH : VX1_Int_Ty< 66, "vmaxuh", int_ppc_altivec_vmaxuh, v8i16>;
444 def VMAXUW : VX1_Int_Ty< 130, "vmaxuw", int_ppc_altivec_vmaxuw, v4i32>;
445 def VMINFP : VX1_Int_Ty<1098, "vminfp", int_ppc_altivec_vminfp, v4f32>;
446 def VMINSB : VX1_Int_Ty< 770, "vminsb", int_ppc_altivec_vminsb, v16i8>;
447 def VMINSH : VX1_Int_Ty< 834, "vminsh", int_ppc_altivec_vminsh, v8i16>;
448 def VMINSW : VX1_Int_Ty< 898, "vminsw", int_ppc_altivec_vminsw, v4i32>;
449 def VMINUB : VX1_Int_Ty< 514, "vminub", int_ppc_altivec_vminub, v16i8>;
450 def VMINUH : VX1_Int_Ty< 578, "vminuh", int_ppc_altivec_vminuh, v8i16>;
451 def VMINUW : VX1_Int_Ty< 642, "vminuw", int_ppc_altivec_vminuw, v4i32>;
454 def VMRGHB : VXForm_1< 12, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
455 "vmrghb $vD, $vA, $vB", IIC_VecFP,
456 [(set v16i8:$vD, (vmrghb_shuffle v16i8:$vA, v16i8:$vB))]>;
457 def VMRGHH : VXForm_1< 76, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
458 "vmrghh $vD, $vA, $vB", IIC_VecFP,
459 [(set v16i8:$vD, (vmrghh_shuffle v16i8:$vA, v16i8:$vB))]>;
460 def VMRGHW : VXForm_1<140, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
461 "vmrghw $vD, $vA, $vB", IIC_VecFP,
462 [(set v16i8:$vD, (vmrghw_shuffle v16i8:$vA, v16i8:$vB))]>;
463 def VMRGLB : VXForm_1<268, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
464 "vmrglb $vD, $vA, $vB", IIC_VecFP,
465 [(set v16i8:$vD, (vmrglb_shuffle v16i8:$vA, v16i8:$vB))]>;
466 def VMRGLH : VXForm_1<332, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
467 "vmrglh $vD, $vA, $vB", IIC_VecFP,
468 [(set v16i8:$vD, (vmrglh_shuffle v16i8:$vA, v16i8:$vB))]>;
469 def VMRGLW : VXForm_1<396, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
470 "vmrglw $vD, $vA, $vB", IIC_VecFP,
471 [(set v16i8:$vD, (vmrglw_shuffle v16i8:$vA, v16i8:$vB))]>;
473 def VMSUMMBM : VA1a_Int_Ty3<37, "vmsummbm", int_ppc_altivec_vmsummbm,
474 v4i32, v16i8, v4i32>;
475 def VMSUMSHM : VA1a_Int_Ty3<40, "vmsumshm", int_ppc_altivec_vmsumshm,
476 v4i32, v8i16, v4i32>;
477 def VMSUMSHS : VA1a_Int_Ty3<41, "vmsumshs", int_ppc_altivec_vmsumshs,
478 v4i32, v8i16, v4i32>;
479 def VMSUMUBM : VA1a_Int_Ty3<36, "vmsumubm", int_ppc_altivec_vmsumubm,
480 v4i32, v16i8, v4i32>;
481 def VMSUMUHM : VA1a_Int_Ty3<38, "vmsumuhm", int_ppc_altivec_vmsumuhm,
482 v4i32, v8i16, v4i32>;
483 def VMSUMUHS : VA1a_Int_Ty3<39, "vmsumuhs", int_ppc_altivec_vmsumuhs,
484 v4i32, v8i16, v4i32>;
486 let isCommutable = 1 in {
487 def VMULESB : VX1_Int_Ty2<776, "vmulesb", int_ppc_altivec_vmulesb,
489 def VMULESH : VX1_Int_Ty2<840, "vmulesh", int_ppc_altivec_vmulesh,
491 def VMULEUB : VX1_Int_Ty2<520, "vmuleub", int_ppc_altivec_vmuleub,
493 def VMULEUH : VX1_Int_Ty2<584, "vmuleuh", int_ppc_altivec_vmuleuh,
495 def VMULOSB : VX1_Int_Ty2<264, "vmulosb", int_ppc_altivec_vmulosb,
497 def VMULOSH : VX1_Int_Ty2<328, "vmulosh", int_ppc_altivec_vmulosh,
499 def VMULOUB : VX1_Int_Ty2< 8, "vmuloub", int_ppc_altivec_vmuloub,
501 def VMULOUH : VX1_Int_Ty2< 72, "vmulouh", int_ppc_altivec_vmulouh,
505 def VREFP : VX2_Int_SP<266, "vrefp", int_ppc_altivec_vrefp>;
506 def VRFIM : VX2_Int_SP<714, "vrfim", int_ppc_altivec_vrfim>;
507 def VRFIN : VX2_Int_SP<522, "vrfin", int_ppc_altivec_vrfin>;
508 def VRFIP : VX2_Int_SP<650, "vrfip", int_ppc_altivec_vrfip>;
509 def VRFIZ : VX2_Int_SP<586, "vrfiz", int_ppc_altivec_vrfiz>;
510 def VRSQRTEFP : VX2_Int_SP<330, "vrsqrtefp", int_ppc_altivec_vrsqrtefp>;
512 def VSUBCUW : VX1_Int_Ty<1408, "vsubcuw", int_ppc_altivec_vsubcuw, v4i32>;
514 def VSUBFP : VXForm_1<74, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
515 "vsubfp $vD, $vA, $vB", IIC_VecGeneral,
516 [(set v4f32:$vD, (fsub v4f32:$vA, v4f32:$vB))]>;
517 def VSUBUBM : VXForm_1<1024, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
518 "vsububm $vD, $vA, $vB", IIC_VecGeneral,
519 [(set v16i8:$vD, (sub v16i8:$vA, v16i8:$vB))]>;
520 def VSUBUHM : VXForm_1<1088, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
521 "vsubuhm $vD, $vA, $vB", IIC_VecGeneral,
522 [(set v8i16:$vD, (sub v8i16:$vA, v8i16:$vB))]>;
523 def VSUBUWM : VXForm_1<1152, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
524 "vsubuwm $vD, $vA, $vB", IIC_VecGeneral,
525 [(set v4i32:$vD, (sub v4i32:$vA, v4i32:$vB))]>;
527 def VSUBSBS : VX1_Int_Ty<1792, "vsubsbs" , int_ppc_altivec_vsubsbs, v16i8>;
528 def VSUBSHS : VX1_Int_Ty<1856, "vsubshs" , int_ppc_altivec_vsubshs, v8i16>;
529 def VSUBSWS : VX1_Int_Ty<1920, "vsubsws" , int_ppc_altivec_vsubsws, v4i32>;
530 def VSUBUBS : VX1_Int_Ty<1536, "vsububs" , int_ppc_altivec_vsububs, v16i8>;
531 def VSUBUHS : VX1_Int_Ty<1600, "vsubuhs" , int_ppc_altivec_vsubuhs, v8i16>;
532 def VSUBUWS : VX1_Int_Ty<1664, "vsubuws" , int_ppc_altivec_vsubuws, v4i32>;
534 def VSUMSWS : VX1_Int_Ty<1928, "vsumsws" , int_ppc_altivec_vsumsws, v4i32>;
535 def VSUM2SWS: VX1_Int_Ty<1672, "vsum2sws", int_ppc_altivec_vsum2sws, v4i32>;
537 def VSUM4SBS: VX1_Int_Ty3<1800, "vsum4sbs", int_ppc_altivec_vsum4sbs,
538 v4i32, v16i8, v4i32>;
539 def VSUM4SHS: VX1_Int_Ty3<1608, "vsum4shs", int_ppc_altivec_vsum4shs,
540 v4i32, v8i16, v4i32>;
541 def VSUM4UBS: VX1_Int_Ty3<1544, "vsum4ubs", int_ppc_altivec_vsum4ubs,
542 v4i32, v16i8, v4i32>;
544 def VNOR : VXForm_1<1284, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
545 "vnor $vD, $vA, $vB", IIC_VecFP,
546 [(set v4i32:$vD, (vnot_ppc (or v4i32:$vA,
548 let isCommutable = 1 in {
549 def VOR : VXForm_1<1156, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
550 "vor $vD, $vA, $vB", IIC_VecFP,
551 [(set v4i32:$vD, (or v4i32:$vA, v4i32:$vB))]>;
552 def VXOR : VXForm_1<1220, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
553 "vxor $vD, $vA, $vB", IIC_VecFP,
554 [(set v4i32:$vD, (xor v4i32:$vA, v4i32:$vB))]>;
557 def VRLB : VX1_Int_Ty< 4, "vrlb", int_ppc_altivec_vrlb, v16i8>;
558 def VRLH : VX1_Int_Ty< 68, "vrlh", int_ppc_altivec_vrlh, v8i16>;
559 def VRLW : VX1_Int_Ty< 132, "vrlw", int_ppc_altivec_vrlw, v4i32>;
561 def VSL : VX1_Int_Ty< 452, "vsl" , int_ppc_altivec_vsl, v4i32 >;
562 def VSLO : VX1_Int_Ty<1036, "vslo", int_ppc_altivec_vslo, v4i32>;
564 def VSLB : VX1_Int_Ty< 260, "vslb", int_ppc_altivec_vslb, v16i8>;
565 def VSLH : VX1_Int_Ty< 324, "vslh", int_ppc_altivec_vslh, v8i16>;
566 def VSLW : VX1_Int_Ty< 388, "vslw", int_ppc_altivec_vslw, v4i32>;
568 def VSPLTB : VXForm_1<524, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
569 "vspltb $vD, $vB, $UIMM", IIC_VecPerm,
571 (vspltb_shuffle:$UIMM v16i8:$vB, (undef)))]>;
572 def VSPLTH : VXForm_1<588, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
573 "vsplth $vD, $vB, $UIMM", IIC_VecPerm,
575 (vsplth_shuffle:$UIMM v16i8:$vB, (undef)))]>;
576 def VSPLTW : VXForm_1<652, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
577 "vspltw $vD, $vB, $UIMM", IIC_VecPerm,
579 (vspltw_shuffle:$UIMM v16i8:$vB, (undef)))]>;
581 def VSR : VX1_Int_Ty< 708, "vsr" , int_ppc_altivec_vsr, v4i32>;
582 def VSRO : VX1_Int_Ty<1100, "vsro" , int_ppc_altivec_vsro, v4i32>;
584 def VSRAB : VX1_Int_Ty< 772, "vsrab", int_ppc_altivec_vsrab, v16i8>;
585 def VSRAH : VX1_Int_Ty< 836, "vsrah", int_ppc_altivec_vsrah, v8i16>;
586 def VSRAW : VX1_Int_Ty< 900, "vsraw", int_ppc_altivec_vsraw, v4i32>;
587 def VSRB : VX1_Int_Ty< 516, "vsrb" , int_ppc_altivec_vsrb , v16i8>;
588 def VSRH : VX1_Int_Ty< 580, "vsrh" , int_ppc_altivec_vsrh , v8i16>;
589 def VSRW : VX1_Int_Ty< 644, "vsrw" , int_ppc_altivec_vsrw , v4i32>;
592 def VSPLTISB : VXForm_3<780, (outs vrrc:$vD), (ins s5imm:$SIMM),
593 "vspltisb $vD, $SIMM", IIC_VecPerm,
594 [(set v16i8:$vD, (v16i8 vecspltisb:$SIMM))]>;
595 def VSPLTISH : VXForm_3<844, (outs vrrc:$vD), (ins s5imm:$SIMM),
596 "vspltish $vD, $SIMM", IIC_VecPerm,
597 [(set v8i16:$vD, (v8i16 vecspltish:$SIMM))]>;
598 def VSPLTISW : VXForm_3<908, (outs vrrc:$vD), (ins s5imm:$SIMM),
599 "vspltisw $vD, $SIMM", IIC_VecPerm,
600 [(set v4i32:$vD, (v4i32 vecspltisw:$SIMM))]>;
603 def VPKPX : VX1_Int_Ty2<782, "vpkpx", int_ppc_altivec_vpkpx,
605 def VPKSHSS : VX1_Int_Ty2<398, "vpkshss", int_ppc_altivec_vpkshss,
607 def VPKSHUS : VX1_Int_Ty2<270, "vpkshus", int_ppc_altivec_vpkshus,
609 def VPKSWSS : VX1_Int_Ty2<462, "vpkswss", int_ppc_altivec_vpkswss,
611 def VPKSWUS : VX1_Int_Ty2<334, "vpkswus", int_ppc_altivec_vpkswus,
613 def VPKUHUM : VXForm_1<14, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
614 "vpkuhum $vD, $vA, $vB", IIC_VecFP,
616 (vpkuhum_shuffle v16i8:$vA, v16i8:$vB))]>;
617 def VPKUHUS : VX1_Int_Ty2<142, "vpkuhus", int_ppc_altivec_vpkuhus,
619 def VPKUWUM : VXForm_1<78, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
620 "vpkuwum $vD, $vA, $vB", IIC_VecFP,
622 (vpkuwum_shuffle v16i8:$vA, v16i8:$vB))]>;
623 def VPKUWUS : VX1_Int_Ty2<206, "vpkuwus", int_ppc_altivec_vpkuwus,
627 def VUPKHPX : VX2_Int_Ty2<846, "vupkhpx", int_ppc_altivec_vupkhpx,
629 def VUPKHSB : VX2_Int_Ty2<526, "vupkhsb", int_ppc_altivec_vupkhsb,
631 def VUPKHSH : VX2_Int_Ty2<590, "vupkhsh", int_ppc_altivec_vupkhsh,
633 def VUPKLPX : VX2_Int_Ty2<974, "vupklpx", int_ppc_altivec_vupklpx,
635 def VUPKLSB : VX2_Int_Ty2<654, "vupklsb", int_ppc_altivec_vupklsb,
637 def VUPKLSH : VX2_Int_Ty2<718, "vupklsh", int_ppc_altivec_vupklsh,
641 // Altivec Comparisons.
643 class VCMP<bits<10> xo, string asmstr, ValueType Ty>
644 : VXRForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB), asmstr,
646 [(set Ty:$vD, (Ty (PPCvcmp Ty:$vA, Ty:$vB, xo)))]>;
647 class VCMPo<bits<10> xo, string asmstr, ValueType Ty>
648 : VXRForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB), asmstr,
650 [(set Ty:$vD, (Ty (PPCvcmp_o Ty:$vA, Ty:$vB, xo)))]> {
655 // f32 element comparisons.0
656 def VCMPBFP : VCMP <966, "vcmpbfp $vD, $vA, $vB" , v4f32>;
657 def VCMPBFPo : VCMPo<966, "vcmpbfp. $vD, $vA, $vB" , v4f32>;
658 def VCMPEQFP : VCMP <198, "vcmpeqfp $vD, $vA, $vB" , v4f32>;
659 def VCMPEQFPo : VCMPo<198, "vcmpeqfp. $vD, $vA, $vB", v4f32>;
660 def VCMPGEFP : VCMP <454, "vcmpgefp $vD, $vA, $vB" , v4f32>;
661 def VCMPGEFPo : VCMPo<454, "vcmpgefp. $vD, $vA, $vB", v4f32>;
662 def VCMPGTFP : VCMP <710, "vcmpgtfp $vD, $vA, $vB" , v4f32>;
663 def VCMPGTFPo : VCMPo<710, "vcmpgtfp. $vD, $vA, $vB", v4f32>;
665 // i8 element comparisons.
666 def VCMPEQUB : VCMP < 6, "vcmpequb $vD, $vA, $vB" , v16i8>;
667 def VCMPEQUBo : VCMPo< 6, "vcmpequb. $vD, $vA, $vB", v16i8>;
668 def VCMPGTSB : VCMP <774, "vcmpgtsb $vD, $vA, $vB" , v16i8>;
669 def VCMPGTSBo : VCMPo<774, "vcmpgtsb. $vD, $vA, $vB", v16i8>;
670 def VCMPGTUB : VCMP <518, "vcmpgtub $vD, $vA, $vB" , v16i8>;
671 def VCMPGTUBo : VCMPo<518, "vcmpgtub. $vD, $vA, $vB", v16i8>;
673 // i16 element comparisons.
674 def VCMPEQUH : VCMP < 70, "vcmpequh $vD, $vA, $vB" , v8i16>;
675 def VCMPEQUHo : VCMPo< 70, "vcmpequh. $vD, $vA, $vB", v8i16>;
676 def VCMPGTSH : VCMP <838, "vcmpgtsh $vD, $vA, $vB" , v8i16>;
677 def VCMPGTSHo : VCMPo<838, "vcmpgtsh. $vD, $vA, $vB", v8i16>;
678 def VCMPGTUH : VCMP <582, "vcmpgtuh $vD, $vA, $vB" , v8i16>;
679 def VCMPGTUHo : VCMPo<582, "vcmpgtuh. $vD, $vA, $vB", v8i16>;
681 // i32 element comparisons.
682 def VCMPEQUW : VCMP <134, "vcmpequw $vD, $vA, $vB" , v4i32>;
683 def VCMPEQUWo : VCMPo<134, "vcmpequw. $vD, $vA, $vB", v4i32>;
684 def VCMPGTSW : VCMP <902, "vcmpgtsw $vD, $vA, $vB" , v4i32>;
685 def VCMPGTSWo : VCMPo<902, "vcmpgtsw. $vD, $vA, $vB", v4i32>;
686 def VCMPGTUW : VCMP <646, "vcmpgtuw $vD, $vA, $vB" , v4i32>;
687 def VCMPGTUWo : VCMPo<646, "vcmpgtuw. $vD, $vA, $vB", v4i32>;
689 let isCodeGenOnly = 1 in {
690 def V_SET0B : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
691 "vxor $vD, $vD, $vD", IIC_VecFP,
692 [(set v16i8:$vD, (v16i8 immAllZerosV))]>;
693 def V_SET0H : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
694 "vxor $vD, $vD, $vD", IIC_VecFP,
695 [(set v8i16:$vD, (v8i16 immAllZerosV))]>;
696 def V_SET0 : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
697 "vxor $vD, $vD, $vD", IIC_VecFP,
698 [(set v4i32:$vD, (v4i32 immAllZerosV))]>;
701 def V_SETALLONESB : VXForm_3<908, (outs vrrc:$vD), (ins),
702 "vspltisw $vD, -1", IIC_VecFP,
703 [(set v16i8:$vD, (v16i8 immAllOnesV))]>;
704 def V_SETALLONESH : VXForm_3<908, (outs vrrc:$vD), (ins),
705 "vspltisw $vD, -1", IIC_VecFP,
706 [(set v8i16:$vD, (v8i16 immAllOnesV))]>;
707 def V_SETALLONES : VXForm_3<908, (outs vrrc:$vD), (ins),
708 "vspltisw $vD, -1", IIC_VecFP,
709 [(set v4i32:$vD, (v4i32 immAllOnesV))]>;
712 } // VALU Operations.
714 //===----------------------------------------------------------------------===//
715 // Additional Altivec Patterns
719 def : Pat<(int_ppc_altivec_dssall), (DSSALL 1, 0, 0, 0)>;
720 def : Pat<(int_ppc_altivec_dss imm:$STRM), (DSS 0, imm:$STRM, 0, 0)>;
723 def : Pat<(int_ppc_altivec_dst i32:$rA, i32:$rB, imm:$STRM),
724 (DST 0, imm:$STRM, $rA, $rB)>;
725 def : Pat<(int_ppc_altivec_dstt i32:$rA, i32:$rB, imm:$STRM),
726 (DSTT 1, imm:$STRM, $rA, $rB)>;
727 def : Pat<(int_ppc_altivec_dstst i32:$rA, i32:$rB, imm:$STRM),
728 (DSTST 0, imm:$STRM, $rA, $rB)>;
729 def : Pat<(int_ppc_altivec_dststt i32:$rA, i32:$rB, imm:$STRM),
730 (DSTSTT 1, imm:$STRM, $rA, $rB)>;
733 def : Pat<(int_ppc_altivec_dst i64:$rA, i32:$rB, imm:$STRM),
734 (DST64 0, imm:$STRM, $rA, $rB)>;
735 def : Pat<(int_ppc_altivec_dstt i64:$rA, i32:$rB, imm:$STRM),
736 (DSTT64 1, imm:$STRM, $rA, $rB)>;
737 def : Pat<(int_ppc_altivec_dstst i64:$rA, i32:$rB, imm:$STRM),
738 (DSTST64 0, imm:$STRM, $rA, $rB)>;
739 def : Pat<(int_ppc_altivec_dststt i64:$rA, i32:$rB, imm:$STRM),
740 (DSTSTT64 1, imm:$STRM, $rA, $rB)>;
743 def : Pat<(v4i32 (load xoaddr:$src)), (LVX xoaddr:$src)>;
746 def : Pat<(store v4i32:$rS, xoaddr:$dst),
747 (STVX $rS, xoaddr:$dst)>;
750 def : Pat<(v16i8 (bitconvert (v8i16 VRRC:$src))), (v16i8 VRRC:$src)>;
751 def : Pat<(v16i8 (bitconvert (v4i32 VRRC:$src))), (v16i8 VRRC:$src)>;
752 def : Pat<(v16i8 (bitconvert (v4f32 VRRC:$src))), (v16i8 VRRC:$src)>;
754 def : Pat<(v8i16 (bitconvert (v16i8 VRRC:$src))), (v8i16 VRRC:$src)>;
755 def : Pat<(v8i16 (bitconvert (v4i32 VRRC:$src))), (v8i16 VRRC:$src)>;
756 def : Pat<(v8i16 (bitconvert (v4f32 VRRC:$src))), (v8i16 VRRC:$src)>;
758 def : Pat<(v4i32 (bitconvert (v16i8 VRRC:$src))), (v4i32 VRRC:$src)>;
759 def : Pat<(v4i32 (bitconvert (v8i16 VRRC:$src))), (v4i32 VRRC:$src)>;
760 def : Pat<(v4i32 (bitconvert (v4f32 VRRC:$src))), (v4i32 VRRC:$src)>;
762 def : Pat<(v4f32 (bitconvert (v16i8 VRRC:$src))), (v4f32 VRRC:$src)>;
763 def : Pat<(v4f32 (bitconvert (v8i16 VRRC:$src))), (v4f32 VRRC:$src)>;
764 def : Pat<(v4f32 (bitconvert (v4i32 VRRC:$src))), (v4f32 VRRC:$src)>;
768 // Match vsldoi(x,x), vpkuwum(x,x), vpkuhum(x,x)
769 def:Pat<(vsldoi_unary_shuffle:$in v16i8:$vA, undef),
770 (VSLDOI $vA, $vA, (VSLDOI_unary_get_imm $in))>;
771 def:Pat<(vpkuwum_unary_shuffle v16i8:$vA, undef),
773 def:Pat<(vpkuhum_unary_shuffle v16i8:$vA, undef),
777 def:Pat<(vmrglb_unary_shuffle v16i8:$vA, undef),
779 def:Pat<(vmrglh_unary_shuffle v16i8:$vA, undef),
781 def:Pat<(vmrglw_unary_shuffle v16i8:$vA, undef),
783 def:Pat<(vmrghb_unary_shuffle v16i8:$vA, undef),
785 def:Pat<(vmrghh_unary_shuffle v16i8:$vA, undef),
787 def:Pat<(vmrghw_unary_shuffle v16i8:$vA, undef),
790 // Logical Operations
791 def : Pat<(vnot_ppc v4i32:$vA), (VNOR $vA, $vA)>;
793 def : Pat<(vnot_ppc (or v4i32:$A, v4i32:$B)),
795 def : Pat<(and v4i32:$A, (vnot_ppc v4i32:$B)),
798 def : Pat<(fmul v4f32:$vA, v4f32:$vB),
800 (v4i32 (VSLW (V_SETALLONES), (V_SETALLONES))))>;
802 // Fused multiply add and multiply sub for packed float. These are represented
803 // separately from the real instructions above, for operations that must have
804 // the additional precision, such as Newton-Rhapson (used by divide, sqrt)
805 def : Pat<(PPCvmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
806 (VMADDFP $A, $B, $C)>;
807 def : Pat<(PPCvnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
808 (VNMSUBFP $A, $B, $C)>;
810 def : Pat<(int_ppc_altivec_vmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
811 (VMADDFP $A, $B, $C)>;
812 def : Pat<(int_ppc_altivec_vnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
813 (VNMSUBFP $A, $B, $C)>;
815 def : Pat<(PPCvperm v16i8:$vA, v16i8:$vB, v16i8:$vC),
816 (VPERM $vA, $vB, $vC)>;
818 def : Pat<(PPCfre v4f32:$A), (VREFP $A)>;
819 def : Pat<(PPCfrsqrte v4f32:$A), (VRSQRTEFP $A)>;
822 def : Pat<(v16i8 (shl v16i8:$vA, v16i8:$vB)),
823 (v16i8 (VSLB $vA, $vB))>;
824 def : Pat<(v8i16 (shl v8i16:$vA, v8i16:$vB)),
825 (v8i16 (VSLH $vA, $vB))>;
826 def : Pat<(v4i32 (shl v4i32:$vA, v4i32:$vB)),
827 (v4i32 (VSLW $vA, $vB))>;
829 def : Pat<(v16i8 (srl v16i8:$vA, v16i8:$vB)),
830 (v16i8 (VSRB $vA, $vB))>;
831 def : Pat<(v8i16 (srl v8i16:$vA, v8i16:$vB)),
832 (v8i16 (VSRH $vA, $vB))>;
833 def : Pat<(v4i32 (srl v4i32:$vA, v4i32:$vB)),
834 (v4i32 (VSRW $vA, $vB))>;
836 def : Pat<(v16i8 (sra v16i8:$vA, v16i8:$vB)),
837 (v16i8 (VSRAB $vA, $vB))>;
838 def : Pat<(v8i16 (sra v8i16:$vA, v8i16:$vB)),
839 (v8i16 (VSRAH $vA, $vB))>;
840 def : Pat<(v4i32 (sra v4i32:$vA, v4i32:$vB)),
841 (v4i32 (VSRAW $vA, $vB))>;
843 // Float to integer and integer to float conversions
844 def : Pat<(v4i32 (fp_to_sint v4f32:$vA)),
846 def : Pat<(v4i32 (fp_to_uint v4f32:$vA)),
848 def : Pat<(v4f32 (sint_to_fp v4i32:$vA)),
850 def : Pat<(v4f32 (uint_to_fp v4i32:$vA)),
853 // Floating-point rounding
854 def : Pat<(v4f32 (ffloor v4f32:$vA)),
856 def : Pat<(v4f32 (fceil v4f32:$vA)),
858 def : Pat<(v4f32 (ftrunc v4f32:$vA)),
860 def : Pat<(v4f32 (fnearbyint v4f32:$vA)),