PPCInstrP10.td 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396
  1. //===-- PPCInstrP10.td - Power10 Instruction Set -----------*- tablegen -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  6. // See https://llvm.org/LICENSE.txt for license information.
  7. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  8. //
  9. //===----------------------------------------------------------------------===//
  10. //
  11. // This file describes the instructions introduced for the Power10 CPU.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. //===----------------------------------------------------------------------===//
  15. // Naming convention for future instruction formats
  16. //
  17. // <INSTR_FORM>{_<OP_TYPE><OP_LENGTH>}+
  18. //
  19. // Where:
  20. // <INSTR_FORM> - name of instruction format as per the ISA
  21. // (X-Form, VX-Form, etc.)
  22. // <OP_TYPE> - operand type
  23. // * FRT/RT/VT/XT/BT - target register
  24. // (FPR, GPR, VR, VSR, CR-bit respectively)
  25. // In some situations, the 'T' is replaced by
  26. // 'D' when describing the target register.
  27. // * [FR|R|V|X|B][A-Z] - register source (i.e. FRA, RA, XB, etc.)
  28. // * IMM - immediate (where signedness matters,
  29. // this is SI/UI for signed/unsigned)
  30. // * [R|X|FR]Tp - register pair target (i.e. FRTp, RTp)
  31. // * R - PC-Relative bit
  32. // (denotes that the address is computed pc-relative)
  33. // * VRM - Masked Registers
  34. // * AT - target accumulator
  35. // * N - the Nth bit in a VSR
  36. // * Additional 1-bit operands may be required for certain
  37. // instruction formats such as: MC, P, MP
  38. // * X / Y / P - mask values. In the instruction encoding, this is
  39. // represented as XMSK, YMSK and PMSK.
  40. // * MEM - indicates if the instruction format requires any memory
  41. // accesses. This does not have <OP_LENGTH> attached to it.
  42. // <OP_LENGTH> - the length of each operand in bits.
  43. // For operands that are 1 bit, the '1' is omitted from the name.
  44. //
  45. // Example: 8RR_XX4Form_IMM8_XTAB6
  46. // 8RR_XX4Form is the instruction format.
  47. // The operand is an 8-bit immediate (IMM), the destination (XT)
  48. // and sources (XA, XB) that are all 6-bits. The destination and
  49. // source registers are combined if they are of the same length.
  50. // Moreover, the order of operands reflects the order of operands
  51. // in the encoding.
  52. //-------------------------- Predicate definitions ---------------------------//
  53. def IsPPC32 : Predicate<"!Subtarget->isPPC64()">;
  54. //===----------------------------------------------------------------------===//
  55. // PowerPC ISA 3.1 specific type constraints.
  56. //
  57. def SDT_PPCSplat32 : SDTypeProfile<1, 3, [ SDTCisVT<0, v2i64>,
  58. SDTCisVec<1>, SDTCisInt<2>, SDTCisInt<3>
  59. ]>;
  60. def SDT_PPCAccBuild : SDTypeProfile<1, 4, [
  61. SDTCisVT<0, v512i1>, SDTCisVT<1, v4i32>, SDTCisVT<2, v4i32>,
  62. SDTCisVT<3, v4i32>, SDTCisVT<4, v4i32>
  63. ]>;
  64. def SDT_PPCPairBuild : SDTypeProfile<1, 2, [
  65. SDTCisVT<0, v256i1>, SDTCisVT<1, v4i32>, SDTCisVT<2, v4i32>
  66. ]>;
  67. def SDT_PPCAccExtractVsx : SDTypeProfile<1, 2, [
  68. SDTCisVT<0, v4i32>, SDTCisVT<1, v512i1>, SDTCisPtrTy<2>
  69. ]>;
  70. def SDT_PPCPairExtractVsx : SDTypeProfile<1, 2, [
  71. SDTCisVT<0, v4i32>, SDTCisVT<1, v256i1>, SDTCisPtrTy<2>
  72. ]>;
  73. def SDT_PPCxxmfacc : SDTypeProfile<1, 1, [
  74. SDTCisVT<0, v512i1>, SDTCisVT<1, v512i1>
  75. ]>;
  76. //===----------------------------------------------------------------------===//
  77. // ISA 3.1 specific PPCISD nodes.
  78. //
  79. def PPCxxsplti32dx : SDNode<"PPCISD::XXSPLTI32DX", SDT_PPCSplat32, []>;
  80. def PPCAccBuild : SDNode<"PPCISD::ACC_BUILD", SDT_PPCAccBuild, []>;
  81. def PPCPairBuild : SDNode<"PPCISD::PAIR_BUILD", SDT_PPCPairBuild, []>;
  82. def PPCAccExtractVsx : SDNode<"PPCISD::EXTRACT_VSX_REG", SDT_PPCAccExtractVsx,
  83. []>;
  84. def PPCPairExtractVsx : SDNode<"PPCISD::EXTRACT_VSX_REG", SDT_PPCPairExtractVsx,
  85. []>;
  86. def PPCxxmfacc : SDNode<"PPCISD::XXMFACC", SDT_PPCxxmfacc, []>;
  87. //===----------------------------------------------------------------------===//
  88. // PC Relative flag (for instructions that use the address of the prefix for
  89. // address computations).
  90. class isPCRel { bit PCRel = 1; }
  91. // PowerPC specific type constraints.
  92. def SDT_PPCLXVRZX : SDTypeProfile<1, 2, [
  93. SDTCisVT<0, v1i128>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
  94. ]>;
  95. // PPC Specific DAG Nodes.
  96. def PPClxvrzx : SDNode<"PPCISD::LXVRZX", SDT_PPCLXVRZX,
  97. [SDNPHasChain, SDNPMayLoad]>;
  98. // Top-level class for prefixed instructions.
  99. class PI<bits<6> pref, bits<6> opcode, dag OOL, dag IOL, string asmstr,
  100. InstrItinClass itin> : Instruction {
  101. field bits<64> Inst;
  102. field bits<64> SoftFail = 0;
  103. bit PCRel = 0; // Default value, set by isPCRel.
  104. let Size = 8;
  105. let Namespace = "PPC";
  106. let OutOperandList = OOL;
  107. let InOperandList = IOL;
  108. let AsmString = asmstr;
  109. let Itinerary = itin;
  110. let Inst{0-5} = pref;
  111. let Inst{32-37} = opcode;
  112. bits<1> PPC970_First = 0;
  113. bits<1> PPC970_Single = 0;
  114. bits<1> PPC970_Cracked = 0;
  115. bits<3> PPC970_Unit = 0;
  116. /// These fields correspond to the fields in PPCInstrInfo.h. Any changes to
  117. /// these must be reflected there! See comments there for what these are.
  118. let TSFlags{0} = PPC970_First;
  119. let TSFlags{1} = PPC970_Single;
  120. let TSFlags{2} = PPC970_Cracked;
  121. let TSFlags{5-3} = PPC970_Unit;
  122. bits<1> Prefixed = 1; // This is a prefixed instruction.
  123. let TSFlags{7} = Prefixed;
  124. // For cases where multiple instruction definitions really represent the
  125. // same underlying instruction but with one definition for 64-bit arguments
  126. // and one for 32-bit arguments, this bit breaks the degeneracy between
  127. // the two forms and allows TableGen to generate mapping tables.
  128. bit Interpretation64Bit = 0;
  129. // Fields used for relation models.
  130. string BaseName = "";
  131. }
  132. // VX-Form: [ PO VT R VB RC XO ]
  133. class VXForm_VTB5_RC<bits<10> xo, bits<5> R, dag OOL, dag IOL, string asmstr,
  134. InstrItinClass itin, list<dag> pattern>
  135. : I<4, OOL, IOL, asmstr, itin> {
  136. bits<5> VT;
  137. bits<5> VB;
  138. bit RC = 0;
  139. let Pattern = pattern;
  140. let Inst{6-10} = VT;
  141. let Inst{11-15} = R;
  142. let Inst{16-20} = VB;
  143. let Inst{21} = RC;
  144. let Inst{22-31} = xo;
  145. }
  146. // Multiclass definition to account for record and non-record form
  147. // instructions of VXRForm.
  148. multiclass VXForm_VTB5_RCr<bits<10> xo, bits<5> R, dag OOL, dag IOL,
  149. string asmbase, string asmstr,
  150. InstrItinClass itin, list<dag> pattern> {
  151. let BaseName = asmbase in {
  152. def NAME : VXForm_VTB5_RC<xo, R, OOL, IOL,
  153. !strconcat(asmbase, !strconcat(" ", asmstr)),
  154. itin, pattern>, RecFormRel;
  155. let Defs = [CR6] in
  156. def _rec : VXForm_VTB5_RC<xo, R, OOL, IOL,
  157. !strconcat(asmbase, !strconcat(". ", asmstr)),
  158. itin, []>, isRecordForm, RecFormRel;
  159. }
  160. }
  161. class MLS_DForm_R_SI34_RTA5_MEM<bits<6> opcode, dag OOL, dag IOL, string asmstr,
  162. InstrItinClass itin, list<dag> pattern>
  163. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  164. bits<5> FRS;
  165. bits<39> D_RA;
  166. let Pattern = pattern;
  167. // The prefix.
  168. let Inst{6-7} = 2;
  169. let Inst{8-10} = 0;
  170. let Inst{11} = PCRel;
  171. let Inst{12-13} = 0;
  172. let Inst{14-31} = D_RA{33-16}; // d0
  173. // The instruction.
  174. let Inst{38-42} = FRS{4-0};
  175. let Inst{43-47} = D_RA{38-34}; // RA
  176. let Inst{48-63} = D_RA{15-0}; // d1
  177. }
  178. class MLS_DForm_R_SI34_RTA5<bits<6> opcode, dag OOL, dag IOL, string asmstr,
  179. InstrItinClass itin, list<dag> pattern>
  180. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  181. bits<5> RT;
  182. bits<5> RA;
  183. bits<34> SI;
  184. let Pattern = pattern;
  185. // The prefix.
  186. let Inst{6-7} = 2;
  187. let Inst{8-10} = 0;
  188. let Inst{11} = PCRel;
  189. let Inst{12-13} = 0;
  190. let Inst{14-31} = SI{33-16};
  191. // The instruction.
  192. let Inst{38-42} = RT;
  193. let Inst{43-47} = RA;
  194. let Inst{48-63} = SI{15-0};
  195. }
  196. class MLS_DForm_SI34_RT5<bits<6> opcode, dag OOL, dag IOL, string asmstr,
  197. InstrItinClass itin, list<dag> pattern>
  198. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  199. bits<5> RT;
  200. bits<34> SI;
  201. let Pattern = pattern;
  202. // The prefix.
  203. let Inst{6-7} = 2;
  204. let Inst{8-10} = 0;
  205. let Inst{11} = 0;
  206. let Inst{12-13} = 0;
  207. let Inst{14-31} = SI{33-16};
  208. // The instruction.
  209. let Inst{38-42} = RT;
  210. let Inst{43-47} = 0;
  211. let Inst{48-63} = SI{15-0};
  212. }
  213. multiclass MLS_DForm_R_SI34_RTA5_p<bits<6> opcode, dag OOL, dag IOL,
  214. dag PCRel_IOL, string asmstr,
  215. InstrItinClass itin> {
  216. def NAME : MLS_DForm_R_SI34_RTA5<opcode, OOL, IOL,
  217. !strconcat(asmstr, ", 0"), itin, []>;
  218. def pc : MLS_DForm_R_SI34_RTA5<opcode, OOL, PCRel_IOL,
  219. !strconcat(asmstr, ", 1"), itin, []>, isPCRel;
  220. }
  221. class 8LS_DForm_R_SI34_RTA5_MEM<bits<6> opcode, dag OOL, dag IOL, string asmstr,
  222. InstrItinClass itin, list<dag> pattern>
  223. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  224. bits<5> RT;
  225. bits<39> D_RA;
  226. let Pattern = pattern;
  227. // The prefix.
  228. let Inst{6-10} = 0;
  229. let Inst{11} = PCRel;
  230. let Inst{12-13} = 0;
  231. let Inst{14-31} = D_RA{33-16}; // d0
  232. // The instruction.
  233. let Inst{38-42} = RT{4-0};
  234. let Inst{43-47} = D_RA{38-34}; // RA
  235. let Inst{48-63} = D_RA{15-0}; // d1
  236. }
  237. // 8LS:D-Form: [ 1 0 0 // R // d0
  238. // PO TX T RA d1 ]
  239. class 8LS_DForm_R_SI34_XT6_RA5_MEM<bits<5> opcode, dag OOL, dag IOL,
  240. string asmstr, InstrItinClass itin,
  241. list<dag> pattern>
  242. : PI<1, { opcode, ? }, OOL, IOL, asmstr, itin> {
  243. bits<6> XT;
  244. bits<39> D_RA;
  245. let Pattern = pattern;
  246. // The prefix.
  247. let Inst{6-7} = 0;
  248. let Inst{8} = 0;
  249. let Inst{9-10} = 0; // reserved
  250. let Inst{11} = PCRel;
  251. let Inst{12-13} = 0; // reserved
  252. let Inst{14-31} = D_RA{33-16}; // d0
  253. // The instruction.
  254. let Inst{37} = XT{5};
  255. let Inst{38-42} = XT{4-0};
  256. let Inst{43-47} = D_RA{38-34}; // RA
  257. let Inst{48-63} = D_RA{15-0}; // d1
  258. }
  259. // X-Form: [PO T IMM VRB XO TX]
  260. class XForm_XT6_IMM5_VB5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  261. string asmstr, InstrItinClass itin, list<dag> pattern>
  262. : I<opcode, OOL, IOL, asmstr, itin> {
  263. bits<6> XT;
  264. bits<5> VRB;
  265. bits<5> IMM;
  266. let Pattern = pattern;
  267. let Inst{6-10} = XT{4-0};
  268. let Inst{11-15} = IMM;
  269. let Inst{16-20} = VRB;
  270. let Inst{21-30} = xo;
  271. let Inst{31} = XT{5};
  272. }
  273. class 8RR_XX4Form_IMM8_XTAB6<bits<6> opcode, bits<2> xo,
  274. dag OOL, dag IOL, string asmstr,
  275. InstrItinClass itin, list<dag> pattern>
  276. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  277. bits<6> XT;
  278. bits<6> XA;
  279. bits<6> XB;
  280. bits<6> XC;
  281. bits<8> IMM;
  282. let Pattern = pattern;
  283. // The prefix.
  284. let Inst{6-7} = 1;
  285. let Inst{8} = 0;
  286. let Inst{9-11} = 0;
  287. let Inst{12-13} = 0;
  288. let Inst{14-23} = 0;
  289. let Inst{24-31} = IMM;
  290. // The instruction.
  291. let Inst{38-42} = XT{4-0};
  292. let Inst{43-47} = XA{4-0};
  293. let Inst{48-52} = XB{4-0};
  294. let Inst{53-57} = XC{4-0};
  295. let Inst{58-59} = xo;
  296. let Inst{60} = XC{5};
  297. let Inst{61} = XA{5};
  298. let Inst{62} = XB{5};
  299. let Inst{63} = XT{5};
  300. }
  301. class VXForm_RD5_N3_VB5<bits<11> xo, dag OOL, dag IOL, string asmstr,
  302. InstrItinClass itin, list<dag> pattern>
  303. : I<4, OOL, IOL, asmstr, itin> {
  304. bits<5> RD;
  305. bits<5> VB;
  306. bits<3> N;
  307. let Pattern = pattern;
  308. let Inst{6-10} = RD;
  309. let Inst{11-12} = 0;
  310. let Inst{13-15} = N;
  311. let Inst{16-20} = VB;
  312. let Inst{21-31} = xo;
  313. }
  314. // VX-Form: [PO VRT RA VRB XO].
  315. // Destructive (insert) forms are suffixed with _ins.
  316. class VXForm_VTB5_RA5_ins<bits<11> xo, string opc, list<dag> pattern>
  317. : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vDi, gprc:$rA, vrrc:$vB),
  318. !strconcat(opc, " $vD, $rA, $vB"), IIC_VecGeneral, pattern>,
  319. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  320. // VX-Form: [PO VRT RA RB XO].
  321. // Destructive (insert) forms are suffixed with _ins.
  322. class VXForm_VRT5_RAB5_ins<bits<11> xo, string opc, list<dag> pattern>
  323. : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vDi, gprc:$rA, gprc:$rB),
  324. !strconcat(opc, " $vD, $rA, $rB"), IIC_VecGeneral, pattern>,
  325. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  326. // VX-Form: [ PO BF // VRA VRB XO ]
  327. class VXForm_BF3_VAB5<bits<11> xo, dag OOL, dag IOL, string asmstr,
  328. InstrItinClass itin, list<dag> pattern>
  329. : I<4, OOL, IOL, asmstr, itin> {
  330. bits<3> BF;
  331. bits<5> VA;
  332. bits<5> VB;
  333. let Pattern = pattern;
  334. let Inst{6-8} = BF;
  335. let Inst{9-10} = 0;
  336. let Inst{11-15} = VA;
  337. let Inst{16-20} = VB;
  338. let Inst{21-31} = xo;
  339. }
  340. // VN-Form: [PO VRT VRA VRB PS SD XO]
  341. // SD is "Shift Direction"
  342. class VNForm_VTAB5_SD3<bits<6> xo, bits<2> ps, dag OOL, dag IOL, string asmstr,
  343. InstrItinClass itin, list<dag> pattern>
  344. : I<4, OOL, IOL, asmstr, itin> {
  345. bits<5> VRT;
  346. bits<5> VRA;
  347. bits<5> VRB;
  348. bits<3> SD;
  349. let Pattern = pattern;
  350. let Inst{6-10} = VRT;
  351. let Inst{11-15} = VRA;
  352. let Inst{16-20} = VRB;
  353. let Inst{21-22} = ps;
  354. let Inst{23-25} = SD;
  355. let Inst{26-31} = xo;
  356. }
  357. class VXForm_RD5_MP_VB5<bits<11> xo, bits<4> eo, dag OOL, dag IOL,
  358. string asmstr, InstrItinClass itin, list<dag> pattern>
  359. : I<4, OOL, IOL, asmstr, itin> {
  360. bits<5> RD;
  361. bits<5> VB;
  362. bit MP;
  363. let Pattern = pattern;
  364. let Inst{6-10} = RD;
  365. let Inst{11-14} = eo;
  366. let Inst{15} = MP;
  367. let Inst{16-20} = VB;
  368. let Inst{21-31} = xo;
  369. }
  370. // 8RR:D-Form: [ 1 1 0 // // imm0
  371. // PO T XO TX imm1 ].
  372. class 8RR_DForm_IMM32_XT6<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
  373. string asmstr, InstrItinClass itin,
  374. list<dag> pattern>
  375. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  376. bits<6> XT;
  377. bits<32> IMM32;
  378. let Pattern = pattern;
  379. // The prefix.
  380. let Inst{6-7} = 1;
  381. let Inst{8-11} = 0;
  382. let Inst{12-13} = 0; // reserved
  383. let Inst{14-15} = 0; // reserved
  384. let Inst{16-31} = IMM32{31-16};
  385. // The instruction.
  386. let Inst{38-42} = XT{4-0};
  387. let Inst{43-46} = xo;
  388. let Inst{47} = XT{5};
  389. let Inst{48-63} = IMM32{15-0};
  390. }
  391. // 8RR:D-Form: [ 1 1 0 // // imm0
  392. // PO T XO IX TX imm1 ].
  393. class 8RR_DForm_IMM32_XT6_IX<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
  394. string asmstr, InstrItinClass itin,
  395. list<dag> pattern>
  396. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  397. bits<6> XT;
  398. bit IX;
  399. bits<32> IMM32;
  400. let Pattern = pattern;
  401. // The prefix.
  402. let Inst{6-7} = 1;
  403. let Inst{8-11} = 0;
  404. let Inst{12-13} = 0; // reserved
  405. let Inst{14-15} = 0; // reserved
  406. let Inst{16-31} = IMM32{31-16};
  407. // The instruction.
  408. let Inst{38-42} = XT{4-0};
  409. let Inst{43-45} = xo;
  410. let Inst{46} = IX;
  411. let Inst{47} = XT{5};
  412. let Inst{48-63} = IMM32{15-0};
  413. }
  414. class 8RR_XX4Form_XTABC6<bits<6> opcode, bits<2> xo, dag OOL, dag IOL,
  415. string asmstr, InstrItinClass itin, list<dag> pattern>
  416. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  417. bits<6> XT;
  418. bits<6> XA;
  419. bits<6> XB;
  420. bits<6> XC;
  421. let Pattern = pattern;
  422. // The prefix.
  423. let Inst{6-7} = 1;
  424. let Inst{8-11} = 0;
  425. let Inst{12-13} = 0;
  426. let Inst{14-31} = 0;
  427. // The instruction.
  428. let Inst{38-42} = XT{4-0};
  429. let Inst{43-47} = XA{4-0};
  430. let Inst{48-52} = XB{4-0};
  431. let Inst{53-57} = XC{4-0};
  432. let Inst{58-59} = xo;
  433. let Inst{60} = XC{5};
  434. let Inst{61} = XA{5};
  435. let Inst{62} = XB{5};
  436. let Inst{63} = XT{5};
  437. }
  438. class 8RR_XX4Form_IMM3_XTABC6<bits<6> opcode, bits<2> xo, dag OOL, dag IOL,
  439. string asmstr, InstrItinClass itin,
  440. list<dag> pattern>
  441. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  442. bits<6> XT;
  443. bits<6> XA;
  444. bits<6> XB;
  445. bits<6> XC;
  446. bits<3> IMM;
  447. let Pattern = pattern;
  448. // The prefix.
  449. let Inst{6-7} = 1;
  450. let Inst{8-11} = 0;
  451. let Inst{12-13} = 0;
  452. let Inst{14-28} = 0;
  453. let Inst{29-31} = IMM;
  454. // The instruction.
  455. let Inst{38-42} = XT{4-0};
  456. let Inst{43-47} = XA{4-0};
  457. let Inst{48-52} = XB{4-0};
  458. let Inst{53-57} = XC{4-0};
  459. let Inst{58-59} = xo;
  460. let Inst{60} = XC{5};
  461. let Inst{61} = XA{5};
  462. let Inst{62} = XB{5};
  463. let Inst{63} = XT{5};
  464. }
  465. // [PO BF / XO2 B XO BX /]
  466. class XX2_BF3_XO5_XB6_XO9<bits<6> opcode, bits<5> xo2, bits<9> xo, dag OOL,
  467. dag IOL, string asmstr, InstrItinClass itin,
  468. list<dag> pattern>
  469. : I<opcode, OOL, IOL, asmstr, itin> {
  470. bits<3> BF;
  471. bits<6> XB;
  472. let Pattern = pattern;
  473. let Inst{6-8} = BF;
  474. let Inst{9-10} = 0;
  475. let Inst{11-15} = xo2;
  476. let Inst{16-20} = XB{4-0};
  477. let Inst{21-29} = xo;
  478. let Inst{30} = XB{5};
  479. let Inst{31} = 0;
  480. }
  481. // X-Form: [ PO RT BI /// XO / ]
  482. class XForm_XT5_BI5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  483. string asmstr, InstrItinClass itin, list<dag> pattern>
  484. : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
  485. let B = 0;
  486. }
  487. multiclass MLS_DForm_R_SI34_RTA5_MEM_p<bits<6> opcode, dag OOL, dag IOL,
  488. dag PCRel_IOL, string asmstr,
  489. InstrItinClass itin> {
  490. def NAME : MLS_DForm_R_SI34_RTA5_MEM<opcode, OOL, IOL,
  491. !strconcat(asmstr, ", 0"), itin, []>;
  492. def pc : MLS_DForm_R_SI34_RTA5_MEM<opcode, OOL, PCRel_IOL,
  493. !strconcat(asmstr, ", 1"), itin, []>,
  494. isPCRel;
  495. }
  496. multiclass 8LS_DForm_R_SI34_RTA5_MEM_p<bits<6> opcode, dag OOL, dag IOL,
  497. dag PCRel_IOL, string asmstr,
  498. InstrItinClass itin> {
  499. def NAME : 8LS_DForm_R_SI34_RTA5_MEM<opcode, OOL, IOL,
  500. !strconcat(asmstr, ", 0"), itin, []>;
  501. def pc : 8LS_DForm_R_SI34_RTA5_MEM<opcode, OOL, PCRel_IOL,
  502. !strconcat(asmstr, ", 1"), itin, []>,
  503. isPCRel;
  504. }
  505. multiclass 8LS_DForm_R_SI34_XT6_RA5_MEM_p<bits<5> opcode, dag OOL, dag IOL,
  506. dag PCRel_IOL, string asmstr,
  507. InstrItinClass itin> {
  508. def NAME : 8LS_DForm_R_SI34_XT6_RA5_MEM<opcode, OOL, IOL,
  509. !strconcat(asmstr, ", 0"), itin, []>;
  510. def pc : 8LS_DForm_R_SI34_XT6_RA5_MEM<opcode, OOL, PCRel_IOL,
  511. !strconcat(asmstr, ", 1"), itin, []>,
  512. isPCRel;
  513. }
  514. def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
  515. def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
  516. def PairedVectorMemops : Predicate<"Subtarget->pairedVectorMemops()">;
  517. def RCCp {
  518. dag AToVSRC = (COPY_TO_REGCLASS $XA, VSRC);
  519. dag BToVSRC = (COPY_TO_REGCLASS $XB, VSRC);
  520. }
  521. let Predicates = [PrefixInstrs] in {
  522. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  523. defm PADDI8 :
  524. MLS_DForm_R_SI34_RTA5_p<14, (outs g8rc:$RT), (ins g8rc:$RA, s34imm:$SI),
  525. (ins immZero:$RA, s34imm_pcrel:$SI),
  526. "paddi $RT, $RA, $SI", IIC_LdStLFD>;
  527. let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
  528. def PLI8 : MLS_DForm_SI34_RT5<14, (outs g8rc:$RT),
  529. (ins s34imm:$SI),
  530. "pli $RT, $SI", IIC_IntSimple, []>;
  531. }
  532. }
  533. defm PADDI :
  534. MLS_DForm_R_SI34_RTA5_p<14, (outs gprc:$RT), (ins gprc:$RA, s34imm:$SI),
  535. (ins immZero:$RA, s34imm_pcrel:$SI),
  536. "paddi $RT, $RA, $SI", IIC_LdStLFD>;
  537. let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
  538. def PLI : MLS_DForm_SI34_RT5<14, (outs gprc:$RT),
  539. (ins s34imm:$SI),
  540. "pli $RT, $SI", IIC_IntSimple, []>;
  541. }
  542. let mayLoad = 1, mayStore = 0 in {
  543. defm PLXV :
  544. 8LS_DForm_R_SI34_XT6_RA5_MEM_p<25, (outs vsrc:$XT), (ins memri34:$D_RA),
  545. (ins memri34_pcrel:$D_RA),
  546. "plxv $XT, $D_RA", IIC_LdStLFD>;
  547. defm PLFS :
  548. MLS_DForm_R_SI34_RTA5_MEM_p<48, (outs f4rc:$FRT), (ins memri34:$D_RA),
  549. (ins memri34_pcrel:$D_RA), "plfs $FRT, $D_RA",
  550. IIC_LdStLFD>;
  551. defm PLFD :
  552. MLS_DForm_R_SI34_RTA5_MEM_p<50, (outs f8rc:$FRT), (ins memri34:$D_RA),
  553. (ins memri34_pcrel:$D_RA), "plfd $FRT, $D_RA",
  554. IIC_LdStLFD>;
  555. defm PLXSSP :
  556. 8LS_DForm_R_SI34_RTA5_MEM_p<43, (outs vfrc:$VRT), (ins memri34:$D_RA),
  557. (ins memri34_pcrel:$D_RA),
  558. "plxssp $VRT, $D_RA", IIC_LdStLFD>;
  559. defm PLXSD :
  560. 8LS_DForm_R_SI34_RTA5_MEM_p<42, (outs vfrc:$VRT), (ins memri34:$D_RA),
  561. (ins memri34_pcrel:$D_RA),
  562. "plxsd $VRT, $D_RA", IIC_LdStLFD>;
  563. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  564. defm PLBZ8 :
  565. MLS_DForm_R_SI34_RTA5_MEM_p<34, (outs g8rc:$RT), (ins memri34:$D_RA),
  566. (ins memri34_pcrel:$D_RA), "plbz $RT, $D_RA",
  567. IIC_LdStLFD>;
  568. defm PLHZ8 :
  569. MLS_DForm_R_SI34_RTA5_MEM_p<40, (outs g8rc:$RT), (ins memri34:$D_RA),
  570. (ins memri34_pcrel:$D_RA), "plhz $RT, $D_RA",
  571. IIC_LdStLFD>;
  572. defm PLHA8 :
  573. MLS_DForm_R_SI34_RTA5_MEM_p<42, (outs g8rc:$RT), (ins memri34:$D_RA),
  574. (ins memri34_pcrel:$D_RA), "plha $RT, $D_RA",
  575. IIC_LdStLFD>;
  576. defm PLWA8 :
  577. 8LS_DForm_R_SI34_RTA5_MEM_p<41, (outs g8rc:$RT), (ins memri34:$D_RA),
  578. (ins memri34_pcrel:$D_RA),
  579. "plwa $RT, $D_RA", IIC_LdStLFD>;
  580. defm PLWZ8 :
  581. MLS_DForm_R_SI34_RTA5_MEM_p<32, (outs g8rc:$RT), (ins memri34:$D_RA),
  582. (ins memri34_pcrel:$D_RA), "plwz $RT, $D_RA",
  583. IIC_LdStLFD>;
  584. }
  585. defm PLBZ :
  586. MLS_DForm_R_SI34_RTA5_MEM_p<34, (outs gprc:$RT), (ins memri34:$D_RA),
  587. (ins memri34_pcrel:$D_RA), "plbz $RT, $D_RA",
  588. IIC_LdStLFD>;
  589. defm PLHZ :
  590. MLS_DForm_R_SI34_RTA5_MEM_p<40, (outs gprc:$RT), (ins memri34:$D_RA),
  591. (ins memri34_pcrel:$D_RA), "plhz $RT, $D_RA",
  592. IIC_LdStLFD>;
  593. defm PLHA :
  594. MLS_DForm_R_SI34_RTA5_MEM_p<42, (outs gprc:$RT), (ins memri34:$D_RA),
  595. (ins memri34_pcrel:$D_RA), "plha $RT, $D_RA",
  596. IIC_LdStLFD>;
  597. defm PLWZ :
  598. MLS_DForm_R_SI34_RTA5_MEM_p<32, (outs gprc:$RT), (ins memri34:$D_RA),
  599. (ins memri34_pcrel:$D_RA), "plwz $RT, $D_RA",
  600. IIC_LdStLFD>;
  601. defm PLWA :
  602. 8LS_DForm_R_SI34_RTA5_MEM_p<41, (outs gprc:$RT), (ins memri34:$D_RA),
  603. (ins memri34_pcrel:$D_RA), "plwa $RT, $D_RA",
  604. IIC_LdStLFD>;
  605. defm PLD :
  606. 8LS_DForm_R_SI34_RTA5_MEM_p<57, (outs g8rc:$RT), (ins memri34:$D_RA),
  607. (ins memri34_pcrel:$D_RA), "pld $RT, $D_RA",
  608. IIC_LdStLFD>;
  609. }
  610. let mayStore = 1, mayLoad = 0 in {
  611. defm PSTXV :
  612. 8LS_DForm_R_SI34_XT6_RA5_MEM_p<27, (outs), (ins vsrc:$XS, memri34:$D_RA),
  613. (ins vsrc:$XS, memri34_pcrel:$D_RA),
  614. "pstxv $XS, $D_RA", IIC_LdStLFD>;
  615. defm PSTFS :
  616. MLS_DForm_R_SI34_RTA5_MEM_p<52, (outs), (ins f4rc:$FRS, memri34:$D_RA),
  617. (ins f4rc:$FRS, memri34_pcrel:$D_RA),
  618. "pstfs $FRS, $D_RA", IIC_LdStLFD>;
  619. defm PSTFD :
  620. MLS_DForm_R_SI34_RTA5_MEM_p<54, (outs), (ins f8rc:$FRS, memri34:$D_RA),
  621. (ins f8rc:$FRS, memri34_pcrel:$D_RA),
  622. "pstfd $FRS, $D_RA", IIC_LdStLFD>;
  623. defm PSTXSSP :
  624. 8LS_DForm_R_SI34_RTA5_MEM_p<47, (outs), (ins vfrc:$VRS, memri34:$D_RA),
  625. (ins vfrc:$VRS, memri34_pcrel:$D_RA),
  626. "pstxssp $VRS, $D_RA", IIC_LdStLFD>;
  627. defm PSTXSD :
  628. 8LS_DForm_R_SI34_RTA5_MEM_p<46, (outs), (ins vfrc:$VRS, memri34:$D_RA),
  629. (ins vfrc:$VRS, memri34_pcrel:$D_RA),
  630. "pstxsd $VRS, $D_RA", IIC_LdStLFD>;
  631. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  632. defm PSTB8 :
  633. MLS_DForm_R_SI34_RTA5_MEM_p<38, (outs), (ins g8rc:$RS, memri34:$D_RA),
  634. (ins g8rc:$RS, memri34_pcrel:$D_RA),
  635. "pstb $RS, $D_RA", IIC_LdStLFD>;
  636. defm PSTH8 :
  637. MLS_DForm_R_SI34_RTA5_MEM_p<44, (outs), (ins g8rc:$RS, memri34:$D_RA),
  638. (ins g8rc:$RS, memri34_pcrel:$D_RA),
  639. "psth $RS, $D_RA", IIC_LdStLFD>;
  640. defm PSTW8 :
  641. MLS_DForm_R_SI34_RTA5_MEM_p<36, (outs), (ins g8rc:$RS, memri34:$D_RA),
  642. (ins g8rc:$RS, memri34_pcrel:$D_RA),
  643. "pstw $RS, $D_RA", IIC_LdStLFD>;
  644. }
  645. defm PSTB :
  646. MLS_DForm_R_SI34_RTA5_MEM_p<38, (outs), (ins gprc:$RS, memri34:$D_RA),
  647. (ins gprc:$RS, memri34_pcrel:$D_RA),
  648. "pstb $RS, $D_RA", IIC_LdStLFD>;
  649. defm PSTH :
  650. MLS_DForm_R_SI34_RTA5_MEM_p<44, (outs), (ins gprc:$RS, memri34:$D_RA),
  651. (ins gprc:$RS, memri34_pcrel:$D_RA),
  652. "psth $RS, $D_RA", IIC_LdStLFD>;
  653. defm PSTW :
  654. MLS_DForm_R_SI34_RTA5_MEM_p<36, (outs), (ins gprc:$RS, memri34:$D_RA),
  655. (ins gprc:$RS, memri34_pcrel:$D_RA),
  656. "pstw $RS, $D_RA", IIC_LdStLFD>;
  657. defm PSTD :
  658. 8LS_DForm_R_SI34_RTA5_MEM_p<61, (outs), (ins g8rc:$RS, memri34:$D_RA),
  659. (ins g8rc:$RS, memri34_pcrel:$D_RA),
  660. "pstd $RS, $D_RA", IIC_LdStLFD>;
  661. }
  662. }
  663. class DQForm_XTp5_RA17_MEM<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
  664. string asmstr, InstrItinClass itin, list<dag> pattern>
  665. : I<opcode, OOL, IOL, asmstr, itin> {
  666. bits<5> XTp;
  667. bits<17> DQ_RA;
  668. let Pattern = pattern;
  669. let Inst{6-9} = XTp{3-0};
  670. let Inst{10} = XTp{4};
  671. let Inst{11-15} = DQ_RA{16-12}; // Register #
  672. let Inst{16-27} = DQ_RA{11-0}; // Displacement.
  673. let Inst{28-31} = xo;
  674. }
  675. class XForm_XTp5_XAB5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
  676. string asmstr, InstrItinClass itin, list<dag> pattern>
  677. : I<opcode, OOL, IOL, asmstr, itin>, XFormMemOp {
  678. bits<5> XTp;
  679. bits<5> A;
  680. bits<5> B;
  681. let Pattern = pattern;
  682. let Inst{6-9} = XTp{3-0};
  683. let Inst{10} = XTp{4};
  684. let Inst{11-15} = A;
  685. let Inst{16-20} = B;
  686. let Inst{21-30} = xo;
  687. let Inst{31} = 0;
  688. }
  689. class 8LS_DForm_R_XTp5_SI34_MEM<bits<6> opcode, dag OOL, dag IOL, string asmstr,
  690. InstrItinClass itin, list<dag> pattern>
  691. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  692. bits<5> XTp;
  693. bits<39> D_RA;
  694. let Pattern = pattern;
  695. // The prefix.
  696. let Inst{6-10} = 0;
  697. let Inst{11} = PCRel;
  698. let Inst{12-13} = 0;
  699. let Inst{14-31} = D_RA{33-16}; // Imm18
  700. // The instruction.
  701. let Inst{38-41} = XTp{3-0};
  702. let Inst{42} = XTp{4};
  703. let Inst{43-47} = D_RA{38-34}; // Register #
  704. let Inst{48-63} = D_RA{15-0}; // D
  705. }
  706. multiclass 8LS_DForm_R_XTp5_SI34_MEM_p<bits<6> opcode, dag OOL,
  707. dag IOL, dag PCRel_IOL,
  708. string asmstr, InstrItinClass itin> {
  709. def NAME : 8LS_DForm_R_XTp5_SI34_MEM<opcode, OOL, IOL,
  710. !strconcat(asmstr, ", 0"), itin, []>;
  711. def pc : 8LS_DForm_R_XTp5_SI34_MEM<opcode, OOL, PCRel_IOL,
  712. !strconcat(asmstr, ", 1"), itin, []>,
  713. isPCRel;
  714. }
  715. // [PO AS XO2 XO]
  716. class XForm_AT3<bits<6> opcode, bits<5> xo2, bits<10> xo, dag OOL, dag IOL,
  717. string asmstr, InstrItinClass itin, list<dag> pattern>
  718. : I<opcode, OOL, IOL, asmstr, itin> {
  719. bits<3> AT;
  720. let Pattern = pattern;
  721. let Inst{6-8} = AT;
  722. let Inst{9-10} = 0;
  723. let Inst{11-15} = xo2;
  724. let Inst{16-20} = 0;
  725. let Inst{21-30} = xo;
  726. let Inst{31} = 0;
  727. }
  728. // X-Form: [ PO T EO UIM XO TX ]
  729. class XForm_XT6_IMM5<bits<6> opcode, bits<5> eo, bits<10> xo, dag OOL, dag IOL,
  730. string asmstr, InstrItinClass itin, list<dag> pattern>
  731. : I<opcode, OOL, IOL, asmstr, itin> {
  732. bits<6> XT;
  733. bits<5> UIM;
  734. let Pattern = pattern;
  735. let Inst{6-10} = XT{4-0};
  736. let Inst{11-15} = eo;
  737. let Inst{16-20} = UIM;
  738. let Inst{21-30} = xo;
  739. let Inst{31} = XT{5};
  740. }
  741. class XX3Form_AT3_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  742. string asmstr, InstrItinClass itin,
  743. list<dag> pattern>
  744. : I<opcode, OOL, IOL, asmstr, itin> {
  745. bits<3> AT;
  746. bits<6> XA;
  747. bits<6> XB;
  748. let Pattern = pattern;
  749. let Inst{6-8} = AT;
  750. let Inst{9-10} = 0;
  751. let Inst{11-15} = XA{4-0};
  752. let Inst{16-20} = XB{4-0};
  753. let Inst{21-28} = xo;
  754. let Inst{29} = XA{5};
  755. let Inst{30} = XB{5};
  756. let Inst{31} = 0;
  757. }
  758. class MMIRR_XX3Form_XY4P2_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  759. string asmstr, InstrItinClass itin,
  760. list<dag> pattern>
  761. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  762. bits<3> AT;
  763. bits<6> XA;
  764. bits<6> XB;
  765. bits<4> XMSK;
  766. bits<4> YMSK;
  767. bits<2> PMSK;
  768. let Pattern = pattern;
  769. // The prefix.
  770. let Inst{6-7} = 3;
  771. let Inst{8-11} = 9;
  772. let Inst{12-15} = 0;
  773. let Inst{16-17} = PMSK;
  774. let Inst{18-23} = 0;
  775. let Inst{24-27} = XMSK;
  776. let Inst{28-31} = YMSK;
  777. // The instruction.
  778. let Inst{38-40} = AT;
  779. let Inst{41-42} = 0;
  780. let Inst{43-47} = XA{4-0};
  781. let Inst{48-52} = XB{4-0};
  782. let Inst{53-60} = xo;
  783. let Inst{61} = XA{5};
  784. let Inst{62} = XB{5};
  785. let Inst{63} = 0;
  786. }
  787. class MMIRR_XX3Form_XY4_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  788. string asmstr, InstrItinClass itin,
  789. list<dag> pattern>
  790. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  791. bits<3> AT;
  792. bits<6> XA;
  793. bits<6> XB;
  794. bits<4> XMSK;
  795. bits<4> YMSK;
  796. let Pattern = pattern;
  797. // The prefix.
  798. let Inst{6-7} = 3;
  799. let Inst{8-11} = 9;
  800. let Inst{12-23} = 0;
  801. let Inst{24-27} = XMSK;
  802. let Inst{28-31} = YMSK;
  803. // The instruction.
  804. let Inst{38-40} = AT;
  805. let Inst{41-42} = 0;
  806. let Inst{43-47} = XA{4-0};
  807. let Inst{48-52} = XB{4-0};
  808. let Inst{53-60} = xo;
  809. let Inst{61} = XA{5};
  810. let Inst{62} = XB{5};
  811. let Inst{63} = 0;
  812. }
  813. class MMIRR_XX3Form_X4Y2_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  814. string asmstr, InstrItinClass itin,
  815. list<dag> pattern>
  816. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  817. bits<3> AT;
  818. bits<6> XA;
  819. bits<6> XB;
  820. bits<4> XMSK;
  821. bits<2> YMSK;
  822. let Pattern = pattern;
  823. // The prefix.
  824. let Inst{6-7} = 3;
  825. let Inst{8-11} = 9;
  826. let Inst{12-23} = 0;
  827. let Inst{24-27} = XMSK;
  828. let Inst{28-29} = YMSK;
  829. let Inst{30-31} = 0;
  830. // The instruction.
  831. let Inst{38-40} = AT;
  832. let Inst{41-42} = 0;
  833. let Inst{43-47} = XA{4-0};
  834. let Inst{48-52} = XB{4-0};
  835. let Inst{53-60} = xo;
  836. let Inst{61} = XA{5};
  837. let Inst{62} = XB{5};
  838. let Inst{63} = 0;
  839. }
  840. class MMIRR_XX3Form_XY4P8_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  841. string asmstr, InstrItinClass itin,
  842. list<dag> pattern>
  843. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  844. bits<3> AT;
  845. bits<6> XA;
  846. bits<6> XB;
  847. bits<4> XMSK;
  848. bits<4> YMSK;
  849. bits<8> PMSK;
  850. let Pattern = pattern;
  851. // The prefix.
  852. let Inst{6-7} = 3;
  853. let Inst{8-11} = 9;
  854. let Inst{12-15} = 0;
  855. let Inst{16-23} = PMSK;
  856. let Inst{24-27} = XMSK;
  857. let Inst{28-31} = YMSK;
  858. // The instruction.
  859. let Inst{38-40} = AT;
  860. let Inst{41-42} = 0;
  861. let Inst{43-47} = XA{4-0};
  862. let Inst{48-52} = XB{4-0};
  863. let Inst{53-60} = xo;
  864. let Inst{61} = XA{5};
  865. let Inst{62} = XB{5};
  866. let Inst{63} = 0;
  867. }
  868. class MMIRR_XX3Form_XYP4_XAB6<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
  869. string asmstr, InstrItinClass itin,
  870. list<dag> pattern>
  871. : PI<1, opcode, OOL, IOL, asmstr, itin> {
  872. bits<3> AT;
  873. bits<6> XA;
  874. bits<6> XB;
  875. bits<4> XMSK;
  876. bits<4> YMSK;
  877. bits<4> PMSK;
  878. let Pattern = pattern;
  879. // The prefix.
  880. let Inst{6-7} = 3;
  881. let Inst{8-11} = 9;
  882. let Inst{12-15} = 0;
  883. let Inst{16-19} = PMSK;
  884. let Inst{20-23} = 0;
  885. let Inst{24-27} = XMSK;
  886. let Inst{28-31} = YMSK;
  887. // The instruction.
  888. let Inst{38-40} = AT;
  889. let Inst{41-42} = 0;
  890. let Inst{43-47} = XA{4-0};
  891. let Inst{48-52} = XB{4-0};
  892. let Inst{53-60} = xo;
  893. let Inst{61} = XA{5};
  894. let Inst{62} = XB{5};
  895. let Inst{63} = 0;
  896. }
  897. def Concats {
  898. dag VecsToVecPair0 =
  899. (v256i1 (INSERT_SUBREG
  900. (INSERT_SUBREG (IMPLICIT_DEF), $vs0, sub_vsx1),
  901. $vs1, sub_vsx0));
  902. dag VecsToVecPair1 =
  903. (v256i1 (INSERT_SUBREG
  904. (INSERT_SUBREG (IMPLICIT_DEF), $vs2, sub_vsx1),
  905. $vs3, sub_vsx0));
  906. }
  907. let Predicates = [PairedVectorMemops] in {
  908. def : Pat<(v256i1 (PPCPairBuild v4i32:$vs1, v4i32:$vs0)),
  909. Concats.VecsToVecPair0>;
  910. def : Pat<(v256i1 (int_ppc_vsx_assemble_pair v16i8:$vs1, v16i8:$vs0)),
  911. Concats.VecsToVecPair0>;
  912. def : Pat<(v4i32 (PPCPairExtractVsx vsrpevenrc:$v, 0)),
  913. (v4i32 (EXTRACT_SUBREG $v, sub_vsx0))>;
  914. def : Pat<(v4i32 (PPCPairExtractVsx vsrpevenrc:$v, 1)),
  915. (v4i32 (EXTRACT_SUBREG $v, sub_vsx1))>;
  916. }
  917. let mayLoad = 1, mayStore = 0, Predicates = [PairedVectorMemops] in {
  918. def LXVP : DQForm_XTp5_RA17_MEM<6, 0, (outs vsrprc:$XTp),
  919. (ins memrix16:$DQ_RA), "lxvp $XTp, $DQ_RA",
  920. IIC_LdStLFD, []>;
  921. def LXVPX : XForm_XTp5_XAB5<31, 333, (outs vsrprc:$XTp), (ins memrr:$src),
  922. "lxvpx $XTp, $src", IIC_LdStLFD,
  923. []>;
  924. }
  925. let mayLoad = 0, mayStore = 1, Predicates = [PairedVectorMemops] in {
  926. def STXVP : DQForm_XTp5_RA17_MEM<6, 1, (outs), (ins vsrprc:$XTp,
  927. memrix16:$DQ_RA), "stxvp $XTp, $DQ_RA",
  928. IIC_LdStLFD, []>;
  929. def STXVPX : XForm_XTp5_XAB5<31, 461, (outs), (ins vsrprc:$XTp, memrr:$dst),
  930. "stxvpx $XTp, $dst", IIC_LdStLFD,
  931. []>;
  932. }
  933. let mayLoad = 1, mayStore = 0, Predicates = [PairedVectorMemops, PrefixInstrs] in {
  934. defm PLXVP :
  935. 8LS_DForm_R_XTp5_SI34_MEM_p<58, (outs vsrprc:$XTp), (ins memri34:$D_RA),
  936. (ins memri34_pcrel:$D_RA), "plxvp $XTp, $D_RA",
  937. IIC_LdStLFD>;
  938. }
  939. let mayLoad = 0, mayStore = 1, Predicates = [PairedVectorMemops, PrefixInstrs] in {
  940. defm PSTXVP :
  941. 8LS_DForm_R_XTp5_SI34_MEM_p<62, (outs), (ins vsrprc:$XTp, memri34:$D_RA),
  942. (ins vsrprc:$XTp, memri34_pcrel:$D_RA),
  943. "pstxvp $XTp, $D_RA", IIC_LdStLFD>;
  944. }
  945. let Predicates = [PairedVectorMemops] in {
  946. // Intrinsics for Paired Vector Loads.
  947. def : Pat<(v256i1 (int_ppc_vsx_lxvp DQForm:$src)), (LXVP memrix16:$src)>;
  948. def : Pat<(v256i1 (int_ppc_vsx_lxvp XForm:$src)), (LXVPX XForm:$src)>;
  949. let Predicates = [PairedVectorMemops, PrefixInstrs] in {
  950. def : Pat<(v256i1 (int_ppc_vsx_lxvp PDForm:$src)), (PLXVP memri34:$src)>;
  951. }
  952. // Intrinsics for Paired Vector Stores.
  953. def : Pat<(int_ppc_vsx_stxvp v256i1:$XSp, DQForm:$dst),
  954. (STXVP $XSp, memrix16:$dst)>;
  955. def : Pat<(int_ppc_vsx_stxvp v256i1:$XSp, XForm:$dst),
  956. (STXVPX $XSp, XForm:$dst)>;
  957. let Predicates = [PairedVectorMemops, PrefixInstrs] in {
  958. def : Pat<(int_ppc_vsx_stxvp v256i1:$XSp, PDForm:$dst),
  959. (PSTXVP $XSp, memri34:$dst)>;
  960. }
  961. }
  962. let Predicates = [IsISA3_1] in {
  963. def XSCMPEQQP : X_VT5_VA5_VB5<63, 68, "xscmpeqqp", []>;
  964. def XSCMPGEQP : X_VT5_VA5_VB5<63, 196, "xscmpgeqp", []>;
  965. def XSCMPGTQP : X_VT5_VA5_VB5<63, 228, "xscmpgtqp", []>;
  966. }
  967. let Predicates = [PCRelativeMemops] in {
  968. // Load i32
  969. def : Pat<(i32 (zextloadi1 (PPCmatpcreladdr PCRelForm:$ga))),
  970. (PLBZpc $ga, 0)>;
  971. def : Pat<(i32 (extloadi1 (PPCmatpcreladdr PCRelForm:$ga))),
  972. (PLBZpc $ga, 0)>;
  973. def : Pat<(i32 (zextloadi8 (PPCmatpcreladdr PCRelForm:$ga))),
  974. (PLBZpc $ga, 0)>;
  975. def : Pat<(i32 (extloadi8 (PPCmatpcreladdr PCRelForm:$ga))),
  976. (PLBZpc $ga, 0)>;
  977. def : Pat<(i32 (sextloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  978. (PLHApc $ga, 0)>;
  979. def : Pat<(i32 (zextloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  980. (PLHZpc $ga, 0)>;
  981. def : Pat<(i32 (extloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  982. (PLHZpc $ga, 0)>;
  983. def : Pat<(i32 (load (PPCmatpcreladdr PCRelForm:$ga))), (PLWZpc $ga, 0)>;
  984. // Store i32
  985. def : Pat<(truncstorei8 i32:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  986. (PSTBpc $RS, $ga, 0)>;
  987. def : Pat<(truncstorei16 i32:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  988. (PSTHpc $RS, $ga, 0)>;
  989. def : Pat<(store i32:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  990. (PSTWpc $RS, $ga, 0)>;
  991. // Load i64
  992. def : Pat<(i64 (zextloadi1 (PPCmatpcreladdr PCRelForm:$ga))),
  993. (PLBZ8pc $ga, 0)>;
  994. def : Pat<(i64 (extloadi1 (PPCmatpcreladdr PCRelForm:$ga))),
  995. (PLBZ8pc $ga, 0)>;
  996. def : Pat<(i64 (zextloadi8 (PPCmatpcreladdr PCRelForm:$ga))),
  997. (PLBZ8pc $ga, 0)>;
  998. def : Pat<(i64 (extloadi8 (PPCmatpcreladdr PCRelForm:$ga))),
  999. (PLBZ8pc $ga, 0)>;
  1000. def : Pat<(i64 (sextloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  1001. (PLHA8pc $ga, 0)>;
  1002. def : Pat<(i64 (zextloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  1003. (PLHZ8pc $ga, 0)>;
  1004. def : Pat<(i64 (extloadi16 (PPCmatpcreladdr PCRelForm:$ga))),
  1005. (PLHZ8pc $ga, 0)>;
  1006. def : Pat<(i64 (zextloadi32 (PPCmatpcreladdr PCRelForm:$ga))),
  1007. (PLWZ8pc $ga, 0)>;
  1008. def : Pat<(i64 (sextloadi32 (PPCmatpcreladdr PCRelForm:$ga))),
  1009. (PLWA8pc $ga, 0)>;
  1010. def : Pat<(i64 (extloadi32 (PPCmatpcreladdr PCRelForm:$ga))),
  1011. (PLWZ8pc $ga, 0)>;
  1012. def : Pat<(i64 (load (PPCmatpcreladdr PCRelForm:$ga))), (PLDpc $ga, 0)>;
  1013. // Store i64
  1014. def : Pat<(truncstorei8 i64:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  1015. (PSTB8pc $RS, $ga, 0)>;
  1016. def : Pat<(truncstorei16 i64:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  1017. (PSTH8pc $RS, $ga, 0)>;
  1018. def : Pat<(truncstorei32 i64:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  1019. (PSTW8pc $RS, $ga, 0)>;
  1020. def : Pat<(store i64:$RS, (PPCmatpcreladdr PCRelForm:$ga)),
  1021. (PSTDpc $RS, $ga, 0)>;
  1022. // Load f32
  1023. def : Pat<(f32 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLFSpc $addr, 0)>;
  1024. // Store f32
  1025. def : Pat<(store f32:$FRS, (PPCmatpcreladdr PCRelForm:$ga)),
  1026. (PSTFSpc $FRS, $ga, 0)>;
  1027. // Load f64
  1028. def : Pat<(f64 (extloadf32 (PPCmatpcreladdr PCRelForm:$addr))),
  1029. (COPY_TO_REGCLASS (PLFSpc $addr, 0), VSFRC)>;
  1030. def : Pat<(f64 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLFDpc $addr, 0)>;
  1031. // Store f64
  1032. def : Pat<(store f64:$FRS, (PPCmatpcreladdr PCRelForm:$ga)),
  1033. (PSTFDpc $FRS, $ga, 0)>;
  1034. // Load f128
  1035. def : Pat<(f128 (load (PPCmatpcreladdr PCRelForm:$addr))),
  1036. (COPY_TO_REGCLASS (PLXVpc $addr, 0), VRRC)>;
  1037. // Store f128
  1038. def : Pat<(store f128:$XS, (PPCmatpcreladdr PCRelForm:$ga)),
  1039. (PSTXVpc (COPY_TO_REGCLASS $XS, VSRC), $ga, 0)>;
  1040. // Load v4i32
  1041. def : Pat<(v4i32 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLXVpc $addr, 0)>;
  1042. // Store v4i32
  1043. def : Pat<(store v4i32:$XS, (PPCmatpcreladdr PCRelForm:$ga)),
  1044. (PSTXVpc $XS, $ga, 0)>;
  1045. // Load v2i64
  1046. def : Pat<(v2i64 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLXVpc $addr, 0)>;
  1047. // Store v2i64
  1048. def : Pat<(store v2i64:$XS, (PPCmatpcreladdr PCRelForm:$ga)),
  1049. (PSTXVpc $XS, $ga, 0)>;
  1050. // Load v4f32
  1051. def : Pat<(v4f32 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLXVpc $addr, 0)>;
  1052. // Store v4f32
  1053. def : Pat<(store v4f32:$XS, (PPCmatpcreladdr PCRelForm:$ga)),
  1054. (PSTXVpc $XS, $ga, 0)>;
  1055. // Load v2f64
  1056. def : Pat<(v2f64 (load (PPCmatpcreladdr PCRelForm:$addr))), (PLXVpc $addr, 0)>;
  1057. // Store v2f64
  1058. def : Pat<(store v2f64:$XS, (PPCmatpcreladdr PCRelForm:$ga)),
  1059. (PSTXVpc $XS, $ga, 0)>;
  1060. // Atomic Load
  1061. def : Pat<(atomic_load_8 (PPCmatpcreladdr PCRelForm:$ga)),
  1062. (PLBZpc $ga, 0)>;
  1063. def : Pat<(atomic_load_16 (PPCmatpcreladdr PCRelForm:$ga)),
  1064. (PLHZpc $ga, 0)>;
  1065. def : Pat<(atomic_load_32 (PPCmatpcreladdr PCRelForm:$ga)),
  1066. (PLWZpc $ga, 0)>;
  1067. def : Pat<(atomic_load_64 (PPCmatpcreladdr PCRelForm:$ga)),
  1068. (PLDpc $ga, 0)>;
  1069. // Atomic Store
  1070. def : Pat<(atomic_store_8 (PPCmatpcreladdr PCRelForm:$ga), i32:$RS),
  1071. (PSTBpc $RS, $ga, 0)>;
  1072. def : Pat<(atomic_store_16 (PPCmatpcreladdr PCRelForm:$ga), i32:$RS),
  1073. (PSTHpc $RS, $ga, 0)>;
  1074. def : Pat<(atomic_store_32 (PPCmatpcreladdr PCRelForm:$ga), i32:$RS),
  1075. (PSTWpc $RS, $ga, 0)>;
  1076. def : Pat<(atomic_store_8 (PPCmatpcreladdr PCRelForm:$ga), i64:$RS),
  1077. (PSTB8pc $RS, $ga, 0)>;
  1078. def : Pat<(atomic_store_16 (PPCmatpcreladdr PCRelForm:$ga), i64:$RS),
  1079. (PSTH8pc $RS, $ga, 0)>;
  1080. def : Pat<(atomic_store_32 (PPCmatpcreladdr PCRelForm:$ga), i64:$RS),
  1081. (PSTW8pc $RS, $ga, 0)>;
  1082. def : Pat<(atomic_store_64 (PPCmatpcreladdr PCRelForm:$ga), i64:$RS),
  1083. (PSTDpc $RS, $ga, 0)>;
  1084. // Special Cases For PPCstore_scal_int_from_vsr
  1085. def : Pat<(PPCstore_scal_int_from_vsr
  1086. (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)),
  1087. (PPCmatpcreladdr PCRelForm:$dst), 8),
  1088. (PSTXSDpc (XSCVDPSXDS f64:$src), $dst, 0)>;
  1089. def : Pat<(PPCstore_scal_int_from_vsr
  1090. (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)),
  1091. (PPCmatpcreladdr PCRelForm:$dst), 8),
  1092. (PSTXSDpc (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC), $dst, 0)>;
  1093. def : Pat<(PPCstore_scal_int_from_vsr
  1094. (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)),
  1095. (PPCmatpcreladdr PCRelForm:$dst), 8),
  1096. (PSTXSDpc (XSCVDPUXDS f64:$src), $dst, 0)>;
  1097. def : Pat<(PPCstore_scal_int_from_vsr
  1098. (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)),
  1099. (PPCmatpcreladdr PCRelForm:$dst), 8),
  1100. (PSTXSDpc (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC), $dst, 0)>;
  1101. def : Pat<(v4f32 (PPCldvsxlh (PPCmatpcreladdr PCRelForm:$addr))),
  1102. (SUBREG_TO_REG (i64 1), (PLFDpc $addr, 0), sub_64)>;
  1103. // If the PPCmatpcreladdr node is not caught by any other pattern it should be
  1104. // caught here and turned into a paddi instruction to materialize the address.
  1105. def : Pat<(PPCmatpcreladdr PCRelForm:$addr), (PADDI8pc 0, $addr)>;
  1106. // PPCtlsdynamatpcreladdr node is used for TLS dynamic models to materialize
  1107. // tls global address with paddi instruction.
  1108. def : Pat<(PPCtlsdynamatpcreladdr PCRelForm:$addr), (PADDI8pc 0, $addr)>;
  1109. // PPCtlslocalexecmataddr node is used for TLS local exec models to
  1110. // materialize tls global address with paddi instruction.
  1111. def : Pat<(PPCaddTls i64:$in, (PPCtlslocalexecmataddr tglobaltlsaddr:$addr)),
  1112. (PADDI8 $in, $addr)>;
  1113. }
  1114. let Predicates = [PrefixInstrs] in {
  1115. def XXPERMX :
  1116. 8RR_XX4Form_IMM3_XTABC6<34, 0, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1117. vsrc:$XC, u3imm:$UIM),
  1118. "xxpermx $XT, $XA, $XB, $XC, $UIM",
  1119. IIC_VecPerm, []>;
  1120. def XXBLENDVB :
  1121. 8RR_XX4Form_XTABC6<33, 0, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1122. vsrc:$XC), "xxblendvb $XT, $XA, $XB, $XC",
  1123. IIC_VecGeneral, []>;
  1124. def XXBLENDVH :
  1125. 8RR_XX4Form_XTABC6<33, 1, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1126. vsrc:$XC), "xxblendvh $XT, $XA, $XB, $XC",
  1127. IIC_VecGeneral, []>;
  1128. def XXBLENDVW :
  1129. 8RR_XX4Form_XTABC6<33, 2, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1130. vsrc:$XC), "xxblendvw $XT, $XA, $XB, $XC",
  1131. IIC_VecGeneral, []>;
  1132. def XXBLENDVD :
  1133. 8RR_XX4Form_XTABC6<33, 3, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1134. vsrc:$XC), "xxblendvd $XT, $XA, $XB, $XC",
  1135. IIC_VecGeneral, []>;
  1136. }
  1137. // XXSPLTIW/DP/32DX need extra flags to make sure the compiler does not attempt
  1138. // to spill part of the instruction when the values are similar.
  1139. let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1, Predicates = [PrefixInstrs] in {
  1140. def XXSPLTIW : 8RR_DForm_IMM32_XT6<32, 3, (outs vsrc:$XT),
  1141. (ins i32imm:$IMM32),
  1142. "xxspltiw $XT, $IMM32", IIC_VecGeneral,
  1143. []>;
  1144. def XXSPLTIDP : 8RR_DForm_IMM32_XT6<32, 2, (outs vsrc:$XT),
  1145. (ins i32imm:$IMM32),
  1146. "xxspltidp $XT, $IMM32", IIC_VecGeneral,
  1147. [(set v2f64:$XT,
  1148. (PPCxxspltidp i32:$IMM32))]>;
  1149. def XXSPLTI32DX :
  1150. 8RR_DForm_IMM32_XT6_IX<32, 0, (outs vsrc:$XT),
  1151. (ins vsrc:$XTi, u1imm:$IX, i32imm:$IMM32),
  1152. "xxsplti32dx $XT, $IX, $IMM32", IIC_VecGeneral,
  1153. [(set v2i64:$XT,
  1154. (PPCxxsplti32dx v2i64:$XTi, i32:$IX,
  1155. i32:$IMM32))]>,
  1156. RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">;
  1157. }
  1158. let Predicates = [IsISA3_1] in {
  1159. def SETBC : XForm_XT5_BI5<31, 384, (outs gprc:$RT), (ins crbitrc:$BI),
  1160. "setbc $RT, $BI", IIC_IntCompare, []>,
  1161. SExt32To64, ZExt32To64;
  1162. def SETBCR : XForm_XT5_BI5<31, 416, (outs gprc:$RT), (ins crbitrc:$BI),
  1163. "setbcr $RT, $BI", IIC_IntCompare, []>,
  1164. SExt32To64, ZExt32To64;
  1165. def SETNBC : XForm_XT5_BI5<31, 448, (outs gprc:$RT), (ins crbitrc:$BI),
  1166. "setnbc $RT, $BI", IIC_IntCompare, []>,
  1167. SExt32To64;
  1168. def SETNBCR : XForm_XT5_BI5<31, 480, (outs gprc:$RT), (ins crbitrc:$BI),
  1169. "setnbcr $RT, $BI", IIC_IntCompare, []>,
  1170. SExt32To64;
  1171. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1172. def SETBC8 : XForm_XT5_BI5<31, 384, (outs g8rc:$RT), (ins crbitrc:$BI),
  1173. "setbc $RT, $BI", IIC_IntCompare, []>,
  1174. SExt32To64, ZExt32To64;
  1175. def SETBCR8 : XForm_XT5_BI5<31, 416, (outs g8rc:$RT), (ins crbitrc:$BI),
  1176. "setbcr $RT, $BI", IIC_IntCompare, []>,
  1177. SExt32To64, ZExt32To64;
  1178. def SETNBC8 : XForm_XT5_BI5<31, 448, (outs g8rc:$RT), (ins crbitrc:$BI),
  1179. "setnbc $RT, $BI", IIC_IntCompare, []>,
  1180. SExt32To64;
  1181. def SETNBCR8 : XForm_XT5_BI5<31, 480, (outs g8rc:$RT), (ins crbitrc:$BI),
  1182. "setnbcr $RT, $BI", IIC_IntCompare, []>,
  1183. SExt32To64;
  1184. }
  1185. def VSLDBI : VNForm_VTAB5_SD3<22, 0, (outs vrrc:$VRT),
  1186. (ins vrrc:$VRA, vrrc:$VRB, u3imm:$SH),
  1187. "vsldbi $VRT, $VRA, $VRB, $SH",
  1188. IIC_VecGeneral,
  1189. [(set v16i8:$VRT,
  1190. (int_ppc_altivec_vsldbi v16i8:$VRA,
  1191. v16i8:$VRB,
  1192. timm:$SH))]>;
  1193. def VSRDBI : VNForm_VTAB5_SD3<22, 1, (outs vrrc:$VRT),
  1194. (ins vrrc:$VRA, vrrc:$VRB, u3imm:$SH),
  1195. "vsrdbi $VRT, $VRA, $VRB, $SH",
  1196. IIC_VecGeneral,
  1197. [(set v16i8:$VRT,
  1198. (int_ppc_altivec_vsrdbi v16i8:$VRA,
  1199. v16i8:$VRB,
  1200. timm:$SH))]>;
  1201. defm VSTRIBR : VXForm_VTB5_RCr<13, 1, (outs vrrc:$vT), (ins vrrc:$vB),
  1202. "vstribr", "$vT, $vB", IIC_VecGeneral,
  1203. [(set v16i8:$vT,
  1204. (int_ppc_altivec_vstribr v16i8:$vB))]>;
  1205. defm VSTRIBL : VXForm_VTB5_RCr<13, 0, (outs vrrc:$vT), (ins vrrc:$vB),
  1206. "vstribl", "$vT, $vB", IIC_VecGeneral,
  1207. [(set v16i8:$vT,
  1208. (int_ppc_altivec_vstribl v16i8:$vB))]>;
  1209. defm VSTRIHR : VXForm_VTB5_RCr<13, 3, (outs vrrc:$vT), (ins vrrc:$vB),
  1210. "vstrihr", "$vT, $vB", IIC_VecGeneral,
  1211. [(set v8i16:$vT,
  1212. (int_ppc_altivec_vstrihr v8i16:$vB))]>;
  1213. defm VSTRIHL : VXForm_VTB5_RCr<13, 2, (outs vrrc:$vT), (ins vrrc:$vB),
  1214. "vstrihl", "$vT, $vB", IIC_VecGeneral,
  1215. [(set v8i16:$vT,
  1216. (int_ppc_altivec_vstrihl v8i16:$vB))]>;
  1217. def VINSW :
  1218. VXForm_1<207, (outs vrrc:$vD), (ins vrrc:$vDi, u4imm:$UIM, gprc:$rB),
  1219. "vinsw $vD, $rB, $UIM", IIC_VecGeneral,
  1220. [(set v4i32:$vD,
  1221. (int_ppc_altivec_vinsw v4i32:$vDi, i32:$rB, timm:$UIM))]>,
  1222. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  1223. def VINSD :
  1224. VXForm_1<463, (outs vrrc:$vD), (ins vrrc:$vDi, u4imm:$UIM, g8rc:$rB),
  1225. "vinsd $vD, $rB, $UIM", IIC_VecGeneral,
  1226. [(set v2i64:$vD,
  1227. (int_ppc_altivec_vinsd v2i64:$vDi, i64:$rB, timm:$UIM))]>,
  1228. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  1229. def VINSBVLX :
  1230. VXForm_VTB5_RA5_ins<15, "vinsbvlx",
  1231. [(set v16i8:$vD,
  1232. (int_ppc_altivec_vinsbvlx v16i8:$vDi, i32:$rA,
  1233. v16i8:$vB))]>;
  1234. def VINSBVRX :
  1235. VXForm_VTB5_RA5_ins<271, "vinsbvrx",
  1236. [(set v16i8:$vD,
  1237. (int_ppc_altivec_vinsbvrx v16i8:$vDi, i32:$rA,
  1238. v16i8:$vB))]>;
  1239. def VINSHVLX :
  1240. VXForm_VTB5_RA5_ins<79, "vinshvlx",
  1241. [(set v8i16:$vD,
  1242. (int_ppc_altivec_vinshvlx v8i16:$vDi, i32:$rA,
  1243. v8i16:$vB))]>;
  1244. def VINSHVRX :
  1245. VXForm_VTB5_RA5_ins<335, "vinshvrx",
  1246. [(set v8i16:$vD,
  1247. (int_ppc_altivec_vinshvrx v8i16:$vDi, i32:$rA,
  1248. v8i16:$vB))]>;
  1249. def VINSWVLX :
  1250. VXForm_VTB5_RA5_ins<143, "vinswvlx",
  1251. [(set v4i32:$vD,
  1252. (int_ppc_altivec_vinswvlx v4i32:$vDi, i32:$rA,
  1253. v4i32:$vB))]>;
  1254. def VINSWVRX :
  1255. VXForm_VTB5_RA5_ins<399, "vinswvrx",
  1256. [(set v4i32:$vD,
  1257. (int_ppc_altivec_vinswvrx v4i32:$vDi, i32:$rA,
  1258. v4i32:$vB))]>;
  1259. def VINSBLX :
  1260. VXForm_VRT5_RAB5_ins<527, "vinsblx",
  1261. [(set v16i8:$vD,
  1262. (int_ppc_altivec_vinsblx v16i8:$vDi, i32:$rA,
  1263. i32:$rB))]>;
  1264. def VINSBRX :
  1265. VXForm_VRT5_RAB5_ins<783, "vinsbrx",
  1266. [(set v16i8:$vD,
  1267. (int_ppc_altivec_vinsbrx v16i8:$vDi, i32:$rA,
  1268. i32:$rB))]>;
  1269. def VINSHLX :
  1270. VXForm_VRT5_RAB5_ins<591, "vinshlx",
  1271. [(set v8i16:$vD,
  1272. (int_ppc_altivec_vinshlx v8i16:$vDi, i32:$rA,
  1273. i32:$rB))]>;
  1274. def VINSHRX :
  1275. VXForm_VRT5_RAB5_ins<847, "vinshrx",
  1276. [(set v8i16:$vD,
  1277. (int_ppc_altivec_vinshrx v8i16:$vDi, i32:$rA,
  1278. i32:$rB))]>;
  1279. def VINSWLX :
  1280. VXForm_VRT5_RAB5_ins<655, "vinswlx",
  1281. [(set v4i32:$vD,
  1282. (int_ppc_altivec_vinswlx v4i32:$vDi, i32:$rA,
  1283. i32:$rB))]>;
  1284. def VINSWRX :
  1285. VXForm_VRT5_RAB5_ins<911, "vinswrx",
  1286. [(set v4i32:$vD,
  1287. (int_ppc_altivec_vinswrx v4i32:$vDi, i32:$rA,
  1288. i32:$rB))]>;
  1289. def VINSDLX :
  1290. VXForm_1<719, (outs vrrc:$vD), (ins vrrc:$vDi, g8rc:$rA, g8rc:$rB),
  1291. "vinsdlx $vD, $rA, $rB", IIC_VecGeneral,
  1292. [(set v2i64:$vD,
  1293. (int_ppc_altivec_vinsdlx v2i64:$vDi, i64:$rA, i64:$rB))]>,
  1294. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  1295. def VINSDRX :
  1296. VXForm_1<975, (outs vrrc:$vD), (ins vrrc:$vDi, g8rc:$rA, g8rc:$rB),
  1297. "vinsdrx $vD, $rA, $rB", IIC_VecGeneral,
  1298. [(set v2i64:$vD,
  1299. (int_ppc_altivec_vinsdrx v2i64:$vDi, i64:$rA, i64:$rB))]>,
  1300. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  1301. def VEXTRACTBM : VXForm_RD5_XO5_RS5<1602, 8, (outs gprc:$rD), (ins vrrc:$vB),
  1302. "vextractbm $rD, $vB", IIC_VecGeneral,
  1303. [(set i32:$rD,
  1304. (int_ppc_altivec_vextractbm v16i8:$vB))]>,
  1305. ZExt32To64;
  1306. def VEXTRACTHM : VXForm_RD5_XO5_RS5<1602, 9, (outs gprc:$rD), (ins vrrc:$vB),
  1307. "vextracthm $rD, $vB", IIC_VecGeneral,
  1308. [(set i32:$rD,
  1309. (int_ppc_altivec_vextracthm v8i16:$vB))]>,
  1310. ZExt32To64;
  1311. def VEXTRACTWM : VXForm_RD5_XO5_RS5<1602, 10, (outs gprc:$rD), (ins vrrc:$vB),
  1312. "vextractwm $rD, $vB", IIC_VecGeneral,
  1313. [(set i32:$rD,
  1314. (int_ppc_altivec_vextractwm v4i32:$vB))]>,
  1315. ZExt32To64;
  1316. def VEXTRACTDM : VXForm_RD5_XO5_RS5<1602, 11, (outs gprc:$rD), (ins vrrc:$vB),
  1317. "vextractdm $rD, $vB", IIC_VecGeneral,
  1318. [(set i32:$rD,
  1319. (int_ppc_altivec_vextractdm v2i64:$vB))]>,
  1320. ZExt32To64;
  1321. def VEXTRACTQM : VXForm_RD5_XO5_RS5<1602, 12, (outs gprc:$rD), (ins vrrc:$vB),
  1322. "vextractqm $rD, $vB", IIC_VecGeneral,
  1323. [(set i32:$rD,
  1324. (int_ppc_altivec_vextractqm v1i128:$vB))]>;
  1325. def VEXPANDBM : VXForm_RD5_XO5_RS5<1602, 0, (outs vrrc:$vD), (ins vrrc:$vB),
  1326. "vexpandbm $vD, $vB", IIC_VecGeneral,
  1327. [(set v16i8:$vD, (int_ppc_altivec_vexpandbm
  1328. v16i8:$vB))]>;
  1329. def VEXPANDHM : VXForm_RD5_XO5_RS5<1602, 1, (outs vrrc:$vD), (ins vrrc:$vB),
  1330. "vexpandhm $vD, $vB", IIC_VecGeneral,
  1331. [(set v8i16:$vD, (int_ppc_altivec_vexpandhm
  1332. v8i16:$vB))]>;
  1333. def VEXPANDWM : VXForm_RD5_XO5_RS5<1602, 2, (outs vrrc:$vD), (ins vrrc:$vB),
  1334. "vexpandwm $vD, $vB", IIC_VecGeneral,
  1335. [(set v4i32:$vD, (int_ppc_altivec_vexpandwm
  1336. v4i32:$vB))]>;
  1337. def VEXPANDDM : VXForm_RD5_XO5_RS5<1602, 3, (outs vrrc:$vD), (ins vrrc:$vB),
  1338. "vexpanddm $vD, $vB", IIC_VecGeneral,
  1339. [(set v2i64:$vD, (int_ppc_altivec_vexpanddm
  1340. v2i64:$vB))]>;
  1341. def VEXPANDQM : VXForm_RD5_XO5_RS5<1602, 4, (outs vrrc:$vD), (ins vrrc:$vB),
  1342. "vexpandqm $vD, $vB", IIC_VecGeneral,
  1343. [(set v1i128:$vD, (int_ppc_altivec_vexpandqm
  1344. v1i128:$vB))]>;
  1345. def MTVSRBM : VXForm_RD5_XO5_RS5<1602, 16, (outs vrrc:$vD), (ins g8rc:$rB),
  1346. "mtvsrbm $vD, $rB", IIC_VecGeneral,
  1347. [(set v16i8:$vD,
  1348. (int_ppc_altivec_mtvsrbm i64:$rB))]>;
  1349. def MTVSRHM : VXForm_RD5_XO5_RS5<1602, 17, (outs vrrc:$vD), (ins g8rc:$rB),
  1350. "mtvsrhm $vD, $rB", IIC_VecGeneral,
  1351. [(set v8i16:$vD,
  1352. (int_ppc_altivec_mtvsrhm i64:$rB))]>;
  1353. def MTVSRWM : VXForm_RD5_XO5_RS5<1602, 18, (outs vrrc:$vD), (ins g8rc:$rB),
  1354. "mtvsrwm $vD, $rB", IIC_VecGeneral,
  1355. [(set v4i32:$vD,
  1356. (int_ppc_altivec_mtvsrwm i64:$rB))]>;
  1357. def MTVSRDM : VXForm_RD5_XO5_RS5<1602, 19, (outs vrrc:$vD), (ins g8rc:$rB),
  1358. "mtvsrdm $vD, $rB", IIC_VecGeneral,
  1359. [(set v2i64:$vD,
  1360. (int_ppc_altivec_mtvsrdm i64:$rB))]>;
  1361. def MTVSRQM : VXForm_RD5_XO5_RS5<1602, 20, (outs vrrc:$vD), (ins g8rc:$rB),
  1362. "mtvsrqm $vD, $rB", IIC_VecGeneral,
  1363. [(set v1i128:$vD,
  1364. (int_ppc_altivec_mtvsrqm i64:$rB))]>;
  1365. def MTVSRBMI : DXForm<4, 10, (outs vrrc:$vD), (ins u16imm64:$D),
  1366. "mtvsrbmi $vD, $D", IIC_VecGeneral,
  1367. [(set v16i8:$vD,
  1368. (int_ppc_altivec_mtvsrbm imm:$D))]>;
  1369. def VCNTMBB : VXForm_RD5_MP_VB5<1602, 12, (outs g8rc:$rD),
  1370. (ins vrrc:$vB, u1imm:$MP),
  1371. "vcntmbb $rD, $vB, $MP", IIC_VecGeneral,
  1372. [(set i64:$rD, (int_ppc_altivec_vcntmbb
  1373. v16i8:$vB, timm:$MP))]>;
  1374. def VCNTMBH : VXForm_RD5_MP_VB5<1602, 13, (outs g8rc:$rD),
  1375. (ins vrrc:$vB, u1imm:$MP),
  1376. "vcntmbh $rD, $vB, $MP", IIC_VecGeneral,
  1377. [(set i64:$rD, (int_ppc_altivec_vcntmbh
  1378. v8i16:$vB, timm:$MP))]>;
  1379. def VCNTMBW : VXForm_RD5_MP_VB5<1602, 14, (outs g8rc:$rD),
  1380. (ins vrrc:$vB, u1imm:$MP),
  1381. "vcntmbw $rD, $vB, $MP", IIC_VecGeneral,
  1382. [(set i64:$rD, (int_ppc_altivec_vcntmbw
  1383. v4i32:$vB, timm:$MP))]>;
  1384. def VCNTMBD : VXForm_RD5_MP_VB5<1602, 15, (outs g8rc:$rD),
  1385. (ins vrrc:$vB, u1imm:$MP),
  1386. "vcntmbd $rD, $vB, $MP", IIC_VecGeneral,
  1387. [(set i64:$rD, (int_ppc_altivec_vcntmbd
  1388. v2i64:$vB, timm:$MP))]>;
  1389. def VEXTDUBVLX : VAForm_1a<24, (outs vrrc:$vD),
  1390. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1391. "vextdubvlx $vD, $vA, $vB, $rC",
  1392. IIC_VecGeneral,
  1393. [(set v2i64:$vD,
  1394. (int_ppc_altivec_vextdubvlx v16i8:$vA,
  1395. v16i8:$vB,
  1396. i32:$rC))]>;
  1397. def VEXTDUBVRX : VAForm_1a<25, (outs vrrc:$vD),
  1398. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1399. "vextdubvrx $vD, $vA, $vB, $rC",
  1400. IIC_VecGeneral,
  1401. [(set v2i64:$vD,
  1402. (int_ppc_altivec_vextdubvrx v16i8:$vA,
  1403. v16i8:$vB,
  1404. i32:$rC))]>;
  1405. def VEXTDUHVLX : VAForm_1a<26, (outs vrrc:$vD),
  1406. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1407. "vextduhvlx $vD, $vA, $vB, $rC",
  1408. IIC_VecGeneral,
  1409. [(set v2i64:$vD,
  1410. (int_ppc_altivec_vextduhvlx v8i16:$vA,
  1411. v8i16:$vB,
  1412. i32:$rC))]>;
  1413. def VEXTDUHVRX : VAForm_1a<27, (outs vrrc:$vD),
  1414. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1415. "vextduhvrx $vD, $vA, $vB, $rC",
  1416. IIC_VecGeneral,
  1417. [(set v2i64:$vD,
  1418. (int_ppc_altivec_vextduhvrx v8i16:$vA,
  1419. v8i16:$vB,
  1420. i32:$rC))]>;
  1421. def VEXTDUWVLX : VAForm_1a<28, (outs vrrc:$vD),
  1422. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1423. "vextduwvlx $vD, $vA, $vB, $rC",
  1424. IIC_VecGeneral,
  1425. [(set v2i64:$vD,
  1426. (int_ppc_altivec_vextduwvlx v4i32:$vA,
  1427. v4i32:$vB,
  1428. i32:$rC))]>;
  1429. def VEXTDUWVRX : VAForm_1a<29, (outs vrrc:$vD),
  1430. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1431. "vextduwvrx $vD, $vA, $vB, $rC",
  1432. IIC_VecGeneral,
  1433. [(set v2i64:$vD,
  1434. (int_ppc_altivec_vextduwvrx v4i32:$vA,
  1435. v4i32:$vB,
  1436. i32:$rC))]>;
  1437. def VEXTDDVLX : VAForm_1a<30, (outs vrrc:$vD),
  1438. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1439. "vextddvlx $vD, $vA, $vB, $rC",
  1440. IIC_VecGeneral,
  1441. [(set v2i64:$vD,
  1442. (int_ppc_altivec_vextddvlx v2i64:$vA,
  1443. v2i64:$vB,
  1444. i32:$rC))]>;
  1445. def VEXTDDVRX : VAForm_1a<31, (outs vrrc:$vD),
  1446. (ins vrrc:$vA, vrrc:$vB, gprc:$rC),
  1447. "vextddvrx $vD, $vA, $vB, $rC",
  1448. IIC_VecGeneral,
  1449. [(set v2i64:$vD,
  1450. (int_ppc_altivec_vextddvrx v2i64:$vA,
  1451. v2i64:$vB,
  1452. i32:$rC))]>;
  1453. def VPDEPD : VXForm_1<1485, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1454. "vpdepd $vD, $vA, $vB", IIC_VecGeneral,
  1455. [(set v2i64:$vD,
  1456. (int_ppc_altivec_vpdepd v2i64:$vA, v2i64:$vB))]>;
  1457. def VPEXTD : VXForm_1<1421, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1458. "vpextd $vD, $vA, $vB", IIC_VecGeneral,
  1459. [(set v2i64:$vD,
  1460. (int_ppc_altivec_vpextd v2i64:$vA, v2i64:$vB))]>;
  1461. def PDEPD : XForm_6<31, 156, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  1462. "pdepd $rA, $rS, $rB", IIC_IntGeneral,
  1463. [(set i64:$rA, (int_ppc_pdepd i64:$rS, i64:$rB))]>;
  1464. def PEXTD : XForm_6<31, 188, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  1465. "pextd $rA, $rS, $rB", IIC_IntGeneral,
  1466. [(set i64:$rA, (int_ppc_pextd i64:$rS, i64:$rB))]>;
  1467. def VCFUGED : VXForm_1<1357, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1468. "vcfuged $vD, $vA, $vB", IIC_VecGeneral,
  1469. [(set v2i64:$vD,
  1470. (int_ppc_altivec_vcfuged v2i64:$vA, v2i64:$vB))]>;
  1471. def VGNB : VXForm_RD5_N3_VB5<1228, (outs g8rc:$rD), (ins vrrc:$vB, u3imm:$N),
  1472. "vgnb $rD, $vB, $N", IIC_VecGeneral,
  1473. [(set i64:$rD,
  1474. (int_ppc_altivec_vgnb v1i128:$vB, timm:$N))]>;
  1475. def CFUGED : XForm_6<31, 220, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  1476. "cfuged $rA, $rS, $rB", IIC_IntGeneral,
  1477. [(set i64:$rA, (int_ppc_cfuged i64:$rS, i64:$rB))]>;
  1478. def XXEVAL :
  1479. 8RR_XX4Form_IMM8_XTAB6<34, 1, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB,
  1480. vsrc:$XC, u8imm:$IMM),
  1481. "xxeval $XT, $XA, $XB, $XC, $IMM", IIC_VecGeneral,
  1482. [(set v2i64:$XT, (int_ppc_vsx_xxeval v2i64:$XA,
  1483. v2i64:$XB, v2i64:$XC, timm:$IMM))]>;
  1484. def VCLZDM : VXForm_1<1924, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1485. "vclzdm $vD, $vA, $vB", IIC_VecGeneral,
  1486. [(set v2i64:$vD,
  1487. (int_ppc_altivec_vclzdm v2i64:$vA, v2i64:$vB))]>;
  1488. def VCTZDM : VXForm_1<1988, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1489. "vctzdm $vD, $vA, $vB", IIC_VecGeneral,
  1490. [(set v2i64:$vD,
  1491. (int_ppc_altivec_vctzdm v2i64:$vA, v2i64:$vB))]>;
  1492. def CNTLZDM : XForm_6<31, 59, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  1493. "cntlzdm $rA, $rS, $rB", IIC_IntGeneral,
  1494. [(set i64:$rA,
  1495. (int_ppc_cntlzdm i64:$rS, i64:$rB))]>;
  1496. def CNTTZDM : XForm_6<31, 571, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  1497. "cnttzdm $rA, $rS, $rB", IIC_IntGeneral,
  1498. [(set i64:$rA,
  1499. (int_ppc_cnttzdm i64:$rS, i64:$rB))]>;
  1500. def XXGENPCVBM :
  1501. XForm_XT6_IMM5_VB5<60, 916, (outs vsrc:$XT), (ins vrrc:$VRB, s5imm:$IMM),
  1502. "xxgenpcvbm $XT, $VRB, $IMM", IIC_VecGeneral, []>;
  1503. def XXGENPCVHM :
  1504. XForm_XT6_IMM5_VB5<60, 917, (outs vsrc:$XT), (ins vrrc:$VRB, s5imm:$IMM),
  1505. "xxgenpcvhm $XT, $VRB, $IMM", IIC_VecGeneral, []>;
  1506. def XXGENPCVWM :
  1507. XForm_XT6_IMM5_VB5<60, 948, (outs vsrc:$XT), (ins vrrc:$VRB, s5imm:$IMM),
  1508. "xxgenpcvwm $XT, $VRB, $IMM", IIC_VecGeneral, []>;
  1509. def XXGENPCVDM :
  1510. XForm_XT6_IMM5_VB5<60, 949, (outs vsrc:$XT), (ins vrrc:$VRB, s5imm:$IMM),
  1511. "xxgenpcvdm $XT, $VRB, $IMM", IIC_VecGeneral, []>;
  1512. def VCLRLB : VXForm_1<397, (outs vrrc:$vD), (ins vrrc:$vA, gprc:$rB),
  1513. "vclrlb $vD, $vA, $rB", IIC_VecGeneral,
  1514. [(set v16i8:$vD,
  1515. (int_ppc_altivec_vclrlb v16i8:$vA, i32:$rB))]>;
  1516. def VCLRRB : VXForm_1<461, (outs vrrc:$vD), (ins vrrc:$vA, gprc:$rB),
  1517. "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  1518. [(set v16i8:$vD,
  1519. (int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
  1520. def VMULLD : VXForm_1<457, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1521. "vmulld $vD, $vA, $vB", IIC_VecGeneral,
  1522. [(set v2i64:$vD, (mul v2i64:$vA, v2i64:$vB))]>;
  1523. def VMULHSW : VXForm_1<905, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1524. "vmulhsw $vD, $vA, $vB", IIC_VecGeneral,
  1525. [(set v4i32:$vD, (mulhs v4i32:$vA, v4i32:$vB))]>;
  1526. def VMULHUW : VXForm_1<649, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1527. "vmulhuw $vD, $vA, $vB", IIC_VecGeneral,
  1528. [(set v4i32:$vD, (mulhu v4i32:$vA, v4i32:$vB))]>;
  1529. def VMULHSD : VXForm_1<969, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1530. "vmulhsd $vD, $vA, $vB", IIC_VecGeneral,
  1531. [(set v2i64:$vD, (mulhs v2i64:$vA, v2i64:$vB))]>;
  1532. def VMULHUD : VXForm_1<713, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1533. "vmulhud $vD, $vA, $vB", IIC_VecGeneral,
  1534. [(set v2i64:$vD, (mulhu v2i64:$vA, v2i64:$vB))]>;
  1535. def VMODSW : VXForm_1<1931, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1536. "vmodsw $vD, $vA, $vB", IIC_VecGeneral,
  1537. [(set v4i32:$vD, (srem v4i32:$vA, v4i32:$vB))]>;
  1538. def VMODUW : VXForm_1<1675, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1539. "vmoduw $vD, $vA, $vB", IIC_VecGeneral,
  1540. [(set v4i32:$vD, (urem v4i32:$vA, v4i32:$vB))]>;
  1541. def VMODSD : VXForm_1<1995, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1542. "vmodsd $vD, $vA, $vB", IIC_VecGeneral,
  1543. [(set v2i64:$vD, (srem v2i64:$vA, v2i64:$vB))]>;
  1544. def VMODUD : VXForm_1<1739, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1545. "vmodud $vD, $vA, $vB", IIC_VecGeneral,
  1546. [(set v2i64:$vD, (urem v2i64:$vA, v2i64:$vB))]>;
  1547. def VDIVSW : VXForm_1<395, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1548. "vdivsw $vD, $vA, $vB", IIC_VecGeneral,
  1549. [(set v4i32:$vD, (sdiv v4i32:$vA, v4i32:$vB))]>;
  1550. def VDIVUW : VXForm_1<139, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1551. "vdivuw $vD, $vA, $vB", IIC_VecGeneral,
  1552. [(set v4i32:$vD, (udiv v4i32:$vA, v4i32:$vB))]>;
  1553. def VDIVSD : VXForm_1<459, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1554. "vdivsd $vD, $vA, $vB", IIC_VecGeneral,
  1555. [(set v2i64:$vD, (sdiv v2i64:$vA, v2i64:$vB))]>;
  1556. def VDIVUD : VXForm_1<203, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1557. "vdivud $vD, $vA, $vB", IIC_VecGeneral,
  1558. [(set v2i64:$vD, (udiv v2i64:$vA, v2i64:$vB))]>;
  1559. def VDIVESW : VXForm_1<907, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1560. "vdivesw $vD, $vA, $vB", IIC_VecGeneral,
  1561. [(set v4i32:$vD, (int_ppc_altivec_vdivesw v4i32:$vA,
  1562. v4i32:$vB))]>;
  1563. def VDIVEUW : VXForm_1<651, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1564. "vdiveuw $vD, $vA, $vB", IIC_VecGeneral,
  1565. [(set v4i32:$vD, (int_ppc_altivec_vdiveuw v4i32:$vA,
  1566. v4i32:$vB))]>;
  1567. def VDIVESD : VXForm_1<971, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1568. "vdivesd $vD, $vA, $vB", IIC_VecGeneral,
  1569. [(set v2i64:$vD, (int_ppc_altivec_vdivesd v2i64:$vA,
  1570. v2i64:$vB))]>;
  1571. def VDIVEUD : VXForm_1<715, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1572. "vdiveud $vD, $vA, $vB", IIC_VecGeneral,
  1573. [(set v2i64:$vD, (int_ppc_altivec_vdiveud v2i64:$vA,
  1574. v2i64:$vB))]>;
  1575. def XVTLSBB : XX2_BF3_XO5_XB6_XO9<60, 2, 475, (outs crrc:$BF), (ins vsrc:$XB),
  1576. "xvtlsbb $BF, $XB", IIC_VecGeneral, []>;
  1577. def BRH : XForm_11<31, 219, (outs gprc:$RA), (ins gprc:$RS),
  1578. "brh $RA, $RS", IIC_IntRotate, []>;
  1579. def BRW : XForm_11<31, 155, (outs gprc:$RA), (ins gprc:$RS),
  1580. "brw $RA, $RS", IIC_IntRotate,
  1581. [(set i32:$RA, (bswap i32:$RS))]>;
  1582. let isCodeGenOnly = 1 in {
  1583. def BRH8 : XForm_11<31, 219, (outs g8rc:$RA), (ins g8rc:$RS),
  1584. "brh $RA, $RS", IIC_IntRotate, []>;
  1585. def BRW8 : XForm_11<31, 155, (outs g8rc:$RA), (ins g8rc:$RS),
  1586. "brw $RA, $RS", IIC_IntRotate, []>;
  1587. }
  1588. def BRD : XForm_11<31, 187, (outs g8rc:$RA), (ins g8rc:$RS),
  1589. "brd $RA, $RS", IIC_IntRotate,
  1590. [(set i64:$RA, (bswap i64:$RS))]>;
  1591. // The XFormMemOp flag for the following 8 instructions is set on
  1592. // the instruction format.
  1593. let mayLoad = 1, mayStore = 0 in {
  1594. def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
  1595. def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
  1596. def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
  1597. def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
  1598. }
  1599. let mayLoad = 0, mayStore = 1 in {
  1600. def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
  1601. def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
  1602. def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
  1603. def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
  1604. }
  1605. def VMULESD : VXForm_1<968, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1606. "vmulesd $vD, $vA, $vB", IIC_VecGeneral,
  1607. [(set v1i128:$vD, (int_ppc_altivec_vmulesd v2i64:$vA,
  1608. v2i64:$vB))]>;
  1609. def VMULEUD : VXForm_1<712, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1610. "vmuleud $vD, $vA, $vB", IIC_VecGeneral,
  1611. [(set v1i128:$vD, (int_ppc_altivec_vmuleud v2i64:$vA,
  1612. v2i64:$vB))]>;
  1613. def VMULOSD : VXForm_1<456, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1614. "vmulosd $vD, $vA, $vB", IIC_VecGeneral,
  1615. [(set v1i128:$vD, (int_ppc_altivec_vmulosd v2i64:$vA,
  1616. v2i64:$vB))]>;
  1617. def VMULOUD : VXForm_1<200, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1618. "vmuloud $vD, $vA, $vB", IIC_VecGeneral,
  1619. [(set v1i128:$vD, (int_ppc_altivec_vmuloud v2i64:$vA,
  1620. v2i64:$vB))]>;
  1621. def VMSUMCUD : VAForm_1a<23, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
  1622. "vmsumcud $vD, $vA, $vB, $vC", IIC_VecGeneral,
  1623. [(set v1i128:$vD, (int_ppc_altivec_vmsumcud
  1624. v2i64:$vA, v2i64:$vB, v1i128:$vC))]>;
  1625. def VDIVSQ : VXForm_1<267, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1626. "vdivsq $vD, $vA, $vB", IIC_VecGeneral,
  1627. [(set v1i128:$vD, (sdiv v1i128:$vA, v1i128:$vB))]>;
  1628. def VDIVUQ : VXForm_1<11, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1629. "vdivuq $vD, $vA, $vB", IIC_VecGeneral,
  1630. [(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
  1631. def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1632. "vdivesq $vD, $vA, $vB", IIC_VecGeneral,
  1633. [(set v1i128:$vD, (int_ppc_altivec_vdivesq v1i128:$vA,
  1634. v1i128:$vB))]>;
  1635. def VDIVEUQ : VXForm_1<523, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1636. "vdiveuq $vD, $vA, $vB", IIC_VecGeneral,
  1637. [(set v1i128:$vD, (int_ppc_altivec_vdiveuq v1i128:$vA,
  1638. v1i128:$vB))]>;
  1639. def VCMPEQUQ : VCMP <455, "vcmpequq $vD, $vA, $vB" , v1i128>;
  1640. def VCMPGTSQ : VCMP <903, "vcmpgtsq $vD, $vA, $vB" , v1i128>;
  1641. def VCMPGTUQ : VCMP <647, "vcmpgtuq $vD, $vA, $vB" , v1i128>;
  1642. def VCMPEQUQ_rec : VCMP_rec <455, "vcmpequq. $vD, $vA, $vB" , v1i128>;
  1643. def VCMPGTSQ_rec : VCMP_rec <903, "vcmpgtsq. $vD, $vA, $vB" , v1i128>;
  1644. def VCMPGTUQ_rec : VCMP_rec <647, "vcmpgtuq. $vD, $vA, $vB" , v1i128>;
  1645. def VMODSQ : VXForm_1<1803, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1646. "vmodsq $vD, $vA, $vB", IIC_VecGeneral,
  1647. [(set v1i128:$vD, (srem v1i128:$vA, v1i128:$vB))]>;
  1648. def VMODUQ : VXForm_1<1547, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  1649. "vmoduq $vD, $vA, $vB", IIC_VecGeneral,
  1650. [(set v1i128:$vD, (urem v1i128:$vA, v1i128:$vB))]>;
  1651. def VEXTSD2Q : VXForm_RD5_XO5_RS5<1538, 27, (outs vrrc:$vD), (ins vrrc:$vB),
  1652. "vextsd2q $vD, $vB", IIC_VecGeneral,
  1653. [(set v1i128:$vD, (int_ppc_altivec_vextsd2q v2i64:$vB))]>;
  1654. def VCMPUQ : VXForm_BF3_VAB5<257, (outs crrc:$BF), (ins vrrc:$vA, vrrc:$vB),
  1655. "vcmpuq $BF, $vA, $vB", IIC_VecGeneral, []>;
  1656. def VCMPSQ : VXForm_BF3_VAB5<321, (outs crrc:$BF), (ins vrrc:$vA, vrrc:$vB),
  1657. "vcmpsq $BF, $vA, $vB", IIC_VecGeneral, []>;
  1658. def VRLQNM : VX1_VT5_VA5_VB5<325, "vrlqnm",
  1659. [(set v1i128:$vD,
  1660. (int_ppc_altivec_vrlqnm v1i128:$vA,
  1661. v1i128:$vB))]>;
  1662. def VRLQMI : VXForm_1<69, (outs vrrc:$vD),
  1663. (ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
  1664. "vrlqmi $vD, $vA, $vB", IIC_VecFP,
  1665. [(set v1i128:$vD,
  1666. (int_ppc_altivec_vrlqmi v1i128:$vA, v1i128:$vB,
  1667. v1i128:$vDi))]>,
  1668. RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
  1669. def VSLQ : VX1_VT5_VA5_VB5<261, "vslq", []>;
  1670. def VSRAQ : VX1_VT5_VA5_VB5<773, "vsraq", []>;
  1671. def VSRQ : VX1_VT5_VA5_VB5<517, "vsrq", []>;
  1672. def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
  1673. def XSCVQPUQZ : X_VT5_XO5_VB5<63, 0, 836, "xscvqpuqz", []>;
  1674. def XSCVQPSQZ : X_VT5_XO5_VB5<63, 8, 836, "xscvqpsqz", []>;
  1675. def XSCVUQQP : X_VT5_XO5_VB5<63, 3, 836, "xscvuqqp", []>;
  1676. def XSCVSQQP : X_VT5_XO5_VB5<63, 11, 836, "xscvsqqp", []>;
  1677. def LXVKQ : XForm_XT6_IMM5<60, 31, 360, (outs vsrc:$XT), (ins u5imm:$UIM),
  1678. "lxvkq $XT, $UIM", IIC_VecGeneral, []>;
  1679. }
  1680. let Predicates = [IsISA3_1, HasVSX] in {
  1681. def XVCVSPBF16 : XX2_XT6_XO5_XB6<60, 17, 475, "xvcvspbf16", vsrc, []>;
  1682. def XVCVBF16SPN : XX2_XT6_XO5_XB6<60, 16, 475, "xvcvbf16spn", vsrc, []>;
  1683. def XSMAXCQP : X_VT5_VA5_VB5<63, 676, "xsmaxcqp",
  1684. [(set f128:$vT, (PPCxsmaxc f128:$vA, f128:$vB))]>;
  1685. def XSMINCQP : X_VT5_VA5_VB5<63, 740, "xsmincqp",
  1686. [(set f128:$vT, (PPCxsminc f128:$vA, f128:$vB))]>;
  1687. }
  1688. // Multiclass defining patterns for Set Boolean Extension Reverse Instructions.
  1689. // This is analogous to the CRNotPat multiclass but specifically for Power10
  1690. // and newer subtargets since the extended forms use Set Boolean instructions.
  1691. // The first two anonymous patterns defined are actually a duplicate of those
  1692. // in CRNotPat, but it is preferable to define both multiclasses as complete
  1693. // ones rather than pulling that small common section out.
  1694. multiclass P10ReverseSetBool<dag pattern, dag result> {
  1695. def : Pat<pattern, (crnot result)>;
  1696. def : Pat<(not pattern), result>;
  1697. def : Pat<(i32 (zext pattern)),
  1698. (SETBCR result)>;
  1699. def : Pat<(i64 (zext pattern)),
  1700. (SETBCR8 result)>;
  1701. def : Pat<(i32 (sext pattern)),
  1702. (SETNBCR result)>;
  1703. def : Pat<(i64 (sext pattern)),
  1704. (SETNBCR8 result)>;
  1705. def : Pat<(i32 (anyext pattern)),
  1706. (SETBCR result)>;
  1707. def : Pat<(i64 (anyext pattern)),
  1708. (SETBCR8 result)>;
  1709. }
  1710. multiclass IntSetP10RevSetBool<SDNode SetCC, ValueType Ty, PatLeaf ZExtTy,
  1711. ImmLeaf SExtTy, I Cmpi, I Cmpli,
  1712. I Cmp, I Cmpl> {
  1713. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETUGE)),
  1714. (EXTRACT_SUBREG (Cmpl $s1, $s2), sub_lt)>;
  1715. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETGE)),
  1716. (EXTRACT_SUBREG (Cmp $s1, $s2), sub_lt)>;
  1717. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETULE)),
  1718. (EXTRACT_SUBREG (Cmpl $s1, $s2), sub_gt)>;
  1719. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETLE)),
  1720. (EXTRACT_SUBREG (Cmp $s1, $s2), sub_gt)>;
  1721. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETNE)),
  1722. (EXTRACT_SUBREG (Cmp $s1, $s2), sub_eq)>;
  1723. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, ZExtTy:$imm, SETUGE)),
  1724. (EXTRACT_SUBREG (Cmpli $s1, imm:$imm), sub_lt)>;
  1725. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, SExtTy:$imm, SETGE)),
  1726. (EXTRACT_SUBREG (Cmpi $s1, imm:$imm), sub_lt)>;
  1727. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, ZExtTy:$imm, SETULE)),
  1728. (EXTRACT_SUBREG (Cmpli $s1, imm:$imm), sub_gt)>;
  1729. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, SExtTy:$imm, SETLE)),
  1730. (EXTRACT_SUBREG (Cmpi $s1, imm:$imm), sub_gt)>;
  1731. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, SExtTy:$imm, SETNE)),
  1732. (EXTRACT_SUBREG (Cmpi $s1, imm:$imm), sub_eq)>;
  1733. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, ZExtTy:$imm, SETNE)),
  1734. (EXTRACT_SUBREG (Cmpli $s1, imm:$imm), sub_eq)>;
  1735. }
  1736. multiclass FSetP10RevSetBool<SDNode SetCC, ValueType Ty, I FCmp> {
  1737. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETUGE)),
  1738. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  1739. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETGE)),
  1740. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
  1741. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETULE)),
  1742. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  1743. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETLE)),
  1744. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
  1745. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETUNE)),
  1746. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  1747. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETNE)),
  1748. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
  1749. defm : P10ReverseSetBool<(i1 (SetCC Ty:$s1, Ty:$s2, SETO)),
  1750. (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>;
  1751. }
  1752. let Predicates = [IsISA3_1] in {
  1753. def : Pat<(i32 (zext i1:$in)),
  1754. (SETBC $in)>;
  1755. def : Pat<(i64 (zext i1:$in)),
  1756. (SETBC8 $in)>;
  1757. def : Pat<(i32 (sext i1:$in)),
  1758. (SETNBC $in)>;
  1759. def : Pat<(i64 (sext i1:$in)),
  1760. (SETNBC8 $in)>;
  1761. def : Pat<(i32 (anyext i1:$in)),
  1762. (SETBC $in)>;
  1763. def : Pat<(i64 (anyext i1:$in)),
  1764. (SETBC8 $in)>;
  1765. // Instantiation of the set boolean reverse patterns for 32-bit integers.
  1766. defm : IntSetP10RevSetBool<setcc, i32, immZExt16, imm32SExt16,
  1767. CMPWI, CMPLWI, CMPW, CMPLW>;
  1768. defm : P10ReverseSetBool<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
  1769. (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
  1770. (LO16 imm:$imm)), sub_eq)>;
  1771. // Instantiation of the set boolean reverse patterns for 64-bit integers.
  1772. defm : IntSetP10RevSetBool<setcc, i64, immZExt16, imm64SExt16,
  1773. CMPDI, CMPLDI, CMPD, CMPLD>;
  1774. defm : P10ReverseSetBool<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
  1775. (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
  1776. (LO16 imm:$imm)), sub_eq)>;
  1777. }
  1778. // Instantiation of the set boolean reverse patterns for f32, f64, f128.
  1779. let Predicates = [IsISA3_1, HasFPU] in {
  1780. defm : FSetP10RevSetBool<setcc, f32, FCMPUS>;
  1781. defm : FSetP10RevSetBool<setcc, f64, FCMPUD>;
  1782. defm : FSetP10RevSetBool<setcc, f128, XSCMPUQP>;
  1783. }
  1784. //---------------------------- Anonymous Patterns ----------------------------//
  1785. let Predicates = [IsISA3_1] in {
  1786. // Exploit the vector multiply high instructions using intrinsics.
  1787. def : Pat<(v4i32 (int_ppc_altivec_vmulhsw v4i32:$vA, v4i32:$vB)),
  1788. (v4i32 (VMULHSW $vA, $vB))>;
  1789. def : Pat<(v4i32 (int_ppc_altivec_vmulhuw v4i32:$vA, v4i32:$vB)),
  1790. (v4i32 (VMULHUW $vA, $vB))>;
  1791. def : Pat<(v2i64 (int_ppc_altivec_vmulhsd v2i64:$vA, v2i64:$vB)),
  1792. (v2i64 (VMULHSD $vA, $vB))>;
  1793. def : Pat<(v2i64 (int_ppc_altivec_vmulhud v2i64:$vA, v2i64:$vB)),
  1794. (v2i64 (VMULHUD $vA, $vB))>;
  1795. def : Pat<(v16i8 (int_ppc_vsx_xxgenpcvbm v16i8:$VRB, imm:$IMM)),
  1796. (v16i8 (COPY_TO_REGCLASS (XXGENPCVBM $VRB, imm:$IMM), VRRC))>;
  1797. def : Pat<(v8i16 (int_ppc_vsx_xxgenpcvhm v8i16:$VRB, imm:$IMM)),
  1798. (v8i16 (COPY_TO_REGCLASS (XXGENPCVHM $VRB, imm:$IMM), VRRC))>;
  1799. def : Pat<(v4i32 (int_ppc_vsx_xxgenpcvwm v4i32:$VRB, imm:$IMM)),
  1800. (v4i32 (COPY_TO_REGCLASS (XXGENPCVWM $VRB, imm:$IMM), VRRC))>;
  1801. def : Pat<(v2i64 (int_ppc_vsx_xxgenpcvdm v2i64:$VRB, imm:$IMM)),
  1802. (v2i64 (COPY_TO_REGCLASS (XXGENPCVDM $VRB, imm:$IMM), VRRC))>;
  1803. def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 1)),
  1804. (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_lt)>;
  1805. def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 0)),
  1806. (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>;
  1807. def : Pat<(srl (bswap i32:$RS), (i32 16)),
  1808. (RLDICL_32 (BRH $RS), 0, 48)>;
  1809. def : Pat<(i64 (zext (i32 (srl (bswap i32:$RS), (i32 16))))),
  1810. (RLDICL_32_64 (BRH $RS), 0, 48)>;
  1811. def : Pat <(v1i128 (PPClxvrzx ForceXForm:$src, 8)),
  1812. (v1i128 (COPY_TO_REGCLASS (LXVRBX ForceXForm:$src), VRRC))>;
  1813. def : Pat <(v1i128 (PPClxvrzx ForceXForm:$src, 16)),
  1814. (v1i128 (COPY_TO_REGCLASS (LXVRHX ForceXForm:$src), VRRC))>;
  1815. def : Pat <(v1i128 (PPClxvrzx ForceXForm:$src, 32)),
  1816. (v1i128 (COPY_TO_REGCLASS (LXVRWX ForceXForm:$src), VRRC))>;
  1817. def : Pat <(v1i128 (PPClxvrzx ForceXForm:$src, 64)),
  1818. (v1i128 (COPY_TO_REGCLASS (LXVRDX ForceXForm:$src), VRRC))>;
  1819. def : Pat<(v1i128 (rotl v1i128:$vA, v1i128:$vB)),
  1820. (v1i128 (VRLQ v1i128:$vA, v1i128:$vB))>;
  1821. def : Pat <(v2i64 (PPCxxsplti32dx v2i64:$XT, i32:$XI, i32:$IMM32)),
  1822. (v2i64 (XXSPLTI32DX v2i64:$XT, i32:$XI, i32:$IMM32))>;
  1823. }
  1824. let Predicates = [IsISA3_1, HasVSX] in {
  1825. def : Pat<(v16i8 (int_ppc_vsx_xvcvspbf16 v16i8:$XA)),
  1826. (COPY_TO_REGCLASS (XVCVSPBF16 RCCp.AToVSRC), VRRC)>;
  1827. def : Pat<(v16i8 (int_ppc_vsx_xvcvbf16spn v16i8:$XA)),
  1828. (COPY_TO_REGCLASS (XVCVBF16SPN RCCp.AToVSRC), VRRC)>;
  1829. }
  1830. let AddedComplexity = 400, Predicates = [IsISA3_1, IsLittleEndian] in {
  1831. // Store element 0 of a VSX register to memory
  1832. def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$src, 0)), ForceXForm:$dst),
  1833. (STXVRBX (COPY_TO_REGCLASS v16i8:$src, VSRC), ForceXForm:$dst)>;
  1834. def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$src, 0)), ForceXForm:$dst),
  1835. (STXVRHX (COPY_TO_REGCLASS v8i16:$src, VSRC), ForceXForm:$dst)>;
  1836. def : Pat<(store (i32 (extractelt v4i32:$src, 0)), ForceXForm:$dst),
  1837. (STXVRWX $src, ForceXForm:$dst)>;
  1838. def : Pat<(store (f32 (extractelt v4f32:$src, 0)), ForceXForm:$dst),
  1839. (STXVRWX $src, ForceXForm:$dst)>;
  1840. def : Pat<(store (i64 (extractelt v2i64:$src, 0)), ForceXForm:$dst),
  1841. (STXVRDX $src, ForceXForm:$dst)>;
  1842. def : Pat<(store (f64 (extractelt v2f64:$src, 0)), ForceXForm:$dst),
  1843. (STXVRDX $src, ForceXForm:$dst)>;
  1844. // Load element 0 of a VSX register to memory
  1845. def : Pat<(v8i16 (scalar_to_vector (i32 (extloadi16 ForceXForm:$src)))),
  1846. (v8i16 (COPY_TO_REGCLASS (LXVRHX ForceXForm:$src), VSRC))>;
  1847. def : Pat<(v16i8 (scalar_to_vector (i32 (extloadi8 ForceXForm:$src)))),
  1848. (v16i8 (COPY_TO_REGCLASS (LXVRBX ForceXForm:$src), VSRC))>;
  1849. }
  1850. // FIXME: The swap is overkill when the shift amount is a constant.
  1851. // We should just fix the constant in the DAG.
  1852. let AddedComplexity = 400, Predicates = [IsISA3_1, HasVSX] in {
  1853. def : Pat<(v1i128 (shl v1i128:$VRA, v1i128:$VRB)),
  1854. (v1i128 (VSLQ v1i128:$VRA,
  1855. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1856. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1857. def : Pat<(v1i128 (PPCshl v1i128:$VRA, v1i128:$VRB)),
  1858. (v1i128 (VSLQ v1i128:$VRA,
  1859. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1860. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1861. def : Pat<(v1i128 (srl v1i128:$VRA, v1i128:$VRB)),
  1862. (v1i128 (VSRQ v1i128:$VRA,
  1863. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1864. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1865. def : Pat<(v1i128 (PPCsrl v1i128:$VRA, v1i128:$VRB)),
  1866. (v1i128 (VSRQ v1i128:$VRA,
  1867. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1868. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1869. def : Pat<(v1i128 (sra v1i128:$VRA, v1i128:$VRB)),
  1870. (v1i128 (VSRAQ v1i128:$VRA,
  1871. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1872. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1873. def : Pat<(v1i128 (PPCsra v1i128:$VRA, v1i128:$VRB)),
  1874. (v1i128 (VSRAQ v1i128:$VRA,
  1875. (XXPERMDI (COPY_TO_REGCLASS $VRB, VSRC),
  1876. (COPY_TO_REGCLASS $VRB, VSRC), 2)))>;
  1877. }
  1878. class xxevalPattern <dag pattern, bits<8> imm> :
  1879. Pat<(v4i32 pattern), (XXEVAL $vA, $vB, $vC, imm)> {}
  1880. let AddedComplexity = 400, Predicates = [PrefixInstrs] in {
  1881. def : Pat<(v4i32 (build_vector i32immNonAllOneNonZero:$A,
  1882. i32immNonAllOneNonZero:$A,
  1883. i32immNonAllOneNonZero:$A,
  1884. i32immNonAllOneNonZero:$A)),
  1885. (v4i32 (XXSPLTIW imm:$A))>;
  1886. def : Pat<(f32 nzFPImmAsi32:$A),
  1887. (COPY_TO_REGCLASS (XXSPLTIDP (getFPAs32BitInt fpimm:$A)),
  1888. VSFRC)>;
  1889. def : Pat<(f64 nzFPImmAsi32:$A),
  1890. (COPY_TO_REGCLASS (XXSPLTIDP (getFPAs32BitInt fpimm:$A)),
  1891. VSFRC)>;
  1892. // To replace constant pool with XXSPLTI32DX for scalars.
  1893. def : Pat<(f32 nzFPImmAsi64:$A),
  1894. (COPY_TO_REGCLASS (XXSPLTI32DX (XXSPLTI32DX(IMPLICIT_DEF), 0,
  1895. (getFPAs64BitIntHi $A)),
  1896. 1, (getFPAs64BitIntLo $A)),
  1897. VSSRC)>;
  1898. def : Pat<(f64 nzFPImmAsi64:$A),
  1899. (COPY_TO_REGCLASS (XXSPLTI32DX (XXSPLTI32DX (IMPLICIT_DEF), 0,
  1900. (getFPAs64BitIntHi $A)),
  1901. 1, (getFPAs64BitIntLo $A)),
  1902. VSFRC)>;
  1903. // Anonymous patterns for XXEVAL
  1904. // AND
  1905. // and(A, B, C)
  1906. def : xxevalPattern<(and v4i32:$vA, (and v4i32:$vB, v4i32:$vC)), 1>;
  1907. // and(A, xor(B, C))
  1908. def : xxevalPattern<(and v4i32:$vA, (xor v4i32:$vB, v4i32:$vC)), 6>;
  1909. // and(A, or(B, C))
  1910. def : xxevalPattern<(and v4i32:$vA, (or v4i32:$vB, v4i32:$vC)), 7>;
  1911. // and(A, nor(B, C))
  1912. def : xxevalPattern<(and v4i32:$vA, (vnot (or v4i32:$vB, v4i32:$vC))), 8>;
  1913. // and(A, eqv(B, C))
  1914. def : xxevalPattern<(and v4i32:$vA, (vnot (xor v4i32:$vB, v4i32:$vC))), 9>;
  1915. // and(A, nand(B, C))
  1916. def : xxevalPattern<(and v4i32:$vA, (vnot (and v4i32:$vB, v4i32:$vC))), 14>;
  1917. // NAND
  1918. // nand(A, B, C)
  1919. def : xxevalPattern<(vnot (and v4i32:$vA, (and v4i32:$vB, v4i32:$vC))),
  1920. !sub(255, 1)>;
  1921. // nand(A, xor(B, C))
  1922. def : xxevalPattern<(vnot (and v4i32:$vA, (xor v4i32:$vB, v4i32:$vC))),
  1923. !sub(255, 6)>;
  1924. // nand(A, or(B, C))
  1925. def : xxevalPattern<(vnot (and v4i32:$vA, (or v4i32:$vB, v4i32:$vC))),
  1926. !sub(255, 7)>;
  1927. // nand(A, nor(B, C))
  1928. def : xxevalPattern<(or (vnot v4i32:$vA), (or v4i32:$vB, v4i32:$vC)),
  1929. !sub(255, 8)>;
  1930. // nand(A, eqv(B, C))
  1931. def : xxevalPattern<(or (vnot v4i32:$vA), (xor v4i32:$vB, v4i32:$vC)),
  1932. !sub(255, 9)>;
  1933. // nand(A, nand(B, C))
  1934. def : xxevalPattern<(or (vnot v4i32:$vA), (and v4i32:$vB, v4i32:$vC)),
  1935. !sub(255, 14)>;
  1936. // EQV
  1937. // (eqv A, B, C)
  1938. def : xxevalPattern<(or (and v4i32:$vA, (and v4i32:$vB, v4i32:$vC)),
  1939. (vnot (or v4i32:$vA, (or v4i32:$vB, v4i32:$vC)))),
  1940. 150>;
  1941. // (eqv A, (and B, C))
  1942. def : xxevalPattern<(vnot (xor v4i32:$vA, (and v4i32:$vB, v4i32:$vC))), 225>;
  1943. // (eqv A, (or B, C))
  1944. def : xxevalPattern<(vnot (xor v4i32:$vA, (or v4i32:$vB, v4i32:$vC))), 135>;
  1945. // NOR
  1946. // (nor A, B, C)
  1947. def : xxevalPattern<(vnot (or v4i32:$vA, (or v4i32:$vB, v4i32:$vC))), 128>;
  1948. // (nor A, (and B, C))
  1949. def : xxevalPattern<(vnot (or v4i32:$vA, (and v4i32:$vB, v4i32:$vC))), 224>;
  1950. // (nor A, (eqv B, C))
  1951. def : xxevalPattern<(and (vnot v4i32:$vA), (xor v4i32:$vB, v4i32:$vC)), 96>;
  1952. // (nor A, (nand B, C))
  1953. def : xxevalPattern<(and (vnot v4i32:$vA), (and v4i32:$vB, v4i32:$vC)), 16>;
  1954. // (nor A, (nor B, C))
  1955. def : xxevalPattern<(and (vnot v4i32:$vA), (or v4i32:$vB, v4i32:$vC)), 112>;
  1956. // (nor A, (xor B, C))
  1957. def : xxevalPattern<(vnot (or v4i32:$vA, (xor v4i32:$vB, v4i32:$vC))), 144>;
  1958. // OR
  1959. // (or A, B, C)
  1960. def : xxevalPattern<(or v4i32:$vA, (or v4i32:$vB, v4i32:$vC)), 127>;
  1961. // (or A, (and B, C))
  1962. def : xxevalPattern<(or v4i32:$vA, (and v4i32:$vB, v4i32:$vC)), 31>;
  1963. // (or A, (eqv B, C))
  1964. def : xxevalPattern<(or v4i32:$vA, (vnot (xor v4i32:$vB, v4i32:$vC))), 159>;
  1965. // (or A, (nand B, C))
  1966. def : xxevalPattern<(or v4i32:$vA, (vnot (and v4i32:$vB, v4i32:$vC))), 239>;
  1967. // (or A, (nor B, C))
  1968. def : xxevalPattern<(or v4i32:$vA, (vnot (or v4i32:$vB, v4i32:$vC))), 143>;
  1969. // (or A, (xor B, C))
  1970. def : xxevalPattern<(or v4i32:$vA, (xor v4i32:$vB, v4i32:$vC)), 111>;
  1971. // XOR
  1972. // (xor A, B, C)
  1973. def : xxevalPattern<(xor v4i32:$vA, (xor v4i32:$vB, v4i32:$vC)), 105>;
  1974. // (xor A, (and B, C))
  1975. def : xxevalPattern<(xor v4i32:$vA, (and v4i32:$vB, v4i32:$vC)), 30>;
  1976. // (xor A, (or B, C))
  1977. def : xxevalPattern<(xor v4i32:$vA, (or v4i32:$vB, v4i32:$vC)), 120>;
  1978. // Anonymous patterns to select prefixed VSX loads and stores.
  1979. // Load / Store f128
  1980. def : Pat<(f128 (load PDForm:$src)),
  1981. (COPY_TO_REGCLASS (PLXV memri34:$src), VRRC)>;
  1982. def : Pat<(store f128:$XS, PDForm:$dst),
  1983. (PSTXV (COPY_TO_REGCLASS $XS, VSRC), memri34:$dst)>;
  1984. // Load / Store v4i32
  1985. def : Pat<(v4i32 (load PDForm:$src)), (PLXV memri34:$src)>;
  1986. def : Pat<(store v4i32:$XS, PDForm:$dst), (PSTXV $XS, memri34:$dst)>;
  1987. // Load / Store v2i64
  1988. def : Pat<(v2i64 (load PDForm:$src)), (PLXV memri34:$src)>;
  1989. def : Pat<(store v2i64:$XS, PDForm:$dst), (PSTXV $XS, memri34:$dst)>;
  1990. // Load / Store v4f32
  1991. def : Pat<(v4f32 (load PDForm:$src)), (PLXV memri34:$src)>;
  1992. def : Pat<(store v4f32:$XS, PDForm:$dst), (PSTXV $XS, memri34:$dst)>;
  1993. // Load / Store v2f64
  1994. def : Pat<(v2f64 (load PDForm:$src)), (PLXV memri34:$src)>;
  1995. def : Pat<(store v2f64:$XS, PDForm:$dst), (PSTXV $XS, memri34:$dst)>;
  1996. // Cases For PPCstore_scal_int_from_vsr
  1997. def : Pat<(PPCstore_scal_int_from_vsr
  1998. (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), PDForm:$dst, 8),
  1999. (PSTXSD (XSCVDPUXDS f64:$src), PDForm:$dst)>;
  2000. def : Pat<(PPCstore_scal_int_from_vsr
  2001. (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), PDForm:$dst, 8),
  2002. (PSTXSD (XSCVDPSXDS f64:$src), PDForm:$dst)>;
  2003. def : Pat<(PPCstore_scal_int_from_vsr
  2004. (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), PDForm:$dst, 8),
  2005. (PSTXSD (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC),
  2006. PDForm:$dst)>;
  2007. def : Pat<(PPCstore_scal_int_from_vsr
  2008. (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), PDForm:$dst, 8),
  2009. (PSTXSD (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC),
  2010. PDForm:$dst)>;
  2011. }
  2012. let Predicates = [PrefixInstrs] in {
  2013. def : Pat<(i32 imm34:$imm), (PLI (getImmAs64BitInt imm:$imm))>;
  2014. def : Pat<(i64 imm34:$imm), (PLI8 (getImmAs64BitInt imm:$imm))>;
  2015. def : Pat<(v16i8 (int_ppc_vsx_xxpermx v16i8:$A, v16i8:$B, v16i8:$C, timm:$D)),
  2016. (COPY_TO_REGCLASS (XXPERMX (COPY_TO_REGCLASS $A, VSRC),
  2017. (COPY_TO_REGCLASS $B, VSRC),
  2018. (COPY_TO_REGCLASS $C, VSRC), $D), VSRC)>;
  2019. def : Pat<(v16i8 (int_ppc_vsx_xxblendvb v16i8:$A, v16i8:$B, v16i8:$C)),
  2020. (COPY_TO_REGCLASS
  2021. (XXBLENDVB (COPY_TO_REGCLASS $A, VSRC),
  2022. (COPY_TO_REGCLASS $B, VSRC),
  2023. (COPY_TO_REGCLASS $C, VSRC)), VSRC)>;
  2024. def : Pat<(v8i16 (int_ppc_vsx_xxblendvh v8i16:$A, v8i16:$B, v8i16:$C)),
  2025. (COPY_TO_REGCLASS
  2026. (XXBLENDVH (COPY_TO_REGCLASS $A, VSRC),
  2027. (COPY_TO_REGCLASS $B, VSRC),
  2028. (COPY_TO_REGCLASS $C, VSRC)), VSRC)>;
  2029. def : Pat<(int_ppc_vsx_xxblendvw v4i32:$A, v4i32:$B, v4i32:$C),
  2030. (XXBLENDVW $A, $B, $C)>;
  2031. def : Pat<(int_ppc_vsx_xxblendvd v2i64:$A, v2i64:$B, v2i64:$C),
  2032. (XXBLENDVD $A, $B, $C)>;
  2033. // Anonymous patterns to select prefixed loads and stores.
  2034. // Load i32
  2035. def : Pat<(i32 (extloadi1 PDForm:$src)), (PLBZ memri34:$src)>;
  2036. def : Pat<(i32 (zextloadi1 PDForm:$src)), (PLBZ memri34:$src)>;
  2037. def : Pat<(i32 (extloadi8 PDForm:$src)), (PLBZ memri34:$src)>;
  2038. def : Pat<(i32 (zextloadi8 PDForm:$src)), (PLBZ memri34:$src)>;
  2039. def : Pat<(i32 (extloadi16 PDForm:$src)), (PLHZ memri34:$src)>;
  2040. def : Pat<(i32 (zextloadi16 PDForm:$src)), (PLHZ memri34:$src)>;
  2041. def : Pat<(i32 (sextloadi16 PDForm:$src)), (PLHA memri34:$src)>;
  2042. def : Pat<(i32 (load PDForm:$src)), (PLWZ memri34:$src)>;
  2043. // Store i32
  2044. def : Pat<(truncstorei8 i32:$rS, PDForm:$dst), (PSTB gprc:$rS, memri34:$dst)>;
  2045. def : Pat<(truncstorei16 i32:$rS, PDForm:$dst), (PSTH gprc:$rS, memri34:$dst)>;
  2046. def : Pat<(store i32:$rS, PDForm:$dst), (PSTW gprc:$rS, memri34:$dst)>;
  2047. // Load i64
  2048. def : Pat<(i64 (extloadi1 PDForm:$src)), (PLBZ8 memri34:$src)>;
  2049. def : Pat<(i64 (zextloadi1 PDForm:$src)), (PLBZ8 memri34:$src)>;
  2050. def : Pat<(i64 (extloadi8 PDForm:$src)), (PLBZ8 memri34:$src)>;
  2051. def : Pat<(i64 (zextloadi8 PDForm:$src)), (PLBZ8 memri34:$src)>;
  2052. def : Pat<(i64 (extloadi16 PDForm:$src)), (PLHZ8 memri34:$src)>;
  2053. def : Pat<(i64 (zextloadi16 PDForm:$src)), (PLHZ8 memri34:$src)>;
  2054. def : Pat<(i64 (sextloadi16 PDForm:$src)), (PLHA8 memri34:$src)>;
  2055. def : Pat<(i64 (extloadi32 PDForm:$src)), (PLWZ8 memri34:$src)>;
  2056. def : Pat<(i64 (zextloadi32 PDForm:$src)), (PLWZ8 memri34:$src)>;
  2057. def : Pat<(i64 (sextloadi32 PDForm:$src)), (PLWA8 memri34:$src)>;
  2058. def : Pat<(i64 (load PDForm:$src)), (PLD memri34:$src)>;
  2059. // Store i64
  2060. def : Pat<(truncstorei8 i64:$rS, PDForm:$dst), (PSTB8 g8rc:$rS, memri34:$dst)>;
  2061. def : Pat<(truncstorei16 i64:$rS, PDForm:$dst), (PSTH8 g8rc:$rS, memri34:$dst)>;
  2062. def : Pat<(truncstorei32 i64:$rS, PDForm:$dst), (PSTW8 g8rc:$rS, memri34:$dst)>;
  2063. def : Pat<(store i64:$rS, PDForm:$dst), (PSTD g8rc:$rS, memri34:$dst)>;
  2064. // Load / Store f32
  2065. def : Pat<(f32 (load PDForm:$src)), (PLFS memri34:$src)>;
  2066. def : Pat<(store f32:$FRS, PDForm:$dst), (PSTFS $FRS, memri34:$dst)>;
  2067. // Load / Store f64
  2068. def : Pat<(f64 (extloadf32 PDForm:$src)),
  2069. (COPY_TO_REGCLASS (PLFS memri34:$src), VSFRC)>;
  2070. def : Pat<(f64 (load PDForm:$src)), (PLFD memri34:$src)>;
  2071. def : Pat<(store f64:$FRS, PDForm:$dst), (PSTFD $FRS, memri34:$dst)>;
  2072. // Atomic Load
  2073. def : Pat<(atomic_load_8 PDForm:$src), (PLBZ memri34:$src)>;
  2074. def : Pat<(atomic_load_16 PDForm:$src), (PLHZ memri34:$src)>;
  2075. def : Pat<(atomic_load_32 PDForm:$src), (PLWZ memri34:$src)>;
  2076. def : Pat<(atomic_load_64 PDForm:$src), (PLD memri34:$src)>;
  2077. // Atomic Store
  2078. def : Pat<(atomic_store_8 PDForm:$dst, i32:$RS), (PSTB $RS, memri34:$dst)>;
  2079. def : Pat<(atomic_store_16 PDForm:$dst, i32:$RS), (PSTH $RS, memri34:$dst)>;
  2080. def : Pat<(atomic_store_32 PDForm:$dst, i32:$RS), (PSTW $RS, memri34:$dst)>;
  2081. def : Pat<(atomic_store_64 PDForm:$dst, i64:$RS), (PSTD $RS, memri34:$dst)>;
  2082. // Prefixed fpext to v2f64
  2083. def : Pat<(v4f32 (PPCldvsxlh PDForm:$src)),
  2084. (SUBREG_TO_REG (i64 1), (PLFD PDForm:$src), sub_64)>;
  2085. }
  2086. def InsertEltShift {
  2087. dag Sub32 = (i32 (EXTRACT_SUBREG $rB, sub_32));
  2088. dag Sub32Left1 = (RLWINM (EXTRACT_SUBREG $rB, sub_32), 1, 0, 30);
  2089. dag Sub32Left2 = (RLWINM (EXTRACT_SUBREG $rB, sub_32), 2, 0, 29);
  2090. dag Left1 = (RLWINM $rB, 1, 0, 30);
  2091. dag Left2 = (RLWINM $rB, 2, 0, 29);
  2092. dag Left3 = (RLWINM8 $rB, 3, 0, 28);
  2093. }
  2094. let Predicates = [IsISA3_1, HasVSX, IsLittleEndian] in {
  2095. // Indexed vector insert element
  2096. def : Pat<(v16i8 (vector_insert v16i8:$vDi, i32:$rA, i64:$rB)),
  2097. (VINSBRX $vDi, InsertEltShift.Sub32, $rA)>;
  2098. def : Pat<(v8i16 (vector_insert v8i16:$vDi, i32:$rA, i64:$rB)),
  2099. (VINSHRX $vDi, InsertEltShift.Sub32Left1, $rA)>;
  2100. def : Pat<(v4i32 (insertelt v4i32:$vDi, i32:$rA, i64:$rB)),
  2101. (VINSWRX $vDi, InsertEltShift.Sub32Left2, $rA)>;
  2102. def : Pat<(v2i64 (insertelt v2i64:$vDi, i64:$rA, i64:$rB)),
  2103. (VINSDRX $vDi, InsertEltShift.Left3, $rA)>;
  2104. def : Pat<(v4f32 (insertelt v4f32:$vDi, f32:$rA, i64:$rB)),
  2105. (VINSWVRX $vDi, InsertEltShift.Sub32Left2, (XSCVDPSPN $rA))>;
  2106. def : Pat<(v2f64 (insertelt v2f64:$vDi, f64:$A, i64:$rB)),
  2107. (VINSDRX $vDi, InsertEltShift.Left3, Bitcast.DblToLong)>;
  2108. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load DSForm:$rA)), i64:$rB)),
  2109. (VINSDRX $vDi, InsertEltShift.Left3, (LD memrix:$rA))>;
  2110. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load PDForm:$rA)), i64:$rB)),
  2111. (VINSDRX $vDi, InsertEltShift.Left3, (PLD memri34:$rA))>;
  2112. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load XForm:$rA)), i64:$rB)),
  2113. (VINSDRX $vDi, InsertEltShift.Left3, (LDX memrr:$rA))>;
  2114. let AddedComplexity = 400 in {
  2115. // Immediate vector insert element
  2116. foreach Idx = [0, 1, 2, 3] in {
  2117. def : Pat<(v4i32 (insertelt v4i32:$vDi, i32:$rA, Idx)),
  2118. (VINSW $vDi, !mul(!sub(3, Idx), 4), $rA)>;
  2119. }
  2120. foreach i = [0, 1] in
  2121. def : Pat<(v2i64 (insertelt v2i64:$vDi, i64:$rA, (i64 i))),
  2122. (VINSD $vDi, !mul(!sub(1, i), 8), $rA)>;
  2123. }
  2124. }
  2125. let Predicates = [IsISA3_1, HasVSX, IsBigEndian, IsPPC32] in {
  2126. // Indexed vector insert element
  2127. def : Pat<(v16i8 (vector_insert v16i8:$vDi, i32:$rA, i32:$rB)),
  2128. (VINSBLX $vDi, $rB, $rA)>;
  2129. def : Pat<(v8i16 (vector_insert v8i16:$vDi, i32:$rA, i32:$rB)),
  2130. (VINSHLX $vDi, InsertEltShift.Left1, $rA)>;
  2131. def : Pat<(v4i32 (insertelt v4i32:$vDi, i32:$rA, i32:$rB)),
  2132. (VINSWLX $vDi, InsertEltShift.Left2, $rA)>;
  2133. def : Pat<(v4f32 (insertelt v4f32:$vDi, f32:$rA, i32:$rB)),
  2134. (VINSWVLX $vDi, InsertEltShift.Left2, (XSCVDPSPN $rA))>;
  2135. }
  2136. let Predicates = [IsISA3_1, HasVSX, IsBigEndian, IsPPC64] in {
  2137. // Indexed vector insert element
  2138. def : Pat<(v16i8 (vector_insert v16i8:$vDi, i32:$rA, i64:$rB)),
  2139. (VINSBLX $vDi, InsertEltShift.Sub32, $rA)>;
  2140. def : Pat<(v8i16 (vector_insert v8i16:$vDi, i32:$rA, i64:$rB)),
  2141. (VINSHLX $vDi, InsertEltShift.Sub32Left1, $rA)>;
  2142. def : Pat<(v4i32 (insertelt v4i32:$vDi, i32:$rA, i64:$rB)),
  2143. (VINSWLX $vDi, InsertEltShift.Sub32Left2, $rA)>;
  2144. def : Pat<(v2i64 (insertelt v2i64:$vDi, i64:$rA, i64:$rB)),
  2145. (VINSDLX $vDi, InsertEltShift.Left3, $rA)>;
  2146. def : Pat<(v4f32 (insertelt v4f32:$vDi, f32:$rA, i64:$rB)),
  2147. (VINSWVLX $vDi, InsertEltShift.Sub32Left2, (XSCVDPSPN $rA))>;
  2148. def : Pat<(v2f64 (insertelt v2f64:$vDi, f64:$A, i64:$rB)),
  2149. (VINSDLX $vDi, InsertEltShift.Left3, Bitcast.DblToLong)>;
  2150. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load DSForm:$rA)), i64:$rB)),
  2151. (VINSDLX $vDi, InsertEltShift.Left3, (LD memrix:$rA))>;
  2152. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load PDForm:$rA)), i64:$rB)),
  2153. (VINSDLX $vDi, InsertEltShift.Left3, (PLD memri34:$rA))>;
  2154. def : Pat<(v2f64 (insertelt v2f64:$vDi, (f64 (load XForm:$rA)), i64:$rB)),
  2155. (VINSDLX $vDi, InsertEltShift.Left3, (LDX memrr:$rA))>;
  2156. }
  2157. let AddedComplexity = 400, Predicates = [IsISA3_1, HasVSX, IsBigEndian] in {
  2158. // Immediate vector insert element
  2159. foreach Ty = [i32, i64] in {
  2160. foreach Idx = [0, 1, 2, 3] in {
  2161. def : Pat<(v4i32 (insertelt v4i32:$vDi, i32:$rA, (Ty Idx))),
  2162. (VINSW $vDi, !mul(Idx, 4), $rA)>;
  2163. }
  2164. }
  2165. foreach Idx = [0, 1] in
  2166. def : Pat<(v2i64 (insertelt v2i64:$vDi, i64:$rA, Idx)),
  2167. (VINSD $vDi, !mul(Idx, 8), $rA)>;
  2168. }