PPCInstrAltivec.td 80 KB

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