xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCInstrAltivec.td (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
10b57cec5SDimitry Andric//===-- PPCInstrAltivec.td - The PowerPC Altivec Extension -*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric//
90b57cec5SDimitry Andric// This file describes the Altivec extension to the PowerPC instruction set.
100b57cec5SDimitry Andric//
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric// *********************************** NOTE ***********************************
140b57cec5SDimitry Andric// ** For POWER8 Little Endian, the VSX swap optimization relies on knowing  **
150b57cec5SDimitry Andric// ** which VMX and VSX instructions are lane-sensitive and which are not.   **
160b57cec5SDimitry Andric// ** A lane-sensitive instruction relies, implicitly or explicitly, on      **
170b57cec5SDimitry Andric// ** whether lanes are numbered from left to right.  An instruction like    **
180b57cec5SDimitry Andric// ** VADDFP is not lane-sensitive, because each lane of the result vector   **
190b57cec5SDimitry Andric// ** relies only on the corresponding lane of the source vectors.  However, **
200b57cec5SDimitry Andric// ** an instruction like VMULESB is lane-sensitive, because "even" and      **
210b57cec5SDimitry Andric// ** "odd" lanes are different for big-endian and little-endian numbering.  **
220b57cec5SDimitry Andric// **                                                                        **
230b57cec5SDimitry Andric// ** When adding new VMX and VSX instructions, please consider whether they **
240b57cec5SDimitry Andric// ** are lane-sensitive.  If so, they must be added to a switch statement   **
250b57cec5SDimitry Andric// ** in PPCVSXSwapRemoval::gatherVectorInstructions().                      **
260b57cec5SDimitry Andric// ****************************************************************************
270b57cec5SDimitry Andric
280b57cec5SDimitry Andric
290b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
300b57cec5SDimitry Andric// Altivec transformation functions and pattern fragments.
310b57cec5SDimitry Andric//
320b57cec5SDimitry Andric
330b57cec5SDimitry Andricdef vpkuhum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
340b57cec5SDimitry Andric                              (vector_shuffle node:$lhs, node:$rhs), [{
350b57cec5SDimitry Andric  return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
360b57cec5SDimitry Andric}]>;
370b57cec5SDimitry Andricdef vpkuwum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
380b57cec5SDimitry Andric                              (vector_shuffle node:$lhs, node:$rhs), [{
390b57cec5SDimitry Andric  return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
400b57cec5SDimitry Andric}]>;
410b57cec5SDimitry Andricdef vpkudum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
420b57cec5SDimitry Andric                              (vector_shuffle node:$lhs, node:$rhs), [{
430b57cec5SDimitry Andric  return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 0, *CurDAG);
440b57cec5SDimitry Andric}]>;
450b57cec5SDimitry Andricdef vpkuhum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
460b57cec5SDimitry Andric                                    (vector_shuffle node:$lhs, node:$rhs), [{
470b57cec5SDimitry Andric  return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
480b57cec5SDimitry Andric}]>;
490b57cec5SDimitry Andricdef vpkuwum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
500b57cec5SDimitry Andric                                    (vector_shuffle node:$lhs, node:$rhs), [{
510b57cec5SDimitry Andric  return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
520b57cec5SDimitry Andric}]>;
530b57cec5SDimitry Andricdef vpkudum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
540b57cec5SDimitry Andric                                    (vector_shuffle node:$lhs, node:$rhs), [{
550b57cec5SDimitry Andric  return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 1, *CurDAG);
560b57cec5SDimitry Andric}]>;
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric// These fragments are provided for little-endian, where the inputs must be
590b57cec5SDimitry Andric// swapped for correct semantics.
600b57cec5SDimitry Andricdef vpkuhum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
610b57cec5SDimitry Andric                                      (vector_shuffle node:$lhs, node:$rhs), [{
620b57cec5SDimitry Andric  return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
630b57cec5SDimitry Andric}]>;
640b57cec5SDimitry Andricdef vpkuwum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
650b57cec5SDimitry Andric                                      (vector_shuffle node:$lhs, node:$rhs), [{
660b57cec5SDimitry Andric  return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
670b57cec5SDimitry Andric}]>;
680b57cec5SDimitry Andricdef vpkudum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
690b57cec5SDimitry Andric                                      (vector_shuffle node:$lhs, node:$rhs), [{
700b57cec5SDimitry Andric  return PPC::isVPKUDUMShuffleMask(cast<ShuffleVectorSDNode>(N), 2, *CurDAG);
710b57cec5SDimitry Andric}]>;
720b57cec5SDimitry Andric
730b57cec5SDimitry Andricdef vmrglb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
740b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
750b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 0, *CurDAG);
760b57cec5SDimitry Andric}]>;
770b57cec5SDimitry Andricdef vmrglh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
780b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
790b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 0, *CurDAG);
800b57cec5SDimitry Andric}]>;
810b57cec5SDimitry Andricdef vmrglw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
820b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
830b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 0, *CurDAG);
840b57cec5SDimitry Andric}]>;
850b57cec5SDimitry Andricdef vmrghb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
860b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
870b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 0, *CurDAG);
880b57cec5SDimitry Andric}]>;
890b57cec5SDimitry Andricdef vmrghh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
900b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
910b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 0, *CurDAG);
920b57cec5SDimitry Andric}]>;
930b57cec5SDimitry Andricdef vmrghw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
940b57cec5SDimitry Andric                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
950b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 0, *CurDAG);
960b57cec5SDimitry Andric}]>;
970b57cec5SDimitry Andric
980b57cec5SDimitry Andric
990b57cec5SDimitry Andricdef vmrglb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1000b57cec5SDimitry Andric                               (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
1010b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 1, *CurDAG);
1020b57cec5SDimitry Andric}]>;
1030b57cec5SDimitry Andricdef vmrglh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1040b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1050b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 1, *CurDAG);
1060b57cec5SDimitry Andric}]>;
1070b57cec5SDimitry Andricdef vmrglw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1080b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1090b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 1, *CurDAG);
1100b57cec5SDimitry Andric}]>;
1110b57cec5SDimitry Andricdef vmrghb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1120b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1130b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 1, *CurDAG);
1140b57cec5SDimitry Andric}]>;
1150b57cec5SDimitry Andricdef vmrghh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1160b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1170b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 1, *CurDAG);
1180b57cec5SDimitry Andric}]>;
1190b57cec5SDimitry Andricdef vmrghw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1200b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1210b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 1, *CurDAG);
1220b57cec5SDimitry Andric}]>;
1230b57cec5SDimitry Andric
1240b57cec5SDimitry Andric
1250b57cec5SDimitry Andric// These fragments are provided for little-endian, where the inputs must be
1260b57cec5SDimitry Andric// swapped for correct semantics.
1270b57cec5SDimitry Andricdef vmrglb_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1280b57cec5SDimitry Andric                               (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
1290b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 2, *CurDAG);
1300b57cec5SDimitry Andric}]>;
1310b57cec5SDimitry Andricdef vmrglh_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1320b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1330b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 2, *CurDAG);
1340b57cec5SDimitry Andric}]>;
1350b57cec5SDimitry Andricdef vmrglw_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1360b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1370b57cec5SDimitry Andric  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 2, *CurDAG);
1380b57cec5SDimitry Andric}]>;
1390b57cec5SDimitry Andricdef vmrghb_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1400b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1410b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, 2, *CurDAG);
1420b57cec5SDimitry Andric}]>;
1430b57cec5SDimitry Andricdef vmrghh_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1440b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1450b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, 2, *CurDAG);
1460b57cec5SDimitry Andric}]>;
1470b57cec5SDimitry Andricdef vmrghw_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1480b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1490b57cec5SDimitry Andric  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, 2, *CurDAG);
1500b57cec5SDimitry Andric}]>;
1510b57cec5SDimitry Andric
1520b57cec5SDimitry Andric
1530b57cec5SDimitry Andricdef vmrgew_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1540b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
1550b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 0, *CurDAG);
1560b57cec5SDimitry Andric}]>;
1570b57cec5SDimitry Andricdef vmrgow_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1580b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
1590b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 0, *CurDAG);
1600b57cec5SDimitry Andric}]>;
1610b57cec5SDimitry Andricdef vmrgew_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1620b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1630b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 1, *CurDAG);
1640b57cec5SDimitry Andric}]>;
1650b57cec5SDimitry Andricdef vmrgow_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1660b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1670b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 1, *CurDAG);
1680b57cec5SDimitry Andric}]>;
1690b57cec5SDimitry Andricdef vmrgew_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1700b57cec5SDimitry Andric                                     (vector_shuffle node:$lhs, node:$rhs), [{
1710b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), true, 2, *CurDAG);
1720b57cec5SDimitry Andric}]>;
1730b57cec5SDimitry Andricdef vmrgow_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1740b57cec5SDimitry Andric                                     (vector_shuffle node:$lhs, node:$rhs), [{
1750b57cec5SDimitry Andric  return PPC::isVMRGEOShuffleMask(cast<ShuffleVectorSDNode>(N), false, 2, *CurDAG);
1760b57cec5SDimitry Andric}]>;
1770b57cec5SDimitry Andric
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andric
1800b57cec5SDimitry Andricdef VSLDOI_get_imm : SDNodeXForm<vector_shuffle, [{
1810b57cec5SDimitry Andric  return getI32Imm(PPC::isVSLDOIShuffleMask(N, 0, *CurDAG), SDLoc(N));
1820b57cec5SDimitry Andric}]>;
1830b57cec5SDimitry Andricdef vsldoi_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1840b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
1850b57cec5SDimitry Andric  return PPC::isVSLDOIShuffleMask(N, 0, *CurDAG) != -1;
1860b57cec5SDimitry Andric}], VSLDOI_get_imm>;
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andric
1890b57cec5SDimitry Andric/// VSLDOI_unary* - These are used to match vsldoi(X,X), which is turned into
1900b57cec5SDimitry Andric/// vector_shuffle(X,undef,mask) by the dag combiner.
1910b57cec5SDimitry Andricdef VSLDOI_unary_get_imm : SDNodeXForm<vector_shuffle, [{
1920b57cec5SDimitry Andric  return getI32Imm(PPC::isVSLDOIShuffleMask(N, 1, *CurDAG), SDLoc(N));
1930b57cec5SDimitry Andric}]>;
1940b57cec5SDimitry Andricdef vsldoi_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
1950b57cec5SDimitry Andric                                   (vector_shuffle node:$lhs, node:$rhs), [{
1960b57cec5SDimitry Andric  return PPC::isVSLDOIShuffleMask(N, 1, *CurDAG) != -1;
1970b57cec5SDimitry Andric}], VSLDOI_unary_get_imm>;
1980b57cec5SDimitry Andric
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric/// VSLDOI_swapped* - These fragments are provided for little-endian, where
2010b57cec5SDimitry Andric/// the inputs must be swapped for correct semantics.
2020b57cec5SDimitry Andricdef VSLDOI_swapped_get_imm : SDNodeXForm<vector_shuffle, [{
2030b57cec5SDimitry Andric  return getI32Imm(PPC::isVSLDOIShuffleMask(N, 2, *CurDAG), SDLoc(N));
2040b57cec5SDimitry Andric}]>;
2050b57cec5SDimitry Andricdef vsldoi_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2060b57cec5SDimitry Andric                                     (vector_shuffle node:$lhs, node:$rhs), [{
2070b57cec5SDimitry Andric  return PPC::isVSLDOIShuffleMask(N, 2, *CurDAG) != -1;
2080b57cec5SDimitry Andric}], VSLDOI_get_imm>;
2090b57cec5SDimitry Andric
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andric// VSPLT*_get_imm xform function: convert vector_shuffle mask to VSPLT* imm.
2120b57cec5SDimitry Andricdef VSPLTB_get_imm : SDNodeXForm<vector_shuffle, [{
2138bcb0991SDimitry Andric  return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 1, *CurDAG), SDLoc(N));
2140b57cec5SDimitry Andric}]>;
2150b57cec5SDimitry Andricdef vspltb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2160b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
2170b57cec5SDimitry Andric  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 1);
2180b57cec5SDimitry Andric}], VSPLTB_get_imm>;
2190b57cec5SDimitry Andricdef VSPLTH_get_imm : SDNodeXForm<vector_shuffle, [{
2208bcb0991SDimitry Andric  return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 2, *CurDAG), SDLoc(N));
2210b57cec5SDimitry Andric}]>;
2220b57cec5SDimitry Andricdef vsplth_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2230b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
2240b57cec5SDimitry Andric  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 2);
2250b57cec5SDimitry Andric}], VSPLTH_get_imm>;
2260b57cec5SDimitry Andricdef VSPLTW_get_imm : SDNodeXForm<vector_shuffle, [{
2278bcb0991SDimitry Andric  return getI32Imm(PPC::getSplatIdxForPPCMnemonics(N, 4, *CurDAG), SDLoc(N));
2280b57cec5SDimitry Andric}]>;
2290b57cec5SDimitry Andricdef vspltw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2300b57cec5SDimitry Andric                             (vector_shuffle node:$lhs, node:$rhs), [{
2310b57cec5SDimitry Andric  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 4);
2320b57cec5SDimitry Andric}], VSPLTW_get_imm>;
2330b57cec5SDimitry Andric
2340b57cec5SDimitry Andric
2350b57cec5SDimitry Andric// VSPLTISB_get_imm xform function: convert build_vector to VSPLTISB imm.
2360b57cec5SDimitry Andricdef VSPLTISB_get_imm : SDNodeXForm<build_vector, [{
2370b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 1, *CurDAG);
2380b57cec5SDimitry Andric}]>;
2390b57cec5SDimitry Andricdef vecspltisb : PatLeaf<(build_vector), [{
2400b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 1, *CurDAG).getNode() != nullptr;
2410b57cec5SDimitry Andric}], VSPLTISB_get_imm>;
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andric// VSPLTISH_get_imm xform function: convert build_vector to VSPLTISH imm.
2440b57cec5SDimitry Andricdef VSPLTISH_get_imm : SDNodeXForm<build_vector, [{
2450b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 2, *CurDAG);
2460b57cec5SDimitry Andric}]>;
2470b57cec5SDimitry Andricdef vecspltish : PatLeaf<(build_vector), [{
2480b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 2, *CurDAG).getNode() != nullptr;
2490b57cec5SDimitry Andric}], VSPLTISH_get_imm>;
2500b57cec5SDimitry Andric
2510b57cec5SDimitry Andric// VSPLTISW_get_imm xform function: convert build_vector to VSPLTISW imm.
2520b57cec5SDimitry Andricdef VSPLTISW_get_imm : SDNodeXForm<build_vector, [{
2530b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 4, *CurDAG);
2540b57cec5SDimitry Andric}]>;
2550b57cec5SDimitry Andricdef vecspltisw : PatLeaf<(build_vector), [{
2560b57cec5SDimitry Andric  return PPC::get_VSPLTI_elt(N, 4, *CurDAG).getNode() != nullptr;
2570b57cec5SDimitry Andric}], VSPLTISW_get_imm>;
2580b57cec5SDimitry Andric
259480093f4SDimitry Andricdef immEQOneV : PatLeaf<(build_vector), [{
260480093f4SDimitry Andric  if (ConstantSDNode *C = cast<BuildVectorSDNode>(N)->getConstantSplatNode())
261480093f4SDimitry Andric    return C->isOne();
262480093f4SDimitry Andric  return false;
263480093f4SDimitry Andric}]>;
2640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2650b57cec5SDimitry Andric// Helpers for defining instructions that directly correspond to intrinsics.
2660b57cec5SDimitry Andric
2670b57cec5SDimitry Andric// VA1a_Int_Ty - A VAForm_1a intrinsic definition of specific type.
2680b57cec5SDimitry Andricclass VA1a_Int_Ty<bits<6> xo, string opc, Intrinsic IntID, ValueType Ty>
269*06c3fb27SDimitry Andric  : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
270*06c3fb27SDimitry Andric              !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
271*06c3fb27SDimitry Andric                       [(set Ty:$RT, (IntID Ty:$RA, Ty:$RB, Ty:$RC))]>;
2720b57cec5SDimitry Andric
2730b57cec5SDimitry Andric// VA1a_Int_Ty2 - A VAForm_1a intrinsic definition where the type of the
2740b57cec5SDimitry Andric// inputs doesn't match the type of the output.
2750b57cec5SDimitry Andricclass VA1a_Int_Ty2<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
2760b57cec5SDimitry Andric                   ValueType InTy>
277*06c3fb27SDimitry Andric  : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
278*06c3fb27SDimitry Andric              !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
279*06c3fb27SDimitry Andric                       [(set OutTy:$RT, (IntID InTy:$RA, InTy:$RB, InTy:$RC))]>;
2800b57cec5SDimitry Andric
2810b57cec5SDimitry Andric// VA1a_Int_Ty3 - A VAForm_1a intrinsic definition where there are two
2820b57cec5SDimitry Andric// input types and an output type.
2830b57cec5SDimitry Andricclass VA1a_Int_Ty3<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
2840b57cec5SDimitry Andric                   ValueType In1Ty, ValueType In2Ty>
285*06c3fb27SDimitry Andric  : VAForm_1a<xo, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
286*06c3fb27SDimitry Andric              !strconcat(opc, " $RT, $RA, $RB, $RC"), IIC_VecFP,
287*06c3fb27SDimitry Andric                       [(set OutTy:$RT,
288*06c3fb27SDimitry Andric                         (IntID In1Ty:$RA, In1Ty:$RB, In2Ty:$RC))]>;
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andric// VX1_Int_Ty - A VXForm_1 intrinsic definition of specific type.
2910b57cec5SDimitry Andricclass VX1_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
292*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
293*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
294*06c3fb27SDimitry Andric             [(set Ty:$VD, (IntID Ty:$VA, Ty:$VB))]>;
2950b57cec5SDimitry Andric
2960b57cec5SDimitry Andric// VX1_Int_Ty2 - A VXForm_1 intrinsic definition where the type of the
2970b57cec5SDimitry Andric// inputs doesn't match the type of the output.
2980b57cec5SDimitry Andricclass VX1_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
2990b57cec5SDimitry Andric                  ValueType InTy>
300*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
301*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
302*06c3fb27SDimitry Andric             [(set OutTy:$VD, (IntID InTy:$VA, InTy:$VB))]>;
3030b57cec5SDimitry Andric
3040b57cec5SDimitry Andric// VX1_Int_Ty3 - A VXForm_1 intrinsic definition where there are two
3050b57cec5SDimitry Andric// input types and an output type.
3060b57cec5SDimitry Andricclass VX1_Int_Ty3<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
3070b57cec5SDimitry Andric                  ValueType In1Ty, ValueType In2Ty>
308*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
309*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP,
310*06c3fb27SDimitry Andric             [(set OutTy:$VD, (IntID In1Ty:$VA, In2Ty:$VB))]>;
3110b57cec5SDimitry Andric
3120b57cec5SDimitry Andric// VX2_Int_SP - A VXForm_2 intrinsic definition of vector single-precision type.
3130b57cec5SDimitry Andricclass VX2_Int_SP<bits<11> xo, string opc, Intrinsic IntID>
314*06c3fb27SDimitry Andric  : VXForm_2<xo, (outs vrrc:$VD), (ins vrrc:$VB),
315*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VB"), IIC_VecFP,
316*06c3fb27SDimitry Andric             [(set v4f32:$VD, (IntID v4f32:$VB))]>;
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andric// VX2_Int_Ty2 - A VXForm_2 intrinsic definition where the type of the
3190b57cec5SDimitry Andric// inputs doesn't match the type of the output.
3200b57cec5SDimitry Andricclass VX2_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
3210b57cec5SDimitry Andric                  ValueType InTy>
322*06c3fb27SDimitry Andric  : VXForm_2<xo, (outs vrrc:$VD), (ins vrrc:$VB),
323*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VB"), IIC_VecFP,
324*06c3fb27SDimitry Andric             [(set OutTy:$VD, (IntID InTy:$VB))]>;
3250b57cec5SDimitry Andric
3260b57cec5SDimitry Andricclass VXBX_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
327*06c3fb27SDimitry Andric  : VXForm_BX<xo, (outs vrrc:$VD), (ins vrrc:$VA),
328*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA"), IIC_VecFP,
329*06c3fb27SDimitry Andric             [(set Ty:$VD, (IntID Ty:$VA))]>;
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andricclass VXCR_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
332*06c3fb27SDimitry Andric  : VXForm_CR<xo, (outs vrrc:$VD), (ins vrrc:$VA, u1imm:$ST, u4imm:$SIX),
333*06c3fb27SDimitry Andric              !strconcat(opc, " $VD, $VA, $ST, $SIX"), IIC_VecFP,
334*06c3fb27SDimitry Andric              [(set Ty:$VD, (IntID Ty:$VA, timm:$ST, timm:$SIX))]>;
3350b57cec5SDimitry Andric
3360b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
3370b57cec5SDimitry Andric// Instruction Definitions.
3380b57cec5SDimitry Andric
3395ffd83dbSDimitry Andricdef HasAltivec : Predicate<"Subtarget->hasAltivec()">;
3400b57cec5SDimitry Andriclet Predicates = [HasAltivec] in {
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andricdef DSS      : DSS_Form<0, 822, (outs), (ins u5imm:$STRM),
3430b57cec5SDimitry Andric                        "dss $STRM", IIC_LdStLoad /*FIXME*/, [(int_ppc_altivec_dss imm:$STRM)]>,
3440b57cec5SDimitry Andric                        Deprecated<DeprecatedDST> {
345*06c3fb27SDimitry Andric  let RA = 0;
346*06c3fb27SDimitry Andric  let RB = 0;
3470b57cec5SDimitry Andric}
3480b57cec5SDimitry Andric
3490b57cec5SDimitry Andricdef DSSALL   : DSS_Form<1, 822, (outs), (ins),
350fe6060f1SDimitry Andric                        "dssall", IIC_LdStLoad /*FIXME*/, []>,
3510b57cec5SDimitry Andric                        Deprecated<DeprecatedDST> {
3520b57cec5SDimitry Andric  let STRM = 0;
353*06c3fb27SDimitry Andric  let RA = 0;
354*06c3fb27SDimitry Andric  let RB = 0;
3550b57cec5SDimitry Andric}
3560b57cec5SDimitry Andric
357*06c3fb27SDimitry Andricdef DST      : DSS_Form<0, 342, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
358*06c3fb27SDimitry Andric                        "dst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
359*06c3fb27SDimitry Andric                        [(int_ppc_altivec_dst i32:$RA, i32:$RB, imm:$STRM)]>,
3600b57cec5SDimitry Andric                        Deprecated<DeprecatedDST>;
3610b57cec5SDimitry Andric
362*06c3fb27SDimitry Andricdef DSTT     : DSS_Form<1, 342, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
363*06c3fb27SDimitry Andric                        "dstt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
364*06c3fb27SDimitry Andric                        [(int_ppc_altivec_dstt i32:$RA, i32:$RB, imm:$STRM)]>,
3650b57cec5SDimitry Andric                        Deprecated<DeprecatedDST>;
3660b57cec5SDimitry Andric
367*06c3fb27SDimitry Andricdef DSTST    : DSS_Form<0, 374, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
368*06c3fb27SDimitry Andric                        "dstst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
369*06c3fb27SDimitry Andric                        [(int_ppc_altivec_dstst i32:$RA, i32:$RB, imm:$STRM)]>,
3700b57cec5SDimitry Andric                        Deprecated<DeprecatedDST>;
3710b57cec5SDimitry Andric
372*06c3fb27SDimitry Andricdef DSTSTT   : DSS_Form<1, 374, (outs), (ins u5imm:$STRM, gprc:$RA, gprc:$RB),
373*06c3fb27SDimitry Andric                        "dststt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
374*06c3fb27SDimitry Andric                        [(int_ppc_altivec_dststt i32:$RA, i32:$RB, imm:$STRM)]>,
3750b57cec5SDimitry Andric                        Deprecated<DeprecatedDST>;
3760b57cec5SDimitry Andric
3770b57cec5SDimitry Andriclet isCodeGenOnly = 1 in {
3780b57cec5SDimitry Andric  // The very same instructions as above, but formally matching 64bit registers.
379*06c3fb27SDimitry Andric  def DST64    : DSS_Form<0, 342, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
380*06c3fb27SDimitry Andric                          "dst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
381*06c3fb27SDimitry Andric                          [(int_ppc_altivec_dst i64:$RA, i32:$RB, imm:$STRM)]>,
3820b57cec5SDimitry Andric                          Deprecated<DeprecatedDST>;
3830b57cec5SDimitry Andric
384*06c3fb27SDimitry Andric  def DSTT64   : DSS_Form<1, 342, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
385*06c3fb27SDimitry Andric                          "dstt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
386*06c3fb27SDimitry Andric                          [(int_ppc_altivec_dstt i64:$RA, i32:$RB, imm:$STRM)]>,
3870b57cec5SDimitry Andric                          Deprecated<DeprecatedDST>;
3880b57cec5SDimitry Andric
389*06c3fb27SDimitry Andric  def DSTST64  : DSS_Form<0, 374, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
390*06c3fb27SDimitry Andric                          "dstst $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
391*06c3fb27SDimitry Andric                          [(int_ppc_altivec_dstst i64:$RA, i32:$RB,
3920b57cec5SDimitry Andric                                                  imm:$STRM)]>,
3930b57cec5SDimitry Andric                          Deprecated<DeprecatedDST>;
3940b57cec5SDimitry Andric
395*06c3fb27SDimitry Andric  def DSTSTT64 : DSS_Form<1, 374, (outs), (ins u5imm:$STRM, g8rc:$RA, gprc:$RB),
396*06c3fb27SDimitry Andric                          "dststt $RA, $RB, $STRM", IIC_LdStLoad /*FIXME*/,
397*06c3fb27SDimitry Andric                          [(int_ppc_altivec_dststt i64:$RA, i32:$RB,
3980b57cec5SDimitry Andric                                                   imm:$STRM)]>,
3990b57cec5SDimitry Andric                          Deprecated<DeprecatedDST>;
4000b57cec5SDimitry Andric}
4010b57cec5SDimitry Andric
402e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
403*06c3fb27SDimitry Andric  def MFVSCR : VXForm_4<1540, (outs vrrc:$VD), (ins),
404*06c3fb27SDimitry Andric                        "mfvscr $VD", IIC_LdStStore,
405*06c3fb27SDimitry Andric                        [(set v8i16:$VD, (int_ppc_altivec_mfvscr))]>;
406*06c3fb27SDimitry Andric  def MTVSCR : VXForm_5<1604, (outs), (ins vrrc:$VB),
407*06c3fb27SDimitry Andric                        "mtvscr $VB", IIC_LdStLoad,
408*06c3fb27SDimitry Andric                        [(int_ppc_altivec_mtvscr v4i32:$VB)]>;
409e8d8bef9SDimitry Andric}
4100b57cec5SDimitry Andric
4110b57cec5SDimitry Andriclet PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {  // Loads.
412*06c3fb27SDimitry Andricdef LVEBX: XForm_1_memOp<31,   7, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
413*06c3fb27SDimitry Andric                   "lvebx $RST, $addr", IIC_LdStLoad,
414*06c3fb27SDimitry Andric                   [(set v16i8:$RST, (int_ppc_altivec_lvebx ForceXForm:$addr))]>;
415*06c3fb27SDimitry Andricdef LVEHX: XForm_1_memOp<31,  39, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
416*06c3fb27SDimitry Andric                   "lvehx $RST, $addr", IIC_LdStLoad,
417*06c3fb27SDimitry Andric                   [(set v8i16:$RST, (int_ppc_altivec_lvehx ForceXForm:$addr))]>;
418*06c3fb27SDimitry Andricdef LVEWX: XForm_1_memOp<31,  71, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
419*06c3fb27SDimitry Andric                   "lvewx $RST, $addr", IIC_LdStLoad,
420*06c3fb27SDimitry Andric                   [(set v4i32:$RST, (int_ppc_altivec_lvewx ForceXForm:$addr))]>;
421*06c3fb27SDimitry Andricdef LVX  : XForm_1_memOp<31, 103, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
422*06c3fb27SDimitry Andric                   "lvx $RST, $addr", IIC_LdStLoad,
423*06c3fb27SDimitry Andric                   [(set v4i32:$RST, (int_ppc_altivec_lvx ForceXForm:$addr))]>;
424*06c3fb27SDimitry Andricdef LVXL : XForm_1_memOp<31, 359, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
425*06c3fb27SDimitry Andric                   "lvxl $RST, $addr", IIC_LdStLoad,
426*06c3fb27SDimitry Andric                   [(set v4i32:$RST, (int_ppc_altivec_lvxl ForceXForm:$addr))]>;
4270b57cec5SDimitry Andric}
4280b57cec5SDimitry Andric
429*06c3fb27SDimitry Andricdef LVSL : XForm_1_memOp<31,   6, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
430*06c3fb27SDimitry Andric                   "lvsl $RST, $addr", IIC_LdStLoad,
431*06c3fb27SDimitry Andric                   [(set v16i8:$RST, (int_ppc_altivec_lvsl ForceXForm:$addr))]>,
4320b57cec5SDimitry Andric                   PPC970_Unit_LSU;
433*06c3fb27SDimitry Andricdef LVSR : XForm_1_memOp<31,  38, (outs vrrc:$RST), (ins (memrr $RA, $RB):$addr),
434*06c3fb27SDimitry Andric                   "lvsr $RST, $addr", IIC_LdStLoad,
435*06c3fb27SDimitry Andric                   [(set v16i8:$RST, (int_ppc_altivec_lvsr ForceXForm:$addr))]>,
4360b57cec5SDimitry Andric                   PPC970_Unit_LSU;
4370b57cec5SDimitry Andric
4380b57cec5SDimitry Andriclet PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {   // Stores.
439*06c3fb27SDimitry Andricdef STVEBX: XForm_8_memOp<31, 135, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
440*06c3fb27SDimitry Andric                   "stvebx $RST, $addr", IIC_LdStStore,
441*06c3fb27SDimitry Andric                   [(int_ppc_altivec_stvebx v16i8:$RST, ForceXForm:$addr)]>;
442*06c3fb27SDimitry Andricdef STVEHX: XForm_8_memOp<31, 167, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
443*06c3fb27SDimitry Andric                   "stvehx $RST, $addr", IIC_LdStStore,
444*06c3fb27SDimitry Andric                   [(int_ppc_altivec_stvehx v8i16:$RST, ForceXForm:$addr)]>;
445*06c3fb27SDimitry Andricdef STVEWX: XForm_8_memOp<31, 199, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
446*06c3fb27SDimitry Andric                   "stvewx $RST, $addr", IIC_LdStStore,
447*06c3fb27SDimitry Andric                   [(int_ppc_altivec_stvewx v4i32:$RST, ForceXForm:$addr)]>;
448*06c3fb27SDimitry Andricdef STVX  : XForm_8_memOp<31, 231, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
449*06c3fb27SDimitry Andric                   "stvx $RST, $addr", IIC_LdStStore,
450*06c3fb27SDimitry Andric                   [(int_ppc_altivec_stvx v4i32:$RST, ForceXForm:$addr)]>;
451*06c3fb27SDimitry Andricdef STVXL : XForm_8_memOp<31, 487, (outs), (ins vrrc:$RST, (memrr $RA, $RB):$addr),
452*06c3fb27SDimitry Andric                   "stvxl $RST, $addr", IIC_LdStStore,
453*06c3fb27SDimitry Andric                   [(int_ppc_altivec_stvxl v4i32:$RST, ForceXForm:$addr)]>;
4540b57cec5SDimitry Andric}
4550b57cec5SDimitry Andric
4560b57cec5SDimitry Andriclet PPC970_Unit = 5 in {  // VALU Operations.
4570b57cec5SDimitry Andric// VA-Form instructions.  3-input AltiVec ops.
4580b57cec5SDimitry Andriclet isCommutable = 1 in {
459*06c3fb27SDimitry Andricdef VMADDFP : VAForm_1<46, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RC, vrrc:$RB),
460*06c3fb27SDimitry Andric                       "vmaddfp $RT, $RA, $RC, $RB", IIC_VecFP,
461*06c3fb27SDimitry Andric                       [(set v4f32:$RT,
462*06c3fb27SDimitry Andric                        (fma v4f32:$RA, v4f32:$RC, v4f32:$RB))]>;
4630b57cec5SDimitry Andric
4640b57cec5SDimitry Andric// FIXME: The fma+fneg pattern won't match because fneg is not legal.
465*06c3fb27SDimitry Andricdef VNMSUBFP: VAForm_1<47, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RC, vrrc:$RB),
466*06c3fb27SDimitry Andric                       "vnmsubfp $RT, $RA, $RC, $RB", IIC_VecFP,
467*06c3fb27SDimitry Andric                       [(set v4f32:$RT, (fneg (fma v4f32:$RA, v4f32:$RC,
468*06c3fb27SDimitry Andric                                                  (fneg v4f32:$RB))))]>;
469e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
4700b57cec5SDimitry Andric  def VMHADDSHS  : VA1a_Int_Ty<32, "vmhaddshs", int_ppc_altivec_vmhaddshs, v8i16>;
4710b57cec5SDimitry Andric  def VMHRADDSHS : VA1a_Int_Ty<33, "vmhraddshs", int_ppc_altivec_vmhraddshs,
4720b57cec5SDimitry Andric                               v8i16>;
473e8d8bef9SDimitry Andric}
4740b57cec5SDimitry Andricdef VMLADDUHM  : VA1a_Int_Ty<34, "vmladduhm", int_ppc_altivec_vmladduhm, v8i16>;
4750b57cec5SDimitry Andric} // isCommutable
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andricdef VPERM      : VA1a_Int_Ty3<43, "vperm", int_ppc_altivec_vperm,
4780b57cec5SDimitry Andric                              v4i32, v4i32, v16i8>;
4790b57cec5SDimitry Andricdef VSEL       : VA1a_Int_Ty<42, "vsel",  int_ppc_altivec_vsel, v4i32>;
4800b57cec5SDimitry Andric
4810b57cec5SDimitry Andric// Shuffles.
482*06c3fb27SDimitry Andricdef VSLDOI  : VAForm_2<44, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, u4imm:$SH),
483*06c3fb27SDimitry Andric                       "vsldoi $RT, $RA, $RB, $SH", IIC_VecFP,
484*06c3fb27SDimitry Andric                       [(set v16i8:$RT,
485*06c3fb27SDimitry Andric                         (PPCvecshl v16i8:$RA, v16i8:$RB, imm32SExt16:$SH))]>;
4860b57cec5SDimitry Andric
4870b57cec5SDimitry Andric// VX-Form instructions.  AltiVec arithmetic ops.
4880b57cec5SDimitry Andriclet isCommutable = 1 in {
489*06c3fb27SDimitry Andricdef VADDFP : VXForm_1<10, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
490*06c3fb27SDimitry Andric                      "vaddfp $VD, $VA, $VB", IIC_VecFP,
491*06c3fb27SDimitry Andric                      [(set v4f32:$VD, (fadd v4f32:$VA, v4f32:$VB))]>;
4920b57cec5SDimitry Andric
493*06c3fb27SDimitry Andricdef VADDUBM : VXForm_1<0, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
494*06c3fb27SDimitry Andric                      "vaddubm $VD, $VA, $VB", IIC_VecGeneral,
495*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (add v16i8:$VA, v16i8:$VB))]>;
496*06c3fb27SDimitry Andricdef VADDUHM : VXForm_1<64, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
497*06c3fb27SDimitry Andric                      "vadduhm $VD, $VA, $VB", IIC_VecGeneral,
498*06c3fb27SDimitry Andric                      [(set v8i16:$VD, (add v8i16:$VA, v8i16:$VB))]>;
499*06c3fb27SDimitry Andricdef VADDUWM : VXForm_1<128, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
500*06c3fb27SDimitry Andric                      "vadduwm $VD, $VA, $VB", IIC_VecGeneral,
501*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (add v4i32:$VA, v4i32:$VB))]>;
5020b57cec5SDimitry Andric
5030b57cec5SDimitry Andricdef VADDCUW : VX1_Int_Ty<384, "vaddcuw", int_ppc_altivec_vaddcuw, v4i32>;
5040b57cec5SDimitry Andricdef VADDSBS : VX1_Int_Ty<768, "vaddsbs", int_ppc_altivec_vaddsbs, v16i8>;
5050b57cec5SDimitry Andricdef VADDSHS : VX1_Int_Ty<832, "vaddshs", int_ppc_altivec_vaddshs, v8i16>;
5060b57cec5SDimitry Andricdef VADDSWS : VX1_Int_Ty<896, "vaddsws", int_ppc_altivec_vaddsws, v4i32>;
5070b57cec5SDimitry Andricdef VADDUBS : VX1_Int_Ty<512, "vaddubs", int_ppc_altivec_vaddubs, v16i8>;
5080b57cec5SDimitry Andricdef VADDUHS : VX1_Int_Ty<576, "vadduhs", int_ppc_altivec_vadduhs, v8i16>;
5090b57cec5SDimitry Andricdef VADDUWS : VX1_Int_Ty<640, "vadduws", int_ppc_altivec_vadduws, v4i32>;
5100b57cec5SDimitry Andric} // isCommutable
5110b57cec5SDimitry Andric
5120b57cec5SDimitry Andriclet isCommutable = 1 in
513*06c3fb27SDimitry Andricdef VAND : VXForm_1<1028, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
514*06c3fb27SDimitry Andric                    "vand $VD, $VA, $VB", IIC_VecFP,
515*06c3fb27SDimitry Andric                    [(set v4i32:$VD, (and v4i32:$VA, v4i32:$VB))]>;
516*06c3fb27SDimitry Andricdef VANDC : VXForm_1<1092, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
517*06c3fb27SDimitry Andric                     "vandc $VD, $VA, $VB", IIC_VecFP,
518*06c3fb27SDimitry Andric                     [(set v4i32:$VD, (and v4i32:$VA,
519*06c3fb27SDimitry Andric                                           (vnot v4i32:$VB)))]>;
5200b57cec5SDimitry Andric
521*06c3fb27SDimitry Andricdef VCFSX  : VXForm_1<842, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
522*06c3fb27SDimitry Andric                      "vcfsx $VD, $VB, $VA", IIC_VecFP,
523*06c3fb27SDimitry Andric                      [(set v4f32:$VD,
524*06c3fb27SDimitry Andric                             (int_ppc_altivec_vcfsx v4i32:$VB, timm:$VA))]>;
525*06c3fb27SDimitry Andricdef VCFUX  : VXForm_1<778, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
526*06c3fb27SDimitry Andric                      "vcfux $VD, $VB, $VA", IIC_VecFP,
527*06c3fb27SDimitry Andric                      [(set v4f32:$VD,
528*06c3fb27SDimitry Andric                             (int_ppc_altivec_vcfux v4i32:$VB, timm:$VA))]>;
529*06c3fb27SDimitry Andricdef VCTSXS : VXForm_1<970, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
530*06c3fb27SDimitry Andric                      "vctsxs $VD, $VB, $VA", IIC_VecFP,
531*06c3fb27SDimitry Andric                      [(set v4i32:$VD,
532*06c3fb27SDimitry Andric                             (int_ppc_altivec_vctsxs v4f32:$VB, timm:$VA))]>;
533*06c3fb27SDimitry Andricdef VCTUXS : VXForm_1<906, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
534*06c3fb27SDimitry Andric                      "vctuxs $VD, $VB, $VA", IIC_VecFP,
535*06c3fb27SDimitry Andric                      [(set v4i32:$VD,
536*06c3fb27SDimitry Andric                             (int_ppc_altivec_vctuxs v4f32:$VB, timm:$VA))]>;
5370b57cec5SDimitry Andric
5380b57cec5SDimitry Andric// Defines with the UIM field set to 0 for floating-point
5390b57cec5SDimitry Andric// to integer (fp_to_sint/fp_to_uint) conversions and integer
5400b57cec5SDimitry Andric// to floating-point (sint_to_fp/uint_to_fp) conversions.
5410b57cec5SDimitry Andriclet isCodeGenOnly = 1, VA = 0 in {
542*06c3fb27SDimitry Andricdef VCFSX_0 : VXForm_1<842, (outs vrrc:$VD), (ins vrrc:$VB),
543*06c3fb27SDimitry Andric                       "vcfsx $VD, $VB, 0", IIC_VecFP,
544*06c3fb27SDimitry Andric                       [(set v4f32:$VD,
545*06c3fb27SDimitry Andric                             (int_ppc_altivec_vcfsx v4i32:$VB, 0))]>;
546*06c3fb27SDimitry Andricdef VCTUXS_0 : VXForm_1<906, (outs vrrc:$VD), (ins vrrc:$VB),
547*06c3fb27SDimitry Andric                        "vctuxs $VD, $VB, 0", IIC_VecFP,
548*06c3fb27SDimitry Andric                        [(set v4i32:$VD,
549*06c3fb27SDimitry Andric                               (int_ppc_altivec_vctuxs v4f32:$VB, 0))]>;
550*06c3fb27SDimitry Andricdef VCFUX_0 : VXForm_1<778, (outs vrrc:$VD), (ins vrrc:$VB),
551*06c3fb27SDimitry Andric                       "vcfux $VD, $VB, 0", IIC_VecFP,
552*06c3fb27SDimitry Andric                       [(set v4f32:$VD,
553*06c3fb27SDimitry Andric                               (int_ppc_altivec_vcfux v4i32:$VB, 0))]>;
554*06c3fb27SDimitry Andricdef VCTSXS_0 : VXForm_1<970, (outs vrrc:$VD), (ins vrrc:$VB),
555*06c3fb27SDimitry Andric                      "vctsxs $VD, $VB, 0", IIC_VecFP,
556*06c3fb27SDimitry Andric                      [(set v4i32:$VD,
557*06c3fb27SDimitry Andric                             (int_ppc_altivec_vctsxs v4f32:$VB, 0))]>;
5580b57cec5SDimitry Andric}
5590b57cec5SDimitry Andricdef VEXPTEFP : VX2_Int_SP<394, "vexptefp", int_ppc_altivec_vexptefp>;
5600b57cec5SDimitry Andricdef VLOGEFP  : VX2_Int_SP<458, "vlogefp",  int_ppc_altivec_vlogefp>;
5610b57cec5SDimitry Andric
5620b57cec5SDimitry Andriclet isCommutable = 1 in {
5630b57cec5SDimitry Andricdef VAVGSB : VX1_Int_Ty<1282, "vavgsb", int_ppc_altivec_vavgsb, v16i8>;
5640b57cec5SDimitry Andricdef VAVGSH : VX1_Int_Ty<1346, "vavgsh", int_ppc_altivec_vavgsh, v8i16>;
5650b57cec5SDimitry Andricdef VAVGSW : VX1_Int_Ty<1410, "vavgsw", int_ppc_altivec_vavgsw, v4i32>;
5660b57cec5SDimitry Andricdef VAVGUB : VX1_Int_Ty<1026, "vavgub", int_ppc_altivec_vavgub, v16i8>;
5670b57cec5SDimitry Andricdef VAVGUH : VX1_Int_Ty<1090, "vavguh", int_ppc_altivec_vavguh, v8i16>;
5680b57cec5SDimitry Andricdef VAVGUW : VX1_Int_Ty<1154, "vavguw", int_ppc_altivec_vavguw, v4i32>;
5690b57cec5SDimitry Andric
5700b57cec5SDimitry Andricdef VMAXFP : VX1_Int_Ty<1034, "vmaxfp", int_ppc_altivec_vmaxfp, v4f32>;
5710b57cec5SDimitry Andricdef VMAXSB : VX1_Int_Ty< 258, "vmaxsb", int_ppc_altivec_vmaxsb, v16i8>;
5720b57cec5SDimitry Andricdef VMAXSH : VX1_Int_Ty< 322, "vmaxsh", int_ppc_altivec_vmaxsh, v8i16>;
5730b57cec5SDimitry Andricdef VMAXSW : VX1_Int_Ty< 386, "vmaxsw", int_ppc_altivec_vmaxsw, v4i32>;
5740b57cec5SDimitry Andricdef VMAXUB : VX1_Int_Ty<   2, "vmaxub", int_ppc_altivec_vmaxub, v16i8>;
5750b57cec5SDimitry Andricdef VMAXUH : VX1_Int_Ty<  66, "vmaxuh", int_ppc_altivec_vmaxuh, v8i16>;
5760b57cec5SDimitry Andricdef VMAXUW : VX1_Int_Ty< 130, "vmaxuw", int_ppc_altivec_vmaxuw, v4i32>;
5770b57cec5SDimitry Andricdef VMINFP : VX1_Int_Ty<1098, "vminfp", int_ppc_altivec_vminfp, v4f32>;
5780b57cec5SDimitry Andricdef VMINSB : VX1_Int_Ty< 770, "vminsb", int_ppc_altivec_vminsb, v16i8>;
5790b57cec5SDimitry Andricdef VMINSH : VX1_Int_Ty< 834, "vminsh", int_ppc_altivec_vminsh, v8i16>;
5800b57cec5SDimitry Andricdef VMINSW : VX1_Int_Ty< 898, "vminsw", int_ppc_altivec_vminsw, v4i32>;
5810b57cec5SDimitry Andricdef VMINUB : VX1_Int_Ty< 514, "vminub", int_ppc_altivec_vminub, v16i8>;
5820b57cec5SDimitry Andricdef VMINUH : VX1_Int_Ty< 578, "vminuh", int_ppc_altivec_vminuh, v8i16>;
5830b57cec5SDimitry Andricdef VMINUW : VX1_Int_Ty< 642, "vminuw", int_ppc_altivec_vminuw, v4i32>;
5840b57cec5SDimitry Andric} // isCommutable
5850b57cec5SDimitry Andric
586*06c3fb27SDimitry Andricdef VMRGHB : VXForm_1< 12, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
587*06c3fb27SDimitry Andric                      "vmrghb $VD, $VA, $VB", IIC_VecFP,
588*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrghb_shuffle v16i8:$VA, v16i8:$VB))]>;
589*06c3fb27SDimitry Andricdef VMRGHH : VXForm_1< 76, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
590*06c3fb27SDimitry Andric                      "vmrghh $VD, $VA, $VB", IIC_VecFP,
591*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrghh_shuffle v16i8:$VA, v16i8:$VB))]>;
592*06c3fb27SDimitry Andricdef VMRGHW : VXForm_1<140, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
593*06c3fb27SDimitry Andric                      "vmrghw $VD, $VA, $VB", IIC_VecFP,
594*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrghw_shuffle v16i8:$VA, v16i8:$VB))]>;
595*06c3fb27SDimitry Andricdef VMRGLB : VXForm_1<268, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
596*06c3fb27SDimitry Andric                      "vmrglb $VD, $VA, $VB", IIC_VecFP,
597*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrglb_shuffle v16i8:$VA, v16i8:$VB))]>;
598*06c3fb27SDimitry Andricdef VMRGLH : VXForm_1<332, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
599*06c3fb27SDimitry Andric                      "vmrglh $VD, $VA, $VB", IIC_VecFP,
600*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrglh_shuffle v16i8:$VA, v16i8:$VB))]>;
601*06c3fb27SDimitry Andricdef VMRGLW : VXForm_1<396, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
602*06c3fb27SDimitry Andric                      "vmrglw $VD, $VA, $VB", IIC_VecFP,
603*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (vmrglw_shuffle v16i8:$VA, v16i8:$VB))]>;
6040b57cec5SDimitry Andric
6050b57cec5SDimitry Andricdef VMSUMMBM : VA1a_Int_Ty3<37, "vmsummbm", int_ppc_altivec_vmsummbm,
6060b57cec5SDimitry Andric                            v4i32, v16i8, v4i32>;
6070b57cec5SDimitry Andricdef VMSUMSHM : VA1a_Int_Ty3<40, "vmsumshm", int_ppc_altivec_vmsumshm,
6080b57cec5SDimitry Andric                            v4i32, v8i16, v4i32>;
6090b57cec5SDimitry Andricdef VMSUMUBM : VA1a_Int_Ty3<36, "vmsumubm", int_ppc_altivec_vmsumubm,
6100b57cec5SDimitry Andric                            v4i32, v16i8, v4i32>;
6110b57cec5SDimitry Andricdef VMSUMUHM : VA1a_Int_Ty3<38, "vmsumuhm", int_ppc_altivec_vmsumuhm,
6120b57cec5SDimitry Andric                            v4i32, v8i16, v4i32>;
613e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
614e8d8bef9SDimitry Andric  def VMSUMSHS : VA1a_Int_Ty3<41, "vmsumshs", int_ppc_altivec_vmsumshs,
615e8d8bef9SDimitry Andric                              v4i32, v8i16, v4i32>;
6160b57cec5SDimitry Andric  def VMSUMUHS : VA1a_Int_Ty3<39, "vmsumuhs", int_ppc_altivec_vmsumuhs,
6170b57cec5SDimitry Andric                              v4i32, v8i16, v4i32>;
618e8d8bef9SDimitry Andric}
6190b57cec5SDimitry Andric
6200b57cec5SDimitry Andriclet isCommutable = 1 in {
6210b57cec5SDimitry Andricdef VMULESB : VX1_Int_Ty2<776, "vmulesb", int_ppc_altivec_vmulesb,
6220b57cec5SDimitry Andric                          v8i16, v16i8>;
6230b57cec5SDimitry Andricdef VMULESH : VX1_Int_Ty2<840, "vmulesh", int_ppc_altivec_vmulesh,
6240b57cec5SDimitry Andric                          v4i32, v8i16>;
6250b57cec5SDimitry Andricdef VMULEUB : VX1_Int_Ty2<520, "vmuleub", int_ppc_altivec_vmuleub,
6260b57cec5SDimitry Andric                          v8i16, v16i8>;
6270b57cec5SDimitry Andricdef VMULEUH : VX1_Int_Ty2<584, "vmuleuh", int_ppc_altivec_vmuleuh,
6280b57cec5SDimitry Andric                          v4i32, v8i16>;
6290b57cec5SDimitry Andricdef VMULOSB : VX1_Int_Ty2<264, "vmulosb", int_ppc_altivec_vmulosb,
6300b57cec5SDimitry Andric                          v8i16, v16i8>;
6310b57cec5SDimitry Andricdef VMULOSH : VX1_Int_Ty2<328, "vmulosh", int_ppc_altivec_vmulosh,
6320b57cec5SDimitry Andric                          v4i32, v8i16>;
6330b57cec5SDimitry Andricdef VMULOUB : VX1_Int_Ty2<  8, "vmuloub", int_ppc_altivec_vmuloub,
6340b57cec5SDimitry Andric                          v8i16, v16i8>;
6350b57cec5SDimitry Andricdef VMULOUH : VX1_Int_Ty2< 72, "vmulouh", int_ppc_altivec_vmulouh,
6360b57cec5SDimitry Andric                          v4i32, v8i16>;
6370b57cec5SDimitry Andric} // isCommutable
6380b57cec5SDimitry Andric
6390b57cec5SDimitry Andricdef VREFP     : VX2_Int_SP<266, "vrefp",     int_ppc_altivec_vrefp>;
6400b57cec5SDimitry Andricdef VRFIM     : VX2_Int_SP<714, "vrfim",     int_ppc_altivec_vrfim>;
6410b57cec5SDimitry Andricdef VRFIN     : VX2_Int_SP<522, "vrfin",     int_ppc_altivec_vrfin>;
6420b57cec5SDimitry Andricdef VRFIP     : VX2_Int_SP<650, "vrfip",     int_ppc_altivec_vrfip>;
6430b57cec5SDimitry Andricdef VRFIZ     : VX2_Int_SP<586, "vrfiz",     int_ppc_altivec_vrfiz>;
6440b57cec5SDimitry Andricdef VRSQRTEFP : VX2_Int_SP<330, "vrsqrtefp", int_ppc_altivec_vrsqrtefp>;
6450b57cec5SDimitry Andric
6460b57cec5SDimitry Andricdef VSUBCUW : VX1_Int_Ty<1408, "vsubcuw", int_ppc_altivec_vsubcuw, v4i32>;
6470b57cec5SDimitry Andric
648*06c3fb27SDimitry Andricdef VSUBFP  : VXForm_1<74, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
649*06c3fb27SDimitry Andric                      "vsubfp $VD, $VA, $VB", IIC_VecGeneral,
650*06c3fb27SDimitry Andric                      [(set v4f32:$VD, (fsub v4f32:$VA, v4f32:$VB))]>;
651*06c3fb27SDimitry Andricdef VSUBUBM : VXForm_1<1024, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
652*06c3fb27SDimitry Andric                      "vsububm $VD, $VA, $VB", IIC_VecGeneral,
653*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (sub v16i8:$VA, v16i8:$VB))]>;
654*06c3fb27SDimitry Andricdef VSUBUHM : VXForm_1<1088, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
655*06c3fb27SDimitry Andric                      "vsubuhm $VD, $VA, $VB", IIC_VecGeneral,
656*06c3fb27SDimitry Andric                      [(set v8i16:$VD, (sub v8i16:$VA, v8i16:$VB))]>;
657*06c3fb27SDimitry Andricdef VSUBUWM : VXForm_1<1152, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
658*06c3fb27SDimitry Andric                      "vsubuwm $VD, $VA, $VB", IIC_VecGeneral,
659*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (sub v4i32:$VA, v4i32:$VB))]>;
6600b57cec5SDimitry Andric
6610b57cec5SDimitry Andricdef VSUBSBS : VX1_Int_Ty<1792, "vsubsbs" , int_ppc_altivec_vsubsbs, v16i8>;
6620b57cec5SDimitry Andricdef VSUBSHS : VX1_Int_Ty<1856, "vsubshs" , int_ppc_altivec_vsubshs, v8i16>;
6630b57cec5SDimitry Andricdef VSUBSWS : VX1_Int_Ty<1920, "vsubsws" , int_ppc_altivec_vsubsws, v4i32>;
6640b57cec5SDimitry Andricdef VSUBUBS : VX1_Int_Ty<1536, "vsububs" , int_ppc_altivec_vsububs, v16i8>;
6650b57cec5SDimitry Andricdef VSUBUHS : VX1_Int_Ty<1600, "vsubuhs" , int_ppc_altivec_vsubuhs, v8i16>;
6660b57cec5SDimitry Andricdef VSUBUWS : VX1_Int_Ty<1664, "vsubuws" , int_ppc_altivec_vsubuws, v4i32>;
6670b57cec5SDimitry Andric
668e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
6690b57cec5SDimitry Andric  def VSUMSWS : VX1_Int_Ty<1928, "vsumsws" , int_ppc_altivec_vsumsws, v4i32>;
6700b57cec5SDimitry Andric  def VSUM2SWS: VX1_Int_Ty<1672, "vsum2sws", int_ppc_altivec_vsum2sws, v4i32>;
6710b57cec5SDimitry Andric
6720b57cec5SDimitry Andric  def VSUM4SBS: VX1_Int_Ty3<1800, "vsum4sbs", int_ppc_altivec_vsum4sbs,
6730b57cec5SDimitry Andric                            v4i32, v16i8, v4i32>;
6740b57cec5SDimitry Andric  def VSUM4SHS: VX1_Int_Ty3<1608, "vsum4shs", int_ppc_altivec_vsum4shs,
6750b57cec5SDimitry Andric                            v4i32, v8i16, v4i32>;
6760b57cec5SDimitry Andric  def VSUM4UBS: VX1_Int_Ty3<1544, "vsum4ubs", int_ppc_altivec_vsum4ubs,
6770b57cec5SDimitry Andric                            v4i32, v16i8, v4i32>;
678e8d8bef9SDimitry Andric}
6790b57cec5SDimitry Andric
680*06c3fb27SDimitry Andricdef VNOR : VXForm_1<1284, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
681*06c3fb27SDimitry Andric                    "vnor $VD, $VA, $VB", IIC_VecFP,
682*06c3fb27SDimitry Andric                    [(set v4i32:$VD, (vnot (or v4i32:$VA,
683*06c3fb27SDimitry Andric                                               v4i32:$VB)))]>;
6840b57cec5SDimitry Andriclet isCommutable = 1 in {
685*06c3fb27SDimitry Andricdef VOR : VXForm_1<1156, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
686*06c3fb27SDimitry Andric                      "vor $VD, $VA, $VB", IIC_VecFP,
687*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (or v4i32:$VA, v4i32:$VB))]>;
688*06c3fb27SDimitry Andricdef VXOR : VXForm_1<1220, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
689*06c3fb27SDimitry Andric                      "vxor $VD, $VA, $VB", IIC_VecFP,
690*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (xor v4i32:$VA, v4i32:$VB))]>;
6910b57cec5SDimitry Andric} // isCommutable
6920b57cec5SDimitry Andric
6930b57cec5SDimitry Andricdef VRLB   : VX1_Int_Ty<   4, "vrlb", int_ppc_altivec_vrlb, v16i8>;
6940b57cec5SDimitry Andricdef VRLH   : VX1_Int_Ty<  68, "vrlh", int_ppc_altivec_vrlh, v8i16>;
6950b57cec5SDimitry Andricdef VRLW   : VX1_Int_Ty< 132, "vrlw", int_ppc_altivec_vrlw, v4i32>;
6960b57cec5SDimitry Andric
6970b57cec5SDimitry Andricdef VSL    : VX1_Int_Ty< 452, "vsl" , int_ppc_altivec_vsl,  v4i32 >;
6980b57cec5SDimitry Andricdef VSLO   : VX1_Int_Ty<1036, "vslo", int_ppc_altivec_vslo, v4i32>;
6990b57cec5SDimitry Andric
7000b57cec5SDimitry Andricdef VSLB   : VX1_Int_Ty< 260, "vslb", int_ppc_altivec_vslb, v16i8>;
7010b57cec5SDimitry Andricdef VSLH   : VX1_Int_Ty< 324, "vslh", int_ppc_altivec_vslh, v8i16>;
7020b57cec5SDimitry Andricdef VSLW   : VX1_Int_Ty< 388, "vslw", int_ppc_altivec_vslw, v4i32>;
7030b57cec5SDimitry Andric
704*06c3fb27SDimitry Andricdef VSPLTB : VXForm_1<524, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
705*06c3fb27SDimitry Andric                      "vspltb $VD, $VB, $VA", IIC_VecPerm,
706*06c3fb27SDimitry Andric                      [(set v16i8:$VD,
707*06c3fb27SDimitry Andric                        (vspltb_shuffle:$VA v16i8:$VB, (undef)))]>;
708*06c3fb27SDimitry Andricdef VSPLTH : VXForm_1<588, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
709*06c3fb27SDimitry Andric                      "vsplth $VD, $VB, $VA", IIC_VecPerm,
710*06c3fb27SDimitry Andric                      [(set v16i8:$VD,
711*06c3fb27SDimitry Andric                        (vsplth_shuffle:$VA v16i8:$VB, (undef)))]>;
712*06c3fb27SDimitry Andricdef VSPLTW : VXForm_1<652, (outs vrrc:$VD), (ins u5imm:$VA, vrrc:$VB),
713*06c3fb27SDimitry Andric                      "vspltw $VD, $VB, $VA", IIC_VecPerm,
714*06c3fb27SDimitry Andric                      [(set v16i8:$VD,
715*06c3fb27SDimitry Andric                        (vspltw_shuffle:$VA v16i8:$VB, (undef)))]>;
716480093f4SDimitry Andriclet isCodeGenOnly = 1, hasSideEffects = 0 in {
717*06c3fb27SDimitry Andric  def VSPLTBs : VXForm_1<524, (outs vrrc:$VD), (ins u5imm:$VA, vfrc:$VB),
718*06c3fb27SDimitry Andric                         "vspltb $VD, $VB, $VA", IIC_VecPerm, []>;
719*06c3fb27SDimitry Andric  def VSPLTHs : VXForm_1<588, (outs vrrc:$VD), (ins u5imm:$VA, vfrc:$VB),
720*06c3fb27SDimitry Andric                         "vsplth $VD, $VB, $VA", IIC_VecPerm, []>;
7210b57cec5SDimitry Andric}
7220b57cec5SDimitry Andric
7230b57cec5SDimitry Andricdef VSR    : VX1_Int_Ty< 708, "vsr"  , int_ppc_altivec_vsr,  v4i32>;
7240b57cec5SDimitry Andricdef VSRO   : VX1_Int_Ty<1100, "vsro" , int_ppc_altivec_vsro, v4i32>;
7250b57cec5SDimitry Andric
7260b57cec5SDimitry Andricdef VSRAB  : VX1_Int_Ty< 772, "vsrab", int_ppc_altivec_vsrab, v16i8>;
7270b57cec5SDimitry Andricdef VSRAH  : VX1_Int_Ty< 836, "vsrah", int_ppc_altivec_vsrah, v8i16>;
7280b57cec5SDimitry Andricdef VSRAW  : VX1_Int_Ty< 900, "vsraw", int_ppc_altivec_vsraw, v4i32>;
7290b57cec5SDimitry Andricdef VSRB   : VX1_Int_Ty< 516, "vsrb" , int_ppc_altivec_vsrb , v16i8>;
7300b57cec5SDimitry Andricdef VSRH   : VX1_Int_Ty< 580, "vsrh" , int_ppc_altivec_vsrh , v8i16>;
7310b57cec5SDimitry Andricdef VSRW   : VX1_Int_Ty< 644, "vsrw" , int_ppc_altivec_vsrw , v4i32>;
7320b57cec5SDimitry Andric
7330b57cec5SDimitry Andric
734*06c3fb27SDimitry Andricdef VSPLTISB : VXForm_3<780, (outs vrrc:$VD), (ins s5imm:$IMM),
735*06c3fb27SDimitry Andric                       "vspltisb $VD, $IMM", IIC_VecPerm,
736*06c3fb27SDimitry Andric                       [(set v16i8:$VD, (v16i8 vecspltisb:$IMM))]>;
737*06c3fb27SDimitry Andricdef VSPLTISH : VXForm_3<844, (outs vrrc:$VD), (ins s5imm:$IMM),
738*06c3fb27SDimitry Andric                       "vspltish $VD, $IMM", IIC_VecPerm,
739*06c3fb27SDimitry Andric                       [(set v8i16:$VD, (v8i16 vecspltish:$IMM))]>;
740*06c3fb27SDimitry Andricdef VSPLTISW : VXForm_3<908, (outs vrrc:$VD), (ins s5imm:$IMM),
741*06c3fb27SDimitry Andric                       "vspltisw $VD, $IMM", IIC_VecPerm,
742*06c3fb27SDimitry Andric                       [(set v4i32:$VD, (v4i32 vecspltisw:$IMM))]>;
7430b57cec5SDimitry Andric
7440b57cec5SDimitry Andric// Vector Pack.
7450b57cec5SDimitry Andricdef VPKPX   : VX1_Int_Ty2<782, "vpkpx", int_ppc_altivec_vpkpx,
7460b57cec5SDimitry Andric                          v8i16, v4i32>;
747e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
7480b57cec5SDimitry Andric  def VPKSHSS : VX1_Int_Ty2<398, "vpkshss", int_ppc_altivec_vpkshss,
7490b57cec5SDimitry Andric                            v16i8, v8i16>;
7500b57cec5SDimitry Andric  def VPKSHUS : VX1_Int_Ty2<270, "vpkshus", int_ppc_altivec_vpkshus,
7510b57cec5SDimitry Andric                            v16i8, v8i16>;
7520b57cec5SDimitry Andric  def VPKSWSS : VX1_Int_Ty2<462, "vpkswss", int_ppc_altivec_vpkswss,
7530b57cec5SDimitry Andric                            v8i16, v4i32>;
7540b57cec5SDimitry Andric  def VPKSWUS : VX1_Int_Ty2<334, "vpkswus", int_ppc_altivec_vpkswus,
7550b57cec5SDimitry Andric                            v8i16, v4i32>;
756e8d8bef9SDimitry Andric  def VPKUHUS : VX1_Int_Ty2<142, "vpkuhus", int_ppc_altivec_vpkuhus,
757e8d8bef9SDimitry Andric                            v16i8, v8i16>;
758e8d8bef9SDimitry Andric  def VPKUWUS : VX1_Int_Ty2<206, "vpkuwus", int_ppc_altivec_vpkuwus,
759e8d8bef9SDimitry Andric                            v8i16, v4i32>;
760e8d8bef9SDimitry Andric}
761*06c3fb27SDimitry Andricdef VPKUHUM : VXForm_1<14, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
762*06c3fb27SDimitry Andric                       "vpkuhum $VD, $VA, $VB", IIC_VecFP,
763*06c3fb27SDimitry Andric                       [(set v16i8:$VD,
764*06c3fb27SDimitry Andric                         (vpkuhum_shuffle v16i8:$VA, v16i8:$VB))]>;
765*06c3fb27SDimitry Andricdef VPKUWUM : VXForm_1<78, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
766*06c3fb27SDimitry Andric                       "vpkuwum $VD, $VA, $VB", IIC_VecFP,
767*06c3fb27SDimitry Andric                       [(set v16i8:$VD,
768*06c3fb27SDimitry Andric                         (vpkuwum_shuffle v16i8:$VA, v16i8:$VB))]>;
7690b57cec5SDimitry Andric
7700b57cec5SDimitry Andric// Vector Unpack.
7710b57cec5SDimitry Andricdef VUPKHPX : VX2_Int_Ty2<846, "vupkhpx", int_ppc_altivec_vupkhpx,
7720b57cec5SDimitry Andric                          v4i32, v8i16>;
7730b57cec5SDimitry Andricdef VUPKHSB : VX2_Int_Ty2<526, "vupkhsb", int_ppc_altivec_vupkhsb,
7740b57cec5SDimitry Andric                          v8i16, v16i8>;
7750b57cec5SDimitry Andricdef VUPKHSH : VX2_Int_Ty2<590, "vupkhsh", int_ppc_altivec_vupkhsh,
7760b57cec5SDimitry Andric                          v4i32, v8i16>;
7770b57cec5SDimitry Andricdef VUPKLPX : VX2_Int_Ty2<974, "vupklpx", int_ppc_altivec_vupklpx,
7780b57cec5SDimitry Andric                          v4i32, v8i16>;
7790b57cec5SDimitry Andricdef VUPKLSB : VX2_Int_Ty2<654, "vupklsb", int_ppc_altivec_vupklsb,
7800b57cec5SDimitry Andric                          v8i16, v16i8>;
7810b57cec5SDimitry Andricdef VUPKLSH : VX2_Int_Ty2<718, "vupklsh", int_ppc_altivec_vupklsh,
7820b57cec5SDimitry Andric                          v4i32, v8i16>;
7830b57cec5SDimitry Andric
7840b57cec5SDimitry Andric
7850b57cec5SDimitry Andric// Altivec Comparisons.
7860b57cec5SDimitry Andric
7870b57cec5SDimitry Andricclass VCMP<bits<10> xo, string asmstr, ValueType Ty>
788*06c3fb27SDimitry Andric  : VXRForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB), asmstr,
7890b57cec5SDimitry Andric              IIC_VecFPCompare,
790*06c3fb27SDimitry Andric              [(set Ty:$VD, (Ty (PPCvcmp Ty:$VA, Ty:$VB, xo)))]>;
791e8d8bef9SDimitry Andricclass VCMP_rec<bits<10> xo, string asmstr, ValueType Ty>
792*06c3fb27SDimitry Andric  : VXRForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB), asmstr,
7930b57cec5SDimitry Andric              IIC_VecFPCompare,
794*06c3fb27SDimitry Andric              [(set Ty:$VD, (Ty (PPCvcmp_rec Ty:$VA, Ty:$VB, xo)))]> {
7950b57cec5SDimitry Andric  let Defs = [CR6];
7960b57cec5SDimitry Andric  let RC = 1;
7970b57cec5SDimitry Andric}
7980b57cec5SDimitry Andric
7990b57cec5SDimitry Andric// f32 element comparisons.0
800*06c3fb27SDimitry Andricdef VCMPBFP   : VCMP <966, "vcmpbfp $VD, $VA, $VB"  , v4f32>;
801*06c3fb27SDimitry Andricdef VCMPBFP_rec  : VCMP_rec<966, "vcmpbfp. $VD, $VA, $VB" , v4f32>;
802*06c3fb27SDimitry Andricdef VCMPEQFP  : VCMP <198, "vcmpeqfp $VD, $VA, $VB" , v4f32>;
803*06c3fb27SDimitry Andricdef VCMPEQFP_rec : VCMP_rec<198, "vcmpeqfp. $VD, $VA, $VB", v4f32>;
804*06c3fb27SDimitry Andricdef VCMPGEFP  : VCMP <454, "vcmpgefp $VD, $VA, $VB" , v4f32>;
805*06c3fb27SDimitry Andricdef VCMPGEFP_rec : VCMP_rec<454, "vcmpgefp. $VD, $VA, $VB", v4f32>;
806*06c3fb27SDimitry Andricdef VCMPGTFP  : VCMP <710, "vcmpgtfp $VD, $VA, $VB" , v4f32>;
807*06c3fb27SDimitry Andricdef VCMPGTFP_rec : VCMP_rec<710, "vcmpgtfp. $VD, $VA, $VB", v4f32>;
8080b57cec5SDimitry Andric
8090b57cec5SDimitry Andric// i8 element comparisons.
810*06c3fb27SDimitry Andricdef VCMPEQUB  : VCMP <  6, "vcmpequb $VD, $VA, $VB" , v16i8>;
811*06c3fb27SDimitry Andricdef VCMPEQUB_rec : VCMP_rec<  6, "vcmpequb. $VD, $VA, $VB", v16i8>;
812*06c3fb27SDimitry Andricdef VCMPGTSB  : VCMP <774, "vcmpgtsb $VD, $VA, $VB" , v16i8>;
813*06c3fb27SDimitry Andricdef VCMPGTSB_rec : VCMP_rec<774, "vcmpgtsb. $VD, $VA, $VB", v16i8>;
814*06c3fb27SDimitry Andricdef VCMPGTUB  : VCMP <518, "vcmpgtub $VD, $VA, $VB" , v16i8>;
815*06c3fb27SDimitry Andricdef VCMPGTUB_rec : VCMP_rec<518, "vcmpgtub. $VD, $VA, $VB", v16i8>;
8160b57cec5SDimitry Andric
8170b57cec5SDimitry Andric// i16 element comparisons.
818*06c3fb27SDimitry Andricdef VCMPEQUH  : VCMP < 70, "vcmpequh $VD, $VA, $VB" , v8i16>;
819*06c3fb27SDimitry Andricdef VCMPEQUH_rec : VCMP_rec< 70, "vcmpequh. $VD, $VA, $VB", v8i16>;
820*06c3fb27SDimitry Andricdef VCMPGTSH  : VCMP <838, "vcmpgtsh $VD, $VA, $VB" , v8i16>;
821*06c3fb27SDimitry Andricdef VCMPGTSH_rec : VCMP_rec<838, "vcmpgtsh. $VD, $VA, $VB", v8i16>;
822*06c3fb27SDimitry Andricdef VCMPGTUH  : VCMP <582, "vcmpgtuh $VD, $VA, $VB" , v8i16>;
823*06c3fb27SDimitry Andricdef VCMPGTUH_rec : VCMP_rec<582, "vcmpgtuh. $VD, $VA, $VB", v8i16>;
8240b57cec5SDimitry Andric
8250b57cec5SDimitry Andric// i32 element comparisons.
826*06c3fb27SDimitry Andricdef VCMPEQUW  : VCMP <134, "vcmpequw $VD, $VA, $VB" , v4i32>;
827*06c3fb27SDimitry Andricdef VCMPEQUW_rec : VCMP_rec<134, "vcmpequw. $VD, $VA, $VB", v4i32>;
828*06c3fb27SDimitry Andricdef VCMPGTSW  : VCMP <902, "vcmpgtsw $VD, $VA, $VB" , v4i32>;
829*06c3fb27SDimitry Andricdef VCMPGTSW_rec : VCMP_rec<902, "vcmpgtsw. $VD, $VA, $VB", v4i32>;
830*06c3fb27SDimitry Andricdef VCMPGTUW  : VCMP <646, "vcmpgtuw $VD, $VA, $VB" , v4i32>;
831*06c3fb27SDimitry Andricdef VCMPGTUW_rec : VCMP_rec<646, "vcmpgtuw. $VD, $VA, $VB", v4i32>;
8320b57cec5SDimitry Andric
8330b57cec5SDimitry Andriclet isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
8340b57cec5SDimitry Andric    isReMaterializable = 1 in {
8350b57cec5SDimitry Andric
836*06c3fb27SDimitry Andricdef V_SET0B : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
837*06c3fb27SDimitry Andric                      "vxor $VD, $VD, $VD", IIC_VecFP,
838*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (v16i8 immAllZerosV))]>;
839*06c3fb27SDimitry Andricdef V_SET0H : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
840*06c3fb27SDimitry Andric                      "vxor $VD, $VD, $VD", IIC_VecFP,
841*06c3fb27SDimitry Andric                      [(set v8i16:$VD, (v8i16 immAllZerosV))]>;
842*06c3fb27SDimitry Andricdef V_SET0  : VXForm_setzero<1220, (outs vrrc:$VD), (ins),
843*06c3fb27SDimitry Andric                      "vxor $VD, $VD, $VD", IIC_VecFP,
844*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (v4i32 immAllZerosV))]>;
8450b57cec5SDimitry Andric
8460b57cec5SDimitry Andriclet IMM=-1 in {
847*06c3fb27SDimitry Andricdef V_SETALLONESB : VXForm_3<908, (outs vrrc:$VD), (ins),
848*06c3fb27SDimitry Andric                      "vspltisw $VD, -1", IIC_VecFP,
849*06c3fb27SDimitry Andric                      [(set v16i8:$VD, (v16i8 immAllOnesV))]>;
850*06c3fb27SDimitry Andricdef V_SETALLONESH : VXForm_3<908, (outs vrrc:$VD), (ins),
851*06c3fb27SDimitry Andric                      "vspltisw $VD, -1", IIC_VecFP,
852*06c3fb27SDimitry Andric                      [(set v8i16:$VD, (v8i16 immAllOnesV))]>;
853*06c3fb27SDimitry Andricdef V_SETALLONES  : VXForm_3<908, (outs vrrc:$VD), (ins),
854*06c3fb27SDimitry Andric                      "vspltisw $VD, -1", IIC_VecFP,
855*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (v4i32 immAllOnesV))]>;
8560b57cec5SDimitry Andric}
8570b57cec5SDimitry Andric}
8580b57cec5SDimitry Andric} // VALU Operations.
8590b57cec5SDimitry Andric
8600b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8610b57cec5SDimitry Andric// Additional Altivec Patterns
8620b57cec5SDimitry Andric//
8630b57cec5SDimitry Andric
8640b57cec5SDimitry Andric// Extended mnemonics
8650b57cec5SDimitry Andricdef : InstAlias<"vmr $vD, $vA", (VOR vrrc:$vD, vrrc:$vA, vrrc:$vA)>;
8660b57cec5SDimitry Andricdef : InstAlias<"vnot $vD, $vA", (VNOR vrrc:$vD, vrrc:$vA, vrrc:$vA)>;
8670b57cec5SDimitry Andric
868fe6060f1SDimitry Andric// This is a nop on all supported architectures and the AIX assembler
869fe6060f1SDimitry Andric// doesn't support it (and will not be updated to support it).
870fe6060f1SDimitry Andriclet Predicates = [IsAIX] in
871fe6060f1SDimitry Andricdef : Pat<(int_ppc_altivec_dssall), (NOP)>;
872fe6060f1SDimitry Andriclet Predicates = [NotAIX] in
873fe6060f1SDimitry Andricdef : Pat<(int_ppc_altivec_dssall), (DSSALL)>;
874fe6060f1SDimitry Andric
875480093f4SDimitry Andric// Rotates.
876480093f4SDimitry Andricdef : Pat<(v16i8 (rotl v16i8:$vA, v16i8:$vB)),
877480093f4SDimitry Andric          (v16i8 (VRLB v16i8:$vA, v16i8:$vB))>;
878480093f4SDimitry Andricdef : Pat<(v8i16 (rotl v8i16:$vA, v8i16:$vB)),
879480093f4SDimitry Andric          (v8i16 (VRLH v8i16:$vA, v8i16:$vB))>;
880480093f4SDimitry Andricdef : Pat<(v4i32 (rotl v4i32:$vA, v4i32:$vB)),
881480093f4SDimitry Andric          (v4i32 (VRLW v4i32:$vA, v4i32:$vB))>;
882480093f4SDimitry Andric
8835ffd83dbSDimitry Andric// Multiply
8845ffd83dbSDimitry Andricdef : Pat<(mul v8i16:$vA, v8i16:$vB), (VMLADDUHM $vA, $vB, (v8i16(V_SET0H)))>;
8855ffd83dbSDimitry Andric
8865ffd83dbSDimitry Andric// Add
8875ffd83dbSDimitry Andricdef : Pat<(add (mul v8i16:$vA, v8i16:$vB), v8i16:$vC), (VMLADDUHM $vA, $vB, $vC)>;
8885ffd83dbSDimitry Andric
8895ffd83dbSDimitry Andric// Saturating adds/subtracts.
8905ffd83dbSDimitry Andricdef : Pat<(v16i8 (saddsat v16i8:$vA, v16i8:$vB)), (v16i8 (VADDSBS $vA, $vB))>;
8915ffd83dbSDimitry Andricdef : Pat<(v16i8 (uaddsat v16i8:$vA, v16i8:$vB)), (v16i8 (VADDUBS $vA, $vB))>;
8925ffd83dbSDimitry Andricdef : Pat<(v8i16 (saddsat v8i16:$vA, v8i16:$vB)), (v8i16 (VADDSHS $vA, $vB))>;
8935ffd83dbSDimitry Andricdef : Pat<(v8i16 (uaddsat v8i16:$vA, v8i16:$vB)), (v8i16 (VADDUHS $vA, $vB))>;
8945ffd83dbSDimitry Andricdef : Pat<(v4i32 (saddsat v4i32:$vA, v4i32:$vB)), (v4i32 (VADDSWS $vA, $vB))>;
8955ffd83dbSDimitry Andricdef : Pat<(v4i32 (uaddsat v4i32:$vA, v4i32:$vB)), (v4i32 (VADDUWS $vA, $vB))>;
8965ffd83dbSDimitry Andricdef : Pat<(v16i8 (ssubsat v16i8:$vA, v16i8:$vB)), (v16i8 (VSUBSBS $vA, $vB))>;
8975ffd83dbSDimitry Andricdef : Pat<(v16i8 (usubsat v16i8:$vA, v16i8:$vB)), (v16i8 (VSUBUBS $vA, $vB))>;
8985ffd83dbSDimitry Andricdef : Pat<(v8i16 (ssubsat v8i16:$vA, v8i16:$vB)), (v8i16 (VSUBSHS $vA, $vB))>;
8995ffd83dbSDimitry Andricdef : Pat<(v8i16 (usubsat v8i16:$vA, v8i16:$vB)), (v8i16 (VSUBUHS $vA, $vB))>;
9005ffd83dbSDimitry Andricdef : Pat<(v4i32 (ssubsat v4i32:$vA, v4i32:$vB)), (v4i32 (VSUBSWS $vA, $vB))>;
9015ffd83dbSDimitry Andricdef : Pat<(v4i32 (usubsat v4i32:$vA, v4i32:$vB)), (v4i32 (VSUBUWS $vA, $vB))>;
9025ffd83dbSDimitry Andric
9030b57cec5SDimitry Andric// Loads.
904fe6060f1SDimitry Andricdef : Pat<(v4i32 (load ForceXForm:$src)), (LVX ForceXForm:$src)>;
9050b57cec5SDimitry Andric
9060b57cec5SDimitry Andric// Stores.
907fe6060f1SDimitry Andricdef : Pat<(store v4i32:$rS, ForceXForm:$dst),
908fe6060f1SDimitry Andric          (STVX $rS, ForceXForm:$dst)>;
9090b57cec5SDimitry Andric
9100b57cec5SDimitry Andric// Bit conversions.
9110b57cec5SDimitry Andricdef : Pat<(v16i8 (bitconvert (v8i16 VRRC:$src))), (v16i8 VRRC:$src)>;
9120b57cec5SDimitry Andricdef : Pat<(v16i8 (bitconvert (v4i32 VRRC:$src))), (v16i8 VRRC:$src)>;
9130b57cec5SDimitry Andricdef : Pat<(v16i8 (bitconvert (v4f32 VRRC:$src))), (v16i8 VRRC:$src)>;
9140b57cec5SDimitry Andricdef : Pat<(v16i8 (bitconvert (v2i64 VRRC:$src))), (v16i8 VRRC:$src)>;
9150b57cec5SDimitry Andricdef : Pat<(v16i8 (bitconvert (v1i128 VRRC:$src))), (v16i8 VRRC:$src)>;
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andricdef : Pat<(v8i16 (bitconvert (v16i8 VRRC:$src))), (v8i16 VRRC:$src)>;
9180b57cec5SDimitry Andricdef : Pat<(v8i16 (bitconvert (v4i32 VRRC:$src))), (v8i16 VRRC:$src)>;
9190b57cec5SDimitry Andricdef : Pat<(v8i16 (bitconvert (v4f32 VRRC:$src))), (v8i16 VRRC:$src)>;
9200b57cec5SDimitry Andricdef : Pat<(v8i16 (bitconvert (v2i64 VRRC:$src))), (v8i16 VRRC:$src)>;
9210b57cec5SDimitry Andricdef : Pat<(v8i16 (bitconvert (v1i128 VRRC:$src))), (v8i16 VRRC:$src)>;
9220b57cec5SDimitry Andric
9230b57cec5SDimitry Andricdef : Pat<(v4i32 (bitconvert (v16i8 VRRC:$src))), (v4i32 VRRC:$src)>;
9240b57cec5SDimitry Andricdef : Pat<(v4i32 (bitconvert (v8i16 VRRC:$src))), (v4i32 VRRC:$src)>;
9250b57cec5SDimitry Andricdef : Pat<(v4i32 (bitconvert (v4f32 VRRC:$src))), (v4i32 VRRC:$src)>;
9260b57cec5SDimitry Andricdef : Pat<(v4i32 (bitconvert (v2i64 VRRC:$src))), (v4i32 VRRC:$src)>;
9270b57cec5SDimitry Andricdef : Pat<(v4i32 (bitconvert (v1i128 VRRC:$src))), (v4i32 VRRC:$src)>;
9280b57cec5SDimitry Andric
9290b57cec5SDimitry Andricdef : Pat<(v4f32 (bitconvert (v16i8 VRRC:$src))), (v4f32 VRRC:$src)>;
9300b57cec5SDimitry Andricdef : Pat<(v4f32 (bitconvert (v8i16 VRRC:$src))), (v4f32 VRRC:$src)>;
9310b57cec5SDimitry Andricdef : Pat<(v4f32 (bitconvert (v4i32 VRRC:$src))), (v4f32 VRRC:$src)>;
9320b57cec5SDimitry Andricdef : Pat<(v4f32 (bitconvert (v2i64 VRRC:$src))), (v4f32 VRRC:$src)>;
9330b57cec5SDimitry Andricdef : Pat<(v4f32 (bitconvert (v1i128 VRRC:$src))), (v4f32 VRRC:$src)>;
9340b57cec5SDimitry Andric
9350b57cec5SDimitry Andricdef : Pat<(v2i64 (bitconvert (v16i8 VRRC:$src))), (v2i64 VRRC:$src)>;
9360b57cec5SDimitry Andricdef : Pat<(v2i64 (bitconvert (v8i16 VRRC:$src))), (v2i64 VRRC:$src)>;
9370b57cec5SDimitry Andricdef : Pat<(v2i64 (bitconvert (v4i32 VRRC:$src))), (v2i64 VRRC:$src)>;
9380b57cec5SDimitry Andricdef : Pat<(v2i64 (bitconvert (v4f32 VRRC:$src))), (v2i64 VRRC:$src)>;
9390b57cec5SDimitry Andricdef : Pat<(v2i64 (bitconvert (v1i128 VRRC:$src))), (v2i64 VRRC:$src)>;
9400b57cec5SDimitry Andric
9410b57cec5SDimitry Andricdef : Pat<(v1i128 (bitconvert (v16i8 VRRC:$src))), (v1i128 VRRC:$src)>;
9420b57cec5SDimitry Andricdef : Pat<(v1i128 (bitconvert (v8i16 VRRC:$src))), (v1i128 VRRC:$src)>;
9430b57cec5SDimitry Andricdef : Pat<(v1i128 (bitconvert (v4i32 VRRC:$src))), (v1i128 VRRC:$src)>;
9440b57cec5SDimitry Andricdef : Pat<(v1i128 (bitconvert (v4f32 VRRC:$src))), (v1i128 VRRC:$src)>;
9450b57cec5SDimitry Andricdef : Pat<(v1i128 (bitconvert (v2i64 VRRC:$src))), (v1i128 VRRC:$src)>;
9460b57cec5SDimitry Andric
947e8d8bef9SDimitry Andricdef : Pat<(f128 (bitconvert (v16i8 VRRC:$src))), (f128 VRRC:$src)>;
948e8d8bef9SDimitry Andricdef : Pat<(f128 (bitconvert (v8i16 VRRC:$src))), (f128 VRRC:$src)>;
949e8d8bef9SDimitry Andricdef : Pat<(f128 (bitconvert (v4i32 VRRC:$src))), (f128 VRRC:$src)>;
950e8d8bef9SDimitry Andricdef : Pat<(f128 (bitconvert (v4f32 VRRC:$src))), (f128 VRRC:$src)>;
951e8d8bef9SDimitry Andricdef : Pat<(f128 (bitconvert (v2f64 VRRC:$src))), (f128 VRRC:$src)>;
952e8d8bef9SDimitry Andric
953e8d8bef9SDimitry Andricdef : Pat<(v16i8 (bitconvert (f128 VRRC:$src))), (v16i8 VRRC:$src)>;
954e8d8bef9SDimitry Andricdef : Pat<(v8i16 (bitconvert (f128 VRRC:$src))), (v8i16 VRRC:$src)>;
955e8d8bef9SDimitry Andricdef : Pat<(v4i32 (bitconvert (f128 VRRC:$src))), (v4i32 VRRC:$src)>;
956e8d8bef9SDimitry Andricdef : Pat<(v4f32 (bitconvert (f128 VRRC:$src))), (v4f32 VRRC:$src)>;
957e8d8bef9SDimitry Andricdef : Pat<(v2f64 (bitconvert (f128 VRRC:$src))), (v2f64 VRRC:$src)>;
958e8d8bef9SDimitry Andric
9590b57cec5SDimitry Andric// Max/Min
9600b57cec5SDimitry Andricdef : Pat<(v16i8 (umax v16i8:$src1, v16i8:$src2)),
9610b57cec5SDimitry Andric          (v16i8 (VMAXUB $src1, $src2))>;
9620b57cec5SDimitry Andricdef : Pat<(v16i8 (smax v16i8:$src1, v16i8:$src2)),
9630b57cec5SDimitry Andric          (v16i8 (VMAXSB $src1, $src2))>;
9640b57cec5SDimitry Andricdef : Pat<(v8i16 (umax v8i16:$src1, v8i16:$src2)),
9650b57cec5SDimitry Andric          (v8i16 (VMAXUH $src1, $src2))>;
9660b57cec5SDimitry Andricdef : Pat<(v8i16 (smax v8i16:$src1, v8i16:$src2)),
9670b57cec5SDimitry Andric          (v8i16 (VMAXSH $src1, $src2))>;
9680b57cec5SDimitry Andricdef : Pat<(v4i32 (umax v4i32:$src1, v4i32:$src2)),
9690b57cec5SDimitry Andric          (v4i32 (VMAXUW $src1, $src2))>;
9700b57cec5SDimitry Andricdef : Pat<(v4i32 (smax v4i32:$src1, v4i32:$src2)),
9710b57cec5SDimitry Andric          (v4i32 (VMAXSW $src1, $src2))>;
9720b57cec5SDimitry Andricdef : Pat<(v16i8 (umin v16i8:$src1, v16i8:$src2)),
9730b57cec5SDimitry Andric          (v16i8 (VMINUB $src1, $src2))>;
9740b57cec5SDimitry Andricdef : Pat<(v16i8 (smin v16i8:$src1, v16i8:$src2)),
9750b57cec5SDimitry Andric          (v16i8 (VMINSB $src1, $src2))>;
9760b57cec5SDimitry Andricdef : Pat<(v8i16 (umin v8i16:$src1, v8i16:$src2)),
9770b57cec5SDimitry Andric          (v8i16 (VMINUH $src1, $src2))>;
9780b57cec5SDimitry Andricdef : Pat<(v8i16 (smin v8i16:$src1, v8i16:$src2)),
9790b57cec5SDimitry Andric          (v8i16 (VMINSH $src1, $src2))>;
9800b57cec5SDimitry Andricdef : Pat<(v4i32 (umin v4i32:$src1, v4i32:$src2)),
9810b57cec5SDimitry Andric          (v4i32 (VMINUW $src1, $src2))>;
9820b57cec5SDimitry Andricdef : Pat<(v4i32 (smin v4i32:$src1, v4i32:$src2)),
9830b57cec5SDimitry Andric          (v4i32 (VMINSW $src1, $src2))>;
9840b57cec5SDimitry Andric
9850b57cec5SDimitry Andric// Shuffles.
9860b57cec5SDimitry Andric
9870b57cec5SDimitry Andric// Match vsldoi(x,x), vpkuwum(x,x), vpkuhum(x,x)
9880b57cec5SDimitry Andricdef:Pat<(vsldoi_unary_shuffle:$in v16i8:$vA, undef),
9890b57cec5SDimitry Andric        (VSLDOI $vA, $vA, (VSLDOI_unary_get_imm $in))>;
9900b57cec5SDimitry Andricdef:Pat<(vpkuwum_unary_shuffle v16i8:$vA, undef),
9910b57cec5SDimitry Andric        (VPKUWUM $vA, $vA)>;
9920b57cec5SDimitry Andricdef:Pat<(vpkuhum_unary_shuffle v16i8:$vA, undef),
9930b57cec5SDimitry Andric        (VPKUHUM $vA, $vA)>;
9940b57cec5SDimitry Andricdef:Pat<(vsldoi_shuffle:$SH v16i8:$vA, v16i8:$vB),
9950b57cec5SDimitry Andric        (VSLDOI v16i8:$vA, v16i8:$vB, (VSLDOI_get_imm $SH))>;
9960b57cec5SDimitry Andric
9970b57cec5SDimitry Andric
9980b57cec5SDimitry Andric// Match vsldoi(y,x), vpkuwum(y,x), vpkuhum(y,x), i.e., swapped operands.
9990b57cec5SDimitry Andric// These fragments are matched for little-endian, where the inputs must
10000b57cec5SDimitry Andric// be swapped for correct semantics.
10010b57cec5SDimitry Andricdef:Pat<(vsldoi_swapped_shuffle:$in v16i8:$vA, v16i8:$vB),
10020b57cec5SDimitry Andric        (VSLDOI $vB, $vA, (VSLDOI_swapped_get_imm $in))>;
10030b57cec5SDimitry Andricdef:Pat<(vpkuwum_swapped_shuffle v16i8:$vA, v16i8:$vB),
10040b57cec5SDimitry Andric        (VPKUWUM $vB, $vA)>;
10050b57cec5SDimitry Andricdef:Pat<(vpkuhum_swapped_shuffle v16i8:$vA, v16i8:$vB),
10060b57cec5SDimitry Andric        (VPKUHUM $vB, $vA)>;
10070b57cec5SDimitry Andric
10080b57cec5SDimitry Andric// Match vmrg*(x,x)
10090b57cec5SDimitry Andricdef:Pat<(vmrglb_unary_shuffle v16i8:$vA, undef),
10100b57cec5SDimitry Andric        (VMRGLB $vA, $vA)>;
10110b57cec5SDimitry Andricdef:Pat<(vmrglh_unary_shuffle v16i8:$vA, undef),
10120b57cec5SDimitry Andric        (VMRGLH $vA, $vA)>;
10130b57cec5SDimitry Andricdef:Pat<(vmrglw_unary_shuffle v16i8:$vA, undef),
10140b57cec5SDimitry Andric        (VMRGLW $vA, $vA)>;
10150b57cec5SDimitry Andricdef:Pat<(vmrghb_unary_shuffle v16i8:$vA, undef),
10160b57cec5SDimitry Andric        (VMRGHB $vA, $vA)>;
10170b57cec5SDimitry Andricdef:Pat<(vmrghh_unary_shuffle v16i8:$vA, undef),
10180b57cec5SDimitry Andric        (VMRGHH $vA, $vA)>;
10190b57cec5SDimitry Andricdef:Pat<(vmrghw_unary_shuffle v16i8:$vA, undef),
10200b57cec5SDimitry Andric        (VMRGHW $vA, $vA)>;
10210b57cec5SDimitry Andric
10220b57cec5SDimitry Andric// Match vmrg*(y,x), i.e., swapped operands.  These fragments
10230b57cec5SDimitry Andric// are matched for little-endian, where the inputs must be
10240b57cec5SDimitry Andric// swapped for correct semantics.
10250b57cec5SDimitry Andricdef:Pat<(vmrglb_swapped_shuffle v16i8:$vA, v16i8:$vB),
10260b57cec5SDimitry Andric        (VMRGLB $vB, $vA)>;
10270b57cec5SDimitry Andricdef:Pat<(vmrglh_swapped_shuffle v16i8:$vA, v16i8:$vB),
10280b57cec5SDimitry Andric        (VMRGLH $vB, $vA)>;
10290b57cec5SDimitry Andricdef:Pat<(vmrglw_swapped_shuffle v16i8:$vA, v16i8:$vB),
10300b57cec5SDimitry Andric        (VMRGLW $vB, $vA)>;
10310b57cec5SDimitry Andricdef:Pat<(vmrghb_swapped_shuffle v16i8:$vA, v16i8:$vB),
10320b57cec5SDimitry Andric        (VMRGHB $vB, $vA)>;
10330b57cec5SDimitry Andricdef:Pat<(vmrghh_swapped_shuffle v16i8:$vA, v16i8:$vB),
10340b57cec5SDimitry Andric        (VMRGHH $vB, $vA)>;
10350b57cec5SDimitry Andricdef:Pat<(vmrghw_swapped_shuffle v16i8:$vA, v16i8:$vB),
10360b57cec5SDimitry Andric        (VMRGHW $vB, $vA)>;
10370b57cec5SDimitry Andric
10380b57cec5SDimitry Andric// Logical Operations
1039fe6060f1SDimitry Andricdef : Pat<(vnot v4i32:$vA), (VNOR $vA, $vA)>;
10400b57cec5SDimitry Andric
1041fe6060f1SDimitry Andricdef : Pat<(vnot (or v4i32:$A, v4i32:$B)),
10420b57cec5SDimitry Andric          (VNOR $A, $B)>;
1043fe6060f1SDimitry Andricdef : Pat<(and v4i32:$A, (vnot v4i32:$B)),
10440b57cec5SDimitry Andric          (VANDC $A, $B)>;
10450b57cec5SDimitry Andric
10460b57cec5SDimitry Andricdef : Pat<(fmul v4f32:$vA, v4f32:$vB),
10470b57cec5SDimitry Andric          (VMADDFP $vA, $vB,
10480b57cec5SDimitry Andric             (v4i32 (VSLW (v4i32 (V_SETALLONES)), (v4i32 (V_SETALLONES)))))>;
10490b57cec5SDimitry Andric
10505ffd83dbSDimitry Andricdef : Pat<(PPCfnmsub v4f32:$A, v4f32:$B, v4f32:$C),
10510b57cec5SDimitry Andric          (VNMSUBFP $A, $B, $C)>;
10520b57cec5SDimitry Andric
10530b57cec5SDimitry Andricdef : Pat<(int_ppc_altivec_vmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
10540b57cec5SDimitry Andric          (VMADDFP $A, $B, $C)>;
10550b57cec5SDimitry Andricdef : Pat<(int_ppc_altivec_vnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
10560b57cec5SDimitry Andric          (VNMSUBFP $A, $B, $C)>;
10570b57cec5SDimitry Andric
10580b57cec5SDimitry Andricdef : Pat<(PPCvperm v16i8:$vA, v16i8:$vB, v16i8:$vC),
10590b57cec5SDimitry Andric          (VPERM $vA, $vB, $vC)>;
1060bdd1243dSDimitry Andricdef : Pat<(PPCvperm v2f64:$vA, v2f64:$vB, v16i8:$vC),
1061bdd1243dSDimitry Andric          (VPERM $vA, $vB, $vC)>;
10620b57cec5SDimitry Andric
10630b57cec5SDimitry Andricdef : Pat<(PPCfre v4f32:$A), (VREFP $A)>;
10640b57cec5SDimitry Andricdef : Pat<(PPCfrsqrte v4f32:$A), (VRSQRTEFP $A)>;
10650b57cec5SDimitry Andric
10660b57cec5SDimitry Andric// Vector shifts
10670b57cec5SDimitry Andricdef : Pat<(v16i8 (shl v16i8:$vA, v16i8:$vB)),
10680b57cec5SDimitry Andric          (v16i8 (VSLB $vA, $vB))>;
10690b57cec5SDimitry Andricdef : Pat<(v8i16 (shl v8i16:$vA, v8i16:$vB)),
10700b57cec5SDimitry Andric          (v8i16 (VSLH $vA, $vB))>;
10710b57cec5SDimitry Andricdef : Pat<(v4i32 (shl v4i32:$vA, v4i32:$vB)),
10720b57cec5SDimitry Andric          (v4i32 (VSLW $vA, $vB))>;
10730b57cec5SDimitry Andricdef : Pat<(v1i128 (shl v1i128:$vA, v1i128:$vB)),
10740b57cec5SDimitry Andric          (v1i128 (VSL (v16i8 (VSLO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
10750b57cec5SDimitry Andricdef : Pat<(v16i8 (PPCshl v16i8:$vA, v16i8:$vB)),
10760b57cec5SDimitry Andric          (v16i8 (VSLB $vA, $vB))>;
10770b57cec5SDimitry Andricdef : Pat<(v8i16 (PPCshl v8i16:$vA, v8i16:$vB)),
10780b57cec5SDimitry Andric          (v8i16 (VSLH $vA, $vB))>;
10790b57cec5SDimitry Andricdef : Pat<(v4i32 (PPCshl v4i32:$vA, v4i32:$vB)),
10800b57cec5SDimitry Andric          (v4i32 (VSLW $vA, $vB))>;
10810b57cec5SDimitry Andricdef : Pat<(v1i128 (PPCshl v1i128:$vA, v1i128:$vB)),
10820b57cec5SDimitry Andric          (v1i128 (VSL (v16i8 (VSLO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
10830b57cec5SDimitry Andric
10840b57cec5SDimitry Andricdef : Pat<(v16i8 (srl v16i8:$vA, v16i8:$vB)),
10850b57cec5SDimitry Andric          (v16i8 (VSRB $vA, $vB))>;
10860b57cec5SDimitry Andricdef : Pat<(v8i16 (srl v8i16:$vA, v8i16:$vB)),
10870b57cec5SDimitry Andric          (v8i16 (VSRH $vA, $vB))>;
10880b57cec5SDimitry Andricdef : Pat<(v4i32 (srl v4i32:$vA, v4i32:$vB)),
10890b57cec5SDimitry Andric          (v4i32 (VSRW $vA, $vB))>;
10900b57cec5SDimitry Andricdef : Pat<(v1i128 (srl v1i128:$vA, v1i128:$vB)),
10910b57cec5SDimitry Andric          (v1i128 (VSR (v16i8 (VSRO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
10920b57cec5SDimitry Andricdef : Pat<(v16i8 (PPCsrl v16i8:$vA, v16i8:$vB)),
10930b57cec5SDimitry Andric          (v16i8 (VSRB $vA, $vB))>;
10940b57cec5SDimitry Andricdef : Pat<(v8i16 (PPCsrl v8i16:$vA, v8i16:$vB)),
10950b57cec5SDimitry Andric          (v8i16 (VSRH $vA, $vB))>;
10960b57cec5SDimitry Andricdef : Pat<(v4i32 (PPCsrl v4i32:$vA, v4i32:$vB)),
10970b57cec5SDimitry Andric          (v4i32 (VSRW $vA, $vB))>;
10980b57cec5SDimitry Andricdef : Pat<(v1i128 (PPCsrl v1i128:$vA, v1i128:$vB)),
10990b57cec5SDimitry Andric          (v1i128 (VSR (v16i8 (VSRO $vA, $vB)), (v16i8 (VSPLTB 15, $vB))))>;
11000b57cec5SDimitry Andric
11010b57cec5SDimitry Andricdef : Pat<(v16i8 (sra v16i8:$vA, v16i8:$vB)),
11020b57cec5SDimitry Andric          (v16i8 (VSRAB $vA, $vB))>;
11030b57cec5SDimitry Andricdef : Pat<(v8i16 (sra v8i16:$vA, v8i16:$vB)),
11040b57cec5SDimitry Andric          (v8i16 (VSRAH $vA, $vB))>;
11050b57cec5SDimitry Andricdef : Pat<(v4i32 (sra v4i32:$vA, v4i32:$vB)),
11060b57cec5SDimitry Andric          (v4i32 (VSRAW $vA, $vB))>;
11070b57cec5SDimitry Andricdef : Pat<(v16i8 (PPCsra v16i8:$vA, v16i8:$vB)),
11080b57cec5SDimitry Andric          (v16i8 (VSRAB $vA, $vB))>;
11090b57cec5SDimitry Andricdef : Pat<(v8i16 (PPCsra v8i16:$vA, v8i16:$vB)),
11100b57cec5SDimitry Andric          (v8i16 (VSRAH $vA, $vB))>;
11110b57cec5SDimitry Andricdef : Pat<(v4i32 (PPCsra v4i32:$vA, v4i32:$vB)),
11120b57cec5SDimitry Andric          (v4i32 (VSRAW $vA, $vB))>;
11130b57cec5SDimitry Andric
11140b57cec5SDimitry Andric// Float to integer and integer to float conversions
11150b57cec5SDimitry Andricdef : Pat<(v4i32 (fp_to_sint v4f32:$vA)),
11160b57cec5SDimitry Andric           (VCTSXS_0 $vA)>;
11170b57cec5SDimitry Andricdef : Pat<(v4i32 (fp_to_uint v4f32:$vA)),
11180b57cec5SDimitry Andric           (VCTUXS_0 $vA)>;
11190b57cec5SDimitry Andricdef : Pat<(v4f32 (sint_to_fp v4i32:$vA)),
11200b57cec5SDimitry Andric           (VCFSX_0 $vA)>;
11210b57cec5SDimitry Andricdef : Pat<(v4f32 (uint_to_fp v4i32:$vA)),
11220b57cec5SDimitry Andric           (VCFUX_0 $vA)>;
11230b57cec5SDimitry Andric
11240b57cec5SDimitry Andric// Floating-point rounding
11250b57cec5SDimitry Andricdef : Pat<(v4f32 (ffloor v4f32:$vA)),
11260b57cec5SDimitry Andric          (VRFIM $vA)>;
11270b57cec5SDimitry Andricdef : Pat<(v4f32 (fceil v4f32:$vA)),
11280b57cec5SDimitry Andric          (VRFIP $vA)>;
11290b57cec5SDimitry Andricdef : Pat<(v4f32 (ftrunc v4f32:$vA)),
11300b57cec5SDimitry Andric          (VRFIZ $vA)>;
11310b57cec5SDimitry Andricdef : Pat<(v4f32 (fnearbyint v4f32:$vA)),
11320b57cec5SDimitry Andric          (VRFIN $vA)>;
11330b57cec5SDimitry Andric
11340b57cec5SDimitry Andric// Vector selection
11350b57cec5SDimitry Andricdef : Pat<(v16i8 (vselect v16i8:$vA, v16i8:$vB, v16i8:$vC)),
11360b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11370b57cec5SDimitry Andricdef : Pat<(v8i16 (vselect v8i16:$vA, v8i16:$vB, v8i16:$vC)),
11380b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11390b57cec5SDimitry Andricdef : Pat<(v4i32 (vselect v4i32:$vA, v4i32:$vB, v4i32:$vC)),
11400b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11410b57cec5SDimitry Andricdef : Pat<(v2i64 (vselect v2i64:$vA, v2i64:$vB, v2i64:$vC)),
11420b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11430b57cec5SDimitry Andricdef : Pat<(v4f32 (vselect v4i32:$vA, v4f32:$vB, v4f32:$vC)),
11440b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11450b57cec5SDimitry Andricdef : Pat<(v2f64 (vselect v2i64:$vA, v2f64:$vB, v2f64:$vC)),
11460b57cec5SDimitry Andric          (VSEL $vC, $vB, $vA)>;
1147fe6060f1SDimitry Andricdef : Pat<(v1i128 (vselect v1i128:$vA, v1i128:$vB, v1i128:$vC)),
1148fe6060f1SDimitry Andric          (VSEL $vC, $vB, $vA)>;
11490b57cec5SDimitry Andric
1150480093f4SDimitry Andric// Vector Integer Average Instructions
1151fe6060f1SDimitry Andricdef : Pat<(v4i32 (sra (sub v4i32:$vA, (vnot v4i32:$vB)),
1152480093f4SDimitry Andric          (v4i32 (immEQOneV)))), (v4i32 (VAVGSW $vA, $vB))>;
1153fe6060f1SDimitry Andricdef : Pat<(v8i16 (sra (sub v8i16:$vA, (v8i16 (bitconvert(vnot v4i32:$vB)))),
1154480093f4SDimitry Andric          (v8i16 (immEQOneV)))), (v8i16 (VAVGSH $vA, $vB))>;
1155fe6060f1SDimitry Andricdef : Pat<(v16i8 (sra (sub v16i8:$vA, (v16i8 (bitconvert(vnot v4i32:$vB)))),
1156480093f4SDimitry Andric          (v16i8 (immEQOneV)))), (v16i8 (VAVGSB $vA, $vB))>;
1157fe6060f1SDimitry Andricdef : Pat<(v4i32 (srl (sub v4i32:$vA, (vnot v4i32:$vB)),
1158480093f4SDimitry Andric          (v4i32 (immEQOneV)))), (v4i32 (VAVGUW $vA, $vB))>;
1159fe6060f1SDimitry Andricdef : Pat<(v8i16 (srl (sub v8i16:$vA, (v8i16 (bitconvert(vnot v4i32:$vB)))),
1160480093f4SDimitry Andric          (v8i16 (immEQOneV)))), (v8i16 (VAVGUH $vA, $vB))>;
1161fe6060f1SDimitry Andricdef : Pat<(v16i8 (srl (sub v16i8:$vA, (v16i8 (bitconvert(vnot v4i32:$vB)))),
1162480093f4SDimitry Andric          (v16i8 (immEQOneV)))), (v16i8 (VAVGUB $vA, $vB))>;
1163480093f4SDimitry Andric
1164*06c3fb27SDimitry Andricdef : Pat<(v16i8 (shl v16i8:$vA, (v16i8 (immEQOneV)))),
1165*06c3fb27SDimitry Andric          (v16i8 (VADDUBM $vA, $vA))>;
1166*06c3fb27SDimitry Andricdef : Pat<(v8i16 (shl v8i16:$vA, (v8i16 (immEQOneV)))),
1167*06c3fb27SDimitry Andric          (v8i16 (VADDUHM $vA, $vA))>;
1168*06c3fb27SDimitry Andricdef : Pat<(v4i32 (shl v4i32:$vA, (v4i32 (immEQOneV)))),
1169*06c3fb27SDimitry Andric          (v4i32 (VADDUWM $vA, $vA))>;
1170*06c3fb27SDimitry Andric
11710b57cec5SDimitry Andric} // end HasAltivec
11720b57cec5SDimitry Andric
11734824e7fdSDimitry Andric// [PO VRT VRA VRB 1 PS XO], "_o" means CR6 is set.
11744824e7fdSDimitry Andricclass VX_VT5_VA5_VB5_PS1_XO9_o<bits<9> xo, string opc, list<dag> pattern>
11754824e7fdSDimitry Andric  : VX_RD5_RSp5_PS1_XO9<xo,
1176*06c3fb27SDimitry Andric                   (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, u1imm:$PS),
1177*06c3fb27SDimitry Andric                   !strconcat(opc, " $VD, $VA, $VB, $PS"), IIC_VecFP, pattern> {
11784824e7fdSDimitry Andric  let Defs = [CR6];
11794824e7fdSDimitry Andric}
11804824e7fdSDimitry Andric
11814824e7fdSDimitry Andric// [PO VRT VRA VRB 1 / XO]
11824824e7fdSDimitry Andricclass VX_VT5_VA5_VB5_XO9_o<bits<9> xo, string opc, list<dag> pattern>
1183*06c3fb27SDimitry Andric  : VX_RD5_RSp5_PS1_XO9<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1184*06c3fb27SDimitry Andric                        !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP, pattern> {
11854824e7fdSDimitry Andric  let Defs = [CR6];
11864824e7fdSDimitry Andric  let PS = 0;
11874824e7fdSDimitry Andric}
11884824e7fdSDimitry Andric
11895ffd83dbSDimitry Andricdef HasP8Altivec : Predicate<"Subtarget->hasP8Altivec()">;
11905ffd83dbSDimitry Andricdef HasP8Crypto : Predicate<"Subtarget->hasP8Crypto()">;
11910b57cec5SDimitry Andriclet Predicates = [HasP8Altivec] in {
11920b57cec5SDimitry Andric
11930b57cec5SDimitry Andriclet isCommutable = 1 in {
11940b57cec5SDimitry Andricdef VMULESW : VX1_Int_Ty2<904, "vmulesw", int_ppc_altivec_vmulesw,
11950b57cec5SDimitry Andric                          v2i64, v4i32>;
11960b57cec5SDimitry Andricdef VMULEUW : VX1_Int_Ty2<648, "vmuleuw", int_ppc_altivec_vmuleuw,
11970b57cec5SDimitry Andric                          v2i64, v4i32>;
11980b57cec5SDimitry Andricdef VMULOSW : VX1_Int_Ty2<392, "vmulosw", int_ppc_altivec_vmulosw,
11990b57cec5SDimitry Andric                          v2i64, v4i32>;
12000b57cec5SDimitry Andricdef VMULOUW : VX1_Int_Ty2<136, "vmulouw", int_ppc_altivec_vmulouw,
12010b57cec5SDimitry Andric                          v2i64, v4i32>;
1202*06c3fb27SDimitry Andricdef VMULUWM : VXForm_1<137, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1203*06c3fb27SDimitry Andric                       "vmuluwm $VD, $VA, $VB", IIC_VecGeneral,
1204*06c3fb27SDimitry Andric                       [(set v4i32:$VD, (mul v4i32:$VA, v4i32:$VB))]>;
12050b57cec5SDimitry Andricdef VMAXSD : VX1_Int_Ty<450, "vmaxsd", int_ppc_altivec_vmaxsd, v2i64>;
12060b57cec5SDimitry Andricdef VMAXUD : VX1_Int_Ty<194, "vmaxud", int_ppc_altivec_vmaxud, v2i64>;
12070b57cec5SDimitry Andricdef VMINSD : VX1_Int_Ty<962, "vminsd", int_ppc_altivec_vminsd, v2i64>;
12080b57cec5SDimitry Andricdef VMINUD : VX1_Int_Ty<706, "vminud", int_ppc_altivec_vminud, v2i64>;
12090b57cec5SDimitry Andric} // isCommutable
12100b57cec5SDimitry Andric
12110b57cec5SDimitry Andric// Vector merge
1212*06c3fb27SDimitry Andricdef VMRGEW : VXForm_1<1932, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1213*06c3fb27SDimitry Andric                      "vmrgew $VD, $VA, $VB", IIC_VecFP,
1214*06c3fb27SDimitry Andric                      [(set v16i8:$VD,
1215*06c3fb27SDimitry Andric                            (v16i8 (vmrgew_shuffle v16i8:$VA, v16i8:$VB)))]>;
1216*06c3fb27SDimitry Andricdef VMRGOW : VXForm_1<1676, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1217*06c3fb27SDimitry Andric                      "vmrgow $VD, $VA, $VB", IIC_VecFP,
1218*06c3fb27SDimitry Andric                      [(set v16i8:$VD,
1219*06c3fb27SDimitry Andric                            (v16i8 (vmrgow_shuffle v16i8:$VA, v16i8:$VB)))]>;
12200b57cec5SDimitry Andric
12210b57cec5SDimitry Andric// Match vmrgew(x,x) and vmrgow(x,x)
12220b57cec5SDimitry Andricdef:Pat<(vmrgew_unary_shuffle v16i8:$vA, undef),
12230b57cec5SDimitry Andric        (VMRGEW $vA, $vA)>;
12240b57cec5SDimitry Andricdef:Pat<(vmrgow_unary_shuffle v16i8:$vA, undef),
12250b57cec5SDimitry Andric        (VMRGOW $vA, $vA)>;
12260b57cec5SDimitry Andric
12270b57cec5SDimitry Andric// Match vmrgew(y,x) and vmrgow(y,x), i.e., swapped operands.  These fragments
12280b57cec5SDimitry Andric// are matched for little-endian, where the inputs must be swapped for correct
12290b57cec5SDimitry Andric// semantics.w
12300b57cec5SDimitry Andricdef:Pat<(vmrgew_swapped_shuffle v16i8:$vA, v16i8:$vB),
12310b57cec5SDimitry Andric        (VMRGEW $vB, $vA)>;
12320b57cec5SDimitry Andricdef:Pat<(vmrgow_swapped_shuffle v16i8:$vA, v16i8:$vB),
12330b57cec5SDimitry Andric        (VMRGOW $vB, $vA)>;
12340b57cec5SDimitry Andric
1235480093f4SDimitry Andric// Vector rotates.
1236480093f4SDimitry Andricdef VRLD : VX1_Int_Ty<196, "vrld", int_ppc_altivec_vrld, v2i64>;
1237480093f4SDimitry Andric
1238480093f4SDimitry Andricdef : Pat<(v2i64 (rotl v2i64:$vA, v2i64:$vB)),
1239480093f4SDimitry Andric          (v2i64 (VRLD v2i64:$vA, v2i64:$vB))>;
12400b57cec5SDimitry Andric
12410b57cec5SDimitry Andric// Vector shifts
1242*06c3fb27SDimitry Andricdef VSLD : VXForm_1<1476, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1243*06c3fb27SDimitry Andric                    "vsld $VD, $VA, $VB", IIC_VecGeneral, []>;
1244*06c3fb27SDimitry Andricdef VSRD : VXForm_1<1732, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1245*06c3fb27SDimitry Andric                   "vsrd $VD, $VA, $VB", IIC_VecGeneral, []>;
1246*06c3fb27SDimitry Andricdef VSRAD : VXForm_1<964, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1247*06c3fb27SDimitry Andric                    "vsrad $VD, $VA, $VB", IIC_VecGeneral, []>;
12480b57cec5SDimitry Andric
12490b57cec5SDimitry Andricdef : Pat<(v2i64 (shl v2i64:$vA, v2i64:$vB)),
12500b57cec5SDimitry Andric          (v2i64 (VSLD $vA, $vB))>;
12510b57cec5SDimitry Andricdef : Pat<(v2i64 (PPCshl v2i64:$vA, v2i64:$vB)),
12520b57cec5SDimitry Andric          (v2i64 (VSLD $vA, $vB))>;
12530b57cec5SDimitry Andricdef : Pat<(v2i64 (srl v2i64:$vA, v2i64:$vB)),
12540b57cec5SDimitry Andric          (v2i64 (VSRD $vA, $vB))>;
12550b57cec5SDimitry Andricdef : Pat<(v2i64 (PPCsrl v2i64:$vA, v2i64:$vB)),
12560b57cec5SDimitry Andric          (v2i64 (VSRD $vA, $vB))>;
12570b57cec5SDimitry Andricdef : Pat<(v2i64 (sra v2i64:$vA, v2i64:$vB)),
12580b57cec5SDimitry Andric          (v2i64 (VSRAD $vA, $vB))>;
12590b57cec5SDimitry Andricdef : Pat<(v2i64 (PPCsra v2i64:$vA, v2i64:$vB)),
12600b57cec5SDimitry Andric          (v2i64 (VSRAD $vA, $vB))>;
12610b57cec5SDimitry Andric
12620b57cec5SDimitry Andric// Vector Integer Arithmetic Instructions
12630b57cec5SDimitry Andriclet isCommutable = 1 in {
1264*06c3fb27SDimitry Andricdef VADDUDM : VXForm_1<192, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1265*06c3fb27SDimitry Andric                       "vaddudm $VD, $VA, $VB", IIC_VecGeneral,
1266*06c3fb27SDimitry Andric                       [(set v2i64:$VD, (add v2i64:$VA, v2i64:$VB))]>;
1267*06c3fb27SDimitry Andricdef VADDUQM : VXForm_1<256, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1268*06c3fb27SDimitry Andric                       "vadduqm $VD, $VA, $VB", IIC_VecGeneral,
1269*06c3fb27SDimitry Andric                       [(set v1i128:$VD, (add v1i128:$VA, v1i128:$VB))]>;
12700b57cec5SDimitry Andric} // isCommutable
12710b57cec5SDimitry Andric
12720b57cec5SDimitry Andric// Vector Quadword Add
12730b57cec5SDimitry Andricdef VADDEUQM : VA1a_Int_Ty<60, "vaddeuqm", int_ppc_altivec_vaddeuqm, v1i128>;
12740b57cec5SDimitry Andricdef VADDCUQ  : VX1_Int_Ty<320, "vaddcuq", int_ppc_altivec_vaddcuq, v1i128>;
12750b57cec5SDimitry Andricdef VADDECUQ : VA1a_Int_Ty<61, "vaddecuq", int_ppc_altivec_vaddecuq, v1i128>;
12760b57cec5SDimitry Andric
12770b57cec5SDimitry Andric// Vector Doubleword Subtract
1278*06c3fb27SDimitry Andricdef VSUBUDM : VXForm_1<1216, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1279*06c3fb27SDimitry Andric                       "vsubudm $VD, $VA, $VB", IIC_VecGeneral,
1280*06c3fb27SDimitry Andric                       [(set v2i64:$VD, (sub v2i64:$VA, v2i64:$VB))]>;
12810b57cec5SDimitry Andric
12820b57cec5SDimitry Andric// Vector Quadword Subtract
1283*06c3fb27SDimitry Andricdef VSUBUQM : VXForm_1<1280, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1284*06c3fb27SDimitry Andric                       "vsubuqm $VD, $VA, $VB", IIC_VecGeneral,
1285*06c3fb27SDimitry Andric                       [(set v1i128:$VD, (sub v1i128:$VA, v1i128:$VB))]>;
12860b57cec5SDimitry Andricdef VSUBEUQM : VA1a_Int_Ty<62, "vsubeuqm", int_ppc_altivec_vsubeuqm, v1i128>;
12870b57cec5SDimitry Andricdef VSUBCUQ  : VX1_Int_Ty<1344, "vsubcuq", int_ppc_altivec_vsubcuq, v1i128>;
12880b57cec5SDimitry Andricdef VSUBECUQ : VA1a_Int_Ty<63, "vsubecuq", int_ppc_altivec_vsubecuq, v1i128>;
12890b57cec5SDimitry Andric
12900b57cec5SDimitry Andric// Count Leading Zeros
1291*06c3fb27SDimitry Andricdef VCLZB : VXForm_2<1794, (outs vrrc:$VD), (ins vrrc:$VB),
1292*06c3fb27SDimitry Andric                     "vclzb $VD, $VB", IIC_VecGeneral,
1293*06c3fb27SDimitry Andric                     [(set v16i8:$VD, (ctlz v16i8:$VB))]>;
1294*06c3fb27SDimitry Andricdef VCLZH : VXForm_2<1858, (outs vrrc:$VD), (ins vrrc:$VB),
1295*06c3fb27SDimitry Andric                     "vclzh $VD, $VB", IIC_VecGeneral,
1296*06c3fb27SDimitry Andric                     [(set v8i16:$VD, (ctlz v8i16:$VB))]>;
1297*06c3fb27SDimitry Andricdef VCLZW : VXForm_2<1922, (outs vrrc:$VD), (ins vrrc:$VB),
1298*06c3fb27SDimitry Andric                     "vclzw $VD, $VB", IIC_VecGeneral,
1299*06c3fb27SDimitry Andric                     [(set v4i32:$VD, (ctlz v4i32:$VB))]>;
1300*06c3fb27SDimitry Andricdef VCLZD : VXForm_2<1986, (outs vrrc:$VD), (ins vrrc:$VB),
1301*06c3fb27SDimitry Andric                     "vclzd $VD, $VB", IIC_VecGeneral,
1302*06c3fb27SDimitry Andric                     [(set v2i64:$VD, (ctlz v2i64:$VB))]>;
13030b57cec5SDimitry Andric
13040b57cec5SDimitry Andric// Population Count
1305*06c3fb27SDimitry Andricdef VPOPCNTB : VXForm_2<1795, (outs vrrc:$VD), (ins vrrc:$VB),
1306*06c3fb27SDimitry Andric                        "vpopcntb $VD, $VB", IIC_VecGeneral,
1307*06c3fb27SDimitry Andric                        [(set v16i8:$VD, (ctpop v16i8:$VB))]>;
1308*06c3fb27SDimitry Andricdef VPOPCNTH : VXForm_2<1859, (outs vrrc:$VD), (ins vrrc:$VB),
1309*06c3fb27SDimitry Andric                        "vpopcnth $VD, $VB", IIC_VecGeneral,
1310*06c3fb27SDimitry Andric                        [(set v8i16:$VD, (ctpop v8i16:$VB))]>;
1311*06c3fb27SDimitry Andricdef VPOPCNTW : VXForm_2<1923, (outs vrrc:$VD), (ins vrrc:$VB),
1312*06c3fb27SDimitry Andric                        "vpopcntw $VD, $VB", IIC_VecGeneral,
1313*06c3fb27SDimitry Andric                        [(set v4i32:$VD, (ctpop v4i32:$VB))]>;
1314*06c3fb27SDimitry Andricdef VPOPCNTD : VXForm_2<1987, (outs vrrc:$VD), (ins vrrc:$VB),
1315*06c3fb27SDimitry Andric                        "vpopcntd $VD, $VB", IIC_VecGeneral,
1316*06c3fb27SDimitry Andric                        [(set v2i64:$VD, (ctpop v2i64:$VB))]>;
13170b57cec5SDimitry Andric
13180b57cec5SDimitry Andriclet isCommutable = 1 in {
13190b57cec5SDimitry Andric// FIXME: Use AddedComplexity > 400 to ensure these patterns match before the
13200b57cec5SDimitry Andric//        VSX equivalents. We need to fix this up at some point. Two possible
13210b57cec5SDimitry Andric//        solutions for this problem:
13220b57cec5SDimitry Andric//        1. Disable Altivec patterns that compete with VSX patterns using the
13230b57cec5SDimitry Andric//           !HasVSX predicate. This essentially favours VSX over Altivec, in
13240b57cec5SDimitry Andric//           hopes of reducing register pressure (larger register set using VSX
13250b57cec5SDimitry Andric//           instructions than VMX instructions)
13260b57cec5SDimitry Andric//        2. Employ a more disciplined use of AddedComplexity, which would provide
13270b57cec5SDimitry Andric//           more fine-grained control than option 1. This would be beneficial
13280b57cec5SDimitry Andric//           if we find situations where Altivec is really preferred over VSX.
1329*06c3fb27SDimitry Andricdef VEQV  : VXForm_1<1668, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1330*06c3fb27SDimitry Andric                     "veqv $VD, $VA, $VB", IIC_VecGeneral,
1331*06c3fb27SDimitry Andric                     [(set v4i32:$VD, (vnot (xor v4i32:$VA, v4i32:$VB)))]>;
1332*06c3fb27SDimitry Andricdef VNAND : VXForm_1<1412, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1333*06c3fb27SDimitry Andric                     "vnand $VD, $VA, $VB", IIC_VecGeneral,
1334*06c3fb27SDimitry Andric                     [(set v4i32:$VD, (vnot (and v4i32:$VA, v4i32:$VB)))]>;
13350b57cec5SDimitry Andric} // isCommutable
13360b57cec5SDimitry Andric
1337*06c3fb27SDimitry Andricdef VORC : VXForm_1<1348, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1338*06c3fb27SDimitry Andric                      "vorc $VD, $VA, $VB", IIC_VecGeneral,
1339*06c3fb27SDimitry Andric                      [(set v4i32:$VD, (or v4i32:$VA,
1340*06c3fb27SDimitry Andric                                           (vnot v4i32:$VB)))]>;
13410b57cec5SDimitry Andric
13420b57cec5SDimitry Andric// i64 element comparisons.
1343*06c3fb27SDimitry Andricdef VCMPEQUD  : VCMP <199, "vcmpequd $VD, $VA, $VB" , v2i64>;
1344*06c3fb27SDimitry Andricdef VCMPEQUD_rec : VCMP_rec<199, "vcmpequd. $VD, $VA, $VB", v2i64>;
1345*06c3fb27SDimitry Andricdef VCMPGTSD  : VCMP <967, "vcmpgtsd $VD, $VA, $VB" , v2i64>;
1346*06c3fb27SDimitry Andricdef VCMPGTSD_rec : VCMP_rec<967, "vcmpgtsd. $VD, $VA, $VB", v2i64>;
1347*06c3fb27SDimitry Andricdef VCMPGTUD  : VCMP <711, "vcmpgtud $VD, $VA, $VB" , v2i64>;
1348*06c3fb27SDimitry Andricdef VCMPGTUD_rec : VCMP_rec<711, "vcmpgtud. $VD, $VA, $VB", v2i64>;
13490b57cec5SDimitry Andric
13500b57cec5SDimitry Andric// The cryptography instructions that do not require Category:Vector.Crypto
13510b57cec5SDimitry Andricdef VPMSUMB : VX1_Int_Ty<1032, "vpmsumb",
13520b57cec5SDimitry Andric                         int_ppc_altivec_crypto_vpmsumb, v16i8>;
13530b57cec5SDimitry Andricdef VPMSUMH : VX1_Int_Ty<1096, "vpmsumh",
13540b57cec5SDimitry Andric                         int_ppc_altivec_crypto_vpmsumh, v8i16>;
13550b57cec5SDimitry Andricdef VPMSUMW : VX1_Int_Ty<1160, "vpmsumw",
13560b57cec5SDimitry Andric                         int_ppc_altivec_crypto_vpmsumw, v4i32>;
13570b57cec5SDimitry Andricdef VPMSUMD : VX1_Int_Ty<1224, "vpmsumd",
13580b57cec5SDimitry Andric                         int_ppc_altivec_crypto_vpmsumd, v2i64>;
1359*06c3fb27SDimitry Andricdef VPERMXOR : VAForm_1<45, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
1360*06c3fb27SDimitry Andric                        "vpermxor $RT, $RA, $RB, $RC", IIC_VecFP, []>;
13610b57cec5SDimitry Andric
13620b57cec5SDimitry Andric// Vector doubleword integer pack and unpack.
1363e8d8bef9SDimitry Andriclet hasSideEffects = 1 in {
13640b57cec5SDimitry Andric  def VPKSDSS : VX1_Int_Ty2<1486, "vpksdss", int_ppc_altivec_vpksdss,
13650b57cec5SDimitry Andric                            v4i32, v2i64>;
13660b57cec5SDimitry Andric  def VPKSDUS : VX1_Int_Ty2<1358, "vpksdus", int_ppc_altivec_vpksdus,
13670b57cec5SDimitry Andric                            v4i32, v2i64>;
1368e8d8bef9SDimitry Andric  def VPKUDUS : VX1_Int_Ty2<1230, "vpkudus", int_ppc_altivec_vpkudus,
1369e8d8bef9SDimitry Andric                            v4i32, v2i64>;
1370e8d8bef9SDimitry Andric}
1371*06c3fb27SDimitry Andricdef VPKUDUM : VXForm_1<1102, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1372*06c3fb27SDimitry Andric                       "vpkudum $VD, $VA, $VB", IIC_VecFP,
1373*06c3fb27SDimitry Andric                       [(set v16i8:$VD,
1374*06c3fb27SDimitry Andric                         (vpkudum_shuffle v16i8:$VA, v16i8:$VB))]>;
13750b57cec5SDimitry Andricdef VUPKHSW : VX2_Int_Ty2<1614, "vupkhsw", int_ppc_altivec_vupkhsw,
13760b57cec5SDimitry Andric                          v2i64, v4i32>;
13770b57cec5SDimitry Andricdef VUPKLSW : VX2_Int_Ty2<1742, "vupklsw", int_ppc_altivec_vupklsw,
13780b57cec5SDimitry Andric                          v2i64, v4i32>;
13794824e7fdSDimitry Andricdef BCDADD_rec : VX_VT5_VA5_VB5_PS1_XO9_o<1,  "bcdadd." , []>;
13804824e7fdSDimitry Andricdef BCDSUB_rec : VX_VT5_VA5_VB5_PS1_XO9_o<65, "bcdsub." , []>;
13814824e7fdSDimitry Andric
13824824e7fdSDimitry Andricdef : Pat<(v16i8 (int_ppc_bcdadd v16i8:$vA, v16i8:$vB, timm:$PS)),
13834824e7fdSDimitry Andric          (BCDADD_rec $vA, $vB, $PS)>;
13844824e7fdSDimitry Andricdef : Pat<(v16i8 (int_ppc_bcdsub v16i8:$vA, v16i8:$vB, timm:$PS)),
13854824e7fdSDimitry Andric          (BCDSUB_rec $vA, $vB, $PS)>;
13860b57cec5SDimitry Andric
13870b57cec5SDimitry Andric// Shuffle patterns for unary and swapped (LE) vector pack modulo.
13880b57cec5SDimitry Andricdef:Pat<(vpkudum_unary_shuffle v16i8:$vA, undef),
13890b57cec5SDimitry Andric        (VPKUDUM $vA, $vA)>;
13900b57cec5SDimitry Andricdef:Pat<(vpkudum_swapped_shuffle v16i8:$vA, v16i8:$vB),
13910b57cec5SDimitry Andric        (VPKUDUM $vB, $vA)>;
13920b57cec5SDimitry Andric
13930b57cec5SDimitry Andricdef VGBBD : VX2_Int_Ty2<1292, "vgbbd", int_ppc_altivec_vgbbd, v16i8, v16i8>;
13940b57cec5SDimitry Andricdef VBPERMQ : VX1_Int_Ty2<1356, "vbpermq", int_ppc_altivec_vbpermq,
13950b57cec5SDimitry Andric                          v2i64, v16i8>;
13960b57cec5SDimitry Andric} // end HasP8Altivec
13970b57cec5SDimitry Andric
13980b57cec5SDimitry Andric// Crypto instructions (from builtins)
13990b57cec5SDimitry Andriclet Predicates = [HasP8Crypto] in {
14000b57cec5SDimitry Andricdef VSHASIGMAW : VXCR_Int_Ty<1666, "vshasigmaw",
14010b57cec5SDimitry Andric                              int_ppc_altivec_crypto_vshasigmaw, v4i32>;
14020b57cec5SDimitry Andricdef VSHASIGMAD : VXCR_Int_Ty<1730, "vshasigmad",
14030b57cec5SDimitry Andric                              int_ppc_altivec_crypto_vshasigmad, v2i64>;
14040b57cec5SDimitry Andricdef VCIPHER : VX1_Int_Ty<1288, "vcipher", int_ppc_altivec_crypto_vcipher,
14050b57cec5SDimitry Andric                         v2i64>;
14060b57cec5SDimitry Andricdef VCIPHERLAST : VX1_Int_Ty<1289, "vcipherlast",
14070b57cec5SDimitry Andric                              int_ppc_altivec_crypto_vcipherlast, v2i64>;
14080b57cec5SDimitry Andricdef VNCIPHER : VX1_Int_Ty<1352, "vncipher",
14090b57cec5SDimitry Andric                          int_ppc_altivec_crypto_vncipher, v2i64>;
14100b57cec5SDimitry Andricdef VNCIPHERLAST : VX1_Int_Ty<1353, "vncipherlast",
14110b57cec5SDimitry Andric                              int_ppc_altivec_crypto_vncipherlast, v2i64>;
14120b57cec5SDimitry Andricdef VSBOX : VXBX_Int_Ty<1480, "vsbox", int_ppc_altivec_crypto_vsbox, v2i64>;
14130b57cec5SDimitry Andric} // HasP8Crypto
14140b57cec5SDimitry Andric
14150b57cec5SDimitry Andric// The following altivec instructions were introduced in Power ISA 3.0
14165ffd83dbSDimitry Andricdef HasP9Altivec : Predicate<"Subtarget->hasP9Altivec()">;
14170b57cec5SDimitry Andriclet Predicates = [HasP9Altivec] in {
14180b57cec5SDimitry Andric
14190946e70aSDimitry Andric// Vector Multiply-Sum
14200946e70aSDimitry Andricdef VMSUMUDM : VA1a_Int_Ty3<35, "vmsumudm", int_ppc_altivec_vmsumudm,
14210946e70aSDimitry Andric                            v1i128, v2i64, v1i128>;
14220946e70aSDimitry Andric
14230b57cec5SDimitry Andric// i8 element comparisons.
1424*06c3fb27SDimitry Andricdef VCMPNEB   : VCMP   <  7, "vcmpneb $VD, $VA, $VB"  , v16i8>;
1425*06c3fb27SDimitry Andricdef VCMPNEB_rec  : VCMP_rec  <  7, "vcmpneb. $VD, $VA, $VB" , v16i8>;
1426*06c3fb27SDimitry Andricdef VCMPNEZB  : VCMP <263, "vcmpnezb $VD, $VA, $VB" , v16i8>;
1427*06c3fb27SDimitry Andricdef VCMPNEZB_rec : VCMP_rec<263, "vcmpnezb. $VD, $VA, $VB", v16i8>;
14280b57cec5SDimitry Andric
14290b57cec5SDimitry Andric// i16 element comparisons.
1430*06c3fb27SDimitry Andricdef VCMPNEH   : VCMP < 71, "vcmpneh $VD, $VA, $VB"  , v8i16>;
1431*06c3fb27SDimitry Andricdef VCMPNEH_rec  : VCMP_rec< 71, "vcmpneh. $VD, $VA, $VB" , v8i16>;
1432*06c3fb27SDimitry Andricdef VCMPNEZH  : VCMP <327, "vcmpnezh $VD, $VA, $VB" , v8i16>;
1433*06c3fb27SDimitry Andricdef VCMPNEZH_rec : VCMP_rec<327, "vcmpnezh. $VD, $VA, $VB", v8i16>;
14340b57cec5SDimitry Andric
14350b57cec5SDimitry Andric// i32 element comparisons.
1436*06c3fb27SDimitry Andricdef VCMPNEW   : VCMP <135, "vcmpnew $VD, $VA, $VB"  , v4i32>;
1437*06c3fb27SDimitry Andricdef VCMPNEW_rec  : VCMP_rec<135, "vcmpnew. $VD, $VA, $VB" , v4i32>;
1438*06c3fb27SDimitry Andricdef VCMPNEZW  : VCMP <391, "vcmpnezw $VD, $VA, $VB" , v4i32>;
1439*06c3fb27SDimitry Andricdef VCMPNEZW_rec : VCMP_rec<391, "vcmpnezw. $VD, $VA, $VB", v4i32>;
14400b57cec5SDimitry Andric
14410b57cec5SDimitry Andric// VX-Form: [PO VRT / UIM VRB XO].
14420b57cec5SDimitry Andric// We use VXForm_1 to implement it, that is, we use "VRA" (5 bit) to represent
14430b57cec5SDimitry Andric// "/ UIM" (1 + 4 bit)
14440b57cec5SDimitry Andricclass VX1_VT5_UIM5_VB5<bits<11> xo, string opc, list<dag> pattern>
1445*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs vrrc:$VD), (ins u4imm:$VA, vrrc:$VB),
1446*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VB, $VA"), IIC_VecGeneral, pattern>;
14470b57cec5SDimitry Andric
14480b57cec5SDimitry Andricclass VX1_RT5_RA5_VB5<bits<11> xo, string opc, list<dag> pattern>
1449*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs g8rc:$VD), (ins g8rc:$VA, vrrc:$VB),
1450*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA, $VB"), IIC_VecGeneral, pattern>;
14510b57cec5SDimitry Andric
14520b57cec5SDimitry Andric// Vector Extract Unsigned
14530b57cec5SDimitry Andricdef VEXTRACTUB : VX1_VT5_UIM5_VB5<525, "vextractub", []>;
14540b57cec5SDimitry Andricdef VEXTRACTUH : VX1_VT5_UIM5_VB5<589, "vextractuh", []>;
14550b57cec5SDimitry Andricdef VEXTRACTUW : VX1_VT5_UIM5_VB5<653, "vextractuw", []>;
14560b57cec5SDimitry Andricdef VEXTRACTD  : VX1_VT5_UIM5_VB5<717, "vextractd" , []>;
14570b57cec5SDimitry Andric
14580b57cec5SDimitry Andric// Vector Extract Unsigned Byte/Halfword/Word Left/Right-Indexed
1459480093f4SDimitry Andriclet hasSideEffects = 0 in {
1460bdd1243dSDimitry Andricdef VEXTUBLX : VX1_RT5_RA5_VB5<1549, "vextublx", []>, ZExt32To64;
1461bdd1243dSDimitry Andricdef VEXTUBRX : VX1_RT5_RA5_VB5<1805, "vextubrx", []>, ZExt32To64;
1462bdd1243dSDimitry Andricdef VEXTUHLX : VX1_RT5_RA5_VB5<1613, "vextuhlx", []>, ZExt32To64;
1463bdd1243dSDimitry Andricdef VEXTUHRX : VX1_RT5_RA5_VB5<1869, "vextuhrx", []>, ZExt32To64;
1464bdd1243dSDimitry Andricdef VEXTUWLX : VX1_RT5_RA5_VB5<1677, "vextuwlx", []>, ZExt32To64;
1465bdd1243dSDimitry Andricdef VEXTUWRX : VX1_RT5_RA5_VB5<1933, "vextuwrx", []>, ZExt32To64;
1466480093f4SDimitry Andric}
14670b57cec5SDimitry Andric
14680b57cec5SDimitry Andric// Vector Insert Element Instructions
1469*06c3fb27SDimitry Andricdef VINSERTB : VXForm_1<781, (outs vrrc:$VD),
1470*06c3fb27SDimitry Andric                        (ins vrrc:$VDi, u4imm:$VA, vrrc:$VB),
1471*06c3fb27SDimitry Andric                        "vinsertb $VD, $VB, $VA", IIC_VecGeneral,
1472*06c3fb27SDimitry Andric                        [(set v16i8:$VD, (PPCvecinsert v16i8:$VDi, v16i8:$VB,
1473*06c3fb27SDimitry Andric                                                      imm32SExt16:$VA))]>,
1474*06c3fb27SDimitry Andric                        RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
1475*06c3fb27SDimitry Andricdef VINSERTH : VXForm_1<845, (outs vrrc:$VD),
1476*06c3fb27SDimitry Andric                        (ins vrrc:$VDi, u4imm:$VA, vrrc:$VB),
1477*06c3fb27SDimitry Andric                        "vinserth $VD, $VB, $VA", IIC_VecGeneral,
1478*06c3fb27SDimitry Andric                        [(set v8i16:$VD, (PPCvecinsert v8i16:$VDi, v8i16:$VB,
1479*06c3fb27SDimitry Andric                                                      imm32SExt16:$VA))]>,
1480*06c3fb27SDimitry Andric                        RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
14810b57cec5SDimitry Andricdef VINSERTW : VX1_VT5_UIM5_VB5<909, "vinsertw", []>;
14820b57cec5SDimitry Andricdef VINSERTD : VX1_VT5_UIM5_VB5<973, "vinsertd", []>;
14830b57cec5SDimitry Andric
14840b57cec5SDimitry Andricclass VX_VT5_EO5_VB5<bits<11> xo, bits<5> eo, string opc, list<dag> pattern>
1485*06c3fb27SDimitry Andric  : VXForm_RD5_XO5_RS5<xo, eo, (outs vrrc:$VD), (ins vrrc:$VB),
1486*06c3fb27SDimitry Andric                       !strconcat(opc, " $VD, $VB"), IIC_VecGeneral, pattern>;
14870b57cec5SDimitry Andricclass VX_VT5_EO5_VB5s<bits<11> xo, bits<5> eo, string opc, list<dag> pattern>
1488*06c3fb27SDimitry Andric  : VXForm_RD5_XO5_RS5<xo, eo, (outs vfrc:$VD), (ins vfrc:$VB),
1489*06c3fb27SDimitry Andric                       !strconcat(opc, " $VD, $VB"), IIC_VecGeneral, pattern>;
14900b57cec5SDimitry Andric
1491*06c3fb27SDimitry Andric// Vector Count Leading/Trailing Zero LSB. Result is placed into GPR[RD]
1492*06c3fb27SDimitry Andricdef VCLZLSBB : VXForm_RD5_XO5_RS5<1538, 0, (outs gprc:$VD), (ins vrrc:$VB),
1493*06c3fb27SDimitry Andric                                  "vclzlsbb $VD, $VB", IIC_VecGeneral,
1494*06c3fb27SDimitry Andric                                  [(set i32:$VD, (int_ppc_altivec_vclzlsbb
1495*06c3fb27SDimitry Andric                                     v16i8:$VB))]>;
1496*06c3fb27SDimitry Andricdef VCTZLSBB : VXForm_RD5_XO5_RS5<1538, 1, (outs gprc:$VD), (ins vrrc:$VB),
1497*06c3fb27SDimitry Andric                                  "vctzlsbb $VD, $VB", IIC_VecGeneral,
1498*06c3fb27SDimitry Andric                                  [(set i32:$VD, (int_ppc_altivec_vctzlsbb
1499*06c3fb27SDimitry Andric                                     v16i8:$VB))]>;
15000b57cec5SDimitry Andric// Vector Count Trailing Zeros
15010b57cec5SDimitry Andricdef VCTZB : VX_VT5_EO5_VB5<1538, 28, "vctzb",
1502*06c3fb27SDimitry Andric                           [(set v16i8:$VD, (cttz v16i8:$VB))]>;
15030b57cec5SDimitry Andricdef VCTZH : VX_VT5_EO5_VB5<1538, 29, "vctzh",
1504*06c3fb27SDimitry Andric                           [(set v8i16:$VD, (cttz v8i16:$VB))]>;
15050b57cec5SDimitry Andricdef VCTZW : VX_VT5_EO5_VB5<1538, 30, "vctzw",
1506*06c3fb27SDimitry Andric                           [(set v4i32:$VD, (cttz v4i32:$VB))]>;
15070b57cec5SDimitry Andricdef VCTZD : VX_VT5_EO5_VB5<1538, 31, "vctzd",
1508*06c3fb27SDimitry Andric                           [(set v2i64:$VD, (cttz v2i64:$VB))]>;
15090b57cec5SDimitry Andric
15100b57cec5SDimitry Andric// Vector Extend Sign
1511e8d8bef9SDimitry Andricdef VEXTSB2W : VX_VT5_EO5_VB5<1538, 16, "vextsb2w",
1512*06c3fb27SDimitry Andric                              [(set v4i32:$VD, (int_ppc_altivec_vextsb2w v16i8:$VB))]>;
1513e8d8bef9SDimitry Andricdef VEXTSH2W : VX_VT5_EO5_VB5<1538, 17, "vextsh2w",
1514*06c3fb27SDimitry Andric                              [(set v4i32:$VD, (int_ppc_altivec_vextsh2w v8i16:$VB))]>;
1515e8d8bef9SDimitry Andricdef VEXTSB2D : VX_VT5_EO5_VB5<1538, 24, "vextsb2d",
1516*06c3fb27SDimitry Andric                              [(set v2i64:$VD, (int_ppc_altivec_vextsb2d v16i8:$VB))]>;
1517e8d8bef9SDimitry Andricdef VEXTSH2D : VX_VT5_EO5_VB5<1538, 25, "vextsh2d",
1518*06c3fb27SDimitry Andric                              [(set v2i64:$VD, (int_ppc_altivec_vextsh2d v8i16:$VB))]>;
1519e8d8bef9SDimitry Andricdef VEXTSW2D : VX_VT5_EO5_VB5<1538, 26, "vextsw2d",
1520*06c3fb27SDimitry Andric                              [(set v2i64:$VD, (int_ppc_altivec_vextsw2d v4i32:$VB))]>;
15210b57cec5SDimitry Andriclet isCodeGenOnly = 1 in {
15220b57cec5SDimitry Andric  def VEXTSB2Ws : VX_VT5_EO5_VB5s<1538, 16, "vextsb2w", []>;
15230b57cec5SDimitry Andric  def VEXTSH2Ws : VX_VT5_EO5_VB5s<1538, 17, "vextsh2w", []>;
15240b57cec5SDimitry Andric  def VEXTSB2Ds : VX_VT5_EO5_VB5s<1538, 24, "vextsb2d", []>;
15250b57cec5SDimitry Andric  def VEXTSH2Ds : VX_VT5_EO5_VB5s<1538, 25, "vextsh2d", []>;
15260b57cec5SDimitry Andric  def VEXTSW2Ds : VX_VT5_EO5_VB5s<1538, 26, "vextsw2d", []>;
15270b57cec5SDimitry Andric}
15280b57cec5SDimitry Andric
1529480093f4SDimitry Andricdef : Pat<(v4i32 (sext_inreg v4i32:$VRB, v4i8)), (v4i32 (VEXTSB2W $VRB))>;
1530480093f4SDimitry Andricdef : Pat<(v4i32 (sext_inreg v4i32:$VRB, v4i16)), (v4i32 (VEXTSH2W $VRB))>;
1531480093f4SDimitry Andricdef : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i8)), (v2i64 (VEXTSB2D $VRB))>;
1532480093f4SDimitry Andricdef : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i16)), (v2i64 (VEXTSH2D $VRB))>;
1533480093f4SDimitry Andricdef : Pat<(v2i64 (sext_inreg v2i64:$VRB, v2i32)), (v2i64 (VEXTSW2D $VRB))>;
1534480093f4SDimitry Andric
15350b57cec5SDimitry Andric// Vector Integer Negate
15360b57cec5SDimitry Andricdef VNEGW : VX_VT5_EO5_VB5<1538, 6, "vnegw",
1537*06c3fb27SDimitry Andric                           [(set v4i32:$VD,
1538*06c3fb27SDimitry Andric                            (sub (v4i32 immAllZerosV), v4i32:$VB))]>;
15390b57cec5SDimitry Andric
15400b57cec5SDimitry Andricdef VNEGD : VX_VT5_EO5_VB5<1538, 7, "vnegd",
1541*06c3fb27SDimitry Andric                           [(set v2i64:$VD,
1542*06c3fb27SDimitry Andric                            (sub (v2i64 immAllZerosV), v2i64:$VB))]>;
15430b57cec5SDimitry Andric
15440b57cec5SDimitry Andric// Vector Parity Byte
1545*06c3fb27SDimitry Andricdef VPRTYBW : VX_VT5_EO5_VB5<1538, 8, "vprtybw", [(set v4i32:$VD,
1546*06c3fb27SDimitry Andric                            (int_ppc_altivec_vprtybw v4i32:$VB))]>;
1547*06c3fb27SDimitry Andricdef VPRTYBD : VX_VT5_EO5_VB5<1538,  9, "vprtybd", [(set v2i64:$VD,
1548*06c3fb27SDimitry Andric                            (int_ppc_altivec_vprtybd v2i64:$VB))]>;
1549*06c3fb27SDimitry Andricdef VPRTYBQ : VX_VT5_EO5_VB5<1538, 10, "vprtybq", [(set v1i128:$VD,
1550*06c3fb27SDimitry Andric                            (int_ppc_altivec_vprtybq v1i128:$VB))]>;
15510b57cec5SDimitry Andric
15520b57cec5SDimitry Andric// Vector (Bit) Permute (Right-indexed)
1553349cc55cSDimitry Andricdef VBPERMD : VX1_Int_Ty3<1484, "vbpermd", int_ppc_altivec_vbpermd,
1554349cc55cSDimitry Andric                          v2i64, v2i64, v16i8>;
1555*06c3fb27SDimitry Andricdef VPERMR : VAForm_1a<59, (outs vrrc:$RT), (ins vrrc:$RA, vrrc:$RB, vrrc:$RC),
1556*06c3fb27SDimitry Andric                       "vpermr $RT, $RA, $RB, $RC", IIC_VecFP, []>;
15570b57cec5SDimitry Andric
15580b57cec5SDimitry Andricclass VX1_VT5_VA5_VB5<bits<11> xo, string opc, list<dag> pattern>
1559*06c3fb27SDimitry Andric  : VXForm_1<xo, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1560*06c3fb27SDimitry Andric             !strconcat(opc, " $VD, $VA, $VB"), IIC_VecFP, pattern>;
15610b57cec5SDimitry Andric
15620b57cec5SDimitry Andric// Vector Rotate Left Mask/Mask-Insert
15630b57cec5SDimitry Andricdef VRLWNM : VX1_VT5_VA5_VB5<389, "vrlwnm",
1564*06c3fb27SDimitry Andric                             [(set v4i32:$VD,
1565*06c3fb27SDimitry Andric                                 (int_ppc_altivec_vrlwnm v4i32:$VA,
1566*06c3fb27SDimitry Andric                                                         v4i32:$VB))]>;
1567*06c3fb27SDimitry Andricdef VRLWMI : VXForm_1<133, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, vrrc:$VDi),
1568*06c3fb27SDimitry Andric                      "vrlwmi $VD, $VA, $VB", IIC_VecFP,
1569*06c3fb27SDimitry Andric                      [(set v4i32:$VD,
1570*06c3fb27SDimitry Andric                         (int_ppc_altivec_vrlwmi v4i32:$VA, v4i32:$VB,
1571*06c3fb27SDimitry Andric                                                 v4i32:$VDi))]>,
1572*06c3fb27SDimitry Andric                      RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
15730b57cec5SDimitry Andricdef VRLDNM : VX1_VT5_VA5_VB5<453, "vrldnm",
1574*06c3fb27SDimitry Andric                             [(set v2i64:$VD,
1575*06c3fb27SDimitry Andric                                 (int_ppc_altivec_vrldnm v2i64:$VA,
1576*06c3fb27SDimitry Andric                                                         v2i64:$VB))]>;
1577*06c3fb27SDimitry Andricdef VRLDMI : VXForm_1<197, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB, vrrc:$VDi),
1578*06c3fb27SDimitry Andric                      "vrldmi $VD, $VA, $VB", IIC_VecFP,
1579*06c3fb27SDimitry Andric                      [(set v2i64:$VD,
1580*06c3fb27SDimitry Andric                         (int_ppc_altivec_vrldmi v2i64:$VA, v2i64:$VB,
1581*06c3fb27SDimitry Andric                                                 v2i64:$VDi))]>,
1582*06c3fb27SDimitry Andric                      RegConstraint<"$VDi = $VD">, NoEncode<"$VDi">;
15830b57cec5SDimitry Andric
15840b57cec5SDimitry Andric// Vector Shift Left/Right
15850b57cec5SDimitry Andricdef VSLV : VX1_VT5_VA5_VB5<1860, "vslv",
1586*06c3fb27SDimitry Andric                           [(set v16i8 : $VD, (int_ppc_altivec_vslv v16i8 : $VA, v16i8 : $VB))]>;
15870b57cec5SDimitry Andricdef VSRV : VX1_VT5_VA5_VB5<1796, "vsrv",
1588*06c3fb27SDimitry Andric                           [(set v16i8 : $VD, (int_ppc_altivec_vsrv v16i8 : $VA, v16i8 : $VB))]>;
15890b57cec5SDimitry Andric
15900b57cec5SDimitry Andric// Vector Multiply-by-10 (& Write Carry) Unsigned Quadword
1591*06c3fb27SDimitry Andricdef VMUL10UQ   : VXForm_BX<513, (outs vrrc:$VD), (ins vrrc:$VA),
1592*06c3fb27SDimitry Andric                           "vmul10uq $VD, $VA", IIC_VecFP, []>;
1593*06c3fb27SDimitry Andricdef VMUL10CUQ  : VXForm_BX<  1, (outs vrrc:$VD), (ins vrrc:$VA),
1594*06c3fb27SDimitry Andric                           "vmul10cuq $VD, $VA", IIC_VecFP, []>;
15950b57cec5SDimitry Andric
15960b57cec5SDimitry Andric// Vector Multiply-by-10 Extended (& Write Carry) Unsigned Quadword
15970b57cec5SDimitry Andricdef VMUL10EUQ  : VX1_VT5_VA5_VB5<577, "vmul10euq" , []>;
15980b57cec5SDimitry Andricdef VMUL10ECUQ : VX1_VT5_VA5_VB5< 65, "vmul10ecuq", []>;
15990b57cec5SDimitry Andric
16000b57cec5SDimitry Andric// Decimal Integer Format Conversion Instructions
16010b57cec5SDimitry Andric
16020b57cec5SDimitry Andric// [PO VRT EO VRB 1 PS XO], "_o" means CR6 is set.
16030b57cec5SDimitry Andricclass VX_VT5_EO5_VB5_PS1_XO9_o<bits<5> eo, bits<9> xo, string opc,
16040b57cec5SDimitry Andric                               list<dag> pattern>
1605*06c3fb27SDimitry Andric  : VX_RD5_EO5_RS5_PS1_XO9<eo, xo, (outs vrrc:$VD), (ins vrrc:$VB, u1imm:$PS),
1606*06c3fb27SDimitry Andric                        !strconcat(opc, " $VD, $VB, $PS"), IIC_VecFP, pattern> {
16070b57cec5SDimitry Andric  let Defs = [CR6];
16080b57cec5SDimitry Andric}
16090b57cec5SDimitry Andric
16100b57cec5SDimitry Andric// [PO VRT EO VRB 1 / XO]
16110b57cec5SDimitry Andricclass VX_VT5_EO5_VB5_XO9_o<bits<5> eo, bits<9> xo, string opc,
16120b57cec5SDimitry Andric                           list<dag> pattern>
1613*06c3fb27SDimitry Andric  : VX_RD5_EO5_RS5_PS1_XO9<eo, xo, (outs vrrc:$VD), (ins vrrc:$VB),
1614*06c3fb27SDimitry Andric                           !strconcat(opc, " $VD, $VB"), IIC_VecFP, pattern> {
16150b57cec5SDimitry Andric  let Defs = [CR6];
16160b57cec5SDimitry Andric  let PS = 0;
16170b57cec5SDimitry Andric}
16180b57cec5SDimitry Andric
16190b57cec5SDimitry Andric// Decimal Convert From/to National/Zoned/Signed-QWord
1620480093f4SDimitry Andricdef BCDCFN_rec  : VX_VT5_EO5_VB5_PS1_XO9_o<7, 385, "bcdcfn." , []>;
1621480093f4SDimitry Andricdef BCDCFZ_rec  : VX_VT5_EO5_VB5_PS1_XO9_o<6, 385, "bcdcfz." , []>;
1622480093f4SDimitry Andricdef BCDCTN_rec  : VX_VT5_EO5_VB5_XO9_o    <5, 385, "bcdctn." , []>;
1623480093f4SDimitry Andricdef BCDCTZ_rec  : VX_VT5_EO5_VB5_PS1_XO9_o<4, 385, "bcdctz." , []>;
1624480093f4SDimitry Andricdef BCDCFSQ_rec : VX_VT5_EO5_VB5_PS1_XO9_o<2, 385, "bcdcfsq.", []>;
1625480093f4SDimitry Andricdef BCDCTSQ_rec : VX_VT5_EO5_VB5_XO9_o    <0, 385, "bcdctsq.", []>;
16260b57cec5SDimitry Andric
16270b57cec5SDimitry Andric// Decimal Copy-Sign/Set-Sign
16280b57cec5SDimitry Andriclet Defs = [CR6] in
1629480093f4SDimitry Andricdef BCDCPSGN_rec : VX1_VT5_VA5_VB5<833, "bcdcpsgn.", []>;
16300b57cec5SDimitry Andric
1631480093f4SDimitry Andricdef BCDSETSGN_rec : VX_VT5_EO5_VB5_PS1_XO9_o<31, 385, "bcdsetsgn.", []>;
16320b57cec5SDimitry Andric
16330b57cec5SDimitry Andric// Decimal Shift/Unsigned-Shift/Shift-and-Round
1634480093f4SDimitry Andricdef BCDS_rec :  VX_VT5_VA5_VB5_PS1_XO9_o<193, "bcds." , []>;
1635480093f4SDimitry Andricdef BCDUS_rec : VX_VT5_VA5_VB5_XO9_o    <129, "bcdus.", []>;
1636480093f4SDimitry Andricdef BCDSR_rec : VX_VT5_VA5_VB5_PS1_XO9_o<449, "bcdsr.", []>;
16370b57cec5SDimitry Andric
16380b57cec5SDimitry Andric// Decimal (Unsigned) Truncate
1639480093f4SDimitry Andricdef BCDTRUNC_rec :  VX_VT5_VA5_VB5_PS1_XO9_o<257, "bcdtrunc." , []>;
1640480093f4SDimitry Andricdef BCDUTRUNC_rec : VX_VT5_VA5_VB5_XO9_o    <321, "bcdutrunc.", []>;
16410b57cec5SDimitry Andric
16420b57cec5SDimitry Andric// Absolute Difference
1643*06c3fb27SDimitry Andricdef VABSDUB : VXForm_1<1027, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1644*06c3fb27SDimitry Andric                       "vabsdub $VD, $VA, $VB", IIC_VecGeneral,
1645*06c3fb27SDimitry Andric                       [(set v16i8:$VD, (int_ppc_altivec_vabsdub v16i8:$VA, v16i8:$VB))]>;
1646*06c3fb27SDimitry Andricdef VABSDUH : VXForm_1<1091, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1647*06c3fb27SDimitry Andric                       "vabsduh $VD, $VA, $VB", IIC_VecGeneral,
1648*06c3fb27SDimitry Andric                       [(set v8i16:$VD, (int_ppc_altivec_vabsduh v8i16:$VA, v8i16:$VB))]>;
1649*06c3fb27SDimitry Andricdef VABSDUW : VXForm_1<1155, (outs vrrc:$VD), (ins vrrc:$VA, vrrc:$VB),
1650*06c3fb27SDimitry Andric                       "vabsduw $VD, $VA, $VB", IIC_VecGeneral,
1651*06c3fb27SDimitry Andric                       [(set v4i32:$VD, (int_ppc_altivec_vabsduw v4i32:$VA, v4i32:$VB))]>;
16520b57cec5SDimitry Andric
16530b57cec5SDimitry Andric} // end HasP9Altivec
1654