1 //===-- PPCInstrAltivec.td - The PowerPC Altivec Extension -*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the Altivec extension to the PowerPC instruction set.
11 //===----------------------------------------------------------------------===//
13 // *********************************** NOTE ***********************************
14 // ** For POWER8 Little Endian, the VSX swap optimization relies on knowing **
15 // ** which VMX and VSX instructions are lane-sensitive and which are not. **
16 // ** A lane-sensitive instruction relies, implicitly or explicitly, on **
17 // ** whether lanes are numbered from left to right. An instruction like **
18 // ** VADDFP is not lane-sensitive, because each lane of the result vector **
19 // ** relies only on the corresponding lane of the source vectors. However, **
20 // ** an instruction like VMULESB is lane-sensitive, because "even" and **
21 // ** "odd" lanes are different for big-endian and little-endian numbering. **
23 // ** When adding new VMX and VSX instructions, please consider whether they **
24 // ** are lane-sensitive. If so, they must be added to a switch statement **
25 // ** in PPCVSXSwapRemoval::gatherVectorInstructions(). **
26 // ****************************************************************************
29 //===----------------------------------------------------------------------===//
30 // Altivec transformation functions and pattern fragments.
33 def vpkuhum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
34 (vector_shuffle node:$lhs, node:$rhs), [{
35 return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
37 def vpkuwum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
38 (vector_shuffle node:$lhs, node:$rhs), [{
39 return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
41 def vpkudum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
42 (vector_shuffle node:$lhs, node:$rhs), [{
43 return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
45 def vpkuhum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
46 (vector_shuffle node:$lhs, node:$rhs), [{
47 return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
49 def vpkuwum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
50 (vector_shuffle node:$lhs, node:$rhs), [{
51 return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
53 def vpkudum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
54 (vector_shuffle node:$lhs, node:$rhs), [{
55 return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
58 // These fragments are provided for little-endian, where the inputs must be
59 // swapped for correct semantics.
60 def vpkuhum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
61 (vector_shuffle node:$lhs, node:$rhs), [{
62 return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
64 def vpkuwum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
65 (vector_shuffle node:$lhs, node:$rhs), [{
66 return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
68 def vpkudum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
69 (vector_shuffle node:$lhs, node:$rhs), [{
70 return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
73 def vmrglb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
74 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
75 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 0, *CurDAG);
77 def vmrglh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
78 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
79 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 0, *CurDAG);
81 def vmrglw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
82 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
83 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 0, *CurDAG);
85 def vmrghb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
86 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
87 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 0, *CurDAG);
89 def vmrghh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
90 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
91 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 0, *CurDAG);
93 def vmrghw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
94 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
95 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 0, *CurDAG);
99 def vmrglb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
100 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
101 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 1, *CurDAG);
103 def vmrglh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
104 (vector_shuffle node:$lhs, node:$rhs), [{
105 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 1, *CurDAG);
107 def vmrglw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
108 (vector_shuffle node:$lhs, node:$rhs), [{
109 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 1, *CurDAG);
111 def vmrghb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
112 (vector_shuffle node:$lhs, node:$rhs), [{
113 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 1, *CurDAG);
115 def vmrghh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
116 (vector_shuffle node:$lhs, node:$rhs), [{
117 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 1, *CurDAG);
119 def vmrghw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
120 (vector_shuffle node:$lhs, node:$rhs), [{
121 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 1, *CurDAG);
125 // These fragments are provided for little-endian, where the inputs must be
126 // swapped for correct semantics.
127 def vmrglb_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
128 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
129 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 2, *CurDAG);
131 def vmrglh_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
132 (vector_shuffle node:$lhs, node:$rhs), [{
133 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 2, *CurDAG);
135 def vmrglw_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
136 (vector_shuffle node:$lhs, node:$rhs), [{
137 return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 2, *CurDAG);
139 def vmrghb_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
140 (vector_shuffle node:$lhs, node:$rhs), [{
141 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 2, *CurDAG);
143 def vmrghh_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
144 (vector_shuffle node:$lhs, node:$rhs), [{
145 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 2, *CurDAG);
147 def vmrghw_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
148 (vector_shuffle node:$lhs, node:$rhs), [{
149 return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 2, *CurDAG);
153 def vmrgew_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
154 (vector_shuffle node:$lhs, node:$rhs), [{
155 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 0, *CurDAG);
157 def vmrgow_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
158 (vector_shuffle node:$lhs, node:$rhs), [{
159 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 0, *CurDAG);
161 def vmrgew_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
162 (vector_shuffle node:$lhs, node:$rhs), [{
163 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 1, *CurDAG);
165 def vmrgow_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
166 (vector_shuffle node:$lhs, node:$rhs), [{
167 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 1, *CurDAG);
169 def vmrgew_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
170 (vector_shuffle node:$lhs, node:$rhs), [{
171 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 2, *CurDAG);
173 def vmrgow_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
174 (vector_shuffle node:$lhs, node:$rhs), [{
175 return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 2, *CurDAG);
180 def VSLDOI_get_imm : SDNodeXForm<vector_shuffle, [{
181 return getI32Imm(PPC::isVSLDOIShuffleMask(N, 0, *CurDAG), SDLoc(N));
183 def vsldoi_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
184 (vector_shuffle node:$lhs, node:$rhs), [{
185 return PPC::isVSLDOIShuffleMask(N, 0, *CurDAG) != -1;
189 /// VSLDOI_unary* - These are used to match vsldoi(X,X), which is turned into
190 /// vector_shuffle(X,undef,mask) by the dag combiner.
191 def VSLDOI_unary_get_imm : SDNodeXForm<vector_shuffle, [{
192 return getI32Imm(PPC::isVSLDOIShuffleMask(N, 1, *CurDAG), SDLoc(N));
194 def vsldoi_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
195 (vector_shuffle node:$lhs, node:$rhs), [{
196 return PPC::isVSLDOIShuffleMask(N, 1, *CurDAG) != -1;
197 }], VSLDOI_unary_get_imm>;
200 /// VSLDOI_swapped* - These fragments are provided for little-endian, where
201 /// the inputs must be swapped for correct semantics.
202 def VSLDOI_swapped_get_imm : SDNodeXForm<vector_shuffle, [{
203 return getI32Imm(PPC::isVSLDOIShuffleMask(N, 2, *CurDAG), SDLoc(N));
205 def vsldoi_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
206 (vector_shuffle node:$lhs, node:$rhs), [{
207 return PPC::isVSLDOIShuffleMask(N, 2, *CurDAG) != -1;
211 // VSPLT*_get_imm xform function: convert vector_shuffle mask to VSPLT* imm.
212 def VSPLTB_get_imm : SDNodeXForm<vector_shuffle, [{
213 return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 1, *CurDAG), SDLoc(N));
215 def vspltb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
216 (vector_shuffle node:$lhs, node:$rhs), [{
217 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 1);
219 def VSPLTH_get_imm : SDNodeXForm<vector_shuffle, [{
220 return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 2, *CurDAG), SDLoc(N));
222 def vsplth_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
223 (vector_shuffle node:$lhs, node:$rhs), [{
224 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 2);
226 def VSPLTW_get_imm : SDNodeXForm<vector_shuffle, [{
227 return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 4, *CurDAG), SDLoc(N));
229 def vspltw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
230 (vector_shuffle node:$lhs, node:$rhs), [{
231 return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 4);
235 // VSPLTISB_get_imm xform function: convert build_vector to VSPLTISB imm.
236 def VSPLTISB_get_imm : SDNodeXForm<build_vector, [{
237 return PPC::get_VSPLTI_elt(N, 1, *CurDAG);
239 def vecspltisb : PatLeaf<(build_vector), [{
240 return PPC::get_VSPLTI_elt(N, 1, *CurDAG).getNode() != nullptr;
241 }], VSPLTISB_get_imm>;
243 // VSPLTISH_get_imm xform function: convert build_vector to VSPLTISH imm.
244 def VSPLTISH_get_imm : SDNodeXForm<build_vector, [{
245 return PPC::get_VSPLTI_elt(N, 2, *CurDAG);
247 def vecspltish : PatLeaf<(build_vector), [{
248 return PPC::get_VSPLTI_elt(N, 2, *CurDAG).getNode() != nullptr;
249 }], VSPLTISH_get_imm>;
251 // VSPLTISW_get_imm xform function: convert build_vector to VSPLTISW imm.
252 def VSPLTISW_get_imm : SDNodeXForm<build_vector, [{
253 return PPC::get_VSPLTI_elt(N, 4, *CurDAG);
255 def vecspltisw : PatLeaf<(build_vector), [{
256 return PPC::get_VSPLTI_elt(N, 4, *CurDAG).getNode() != nullptr;
257 }], VSPLTISW_get_imm>;
259 def immEQOneV : PatLeaf<(build_vector), [{
260 if (ConstantSDNode *C = cast<BuildVectorSDNode>(N)->getConstantSplatNode())
264 //===----------------------------------------------------------------------===//
265 // Helpers for defining instructions that directly correspond to intrinsics.
267 // VA1a_Int_Ty - A VAForm_1a intrinsic definition of specific type.
268 class VA1a_Int_Ty<bits<6> xo, string opc, Intrinsic IntID, ValueType Ty>
269 : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
270 !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
271 [(set Ty:$RT, (IntID Ty:$RA, Ty:$RB, Ty:$RC))]>;
273 // VA1a_Int_Ty2 - A VAForm_1a intrinsic definition where the type of the
274 // inputs doesn't match the type of the output.
275 class VA1a_Int_Ty2<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
277 : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
278 !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
279 [(set OutTy:$RT, (IntID InTy:$RA, InTy:$RB, InTy:$RC))]>;
281 // VA1a_Int_Ty3 - A VAForm_1a intrinsic definition where there are two
282 // input types and an output type.
283 class VA1a_Int_Ty3<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
284 ValueType In1Ty, ValueType In2Ty>
285 : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
286 !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
288 (IntID In1Ty:$RA, In1Ty:$RB, In2Ty:$RC))]>;
290 // VX1_Int_Ty - A VXForm_1 intrinsic definition of specific type.
291 class VX1_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
292 : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
293 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
294 [(set Ty:$VD, (IntID Ty:$VA, Ty:$VB))]>;
296 // VX1_Int_Ty2 - A VXForm_1 intrinsic definition where the type of the
297 // inputs doesn't match the type of the output.
298 class VX1_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
300 : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
301 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
302 [(set OutTy:$VD, (IntID InTy:$VA, InTy:$VB))]>;
304 // VX1_Int_Ty3 - A VXForm_1 intrinsic definition where there are two
305 // input types and an output type.
306 class VX1_Int_Ty3<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
307 ValueType In1Ty, ValueType In2Ty>
308 : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
309 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
310 [(set OutTy:$VD, (IntID In1Ty:$VA, In2Ty:$VB))]>;
312 // VX2_Int_SP - A VXForm_2 intrinsic definition of vector single-precision type.
313 class VX2_Int_SP<bits<11> xo, string opc, Intrinsic IntID>
314 : VXForm_2<xo, (outs vrrc:$VD), (ins vrrc:$VB),
315 !strconcat(opc, " $VD, $VB"), IIC_VecFP,
316 [(set v4f32:$VD, (IntID v4f32:$VB))]>;
318 // VX2_Int_Ty2 - A VXForm_2 intrinsic definition where the type of the
319 // inputs doesn't match the type of the output.
320 class VX2_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
322 : VXForm_2<xo, (outs vrrc:$VD), (ins vrrc:$VB),
323 !strconcat(opc, " $VD, $VB"), IIC_VecFP,
324 [(set OutTy:$VD, (IntID InTy:$VB))]>;
326 class VXBX_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
327 : VXForm_BX<xo, (outs vrrc:$VD), (ins vrrc:$VA),
328 !strconcat(opc, " $VD, $VA"), IIC_VecFP,
329 [(set Ty:$VD, (IntID Ty:$VA))]>;
331 class VXCR_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
332 : VXForm_CR<xo, (outs vrrc:$VD), (ins vrrc:$VA, u1imm:$ST, u4imm:$SIX),
333 !strconcat(opc, " $VD, $VA, $ST, $SIX"), IIC_VecFP,
334 [(set Ty:$VD, (IntID Ty:$VA, timm:$ST, timm:$SIX))]>;
336 //===----------------------------------------------------------------------===//
337 // Instruction Definitions.
339 def HasAltivec : Predicate<"Subtarget->hasAltivec()">;
340 let Predicates = [HasAltivec] in {
342 def DSS : DSS_Form<0, 822, (outs), (ins u5imm:$STRM),
343 "dss $STRM", IIC_LdStLoad /*FIXME*/, [(int_ppc_altivec_dss imm:$STRM)]>,
344 Deprecated<DeprecatedDST> {
349 def DSSALL : DSS_Form<1, 822, (outs), (ins),
350 "dssall", IIC_LdStLoad /*FIXME*/, []>,
351 Deprecated<DeprecatedDST> {
357 def DST : DSS_Form<0, 342, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
358 "dst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
359 [(int_ppc_altivec_dst i32:$RA, i32:$RB, imm:$STRM)]>,
360 Deprecated<DeprecatedDST>;
362 def DSTT : DSS_Form<1, 342, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
363 "dstt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
364 [(int_ppc_altivec_dstt i32:$RA, i32:$RB, imm:$STRM)]>,
365 Deprecated<DeprecatedDST>;
367 def DSTST : DSS_Form<0, 374, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
368 "dstst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
369 [(int_ppc_altivec_dstst i32:$RA, i32:$RB, imm:$STRM)]>,
370 Deprecated<DeprecatedDST>;
372 def DSTSTT : DSS_Form<1, 374, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
373 "dststt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
374 [(int_ppc_altivec_dststt i32:$RA, i32:$RB, imm:$STRM)]>,
375 Deprecated<DeprecatedDST>;
377 let isCodeGenOnly = 1 in {
378 // The very same instructions as above, but formally matching 64bit registers.
379 def DST64 : DSS_Form<0, 342, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
380 "dst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
381 [(int_ppc_altivec_dst i64:$RA, i32:$RB, imm:$STRM)]>,
382 Deprecated<DeprecatedDST>;
384 def DSTT64 : DSS_Form<1, 342, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
385 "dstt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
386 [(int_ppc_altivec_dstt i64:$RA, i32:$RB, imm:$STRM)]>,
387 Deprecated<DeprecatedDST>;
389 def DSTST64 : DSS_Form<0, 374, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
390 "dstst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
391 [(int_ppc_altivec_dstst i64:$RA, i32:$RB,
393 Deprecated<DeprecatedDST>;
395 def DSTSTT64 : DSS_Form<1, 374, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
396 "dststt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
397 [(int_ppc_altivec_dststt i64:$RA, i32:$RB,
399 Deprecated<DeprecatedDST>;
402 let hasSideEffects = 1 in {
403 def MFVSCR : VXForm_4<1540, (outs vrrc:$VD), (ins),
404 "mfvscr $VD", IIC_LdStStore,
405 [(set v8i16:$VD, (int_ppc_altivec_mfvscr))]>;
406 def MTVSCR : VXForm_5<1604, (outs), (ins vrrc:$VB),
407 "mtvscr $VB", IIC_LdStLoad,
408 [(int_ppc_altivec_mtvscr v4i32:$VB)]>;
411 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in { // Loads.
412 def LVEBX: XForm_1_memOp<31, 7, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
413 "lvebx $RST, $addr", IIC_LdStLoad,
414 [(set v16i8:$RST, (int_ppc_altivec_lvebx ForceXForm:$addr))]>;
415 def LVEHX: XForm_1_memOp<31, 39, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
416 "lvehx $RST, $addr", IIC_LdStLoad,
417 [(set v8i16:$RST, (int_ppc_altivec_lvehx ForceXForm:$addr))]>;
418 def LVEWX: XForm_1_memOp<31, 71, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
419 "lvewx $RST, $addr", IIC_LdStLoad,
420 [(set v4i32:$RST, (int_ppc_altivec_lvewx ForceXForm:$addr))]>;
421 def LVX : XForm_1_memOp<31, 103, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
422 "lvx $RST, $addr", IIC_LdStLoad,
423 [(set v4i32:$RST, (int_ppc_altivec_lvx ForceXForm:$addr))]>;
424 def LVXL : XForm_1_memOp<31, 359, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
425 "lvxl $RST, $addr", IIC_LdStLoad,
426 [(set v4i32:$RST, (int_ppc_altivec_lvxl ForceXForm:$addr))]>;
429 def LVSL : XForm_1_memOp<31, 6, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
430 "lvsl $RST, $addr", IIC_LdStLoad,
431 [(set v16i8:$RST, (int_ppc_altivec_lvsl ForceXForm:$addr))]>,
433 def LVSR : XForm_1_memOp<31, 38, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
434 "lvsr $RST, $addr", IIC_LdStLoad,
435 [(set v16i8:$RST, (int_ppc_altivec_lvsr ForceXForm:$addr))]>,
438 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in { // Stores.
439 def STVEBX: XForm_8_memOp<31, 135, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
440 "stvebx $RST, $addr", IIC_LdStStore,
441 [(int_ppc_altivec_stvebx v16i8:$RST, ForceXForm:$addr)]>;
442 def STVEHX: XForm_8_memOp<31, 167, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
443 "stvehx $RST, $addr", IIC_LdStStore,
444 [(int_ppc_altivec_stvehx v8i16:$RST, ForceXForm:$addr)]>;
445 def STVEWX: XForm_8_memOp<31, 199, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
446 "stvewx $RST, $addr", IIC_LdStStore,
447 [(int_ppc_altivec_stvewx v4i32:$RST, ForceXForm:$addr)]>;
448 def STVX : XForm_8_memOp<31, 231, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
449 "stvx $RST, $addr", IIC_LdStStore,
450 [(int_ppc_altivec_stvx v4i32:$RST, ForceXForm:$addr)]>;
451 def STVXL : XForm_8_memOp<31, 487, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
452 "stvxl $RST, $addr", IIC_LdStStore,
453 [(int_ppc_altivec_stvxl v4i32:$RST, ForceXForm:$addr)]>;
456 let PPC970_Unit = 5 in { // VALU Operations.
457 // VA-Form instructions. 3-input AltiVec ops.
458 let isCommutable = 1 in {
459 def VMADDFP : VAForm_1<46, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RC, vrrc:$RB),
460 "vmaddfp $RT, $RA, $RC, $RB", IIC_VecFP,
462 (fma v4f32:$RA, v4f32:$RC, v4f32:$RB))]>;
464 // FIXME: The fma+fneg pattern won't match because fneg is not legal.
465 def VNMSUBFP: VAForm_1<47, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RC, vrrc:$RB),
466 "vnmsubfp $RT, $RA, $RC, $RB", IIC_VecFP,
467 [(set v4f32:$RT, (fneg (fma v4f32:$RA, v4f32:$RC,
468 (fneg v4f32:$RB))))]>;
469 let hasSideEffects = 1 in {
470 def VMHADDSHS : VA1a_Int_Ty<32, "vmhaddshs", int_ppc_altivec_vmhaddshs, v8i16>;
471 def VMHRADDSHS : VA1a_Int_Ty<33, "vmhraddshs", int_ppc_altivec_vmhraddshs,
474 def VMLADDUHM : VA1a_Int_Ty<34, "vmladduhm", int_ppc_altivec_vmladduhm, v8i16>;
477 def VPERM : VA1a_Int_Ty3<43, "vperm", int_ppc_altivec_vperm,
478 v4i32, v4i32, v16i8>;
479 def VSEL : VA1a_Int_Ty<42, "vsel", int_ppc_altivec_vsel, v4i32>;
482 def VSLDOI : VAForm_2<44, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, u4imm:$SH),
483 "vsldoi $RT, $RA, $RB, $SH", IIC_VecFP,
485 (PPCvecshl v16i8:$RA, v16i8:$RB, imm32SExt16:$SH))]>;
487 // VX-Form instructions. AltiVec arithmetic ops.
488 let isCommutable = 1 in {
489 def VADDFP : VXForm_1<10, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
490 "vaddfp $VD, $VA, $VB", IIC_VecFP,
491 [(set v4f32:$VD, (fadd v4f32:$VA, v4f32:$VB))]>;
493 def VADDUBM : VXForm_1<0, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
494 "vaddubm $VD, $VA, $VB", IIC_VecGeneral,
495 [(set v16i8:$VD, (add v16i8:$VA, v16i8:$VB))]>;
496 def VADDUHM : VXForm_1<64, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
497 "vadduhm $VD, $VA, $VB", IIC_VecGeneral,
498 [(set v8i16:$VD, (add v8i16:$VA, v8i16:$VB))]>;
499 def VADDUWM : VXForm_1<128, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
500 "vadduwm $VD, $VA, $VB", IIC_VecGeneral,
501 [(set v4i32:$VD, (add v4i32:$VA, v4i32:$VB))]>;
503 def VADDCUW : VX1_Int_Ty<384, "vaddcuw", int_ppc_altivec_vaddcuw, v4i32>;
504 def VADDSBS : VX1_Int_Ty<768, "vaddsbs", int_ppc_altivec_vaddsbs, v16i8>;
505 def VADDSHS : VX1_Int_Ty<832, "vaddshs", int_ppc_altivec_vaddshs, v8i16>;
506 def VADDSWS : VX1_Int_Ty<896, "vaddsws", int_ppc_altivec_vaddsws, v4i32>;
507 def VADDUBS : VX1_Int_Ty<512, "vaddubs", int_ppc_altivec_vaddubs, v16i8>;
508 def VADDUHS : VX1_Int_Ty<576, "vadduhs", int_ppc_altivec_vadduhs, v8i16>;
509 def VADDUWS : VX1_Int_Ty<640, "vadduws", int_ppc_altivec_vadduws, v4i32>;
512 let isCommutable = 1 in
513 def VAND : VXForm_1<1028, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
514 "vand $VD, $VA, $VB", IIC_VecFP,
515 [(set v4i32:$VD, (and v4i32:$VA, v4i32:$VB))]>;
516 def VANDC : VXForm_1<1092, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
517 "vandc $VD, $VA, $VB", IIC_VecFP,
518 [(set v4i32:$VD, (and v4i32:$VA,
519 (vnot v4i32:$VB)))]>;
521 def VCFSX : VXForm_1<842, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
522 "vcfsx $VD, $VB, $VA", IIC_VecFP,
524 (int_ppc_altivec_vcfsx v4i32:$VB, timm:$VA))]>;
525 def VCFUX : VXForm_1<778, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
526 "vcfux $VD, $VB, $VA", IIC_VecFP,
528 (int_ppc_altivec_vcfux v4i32:$VB, timm:$VA))]>;
529 def VCTSXS : VXForm_1<970, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
530 "vctsxs $VD, $VB, $VA", IIC_VecFP,
532 (int_ppc_altivec_vctsxs v4f32:$VB, timm:$VA))]>;
533 def VCTUXS : VXForm_1<906, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
534 "vctuxs $VD, $VB, $VA", IIC_VecFP,
536 (int_ppc_altivec_vctuxs v4f32:$VB, timm:$VA))]>;
538 // Defines with the UIM field set to 0 for floating-point
539 // to integer (fp_to_sint/fp_to_uint) conversions and integer
540 // to floating-point (sint_to_fp/uint_to_fp) conversions.
541 let isCodeGenOnly = 1, VA = 0 in {
542 def VCFSX_0 : VXForm_1<842, (outs vrrc:$VD), (ins vrrc:$VB),
543 "vcfsx $VD, $VB, 0", IIC_VecFP,
545 (int_ppc_altivec_vcfsx v4i32:$VB, 0))]>;
546 def VCTUXS_0 : VXForm_1<906, (outs vrrc:$VD), (ins vrrc:$VB),
547 "vctuxs $VD, $VB, 0", IIC_VecFP,
549 (int_ppc_altivec_vctuxs v4f32:$VB, 0))]>;
550 def VCFUX_0 : VXForm_1<778, (outs vrrc:$VD), (ins vrrc:$VB),
551 "vcfux $VD, $VB, 0", IIC_VecFP,
553 (int_ppc_altivec_vcfux v4i32:$VB, 0))]>;
554 def VCTSXS_0 : VXForm_1<970, (outs vrrc:$VD), (ins vrrc:$VB),
555 "vctsxs $VD, $VB, 0", IIC_VecFP,
557 (int_ppc_altivec_vctsxs v4f32:$VB, 0))]>;
559 def VEXPTEFP : VX2_Int_SP<394, "vexptefp", int_ppc_altivec_vexptefp>;
560 def VLOGEFP : VX2_Int_SP<458, "vlogefp", int_ppc_altivec_vlogefp>;
562 let isCommutable = 1 in {
563 def VAVGSB : VX1_Int_Ty<1282, "vavgsb", int_ppc_altivec_vavgsb, v16i8>;
564 def VAVGSH : VX1_Int_Ty<1346, "vavgsh", int_ppc_altivec_vavgsh, v8i16>;
565 def VAVGSW : VX1_Int_Ty<1410, "vavgsw", int_ppc_altivec_vavgsw, v4i32>;
566 def VAVGUB : VX1_Int_Ty<1026, "vavgub", int_ppc_altivec_vavgub, v16i8>;
567 def VAVGUH : VX1_Int_Ty<1090, "vavguh", int_ppc_altivec_vavguh, v8i16>;
568 def VAVGUW : VX1_Int_Ty<1154, "vavguw", int_ppc_altivec_vavguw, v4i32>;
570 def VMAXFP : VX1_Int_Ty<1034, "vmaxfp", int_ppc_altivec_vmaxfp, v4f32>;
571 def VMAXSB : VX1_Int_Ty< 258, "vmaxsb", int_ppc_altivec_vmaxsb, v16i8>;
572 def VMAXSH : VX1_Int_Ty< 322, "vmaxsh", int_ppc_altivec_vmaxsh, v8i16>;
573 def VMAXSW : VX1_Int_Ty< 386, "vmaxsw", int_ppc_altivec_vmaxsw, v4i32>;
574 def VMAXUB : VX1_Int_Ty< 2, "vmaxub", int_ppc_altivec_vmaxub, v16i8>;
575 def VMAXUH : VX1_Int_Ty< 66, "vmaxuh", int_ppc_altivec_vmaxuh, v8i16>;
576 def VMAXUW : VX1_Int_Ty< 130, "vmaxuw", int_ppc_altivec_vmaxuw, v4i32>;
577 def VMINFP : VX1_Int_Ty<1098, "vminfp", int_ppc_altivec_vminfp, v4f32>;
578 def VMINSB : VX1_Int_Ty< 770, "vminsb", int_ppc_altivec_vminsb, v16i8>;
579 def VMINSH : VX1_Int_Ty< 834, "vminsh", int_ppc_altivec_vminsh, v8i16>;
580 def VMINSW : VX1_Int_Ty< 898, "vminsw", int_ppc_altivec_vminsw, v4i32>;
581 def VMINUB : VX1_Int_Ty< 514, "vminub", int_ppc_altivec_vminub, v16i8>;
582 def VMINUH : VX1_Int_Ty< 578, "vminuh", int_ppc_altivec_vminuh, v8i16>;
583 def VMINUW : VX1_Int_Ty< 642, "vminuw", int_ppc_altivec_vminuw, v4i32>;
586 def VMRGHB : VXForm_1< 12, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
587 "vmrghb $VD, $VA, $VB", IIC_VecFP,
588 [(set v16i8:$VD, (vmrghb_shuffle v16i8:$VA, v16i8:$VB))]>;
589 def VMRGHH : VXForm_1< 76, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
590 "vmrghh $VD, $VA, $VB", IIC_VecFP,
591 [(set v16i8:$VD, (vmrghh_shuffle v16i8:$VA, v16i8:$VB))]>;
592 def VMRGHW : VXForm_1<140, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
593 "vmrghw $VD, $VA, $VB", IIC_VecFP,
594 [(set v16i8:$VD, (vmrghw_shuffle v16i8:$VA, v16i8:$VB))]>;
595 def VMRGLB : VXForm_1<268, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
596 "vmrglb $VD, $VA, $VB", IIC_VecFP,
597 [(set v16i8:$VD, (vmrglb_shuffle v16i8:$VA, v16i8:$VB))]>;
598 def VMRGLH : VXForm_1<332, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
599 "vmrglh $VD, $VA, $VB", IIC_VecFP,
600 [(set v16i8:$VD, (vmrglh_shuffle v16i8:$VA, v16i8:$VB))]>;
601 def VMRGLW : VXForm_1<396, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
602 "vmrglw $VD, $VA, $VB", IIC_VecFP,
603 [(set v16i8:$VD, (vmrglw_shuffle v16i8:$VA, v16i8:$VB))]>;
605 def VMSUMMBM : VA1a_Int_Ty3<37, "vmsummbm", int_ppc_altivec_vmsummbm,
606 v4i32, v16i8, v4i32>;
607 def VMSUMSHM : VA1a_Int_Ty3<40, "vmsumshm", int_ppc_altivec_vmsumshm,
608 v4i32, v8i16, v4i32>;
609 def VMSUMUBM : VA1a_Int_Ty3<36, "vmsumubm", int_ppc_altivec_vmsumubm,
610 v4i32, v16i8, v4i32>;
611 def VMSUMUHM : VA1a_Int_Ty3<38, "vmsumuhm", int_ppc_altivec_vmsumuhm,
612 v4i32, v8i16, v4i32>;
613 let hasSideEffects = 1 in {
614 def VMSUMSHS : VA1a_Int_Ty3<41, "vmsumshs", int_ppc_altivec_vmsumshs,
615 v4i32, v8i16, v4i32>;
616 def VMSUMUHS : VA1a_Int_Ty3<39, "vmsumuhs", int_ppc_altivec_vmsumuhs,
617 v4i32, v8i16, v4i32>;
620 let isCommutable = 1 in {
621 def VMULESB : VX1_Int_Ty2<776, "vmulesb", int_ppc_altivec_vmulesb,
623 def VMULESH : VX1_Int_Ty2<840, "vmulesh", int_ppc_altivec_vmulesh,
625 def VMULEUB : VX1_Int_Ty2<520, "vmuleub", int_ppc_altivec_vmuleub,
627 def VMULEUH : VX1_Int_Ty2<584, "vmuleuh", int_ppc_altivec_vmuleuh,
629 def VMULOSB : VX1_Int_Ty2<264, "vmulosb", int_ppc_altivec_vmulosb,
631 def VMULOSH : VX1_Int_Ty2<328, "vmulosh", int_ppc_altivec_vmulosh,
633 def VMULOUB : VX1_Int_Ty2< 8, "vmuloub", int_ppc_altivec_vmuloub,
635 def VMULOUH : VX1_Int_Ty2< 72, "vmulouh", int_ppc_altivec_vmulouh,
639 def VREFP : VX2_Int_SP<266, "vrefp", int_ppc_altivec_vrefp>;
640 def VRFIM : VX2_Int_SP<714, "vrfim", int_ppc_altivec_vrfim>;
641 def VRFIN : VX2_Int_SP<522, "vrfin", int_ppc_altivec_vrfin>;
642 def VRFIP : VX2_Int_SP<650, "vrfip", int_ppc_altivec_vrfip>;
643 def VRFIZ : VX2_Int_SP<586, "vrfiz", int_ppc_altivec_vrfiz>;
644 def VRSQRTEFP : VX2_Int_SP<330, "vrsqrtefp", int_ppc_altivec_vrsqrtefp>;
646 def VSUBCUW : VX1_Int_Ty<1408, "vsubcuw", int_ppc_altivec_vsubcuw, v4i32>;
648 def VSUBFP : VXForm_1<74, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
649 "vsubfp $VD, $VA, $VB", IIC_VecGeneral,
650 [(set v4f32:$VD, (fsub v4f32:$VA, v4f32:$VB))]>;
651 def VSUBUBM : VXForm_1<1024, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
652 "vsububm $VD, $VA, $VB", IIC_VecGeneral,
653 [(set v16i8:$VD, (sub v16i8:$VA, v16i8:$VB))]>;
654 def VSUBUHM : VXForm_1<1088, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
655 "vsubuhm $VD, $VA, $VB", IIC_VecGeneral,
656 [(set v8i16:$VD, (sub v8i16:$VA, v8i16:$VB))]>;
657 def VSUBUWM : VXForm_1<1152, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
658 "vsubuwm $VD, $VA, $VB", IIC_VecGeneral,
659 [(set v4i32:$VD, (sub v4i32:$VA, v4i32:$VB))]>;
661 def VSUBSBS : VX1_Int_Ty<1792, "vsubsbs" , int_ppc_altivec_vsubsbs, v16i8>;
662 def VSUBSHS : VX1_Int_Ty<1856, "vsubshs" , int_ppc_altivec_vsubshs, v8i16>;
663 def VSUBSWS : VX1_Int_Ty<1920, "vsubsws" , int_ppc_altivec_vsubsws, v4i32>;
664 def VSUBUBS : VX1_Int_Ty<1536, "vsububs" , int_ppc_altivec_vsububs, v16i8>;
665 def VSUBUHS : VX1_Int_Ty<1600, "vsubuhs" , int_ppc_altivec_vsubuhs, v8i16>;
666 def VSUBUWS : VX1_Int_Ty<1664, "vsubuws" , int_ppc_altivec_vsubuws, v4i32>;
668 let hasSideEffects = 1 in {
669 def VSUMSWS : VX1_Int_Ty<1928, "vsumsws" , int_ppc_altivec_vsumsws, v4i32>;
670 def VSUM2SWS: VX1_Int_Ty<1672, "vsum2sws", int_ppc_altivec_vsum2sws, v4i32>;
672 def VSUM4SBS: VX1_Int_Ty3<1800, "vsum4sbs", int_ppc_altivec_vsum4sbs,
673 v4i32, v16i8, v4i32>;
674 def VSUM4SHS: VX1_Int_Ty3<1608, "vsum4shs", int_ppc_altivec_vsum4shs,
675 v4i32, v8i16, v4i32>;
676 def VSUM4UBS: VX1_Int_Ty3<1544, "vsum4ubs", int_ppc_altivec_vsum4ubs,
677 v4i32, v16i8, v4i32>;
680 def VNOR : VXForm_1<1284, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
681 "vnor $VD, $VA, $VB", IIC_VecFP,
682 [(set v4i32:$VD, (vnot (or v4i32:$VA,
684 let isCommutable = 1 in {
685 def VOR : VXForm_1<1156, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
686 "vor $VD, $VA, $VB", IIC_VecFP,
687 [(set v4i32:$VD, (or v4i32:$VA, v4i32:$VB))]>;
688 def VXOR : VXForm_1<1220, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
689 "vxor $VD, $VA, $VB", IIC_VecFP,
690 [(set v4i32:$VD, (xor v4i32:$VA, v4i32:$VB))]>;
693 def VRLB : VX1_Int_Ty< 4, "vrlb", int_ppc_altivec_vrlb, v16i8>;
694 def VRLH : VX1_Int_Ty< 68, "vrlh", int_ppc_altivec_vrlh, v8i16>;
695 def VRLW : VX1_Int_Ty< 132, "vrlw", int_ppc_altivec_vrlw, v4i32>;
697 def VSL : VX1_Int_Ty< 452, "vsl" , int_ppc_altivec_vsl, v4i32 >;
698 def VSLO : VX1_Int_Ty<1036, "vslo", int_ppc_altivec_vslo, v4i32>;
700 def VSLB : VX1_Int_Ty< 260, "vslb", int_ppc_altivec_vslb, v16i8>;
701 def VSLH : VX1_Int_Ty< 324, "vslh", int_ppc_altivec_vslh, v8i16>;
702 def VSLW : VX1_Int_Ty< 388, "vslw", int_ppc_altivec_vslw, v4i32>;
704 def VSPLTB : VXForm_1<524, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
705 "vspltb $VD, $VB, $VA", IIC_VecPerm,
707 (vspltb_shuffle:$VA v16i8:$VB, (undef)))]>;
708 def VSPLTH : VXForm_1<588, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
709 "vsplth $VD, $VB, $VA", IIC_VecPerm,
711 (vsplth_shuffle:$VA v16i8:$VB, (undef)))]>;
712 def VSPLTW : VXForm_1<652, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
713 "vspltw $VD, $VB, $VA", IIC_VecPerm,
715 (vspltw_shuffle:$VA v16i8:$VB, (undef)))]>;
716 let isCodeGenOnly = 1, hasSideEffects = 0 in {
717 def VSPLTBs : VXForm_1<524, (outs vrrc:$VD), (ins u5imm:$VA, vfrc:$VB),
718 "vspltb $VD, $VB, $VA", IIC_VecPerm, []>;
719 def VSPLTHs : VXForm_1<588, (outs vrrc:$VD), (ins u5imm:$VA, vfrc:$VB),
720 "vsplth $VD, $VB, $VA", IIC_VecPerm, []>;
723 def VSR : VX1_Int_Ty< 708, "vsr" , int_ppc_altivec_vsr, v4i32>;
724 def VSRO : VX1_Int_Ty<1100, "vsro" , int_ppc_altivec_vsro, v4i32>;
726 def VSRAB : VX1_Int_Ty< 772, "vsrab", int_ppc_altivec_vsrab, v16i8>;
727 def VSRAH : VX1_Int_Ty< 836, "vsrah", int_ppc_altivec_vsrah, v8i16>;
728 def VSRAW : VX1_Int_Ty< 900, "vsraw", int_ppc_altivec_vsraw, v4i32>;
729 def VSRB : VX1_Int_Ty< 516, "vsrb" , int_ppc_altivec_vsrb , v16i8>;
730 def VSRH : VX1_Int_Ty< 580, "vsrh" , int_ppc_altivec_vsrh , v8i16>;
731 def VSRW : VX1_Int_Ty< 644, "vsrw" , int_ppc_altivec_vsrw , v4i32>;
734 def VSPLTISB : VXForm_3<780, (outs vrrc:$VD), (ins s5imm:$IMM),
735 "vspltisb $VD, $IMM", IIC_VecPerm,
736 [(set v16i8:$VD, (v16i8 vecspltisb:$IMM))]>;
737 def VSPLTISH : VXForm_3<844, (outs vrrc:$VD), (ins s5imm:$IMM),
738 "vspltish $VD, $IMM", IIC_VecPerm,
739 [(set v8i16:$VD, (v8i16 vecspltish:$IMM))]>;
740 def VSPLTISW : VXForm_3<908, (outs vrrc:$VD), (ins s5imm:$IMM),
741 "vspltisw $VD, $IMM", IIC_VecPerm,
742 [(set v4i32:$VD, (v4i32 vecspltisw:$IMM))]>;
745 def VPKPX : VX1_Int_Ty2<782, "vpkpx", int_ppc_altivec_vpkpx,
747 let hasSideEffects = 1 in {
748 def VPKSHSS : VX1_Int_Ty2<398, "vpkshss", int_ppc_altivec_vpkshss,
750 def VPKSHUS : VX1_Int_Ty2<270, "vpkshus", int_ppc_altivec_vpkshus,
752 def VPKSWSS : VX1_Int_Ty2<462, "vpkswss", int_ppc_altivec_vpkswss,
754 def VPKSWUS : VX1_Int_Ty2<334, "vpkswus", int_ppc_altivec_vpkswus,
756 def VPKUHUS : VX1_Int_Ty2<142, "vpkuhus", int_ppc_altivec_vpkuhus,
758 def VPKUWUS : VX1_Int_Ty2<206, "vpkuwus", int_ppc_altivec_vpkuwus,
761 def VPKUHUM : VXForm_1<14, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
762 "vpkuhum $VD, $VA, $VB", IIC_VecFP,
764 (vpkuhum_shuffle v16i8:$VA, v16i8:$VB))]>;
765 def VPKUWUM : VXForm_1<78, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
766 "vpkuwum $VD, $VA, $VB", IIC_VecFP,
768 (vpkuwum_shuffle v16i8:$VA, v16i8:$VB))]>;
771 def VUPKHPX : VX2_Int_Ty2<846, "vupkhpx", int_ppc_altivec_vupkhpx,
773 def VUPKHSB : VX2_Int_Ty2<526, "vupkhsb", int_ppc_altivec_vupkhsb,
775 def VUPKHSH : VX2_Int_Ty2<590, "vupkhsh", int_ppc_altivec_vupkhsh,
777 def VUPKLPX : VX2_Int_Ty2<974, "vupklpx", int_ppc_altivec_vupklpx,
779 def VUPKLSB : VX2_Int_Ty2<654, "vupklsb", int_ppc_altivec_vupklsb,
781 def VUPKLSH : VX2_Int_Ty2<718, "vupklsh", int_ppc_altivec_vupklsh,
785 // Altivec Comparisons.
787 class VCMP<bits<10> xo, string asmstr, ValueType Ty>
788 : VXRForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB), asmstr,
790 [(set Ty:$VD, (Ty (PPCvcmp Ty:$VA, Ty:$VB, xo)))]>;
791 class VCMP_rec<bits<10> xo, string asmstr, ValueType Ty>
792 : VXRForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB), asmstr,
794 [(set Ty:$VD, (Ty (PPCvcmp_rec Ty:$VA, Ty:$VB, xo)))]> {
799 // f32 element comparisons.0
800 def VCMPBFP : VCMP <966, "vcmpbfp $VD, $VA, $VB" , v4f32>;
801 def VCMPBFP_rec : VCMP_rec<966, "vcmpbfp. $VD, $VA, $VB" , v4f32>;
802 def VCMPEQFP : VCMP <198, "vcmpeqfp $VD, $VA, $VB" , v4f32>;
803 def VCMPEQFP_rec : VCMP_rec<198, "vcmpeqfp. $VD, $VA, $VB", v4f32>;
804 def VCMPGEFP : VCMP <454, "vcmpgefp $VD, $VA, $VB" , v4f32>;
805 def VCMPGEFP_rec : VCMP_rec<454, "vcmpgefp. $VD, $VA, $VB", v4f32>;
806 def VCMPGTFP : VCMP <710, "vcmpgtfp $VD, $VA, $VB" , v4f32>;
807 def VCMPGTFP_rec : VCMP_rec<710, "vcmpgtfp. $VD, $VA, $VB", v4f32>;
809 // i8 element comparisons.
810 def VCMPEQUB : VCMP < 6, "vcmpequb $VD, $VA, $VB" , v16i8>;
811 def VCMPEQUB_rec : VCMP_rec< 6, "vcmpequb. $VD, $VA, $VB", v16i8>;
812 def VCMPGTSB : VCMP <774, "vcmpgtsb $VD, $VA, $VB" , v16i8>;
813 def VCMPGTSB_rec : VCMP_rec<774, "vcmpgtsb. $VD, $VA, $VB", v16i8>;
814 def VCMPGTUB : VCMP <518, "vcmpgtub $VD, $VA, $VB" , v16i8>;
815 def VCMPGTUB_rec : VCMP_rec<518, "vcmpgtub. $VD, $VA, $VB", v16i8>;
817 // i16 element comparisons.
818 def VCMPEQUH : VCMP < 70, "vcmpequh $VD, $VA, $VB" , v8i16>;
819 def VCMPEQUH_rec : VCMP_rec< 70, "vcmpequh. $VD, $VA, $VB", v8i16>;
820 def VCMPGTSH : VCMP <838, "vcmpgtsh $VD, $VA, $VB" , v8i16>;
821 def VCMPGTSH_rec : VCMP_rec<838, "vcmpgtsh. $VD, $VA, $VB", v8i16>;
822 def VCMPGTUH : VCMP <582, "vcmpgtuh $VD, $VA, $VB" , v8i16>;
823 def VCMPGTUH_rec : VCMP_rec<582, "vcmpgtuh. $VD, $VA, $VB", v8i16>;
825 // i32 element comparisons.
826 def VCMPEQUW : VCMP <134, "vcmpequw $VD, $VA, $VB" , v4i32>;
827 def VCMPEQUW_rec : VCMP_rec<134, "vcmpequw. $VD, $VA, $VB", v4i32>;
828 def VCMPGTSW : VCMP <902, "vcmpgtsw $VD, $VA, $VB" , v4i32>;
829 def VCMPGTSW_rec : VCMP_rec<902, "vcmpgtsw. $VD, $VA, $VB", v4i32>;
830 def VCMPGTUW : VCMP <646, "vcmpgtuw $VD, $VA, $VB" , v4i32>;
831 def VCMPGTUW_rec : VCMP_rec<646, "vcmpgtuw. $VD, $VA, $VB", v4i32>;
833 let isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
834 isReMaterializable = 1 in {
836 def V_SET0B : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
837 "vxor $VD, $VD, $VD", IIC_VecFP,
838 [(set v16i8:$VD, (v16i8 immAllZerosV))]>;
839 def V_SET0H : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
840 "vxor $VD, $VD, $VD", IIC_VecFP,
841 [(set v8i16:$VD, (v8i16 immAllZerosV))]>;
842 def V_SET0 : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
843 "vxor $VD, $VD, $VD", IIC_VecFP,
844 [(set v4i32:$VD, (v4i32 immAllZerosV))]>;
847 def V_SETALLONESB : VXForm_3<908, (outs vrrc:$VD), (ins),
848 "vspltisw $VD, -1", IIC_VecFP,
849 [(set v16i8:$VD, (v16i8 immAllOnesV))]>;
850 def V_SETALLONESH : VXForm_3<908, (outs vrrc:$VD), (ins),
851 "vspltisw $VD, -1", IIC_VecFP,
852 [(set v8i16:$VD, (v8i16 immAllOnesV))]>;
853 def V_SETALLONES : VXForm_3<908, (outs vrrc:$VD), (ins),
854 "vspltisw $VD, -1", IIC_VecFP,
855 [(set v4i32:$VD, (v4i32 immAllOnesV))]>;
858 } // VALU Operations.
860 //===----------------------------------------------------------------------===//
861 // Additional Altivec Patterns
864 // Extended mnemonics
865 def : InstAlias<"vmr $vD, $vA", (VOR vrrc:$vD, vrrc:$vA, vrrc:$vA)>;
866 def : InstAlias<"vnot $vD, $vA", (VNOR vrrc:$vD, vrrc:$vA, vrrc:$vA)>;
868 // This is a nop on all supported architectures and the AIX assembler
869 // doesn't support it (and will not be updated to support it).
870 let Predicates = [IsAIX] in
871 def : Pat<(int_ppc_altivec_dssall), (NOP)>;
872 let Predicates = [NotAIX] in
873 def : Pat<(int_ppc_altivec_dssall), (DSSALL)>;
876 def : Pat<(v16i8 (rotl v16i8:$vA, v16i8:$vB)),
877 (v16i8 (VRLB v16i8:$vA, v16i8:$vB))>;
878 def : Pat<(v8i16 (rotl v8i16:$vA, v8i16:$vB)),
879 (v8i16 (VRLH v8i16:$vA, v8i16:$vB))>;
880 def : Pat<(v4i32 (rotl v4i32:$vA, v4i32:$vB)),
881 (v4i32 (VRLW v4i32:$vA, v4i32:$vB))>;
884 def : Pat<(mul v8i16:$vA, v8i16:$vB), (VMLADDUHM $vA, $vB, (v8i16(V_SET0H)))>;
887 def : Pat<(add (mul v8i16:$vA, v8i16:$vB), v8i16:$vC), (VMLADDUHM $vA, $vB, $vC)>;
889 // Saturating adds/subtracts.
890 def : Pat<(v16i8 (saddsat v16i8:$vA, v16i8:$vB)), (v16i8 (VADDSBS $vA, $vB))>;
891 def : Pat<(v16i8 (uaddsat v16i8:$vA, v16i8:$vB)), (v16i8 (VADDUBS $vA, $vB))>;
892 def : Pat<(v8i16 (saddsat v8i16:$vA, v8i16:$vB)), (v8i16 (VADDSHS $vA, $vB))>;
893 def : Pat<(v8i16 (uaddsat v8i16:$vA, v8i16:$vB)), (v8i16 (VADDUHS $vA, $vB))>;
894 def : Pat<(v4i32 (saddsat v4i32:$vA, v4i32:$vB)), (v4i32 (VADDSWS $vA, $vB))>;
895 def : Pat<(v4i32 (uaddsat v4i32:$vA, v4i32:$vB)), (v4i32 (VADDUWS $vA, $vB))>;
896 def : Pat<(v16i8 (ssubsat v16i8:$vA, v16i8:$vB)), (v16i8 (VSUBSBS $vA, $vB))>;
897 def : Pat<(v16i8 (usubsat v16i8:$vA, v16i8:$vB)), (v16i8 (VSUBUBS $vA, $vB))>;
898 def : Pat<(v8i16 (ssubsat v8i16:$vA, v8i16:$vB)), (v8i16 (VSUBSHS $vA, $vB))>;
899 def : Pat<(v8i16 (usubsat v8i16:$vA, v8i16:$vB)), (v8i16 (VSUBUHS $vA, $vB))>;
900 def : Pat<(v4i32 (ssubsat v4i32:$vA, v4i32:$vB)), (v4i32 (VSUBSWS $vA, $vB))>;
901 def : Pat<(v4i32 (usubsat v4i32:$vA, v4i32:$vB)), (v4i32 (VSUBUWS $vA, $vB))>;
904 def : Pat<(v4i32 (load ForceXForm:$src)), (LVX ForceXForm:$src)>;
907 def : Pat<(store v4i32:$rS, ForceXForm:$dst),
908 (STVX $rS, ForceXForm:$dst)>;
911 def : Pat<(v16i8 (bitconvert (v8i16 VRRC:$src))), (v16i8 VRRC:$src)>;
912 def : Pat<(v16i8 (bitconvert (v4i32 VRRC:$src))), (v16i8 VRRC:$src)>;
913 def : Pat<(v16i8 (bitconvert (v4f32 VRRC:$src))), (v16i8 VRRC:$src)>;
914 def : Pat<(v16i8 (bitconvert (v2i64 VRRC:$src))), (v16i8 VRRC:$src)>;
915 def : Pat<(v16i8 (bitconvert (v1i128 VRRC:$src))), (v16i8 VRRC:$src)>;
917 def : Pat<(v8i16 (bitconvert (v16i8 VRRC:$src))), (v8i16 VRRC:$src)>;
918 def : Pat<(v8i16 (bitconvert (v4i32 VRRC:$src))), (v8i16 VRRC:$src)>;
919 def : Pat<(v8i16 (bitconvert (v4f32 VRRC:$src))), (v8i16 VRRC:$src)>;
920 def : Pat<(v8i16 (bitconvert (v2i64 VRRC:$src))), (v8i16 VRRC:$src)>;
921 def : Pat<(v8i16 (bitconvert (v1i128 VRRC:$src))), (v8i16 VRRC:$src)>;
923 def : Pat<(v4i32 (bitconvert (v16i8 VRRC:$src))), (v4i32 VRRC:$src)>;
924 def : Pat<(v4i32 (bitconvert (v8i16 VRRC:$src))), (v4i32 VRRC:$src)>;
925 def : Pat<(v4i32 (bitconvert (v4f32 VRRC:$src))), (v4i32 VRRC:$src)>;
926 def : Pat<(v4i32 (bitconvert (v2i64 VRRC:$src))), (v4i32 VRRC:$src)>;
927 def : Pat<(v4i32 (bitconvert (v1i128 VRRC:$src))), (v4i32 VRRC:$src)>;
929 def : Pat<(v4f32 (bitconvert (v16i8 VRRC:$src))), (v4f32 VRRC:$src)>;
930 def : Pat<(v4f32 (bitconvert (v8i16 VRRC:$src))), (v4f32 VRRC:$src)>;
931 def : Pat<(v4f32 (bitconvert (v4i32 VRRC:$src))), (v4f32 VRRC:$src)>;
932 def : Pat<(v4f32 (bitconvert (v2i64 VRRC:$src))), (v4f32 VRRC:$src)>;
933 def : Pat<(v4f32 (bitconvert (v1i128 VRRC:$src))), (v4f32 VRRC:$src)>;
935 def : Pat<(v2i64 (bitconvert (v16i8 VRRC:$src))), (v2i64 VRRC:$src)>;
936 def : Pat<(v2i64 (bitconvert (v8i16 VRRC:$src))), (v2i64 VRRC:$src)>;
937 def : Pat<(v2i64 (bitconvert (v4i32 VRRC:$src))), (v2i64 VRRC:$src)>;
938 def : Pat<(v2i64 (bitconvert (v4f32 VRRC:$src))), (v2i64 VRRC:$src)>;
939 def : Pat<(v2i64 (bitconvert (v1i128 VRRC:$src))), (v2i64 VRRC:$src)>;
941 def : Pat<(v1i128 (bitconvert (v16i8 VRRC:$src))), (v1i128 VRRC:$src)>;
942 def : Pat<(v1i128 (bitconvert (v8i16 VRRC:$src))), (v1i128 VRRC:$src)>;
943 def : Pat<(v1i128 (bitconvert (v4i32 VRRC:$src))), (v1i128 VRRC:$src)>;
944 def : Pat<(v1i128 (bitconvert (v4f32 VRRC:$src))), (v1i128 VRRC:$src)>;
945 def : Pat<(v1i128 (bitconvert (v2i64 VRRC:$src))), (v1i128 VRRC:$src)>;
947 def : Pat<(f128 (bitconvert (v16i8 VRRC:$src))), (f128 VRRC:$src)>;
948 def : Pat<(f128 (bitconvert (v8i16 VRRC:$src))), (f128 VRRC:$src)>;
949 def : Pat<(f128 (bitconvert (v4i32 VRRC:$src))), (f128 VRRC:$src)>;
950 def : Pat<(f128 (bitconvert (v4f32 VRRC:$src))), (f128 VRRC:$src)>;
951 def : Pat<(f128 (bitconvert (v2f64 VRRC:$src))), (f128 VRRC:$src)>;
953 def : Pat<(v16i8 (bitconvert (f128 VRRC:$src))), (v16i8 VRRC:$src)>;
954 def : Pat<(v8i16 (bitconvert (f128 VRRC:$src))), (v8i16 VRRC:$src)>;
955 def : Pat<(v4i32 (bitconvert (f128 VRRC:$src))), (v4i32 VRRC:$src)>;
956 def : Pat<(v4f32 (bitconvert (f128 VRRC:$src))), (v4f32 VRRC:$src)>;
957 def : Pat<(v2f64 (bitconvert (f128 VRRC:$src))), (v2f64 VRRC:$src)>;
960 def : Pat<(v16i8 (umax v16i8:$src1, v16i8:$src2)),
961 (v16i8 (VMAXUB $src1, $src2))>;
962 def : Pat<(v16i8 (smax v16i8:$src1, v16i8:$src2)),
963 (v16i8 (VMAXSB $src1, $src2))>;
964 def : Pat<(v8i16 (umax v8i16:$src1, v8i16:$src2)),
965 (v8i16 (VMAXUH $src1, $src2))>;
966 def : Pat<(v8i16 (smax v8i16:$src1, v8i16:$src2)),
967 (v8i16 (VMAXSH $src1, $src2))>;
968 def : Pat<(v4i32 (umax v4i32:$src1, v4i32:$src2)),
969 (v4i32 (VMAXUW $src1, $src2))>;
970 def : Pat<(v4i32 (smax v4i32:$src1, v4i32:$src2)),
971 (v4i32 (VMAXSW $src1, $src2))>;
972 def : Pat<(v16i8 (umin v16i8:$src1, v16i8:$src2)),
973 (v16i8 (VMINUB $src1, $src2))>;
974 def : Pat<(v16i8 (smin v16i8:$src1, v16i8:$src2)),
975 (v16i8 (VMINSB $src1, $src2))>;
976 def : Pat<(v8i16 (umin v8i16:$src1, v8i16:$src2)),
977 (v8i16 (VMINUH $src1, $src2))>;
978 def : Pat<(v8i16 (smin v8i16:$src1, v8i16:$src2)),
979 (v8i16 (VMINSH $src1, $src2))>;
980 def : Pat<(v4i32 (umin v4i32:$src1, v4i32:$src2)),
981 (v4i32 (VMINUW $src1, $src2))>;
982 def : Pat<(v4i32 (smin v4i32:$src1, v4i32:$src2)),
983 (v4i32 (VMINSW $src1, $src2))>;
987 // Match vsldoi(x,x), vpkuwum(x,x), vpkuhum(x,x)
988 def:Pat<(vsldoi_unary_shuffle:$in v16i8:$vA, undef),
989 (VSLDOI $vA, $vA, (VSLDOI_unary_get_imm $in))>;
990 def:Pat<(vpkuwum_unary_shuffle v16i8:$vA, undef),
992 def:Pat<(vpkuhum_unary_shuffle v16i8:$vA, undef),
994 def:Pat<(vsldoi_shuffle:$SH v16i8:$vA, v16i8:$vB),
995 (VSLDOI v16i8:$vA, v16i8:$vB, (VSLDOI_get_imm $SH))>;
998 // Match vsldoi(y,x), vpkuwum(y,x), vpkuhum(y,x), i.e., swapped operands.
999 // These fragments are matched for little-endian, where the inputs must
1000 // be swapped for correct semantics.
1001 def:Pat<(vsldoi_swapped_shuffle:$in v16i8:$vA, v16i8:$vB),
1002 (VSLDOI $vB, $vA, (VSLDOI_swapped_get_imm $in))>;
1003 def:Pat<(vpkuwum_swapped_shuffle v16i8:$vA, v16i8:$vB),
1004 (VPKUWUM $vB, $vA)>;
1005 def:Pat<(vpkuhum_swapped_shuffle v16i8:$vA, v16i8:$vB),
1006 (VPKUHUM $vB, $vA)>;
1009 def:Pat<(vmrglb_unary_shuffle v16i8:$vA, undef),
1011 def:Pat<(vmrglh_unary_shuffle v16i8:$vA, undef),
1013 def:Pat<(vmrglw_unary_shuffle v16i8:$vA, undef),
1015 def:Pat<(vmrghb_unary_shuffle v16i8:$vA, undef),
1017 def:Pat<(vmrghh_unary_shuffle v16i8:$vA, undef),
1019 def:Pat<(vmrghw_unary_shuffle v16i8:$vA, undef),
1022 // Match vmrg*(y,x), i.e., swapped operands. These fragments
1023 // are matched for little-endian, where the inputs must be
1024 // swapped for correct semantics.
1025 def:Pat<(vmrglb_swapped_shuffle v16i8:$vA, v16i8:$vB),
1027 def:Pat<(vmrglh_swapped_shuffle v16i8:$vA, v16i8:$vB),
1029 def:Pat<(vmrglw_swapped_shuffle v16i8:$vA, v16i8:$vB),
1031 def:Pat<(vmrghb_swapped_shuffle v16i8:$vA, v16i8:$vB),
1033 def:Pat<(vmrghh_swapped_shuffle v16i8:$vA, v16i8:$vB),
1035 def:Pat<(vmrghw_swapped_shuffle v16i8:$vA, v16i8:$vB),
1038 // Logical Operations
1039 def : Pat<(vnot v4i32:$vA), (VNOR $vA, $vA)>;
1041 def : Pat<(vnot (or v4i32:$A, v4i32:$B)),
1043 def : Pat<(and v4i32:$A, (vnot v4i32:$B)),
1046 def : Pat<(fmul v4f32:$vA, v4f32:$vB),
1048 (v4i32 (VSLW (v4i32 (V_SETALLONES)), (v4i32 (V_SETALLONES)))))>;
1050 def : Pat<(PPCfnmsub v4f32:$A, v4f32:$B, v4f32:$C),
1051 (VNMSUBFP $A, $B, $C)>;
1053 def : Pat<(int_ppc_altivec_vmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
1054 (VMADDFP $A, $B, $C)>;
1055 def : Pat<(int_ppc_altivec_vnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
1056 (VNMSUBFP $A, $B, $C)>;
1058 def : Pat<(PPCvperm v16i8:$vA, v16i8:$vB, v16i8:$vC),
1059 (VPERM $vA, $vB, $vC)>;
1060 def : Pat<(PPCvperm v2f64:$vA, v2f64:$vB, v16i8:$vC),
1061 (VPERM $vA, $vB, $vC)>;
1063 def : Pat<(PPCfre v4f32:$A), (VREFP $A)>;
1064 def : Pat<(PPCfrsqrte v4f32:$A), (VRSQRTEFP $A)>;
1067 def : Pat<(v16i8 (shl v16i8:$vA, v16i8:$vB)),
1068 (v16i8 (VSLB $vA, $vB))>;
1069 def : Pat<(v8i16 (shl v8i16:$vA, v8i16:$vB)),
1070 (v8i16 (VSLH $vA, $vB))>;
1071 def : Pat<(v4i32 (shl v4i32:$vA, v4i32:$vB)),
1072 (v4i32 (VSLW $vA, $vB))>;
1073 def : Pat<(v1i128 (shl v1i128:$vA, v1i128:$vB)),
1074 (v1i128 (VSL (v16i8 (VSLO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
1075 def : Pat<(v16i8 (PPCshl v16i8:$vA, v16i8:$vB)),
1076 (v16i8 (VSLB $vA, $vB))>;
1077 def : Pat<(v8i16 (PPCshl v8i16:$vA, v8i16:$vB)),
1078 (v8i16 (VSLH $vA, $vB))>;
1079 def : Pat<(v4i32 (PPCshl v4i32:$vA, v4i32:$vB)),
1080 (v4i32 (VSLW $vA, $vB))>;
1081 def : Pat<(v1i128 (PPCshl v1i128:$vA, v1i128:$vB)),
1082 (v1i128 (VSL (v16i8 (VSLO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
1084 def : Pat<(v16i8 (srl v16i8:$vA, v16i8:$vB)),
1085 (v16i8 (VSRB $vA, $vB))>;
1086 def : Pat<(v8i16 (srl v8i16:$vA, v8i16:$vB)),
1087 (v8i16 (VSRH $vA, $vB))>;
1088 def : Pat<(v4i32 (srl v4i32:$vA, v4i32:$vB)),
1089 (v4i32 (VSRW $vA, $vB))>;
1090 def : Pat<(v1i128 (srl v1i128:$vA, v1i128:$vB)),
1091 (v1i128 (VSR (v16i8 (VSRO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
1092 def : Pat<(v16i8 (PPCsrl v16i8:$vA, v16i8:$vB)),
1093 (v16i8 (VSRB $vA, $vB))>;
1094 def : Pat<(v8i16 (PPCsrl v8i16:$vA, v8i16:$vB)),
1095 (v8i16 (VSRH $vA, $vB))>;
1096 def : Pat<(v4i32 (PPCsrl v4i32:$vA, v4i32:$vB)),
1097 (v4i32 (VSRW $vA, $vB))>;
1098 def : Pat<(v1i128 (PPCsrl v1i128:$vA, v1i128:$vB)),
1099 (v1i128 (VSR (v16i8 (VSRO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
1101 def : Pat<(v16i8 (sra v16i8:$vA, v16i8:$vB)),
1102 (v16i8 (VSRAB $vA, $vB))>;
1103 def : Pat<(v8i16 (sra v8i16:$vA, v8i16:$vB)),
1104 (v8i16 (VSRAH $vA, $vB))>;
1105 def : Pat<(v4i32 (sra v4i32:$vA, v4i32:$vB)),
1106 (v4i32 (VSRAW $vA, $vB))>;
1107 def : Pat<(v16i8 (PPCsra v16i8:$vA, v16i8:$vB)),
1108 (v16i8 (VSRAB $vA, $vB))>;
1109 def : Pat<(v8i16 (PPCsra v8i16:$vA, v8i16:$vB)),
1110 (v8i16 (VSRAH $vA, $vB))>;
1111 def : Pat<(v4i32 (PPCsra v4i32:$vA, v4i32:$vB)),
1112 (v4i32 (VSRAW $vA, $vB))>;
1114 // Float to integer and integer to float conversions
1115 def : Pat<(v4i32 (fp_to_sint v4f32:$vA)),
1117 def : Pat<(v4i32 (fp_to_uint v4f32:$vA)),
1119 def : Pat<(v4f32 (sint_to_fp v4i32:$vA)),
1121 def : Pat<(v4f32 (uint_to_fp v4i32:$vA)),
1124 // Floating-point rounding
1125 def : Pat<(v4f32 (ffloor v4f32:$vA)),
1127 def : Pat<(v4f32 (fceil v4f32:$vA)),
1129 def : Pat<(v4f32 (ftrunc v4f32:$vA)),
1131 def : Pat<(v4f32 (fnearbyint v4f32:$vA)),
1135 def : Pat<(v16i8 (vselect v16i8:$vA, v16i8:$vB, v16i8:$vC)),
1136 (VSEL $vC, $vB, $vA)>;
1137 def : Pat<(v8i16 (vselect v8i16:$vA, v8i16:$vB, v8i16:$vC)),
1138 (VSEL $vC, $vB, $vA)>;
1139 def : Pat<(v4i32 (vselect v4i32:$vA, v4i32:$vB, v4i32:$vC)),
1140 (VSEL $vC, $vB, $vA)>;
1141 def : Pat<(v2i64 (vselect v2i64:$vA, v2i64:$vB, v2i64:$vC)),
1142 (VSEL $vC, $vB, $vA)>;
1143 def : Pat<(v4f32 (vselect v4i32:$vA, v4f32:$vB, v4f32:$vC)),
1144 (VSEL $vC, $vB, $vA)>;
1145 def : Pat<(v2f64 (vselect v2i64:$vA, v2f64:$vB, v2f64:$vC)),
1146 (VSEL $vC, $vB, $vA)>;
1147 def : Pat<(v1i128 (vselect v1i128:$vA, v1i128:$vB, v1i128:$vC)),
1148 (VSEL $vC, $vB, $vA)>;
1150 // Vector Integer Average Instructions
1151 def : Pat<(v4i32 (sra (sub v4i32:$vA, (vnot v4i32:$vB)),
1152 (v4i32 (immEQOneV)))), (v4i32 (VAVGSW $vA, $vB))>;
1153 def : Pat<(v8i16 (sra (sub v8i16:$vA, (v8i16 (bitconvert(vnot v4i32:$vB)))),
1154 (v8i16 (immEQOneV)))), (v8i16 (VAVGSH $vA, $vB))>;
1155 def : Pat<(v16i8 (sra (sub v16i8:$vA, (v16i8 (bitconvert(vnot v4i32:$vB)))),
1156 (v16i8 (immEQOneV)))), (v16i8 (VAVGSB $vA, $vB))>;
1157 def : Pat<(v4i32 (srl (sub v4i32:$vA, (vnot v4i32:$vB)),
1158 (v4i32 (immEQOneV)))), (v4i32 (VAVGUW $vA, $vB))>;
1159 def : Pat<(v8i16 (srl (sub v8i16:$vA, (v8i16 (bitconvert(vnot v4i32:$vB)))),
1160 (v8i16 (immEQOneV)))), (v8i16 (VAVGUH $vA, $vB))>;
1161 def : Pat<(v16i8 (srl (sub v16i8:$vA, (v16i8 (bitconvert(vnot v4i32:$vB)))),
1162 (v16i8 (immEQOneV)))), (v16i8 (VAVGUB $vA, $vB))>;
1164 def : Pat<(v16i8 (shl v16i8:$vA, (v16i8 (immEQOneV)))),
1165 (v16i8 (VADDUBM $vA, $vA))>;
1166 def : Pat<(v8i16 (shl v8i16:$vA, (v8i16 (immEQOneV)))),
1167 (v8i16 (VADDUHM $vA, $vA))>;
1168 def : Pat<(v4i32 (shl v4i32:$vA, (v4i32 (immEQOneV)))),
1169 (v4i32 (VADDUWM $vA, $vA))>;
1173 // [PO VRT VRA VRB 1 PS XO], "_o" means CR6 is set.
1174 class VX_VT5_VA5_VB5_PS1_XO9_o<bits<9> xo, string opc, list<dag> pattern>
1175 : VX_RD5_RSp5_PS1_XO9<xo,
1176 (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, u1imm:$PS),
1177 !strconcat(opc, " $VD, $VA, $VB, $PS"), IIC_VecFP, pattern> {
1181 // [PO VRT VRA VRB 1 / XO]
1182 class VX_VT5_VA5_VB5_XO9_o<bits<9> xo, string opc, list<dag> pattern>
1183 : VX_RD5_RSp5_PS1_XO9<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1184 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP, pattern> {
1189 def HasP8Altivec : Predicate<"Subtarget->hasP8Altivec()">;
1190 def HasP8Crypto : Predicate<"Subtarget->hasP8Crypto()">;
1191 let Predicates = [HasP8Altivec] in {
1193 let isCommutable = 1 in {
1194 def VMULESW : VX1_Int_Ty2<904, "vmulesw", int_ppc_altivec_vmulesw,
1196 def VMULEUW : VX1_Int_Ty2<648, "vmuleuw", int_ppc_altivec_vmuleuw,
1198 def VMULOSW : VX1_Int_Ty2<392, "vmulosw", int_ppc_altivec_vmulosw,
1200 def VMULOUW : VX1_Int_Ty2<136, "vmulouw", int_ppc_altivec_vmulouw,
1202 def VMULUWM : VXForm_1<137, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1203 "vmuluwm $VD, $VA, $VB", IIC_VecGeneral,
1204 [(set v4i32:$VD, (mul v4i32:$VA, v4i32:$VB))]>;
1205 def VMAXSD : VX1_Int_Ty<450, "vmaxsd", int_ppc_altivec_vmaxsd, v2i64>;
1206 def VMAXUD : VX1_Int_Ty<194, "vmaxud", int_ppc_altivec_vmaxud, v2i64>;
1207 def VMINSD : VX1_Int_Ty<962, "vminsd", int_ppc_altivec_vminsd, v2i64>;
1208 def VMINUD : VX1_Int_Ty<706, "vminud", int_ppc_altivec_vminud, v2i64>;
1212 def VMRGEW : VXForm_1<1932, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1213 "vmrgew $VD, $VA, $VB", IIC_VecFP,
1215 (v16i8 (vmrgew_shuffle v16i8:$VA, v16i8:$VB)))]>;
1216 def VMRGOW : VXForm_1<1676, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1217 "vmrgow $VD, $VA, $VB", IIC_VecFP,
1219 (v16i8 (vmrgow_shuffle v16i8:$VA, v16i8:$VB)))]>;
1221 // Match vmrgew(x,x) and vmrgow(x,x)
1222 def:Pat<(vmrgew_unary_shuffle v16i8:$vA, undef),
1224 def:Pat<(vmrgow_unary_shuffle v16i8:$vA, undef),
1227 // Match vmrgew(y,x) and vmrgow(y,x), i.e., swapped operands. These fragments
1228 // are matched for little-endian, where the inputs must be swapped for correct
1230 def:Pat<(vmrgew_swapped_shuffle v16i8:$vA, v16i8:$vB),
1232 def:Pat<(vmrgow_swapped_shuffle v16i8:$vA, v16i8:$vB),
1236 def VRLD : VX1_Int_Ty<196, "vrld", int_ppc_altivec_vrld, v2i64>;
1238 def : Pat<(v2i64 (rotl v2i64:$vA, v2i64:$vB)),
1239 (v2i64 (VRLD v2i64:$vA, v2i64:$vB))>;
1242 def VSLD : VXForm_1<1476, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1243 "vsld $VD, $VA, $VB", IIC_VecGeneral, []>;
1244 def VSRD : VXForm_1<1732, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1245 "vsrd $VD, $VA, $VB", IIC_VecGeneral, []>;
1246 def VSRAD : VXForm_1<964, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1247 "vsrad $VD, $VA, $VB", IIC_VecGeneral, []>;
1249 def : Pat<(v2i64 (shl v2i64:$vA, v2i64:$vB)),
1250 (v2i64 (VSLD $vA, $vB))>;
1251 def : Pat<(v2i64 (PPCshl v2i64:$vA, v2i64:$vB)),
1252 (v2i64 (VSLD $vA, $vB))>;
1253 def : Pat<(v2i64 (srl v2i64:$vA, v2i64:$vB)),
1254 (v2i64 (VSRD $vA, $vB))>;
1255 def : Pat<(v2i64 (PPCsrl v2i64:$vA, v2i64:$vB)),
1256 (v2i64 (VSRD $vA, $vB))>;
1257 def : Pat<(v2i64 (sra v2i64:$vA, v2i64:$vB)),
1258 (v2i64 (VSRAD $vA, $vB))>;
1259 def : Pat<(v2i64 (PPCsra v2i64:$vA, v2i64:$vB)),
1260 (v2i64 (VSRAD $vA, $vB))>;
1262 // Vector Integer Arithmetic Instructions
1263 let isCommutable = 1 in {
1264 def VADDUDM : VXForm_1<192, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1265 "vaddudm $VD, $VA, $VB", IIC_VecGeneral,
1266 [(set v2i64:$VD, (add v2i64:$VA, v2i64:$VB))]>;
1267 def VADDUQM : VXForm_1<256, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1268 "vadduqm $VD, $VA, $VB", IIC_VecGeneral,
1269 [(set v1i128:$VD, (add v1i128:$VA, v1i128:$VB))]>;
1272 // Vector Quadword Add
1273 def VADDEUQM : VA1a_Int_Ty<60, "vaddeuqm", int_ppc_altivec_vaddeuqm, v1i128>;
1274 def VADDCUQ : VX1_Int_Ty<320, "vaddcuq", int_ppc_altivec_vaddcuq, v1i128>;
1275 def VADDECUQ : VA1a_Int_Ty<61, "vaddecuq", int_ppc_altivec_vaddecuq, v1i128>;
1277 // Vector Doubleword Subtract
1278 def VSUBUDM : VXForm_1<1216, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1279 "vsubudm $VD, $VA, $VB", IIC_VecGeneral,
1280 [(set v2i64:$VD, (sub v2i64:$VA, v2i64:$VB))]>;
1282 // Vector Quadword Subtract
1283 def VSUBUQM : VXForm_1<1280, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1284 "vsubuqm $VD, $VA, $VB", IIC_VecGeneral,
1285 [(set v1i128:$VD, (sub v1i128:$VA, v1i128:$VB))]>;
1286 def VSUBEUQM : VA1a_Int_Ty<62, "vsubeuqm", int_ppc_altivec_vsubeuqm, v1i128>;
1287 def VSUBCUQ : VX1_Int_Ty<1344, "vsubcuq", int_ppc_altivec_vsubcuq, v1i128>;
1288 def VSUBECUQ : VA1a_Int_Ty<63, "vsubecuq", int_ppc_altivec_vsubecuq, v1i128>;
1290 // Count Leading Zeros
1291 def VCLZB : VXForm_2<1794, (outs vrrc:$VD), (ins vrrc:$VB),
1292 "vclzb $VD, $VB", IIC_VecGeneral,
1293 [(set v16i8:$VD, (ctlz v16i8:$VB))]>;
1294 def VCLZH : VXForm_2<1858, (outs vrrc:$VD), (ins vrrc:$VB),
1295 "vclzh $VD, $VB", IIC_VecGeneral,
1296 [(set v8i16:$VD, (ctlz v8i16:$VB))]>;
1297 def VCLZW : VXForm_2<1922, (outs vrrc:$VD), (ins vrrc:$VB),
1298 "vclzw $VD, $VB", IIC_VecGeneral,
1299 [(set v4i32:$VD, (ctlz v4i32:$VB))]>;
1300 def VCLZD : VXForm_2<1986, (outs vrrc:$VD), (ins vrrc:$VB),
1301 "vclzd $VD, $VB", IIC_VecGeneral,
1302 [(set v2i64:$VD, (ctlz v2i64:$VB))]>;
1305 def VPOPCNTB : VXForm_2<1795, (outs vrrc:$VD), (ins vrrc:$VB),
1306 "vpopcntb $VD, $VB", IIC_VecGeneral,
1307 [(set v16i8:$VD, (ctpop v16i8:$VB))]>;
1308 def VPOPCNTH : VXForm_2<1859, (outs vrrc:$VD), (ins vrrc:$VB),
1309 "vpopcnth $VD, $VB", IIC_VecGeneral,
1310 [(set v8i16:$VD, (ctpop v8i16:$VB))]>;
1311 def VPOPCNTW : VXForm_2<1923, (outs vrrc:$VD), (ins vrrc:$VB),
1312 "vpopcntw $VD, $VB", IIC_VecGeneral,
1313 [(set v4i32:$VD, (ctpop v4i32:$VB))]>;
1314 def VPOPCNTD : VXForm_2<1987, (outs vrrc:$VD), (ins vrrc:$VB),
1315 "vpopcntd $VD, $VB", IIC_VecGeneral,
1316 [(set v2i64:$VD, (ctpop v2i64:$VB))]>;
1318 let isCommutable = 1 in {
1319 // FIXME: Use AddedComplexity > 400 to ensure these patterns match before the
1320 // VSX equivalents. We need to fix this up at some point. Two possible
1321 // solutions for this problem:
1322 // 1. Disable Altivec patterns that compete with VSX patterns using the
1323 // !HasVSX predicate. This essentially favours VSX over Altivec, in
1324 // hopes of reducing register pressure (larger register set using VSX
1325 // instructions than VMX instructions)
1326 // 2. Employ a more disciplined use of AddedComplexity, which would provide
1327 // more fine-grained control than option 1. This would be beneficial
1328 // if we find situations where Altivec is really preferred over VSX.
1329 def VEQV : VXForm_1<1668, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1330 "veqv $VD, $VA, $VB", IIC_VecGeneral,
1331 [(set v4i32:$VD, (vnot (xor v4i32:$VA, v4i32:$VB)))]>;
1332 def VNAND : VXForm_1<1412, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1333 "vnand $VD, $VA, $VB", IIC_VecGeneral,
1334 [(set v4i32:$VD, (vnot (and v4i32:$VA, v4i32:$VB)))]>;
1337 def VORC : VXForm_1<1348, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1338 "vorc $VD, $VA, $VB", IIC_VecGeneral,
1339 [(set v4i32:$VD, (or v4i32:$VA,
1340 (vnot v4i32:$VB)))]>;
1342 // i64 element comparisons.
1343 def VCMPEQUD : VCMP <199, "vcmpequd $VD, $VA, $VB" , v2i64>;
1344 def VCMPEQUD_rec : VCMP_rec<199, "vcmpequd. $VD, $VA, $VB", v2i64>;
1345 def VCMPGTSD : VCMP <967, "vcmpgtsd $VD, $VA, $VB" , v2i64>;
1346 def VCMPGTSD_rec : VCMP_rec<967, "vcmpgtsd. $VD, $VA, $VB", v2i64>;
1347 def VCMPGTUD : VCMP <711, "vcmpgtud $VD, $VA, $VB" , v2i64>;
1348 def VCMPGTUD_rec : VCMP_rec<711, "vcmpgtud. $VD, $VA, $VB", v2i64>;
1350 // The cryptography instructions that do not require Category:Vector.Crypto
1351 def VPMSUMB : VX1_Int_Ty<1032, "vpmsumb",
1352 int_ppc_altivec_crypto_vpmsumb, v16i8>;
1353 def VPMSUMH : VX1_Int_Ty<1096, "vpmsumh",
1354 int_ppc_altivec_crypto_vpmsumh, v8i16>;
1355 def VPMSUMW : VX1_Int_Ty<1160, "vpmsumw",
1356 int_ppc_altivec_crypto_vpmsumw, v4i32>;
1357 def VPMSUMD : VX1_Int_Ty<1224, "vpmsumd",
1358 int_ppc_altivec_crypto_vpmsumd, v2i64>;
1359 def VPERMXOR : VAForm_1<45, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
1360 "vpermxor $RT, $RA, $RB, $RC", IIC_VecFP, []>;
1362 // Vector doubleword integer pack and unpack.
1363 let hasSideEffects = 1 in {
1364 def VPKSDSS : VX1_Int_Ty2<1486, "vpksdss", int_ppc_altivec_vpksdss,
1366 def VPKSDUS : VX1_Int_Ty2<1358, "vpksdus", int_ppc_altivec_vpksdus,
1368 def VPKUDUS : VX1_Int_Ty2<1230, "vpkudus", int_ppc_altivec_vpkudus,
1371 def VPKUDUM : VXForm_1<1102, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1372 "vpkudum $VD, $VA, $VB", IIC_VecFP,
1374 (vpkudum_shuffle v16i8:$VA, v16i8:$VB))]>;
1375 def VUPKHSW : VX2_Int_Ty2<1614, "vupkhsw", int_ppc_altivec_vupkhsw,
1377 def VUPKLSW : VX2_Int_Ty2<1742, "vupklsw", int_ppc_altivec_vupklsw,
1379 def BCDADD_rec : VX_VT5_VA5_VB5_PS1_XO9_o<1, "bcdadd." , []>;
1380 def BCDSUB_rec : VX_VT5_VA5_VB5_PS1_XO9_o<65, "bcdsub." , []>;
1382 def : Pat<(v16i8 (int_ppc_bcdadd v16i8:$vA, v16i8:$vB, timm:$PS)),
1383 (BCDADD_rec $vA, $vB, $PS)>;
1384 def : Pat<(v16i8 (int_ppc_bcdsub v16i8:$vA, v16i8:$vB, timm:$PS)),
1385 (BCDSUB_rec $vA, $vB, $PS)>;
1387 // Shuffle patterns for unary and swapped (LE) vector pack modulo.
1388 def:Pat<(vpkudum_unary_shuffle v16i8:$vA, undef),
1389 (VPKUDUM $vA, $vA)>;
1390 def:Pat<(vpkudum_swapped_shuffle v16i8:$vA, v16i8:$vB),
1391 (VPKUDUM $vB, $vA)>;
1393 def VGBBD : VX2_Int_Ty2<1292, "vgbbd", int_ppc_altivec_vgbbd, v16i8, v16i8>;
1394 def VBPERMQ : VX1_Int_Ty2<1356, "vbpermq", int_ppc_altivec_vbpermq,
1396 } // end HasP8Altivec
1398 // Crypto instructions (from builtins)
1399 let Predicates = [HasP8Crypto] in {
1400 def VSHASIGMAW : VXCR_Int_Ty<1666, "vshasigmaw",
1401 int_ppc_altivec_crypto_vshasigmaw, v4i32>;
1402 def VSHASIGMAD : VXCR_Int_Ty<1730, "vshasigmad",
1403 int_ppc_altivec_crypto_vshasigmad, v2i64>;
1404 def VCIPHER : VX1_Int_Ty<1288, "vcipher", int_ppc_altivec_crypto_vcipher,
1406 def VCIPHERLAST : VX1_Int_Ty<1289, "vcipherlast",
1407 int_ppc_altivec_crypto_vcipherlast, v2i64>;
1408 def VNCIPHER : VX1_Int_Ty<1352, "vncipher",
1409 int_ppc_altivec_crypto_vncipher, v2i64>;
1410 def VNCIPHERLAST : VX1_Int_Ty<1353, "vncipherlast",
1411 int_ppc_altivec_crypto_vncipherlast, v2i64>;
1412 def VSBOX : VXBX_Int_Ty<1480, "vsbox", int_ppc_altivec_crypto_vsbox, v2i64>;
1415 // The following altivec instructions were introduced in Power ISA 3.0
1416 def HasP9Altivec : Predicate<"Subtarget->hasP9Altivec()">;
1417 let Predicates = [HasP9Altivec] in {
1419 // Vector Multiply-Sum
1420 def VMSUMUDM : VA1a_Int_Ty3<35, "vmsumudm", int_ppc_altivec_vmsumudm,
1421 v1i128, v2i64, v1i128>;
1423 // i8 element comparisons.
1424 def VCMPNEB : VCMP < 7, "vcmpneb $VD, $VA, $VB" , v16i8>;
1425 def VCMPNEB_rec : VCMP_rec < 7, "vcmpneb. $VD, $VA, $VB" , v16i8>;
1426 def VCMPNEZB : VCMP <263, "vcmpnezb $VD, $VA, $VB" , v16i8>;
1427 def VCMPNEZB_rec : VCMP_rec<263, "vcmpnezb. $VD, $VA, $VB", v16i8>;
1429 // i16 element comparisons.
1430 def VCMPNEH : VCMP < 71, "vcmpneh $VD, $VA, $VB" , v8i16>;
1431 def VCMPNEH_rec : VCMP_rec< 71, "vcmpneh. $VD, $VA, $VB" , v8i16>;
1432 def VCMPNEZH : VCMP <327, "vcmpnezh $VD, $VA, $VB" , v8i16>;
1433 def VCMPNEZH_rec : VCMP_rec<327, "vcmpnezh. $VD, $VA, $VB", v8i16>;
1435 // i32 element comparisons.
1436 def VCMPNEW : VCMP <135, "vcmpnew $VD, $VA, $VB" , v4i32>;
1437 def VCMPNEW_rec : VCMP_rec<135, "vcmpnew. $VD, $VA, $VB" , v4i32>;
1438 def VCMPNEZW : VCMP <391, "vcmpnezw $VD, $VA, $VB" , v4i32>;
1439 def VCMPNEZW_rec : VCMP_rec<391, "vcmpnezw. $VD, $VA, $VB", v4i32>;
1441 // VX-Form: [PO VRT / UIM VRB XO].
1442 // We use VXForm_1 to implement it, that is, we use "VRA" (5 bit) to represent
1443 // "/ UIM" (1 + 4 bit)
1444 class VX1_VT5_UIM5_VB5<bits<11> xo, string opc, list<dag> pattern>
1445 : VXForm_1<xo, (outs vrrc:$VD), (ins u4imm:$VA, vrrc:$VB),
1446 !strconcat(opc, " $VD, $VB, $VA"), IIC_VecGeneral, pattern>;
1448 class VX1_RT5_RA5_VB5<bits<11> xo, string opc, list<dag> pattern>
1449 : VXForm_1<xo, (outs g8rc:$VD), (ins g8rc:$VA, vrrc:$VB),
1450 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecGeneral, pattern>;
1452 // Vector Extract Unsigned
1453 def VEXTRACTUB : VX1_VT5_UIM5_VB5<525, "vextractub", []>;
1454 def VEXTRACTUH : VX1_VT5_UIM5_VB5<589, "vextractuh", []>;
1455 def VEXTRACTUW : VX1_VT5_UIM5_VB5<653, "vextractuw", []>;
1456 def VEXTRACTD : VX1_VT5_UIM5_VB5<717, "vextractd" , []>;
1458 // Vector Extract Unsigned Byte/Halfword/Word Left/Right-Indexed
1459 let hasSideEffects = 0 in {
1460 def VEXTUBLX : VX1_RT5_RA5_VB5<1549, "vextublx", []>, ZExt32To64;
1461 def VEXTUBRX : VX1_RT5_RA5_VB5<1805, "vextubrx", []>, ZExt32To64;
1462 def VEXTUHLX : VX1_RT5_RA5_VB5<1613, "vextuhlx", []>, ZExt32To64;
1463 def VEXTUHRX : VX1_RT5_RA5_VB5<1869, "vextuhrx", []>, ZExt32To64;
1464 def VEXTUWLX : VX1_RT5_RA5_VB5<1677, "vextuwlx", []>, ZExt32To64;
1465 def VEXTUWRX : VX1_RT5_RA5_VB5<1933, "vextuwrx", []>, ZExt32To64;
1468 // Vector Insert Element Instructions
1469 def VINSERTB : VXForm_1<781, (outs vrrc:$VD),
1470 (ins vrrc:$VDi, u4imm:$VA, vrrc:$VB),
1471 "vinsertb $VD, $VB, $VA", IIC_VecGeneral,
1472 [(set v16i8:$VD, (PPCvecinsert v16i8:$VDi, v16i8:$VB,
1473 imm32SExt16:$VA))]>,
1474 RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
1475 def VINSERTH : VXForm_1<845, (outs vrrc:$VD),
1476 (ins vrrc:$VDi, u4imm:$VA, vrrc:$VB),
1477 "vinserth $VD, $VB, $VA", IIC_VecGeneral,
1478 [(set v8i16:$VD, (PPCvecinsert v8i16:$VDi, v8i16:$VB,
1479 imm32SExt16:$VA))]>,
1480 RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
1481 def VINSERTW : VX1_VT5_UIM5_VB5<909, "vinsertw", []>;
1482 def VINSERTD : VX1_VT5_UIM5_VB5<973, "vinsertd", []>;
1484 class VX_VT5_EO5_VB5<bits<11> xo, bits<5> eo, string opc, list<dag> pattern>
1485 : VXForm_RD5_XO5_RS5<xo, eo, (outs vrrc:$VD), (ins vrrc:$VB),
1486 !strconcat(opc, " $VD, $VB"), IIC_VecGeneral, pattern>;
1487 class VX_VT5_EO5_VB5s<bits<11> xo, bits<5> eo, string opc, list<dag> pattern>
1488 : VXForm_RD5_XO5_RS5<xo, eo, (outs vfrc:$VD), (ins vfrc:$VB),
1489 !strconcat(opc, " $VD, $VB"), IIC_VecGeneral, pattern>;
1491 // Vector Count Leading/Trailing Zero LSB. Result is placed into GPR[RD]
1492 def VCLZLSBB : VXForm_RD5_XO5_RS5<1538, 0, (outs gprc:$VD), (ins vrrc:$VB),
1493 "vclzlsbb $VD, $VB", IIC_VecGeneral,
1494 [(set i32:$VD, (int_ppc_altivec_vclzlsbb
1496 def VCTZLSBB : VXForm_RD5_XO5_RS5<1538, 1, (outs gprc:$VD), (ins vrrc:$VB),
1497 "vctzlsbb $VD, $VB", IIC_VecGeneral,
1498 [(set i32:$VD, (int_ppc_altivec_vctzlsbb
1500 // Vector Count Trailing Zeros
1501 def VCTZB : VX_VT5_EO5_VB5<1538, 28, "vctzb",
1502 [(set v16i8:$VD, (cttz v16i8:$VB))]>;
1503 def VCTZH : VX_VT5_EO5_VB5<1538, 29, "vctzh",
1504 [(set v8i16:$VD, (cttz v8i16:$VB))]>;
1505 def VCTZW : VX_VT5_EO5_VB5<1538, 30, "vctzw",
1506 [(set v4i32:$VD, (cttz v4i32:$VB))]>;
1507 def VCTZD : VX_VT5_EO5_VB5<1538, 31, "vctzd",
1508 [(set v2i64:$VD, (cttz v2i64:$VB))]>;
1510 // Vector Extend Sign
1511 def VEXTSB2W : VX_VT5_EO5_VB5<1538, 16, "vextsb2w",
1512 [(set v4i32:$VD, (int_ppc_altivec_vextsb2w v16i8:$VB))]>;
1513 def VEXTSH2W : VX_VT5_EO5_VB5<1538, 17, "vextsh2w",
1514 [(set v4i32:$VD, (int_ppc_altivec_vextsh2w v8i16:$VB))]>;
1515 def VEXTSB2D : VX_VT5_EO5_VB5<1538, 24, "vextsb2d",
1516 [(set v2i64:$VD, (int_ppc_altivec_vextsb2d v16i8:$VB))]>;
1517 def VEXTSH2D : VX_VT5_EO5_VB5<1538, 25, "vextsh2d",
1518 [(set v2i64:$VD, (int_ppc_altivec_vextsh2d v8i16:$VB))]>;
1519 def VEXTSW2D : VX_VT5_EO5_VB5<1538, 26, "vextsw2d",
1520 [(set v2i64:$VD, (int_ppc_altivec_vextsw2d v4i32:$VB))]>;
1521 let isCodeGenOnly = 1 in {
1522 def VEXTSB2Ws : VX_VT5_EO5_VB5s<1538, 16, "vextsb2w", []>;
1523 def VEXTSH2Ws : VX_VT5_EO5_VB5s<1538, 17, "vextsh2w", []>;
1524 def VEXTSB2Ds : VX_VT5_EO5_VB5s<1538, 24, "vextsb2d", []>;
1525 def VEXTSH2Ds : VX_VT5_EO5_VB5s<1538, 25, "vextsh2d", []>;
1526 def VEXTSW2Ds : VX_VT5_EO5_VB5s<1538, 26, "vextsw2d", []>;
1529 def : Pat<(v4i32 (sext_inreg v4i32:$VRB, v4i8)), (v4i32 (VEXTSB2W $VRB))>;
1530 def : Pat<(v4i32 (sext_inreg v4i32:$VRB, v4i16)), (v4i32 (VEXTSH2W $VRB))>;
1531 def : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i8)), (v2i64 (VEXTSB2D $VRB))>;
1532 def : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i16)), (v2i64 (VEXTSH2D $VRB))>;
1533 def : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i32)), (v2i64 (VEXTSW2D $VRB))>;
1535 // Vector Integer Negate
1536 def VNEGW : VX_VT5_EO5_VB5<1538, 6, "vnegw",
1538 (sub (v4i32 immAllZerosV), v4i32:$VB))]>;
1540 def VNEGD : VX_VT5_EO5_VB5<1538, 7, "vnegd",
1542 (sub (v2i64 immAllZerosV), v2i64:$VB))]>;
1544 // Vector Parity Byte
1545 def VPRTYBW : VX_VT5_EO5_VB5<1538, 8, "vprtybw", [(set v4i32:$VD,
1546 (int_ppc_altivec_vprtybw v4i32:$VB))]>;
1547 def VPRTYBD : VX_VT5_EO5_VB5<1538, 9, "vprtybd", [(set v2i64:$VD,
1548 (int_ppc_altivec_vprtybd v2i64:$VB))]>;
1549 def VPRTYBQ : VX_VT5_EO5_VB5<1538, 10, "vprtybq", [(set v1i128:$VD,
1550 (int_ppc_altivec_vprtybq v1i128:$VB))]>;
1552 // Vector (Bit) Permute (Right-indexed)
1553 def VBPERMD : VX1_Int_Ty3<1484, "vbpermd", int_ppc_altivec_vbpermd,
1554 v2i64, v2i64, v16i8>;
1555 def VPERMR : VAForm_1a<59, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
1556 "vpermr $RT, $RA, $RB, $RC", IIC_VecFP, []>;
1558 class VX1_VT5_VA5_VB5<bits<11> xo, string opc, list<dag> pattern>
1559 : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1560 !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP, pattern>;
1562 // Vector Rotate Left Mask/Mask-Insert
1563 def VRLWNM : VX1_VT5_VA5_VB5<389, "vrlwnm",
1565 (int_ppc_altivec_vrlwnm v4i32:$VA,
1567 def VRLWMI : VXForm_1<133, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, vrrc:$VDi),
1568 "vrlwmi $VD, $VA, $VB", IIC_VecFP,
1570 (int_ppc_altivec_vrlwmi v4i32:$VA, v4i32:$VB,
1572 RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
1573 def VRLDNM : VX1_VT5_VA5_VB5<453, "vrldnm",
1575 (int_ppc_altivec_vrldnm v2i64:$VA,
1577 def VRLDMI : VXForm_1<197, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, vrrc:$VDi),
1578 "vrldmi $VD, $VA, $VB", IIC_VecFP,
1580 (int_ppc_altivec_vrldmi v2i64:$VA, v2i64:$VB,
1582 RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
1584 // Vector Shift Left/Right
1585 def VSLV : VX1_VT5_VA5_VB5<1860, "vslv",
1586 [(set v16i8 : $VD, (int_ppc_altivec_vslv v16i8 : $VA, v16i8 : $VB))]>;
1587 def VSRV : VX1_VT5_VA5_VB5<1796, "vsrv",
1588 [(set v16i8 : $VD, (int_ppc_altivec_vsrv v16i8 : $VA, v16i8 : $VB))]>;
1590 // Vector Multiply-by-10 (& Write Carry) Unsigned Quadword
1591 def VMUL10UQ : VXForm_BX<513, (outs vrrc:$VD), (ins vrrc:$VA),
1592 "vmul10uq $VD, $VA", IIC_VecFP, []>;
1593 def VMUL10CUQ : VXForm_BX< 1, (outs vrrc:$VD), (ins vrrc:$VA),
1594 "vmul10cuq $VD, $VA", IIC_VecFP, []>;
1596 // Vector Multiply-by-10 Extended (& Write Carry) Unsigned Quadword
1597 def VMUL10EUQ : VX1_VT5_VA5_VB5<577, "vmul10euq" , []>;
1598 def VMUL10ECUQ : VX1_VT5_VA5_VB5< 65, "vmul10ecuq", []>;
1600 // Decimal Integer Format Conversion Instructions
1602 // [PO VRT EO VRB 1 PS XO], "_o" means CR6 is set.
1603 class VX_VT5_EO5_VB5_PS1_XO9_o<bits<5> eo, bits<9> xo, string opc,
1605 : VX_RD5_EO5_RS5_PS1_XO9<eo, xo, (outs vrrc:$VD), (ins vrrc:$VB, u1imm:$PS),
1606 !strconcat(opc, " $VD, $VB, $PS"), IIC_VecFP, pattern> {
1610 // [PO VRT EO VRB 1 / XO]
1611 class VX_VT5_EO5_VB5_XO9_o<bits<5> eo, bits<9> xo, string opc,
1613 : VX_RD5_EO5_RS5_PS1_XO9<eo, xo, (outs vrrc:$VD), (ins vrrc:$VB),
1614 !strconcat(opc, " $VD, $VB"), IIC_VecFP, pattern> {
1619 // Decimal Convert From/to National/Zoned/Signed-QWord
1620 def BCDCFN_rec : VX_VT5_EO5_VB5_PS1_XO9_o<7, 385, "bcdcfn." , []>;
1621 def BCDCFZ_rec : VX_VT5_EO5_VB5_PS1_XO9_o<6, 385, "bcdcfz." , []>;
1622 def BCDCTN_rec : VX_VT5_EO5_VB5_XO9_o <5, 385, "bcdctn." , []>;
1623 def BCDCTZ_rec : VX_VT5_EO5_VB5_PS1_XO9_o<4, 385, "bcdctz." , []>;
1624 def BCDCFSQ_rec : VX_VT5_EO5_VB5_PS1_XO9_o<2, 385, "bcdcfsq.", []>;
1625 def BCDCTSQ_rec : VX_VT5_EO5_VB5_XO9_o <0, 385, "bcdctsq.", []>;
1627 // Decimal Copy-Sign/Set-Sign
1629 def BCDCPSGN_rec : VX1_VT5_VA5_VB5<833, "bcdcpsgn.", []>;
1631 def BCDSETSGN_rec : VX_VT5_EO5_VB5_PS1_XO9_o<31, 385, "bcdsetsgn.", []>;
1633 // Decimal Shift/Unsigned-Shift/Shift-and-Round
1634 def BCDS_rec : VX_VT5_VA5_VB5_PS1_XO9_o<193, "bcds." , []>;
1635 def BCDUS_rec : VX_VT5_VA5_VB5_XO9_o <129, "bcdus.", []>;
1636 def BCDSR_rec : VX_VT5_VA5_VB5_PS1_XO9_o<449, "bcdsr.", []>;
1638 // Decimal (Unsigned) Truncate
1639 def BCDTRUNC_rec : VX_VT5_VA5_VB5_PS1_XO9_o<257, "bcdtrunc." , []>;
1640 def BCDUTRUNC_rec : VX_VT5_VA5_VB5_XO9_o <321, "bcdutrunc.", []>;
1642 // Absolute Difference
1643 def VABSDUB : VXForm_1<1027, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1644 "vabsdub $VD, $VA, $VB", IIC_VecGeneral,
1645 [(set v16i8:$VD, (int_ppc_altivec_vabsdub v16i8:$VA, v16i8:$VB))]>;
1646 def VABSDUH : VXForm_1<1091, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1647 "vabsduh $VD, $VA, $VB", IIC_VecGeneral,
1648 [(set v8i16:$VD, (int_ppc_altivec_vabsduh v8i16:$VA, v8i16:$VB))]>;
1649 def VABSDUW : VXForm_1<1155, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1650 "vabsduw $VD, $VA, $VB", IIC_VecGeneral,
1651 [(set v4i32:$VD, (int_ppc_altivec_vabsduw v4i32:$VA, v4i32:$VB))]>;
1653 } // end HasP9Altivec