PPCInstr64Bit.td 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963
  1. //===-- PPCInstr64Bit.td - The PowerPC 64-bit Support ------*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file describes the PowerPC 64-bit instructions. These patterns are used
  10. // both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //===----------------------------------------------------------------------===//
  14. // 64-bit operands.
  15. //
  16. def s16imm64 : Operand<i64> {
  17. let PrintMethod = "printS16ImmOperand";
  18. let EncoderMethod = "getImm16Encoding";
  19. let ParserMatchClass = PPCS16ImmAsmOperand;
  20. let DecoderMethod = "decodeSImmOperand<16>";
  21. let OperandType = "OPERAND_IMMEDIATE";
  22. }
  23. def u16imm64 : Operand<i64> {
  24. let PrintMethod = "printU16ImmOperand";
  25. let EncoderMethod = "getImm16Encoding";
  26. let ParserMatchClass = PPCU16ImmAsmOperand;
  27. let DecoderMethod = "decodeUImmOperand<16>";
  28. let OperandType = "OPERAND_IMMEDIATE";
  29. }
  30. def s17imm64 : Operand<i64> {
  31. // This operand type is used for addis/lis to allow the assembler parser
  32. // to accept immediates in the range -65536..65535 for compatibility with
  33. // the GNU assembler. The operand is treated as 16-bit otherwise.
  34. let PrintMethod = "printS16ImmOperand";
  35. let EncoderMethod = "getImm16Encoding";
  36. let ParserMatchClass = PPCS17ImmAsmOperand;
  37. let DecoderMethod = "decodeSImmOperand<16>";
  38. let OperandType = "OPERAND_IMMEDIATE";
  39. }
  40. def tocentry : Operand<iPTR> {
  41. let MIOperandInfo = (ops i64imm:$imm);
  42. }
  43. def tlsreg : Operand<i64> {
  44. let EncoderMethod = "getTLSRegEncoding";
  45. let ParserMatchClass = PPCTLSRegOperand;
  46. }
  47. def tlsgd : Operand<i64> {}
  48. def tlscall : Operand<i64> {
  49. let PrintMethod = "printTLSCall";
  50. let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym);
  51. let EncoderMethod = "getTLSCallEncoding";
  52. }
  53. //===----------------------------------------------------------------------===//
  54. // 64-bit transformation functions.
  55. //
  56. def SHL64 : SDNodeXForm<imm, [{
  57. // Transformation function: 63 - imm
  58. return getI32Imm(63 - N->getZExtValue(), SDLoc(N));
  59. }]>;
  60. def SRL64 : SDNodeXForm<imm, [{
  61. // Transformation function: 64 - imm
  62. return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue(), SDLoc(N))
  63. : getI32Imm(0, SDLoc(N));
  64. }]>;
  65. //===----------------------------------------------------------------------===//
  66. // Calls.
  67. //
  68. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  69. let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
  70. let isReturn = 1, isPredicable = 1, Uses = [LR8, RM] in
  71. def BLR8 : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
  72. [(retflag)]>, Requires<[In64BitMode]>;
  73. let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in {
  74. let isPredicable = 1 in
  75. def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
  76. []>,
  77. Requires<[In64BitMode]>;
  78. def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
  79. "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
  80. []>,
  81. Requires<[In64BitMode]>;
  82. def BCCTR8 : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
  83. "bcctr 12, $bi, 0", IIC_BrB, []>,
  84. Requires<[In64BitMode]>;
  85. def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
  86. "bcctr 4, $bi, 0", IIC_BrB, []>,
  87. Requires<[In64BitMode]>;
  88. }
  89. }
  90. let Defs = [LR8] in
  91. def MovePCtoLR8 : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR8", []>,
  92. PPC970_Unit_BRU;
  93. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
  94. let Defs = [CTR8], Uses = [CTR8] in {
  95. def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
  96. "bdz $dst">;
  97. def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
  98. "bdnz $dst">;
  99. }
  100. let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in {
  101. def BDZLR8 : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
  102. "bdzlr", IIC_BrB, []>;
  103. def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
  104. "bdnzlr", IIC_BrB, []>;
  105. }
  106. }
  107. let isCall = 1, PPC970_Unit = 7, Defs = [LR8], hasSideEffects = 0 in {
  108. // Convenient aliases for call instructions
  109. let Uses = [RM] in {
  110. def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$func),
  111. "bl $func", IIC_BrB, []>; // See Pat patterns below.
  112. def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$func),
  113. "bl $func", IIC_BrB, []>;
  114. def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
  115. "bla $func", IIC_BrB, [(PPCcall (i64 imm:$func))]>;
  116. }
  117. let Uses = [RM], isCodeGenOnly = 1 in {
  118. def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
  119. (outs), (ins calltarget:$func),
  120. "bl $func\n\tnop", IIC_BrB, []>;
  121. def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
  122. (outs), (ins tlscall:$func),
  123. "bl $func\n\tnop", IIC_BrB, []>;
  124. def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
  125. (outs), (ins abscalltarget:$func),
  126. "bla $func\n\tnop", IIC_BrB,
  127. [(PPCcall_nop (i64 imm:$func))]>;
  128. let Predicates = [PCRelativeMemops] in {
  129. // BL8_NOTOC means that the caller does not use the TOC pointer and if
  130. // it does use R2 then it is just a caller saved register. Therefore it is
  131. // safe to emit only the bl and not the nop for this instruction. The
  132. // linker will not try to restore R2 after the call.
  133. def BL8_NOTOC : IForm<18, 0, 1, (outs),
  134. (ins calltarget:$func),
  135. "bl $func", IIC_BrB, []>;
  136. def BL8_NOTOC_TLS : IForm<18, 0, 1, (outs),
  137. (ins tlscall:$func),
  138. "bl $func", IIC_BrB, []>;
  139. }
  140. }
  141. let Uses = [CTR8, RM] in {
  142. let isPredicable = 1 in
  143. def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
  144. "bctrl", IIC_BrB, [(PPCbctrl)]>,
  145. Requires<[In64BitMode]>;
  146. let isCodeGenOnly = 1 in {
  147. def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
  148. "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
  149. []>,
  150. Requires<[In64BitMode]>;
  151. def BCCTRL8 : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
  152. "bcctrl 12, $bi, 0", IIC_BrB, []>,
  153. Requires<[In64BitMode]>;
  154. def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
  155. "bcctrl 4, $bi, 0", IIC_BrB, []>,
  156. Requires<[In64BitMode]>;
  157. }
  158. }
  159. }
  160. let isCall = 1, PPC970_Unit = 7, Defs = [LR8, RM], hasSideEffects = 0,
  161. isCodeGenOnly = 1, Uses = [RM] in {
  162. // Convenient aliases for call instructions
  163. def BL8_RM : IForm<18, 0, 1, (outs), (ins calltarget:$func),
  164. "bl $func", IIC_BrB, []>; // See Pat patterns below.
  165. def BLA8_RM : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
  166. "bla $func", IIC_BrB, [(PPCcall_rm (i64 imm:$func))]>;
  167. def BL8_NOP_RM : IForm_and_DForm_4_zero<18, 0, 1, 24,
  168. (outs), (ins calltarget:$func),
  169. "bl $func\n\tnop", IIC_BrB, []>;
  170. def BLA8_NOP_RM : IForm_and_DForm_4_zero<18, 1, 1, 24,
  171. (outs), (ins abscalltarget:$func),
  172. "bla $func\n\tnop", IIC_BrB,
  173. [(PPCcall_nop_rm (i64 imm:$func))]>;
  174. let Predicates = [PCRelativeMemops] in {
  175. // BL8_NOTOC means that the caller does not use the TOC pointer and if
  176. // it does use R2 then it is just a caller saved register. Therefore it is
  177. // safe to emit only the bl and not the nop for this instruction. The
  178. // linker will not try to restore R2 after the call.
  179. def BL8_NOTOC_RM : IForm<18, 0, 1, (outs),
  180. (ins calltarget:$func),
  181. "bl $func", IIC_BrB, []>;
  182. }
  183. let Uses = [CTR8, RM] in {
  184. let isPredicable = 1 in
  185. def BCTRL8_RM : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
  186. "bctrl", IIC_BrB, [(PPCbctrl_rm)]>,
  187. Requires<[In64BitMode]>;
  188. }
  189. }
  190. let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
  191. Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
  192. def BCTRL8_LDinto_toc :
  193. XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
  194. (ins memrix:$src),
  195. "bctrl\n\tld 2, $src", IIC_BrB,
  196. [(PPCbctrl_load_toc iaddrX4:$src)]>,
  197. Requires<[In64BitMode]>;
  198. }
  199. let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
  200. Defs = [LR8, X2, RM], Uses = [CTR8, RM], RST = 2 in {
  201. def BCTRL8_LDinto_toc_RM :
  202. XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
  203. (ins memrix:$src),
  204. "bctrl\n\tld 2, $src", IIC_BrB,
  205. [(PPCbctrl_load_toc_rm iaddrX4:$src)]>,
  206. Requires<[In64BitMode]>;
  207. }
  208. } // Interpretation64Bit
  209. // FIXME: Duplicating this for the asm parser should be unnecessary, but the
  210. // previous definition must be marked as CodeGen only to prevent decoding
  211. // conflicts.
  212. let Interpretation64Bit = 1, isAsmParserOnly = 1, hasSideEffects = 0 in
  213. let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
  214. def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func),
  215. "bl $func", IIC_BrB, []>;
  216. // Calls
  217. def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
  218. (BL8 tglobaladdr:$dst)>;
  219. def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
  220. (BL8_NOP tglobaladdr:$dst)>;
  221. def : Pat<(PPCcall (i64 texternalsym:$dst)),
  222. (BL8 texternalsym:$dst)>;
  223. def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
  224. (BL8_NOP texternalsym:$dst)>;
  225. def : Pat<(PPCcall_notoc (i64 tglobaladdr:$dst)),
  226. (BL8_NOTOC tglobaladdr:$dst)>;
  227. def : Pat<(PPCcall_notoc (i64 texternalsym:$dst)),
  228. (BL8_NOTOC texternalsym:$dst)>;
  229. def : Pat<(PPCcall_rm (i64 tglobaladdr:$dst)),
  230. (BL8_RM tglobaladdr:$dst)>;
  231. def : Pat<(PPCcall_nop_rm (i64 tglobaladdr:$dst)),
  232. (BL8_NOP_RM tglobaladdr:$dst)>;
  233. def : Pat<(PPCcall_rm (i64 texternalsym:$dst)),
  234. (BL8_RM texternalsym:$dst)>;
  235. def : Pat<(PPCcall_nop_rm (i64 texternalsym:$dst)),
  236. (BL8_NOP_RM texternalsym:$dst)>;
  237. def : Pat<(PPCcall_notoc_rm (i64 tglobaladdr:$dst)),
  238. (BL8_NOTOC_RM tglobaladdr:$dst)>;
  239. def : Pat<(PPCcall_notoc_rm (i64 texternalsym:$dst)),
  240. (BL8_NOTOC_RM texternalsym:$dst)>;
  241. // Calls for AIX
  242. def : Pat<(PPCcall (i64 mcsym:$dst)),
  243. (BL8 mcsym:$dst)>;
  244. def : Pat<(PPCcall_nop (i64 mcsym:$dst)),
  245. (BL8_NOP mcsym:$dst)>;
  246. def : Pat<(PPCcall_rm (i64 mcsym:$dst)),
  247. (BL8_RM mcsym:$dst)>;
  248. def : Pat<(PPCcall_nop_rm (i64 mcsym:$dst)),
  249. (BL8_NOP_RM mcsym:$dst)>;
  250. // Atomic operations
  251. // FIXME: some of these might be used with constant operands. This will result
  252. // in constant materialization instructions that may be redundant. We currently
  253. // clean this up in PPCMIPeephole with calls to
  254. // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
  255. // in the first place.
  256. let Defs = [CR0] in {
  257. def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
  258. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
  259. [(set i64:$dst, (atomic_load_add_64 ForceXForm:$ptr, i64:$incr))]>;
  260. def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
  261. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
  262. [(set i64:$dst, (atomic_load_sub_64 ForceXForm:$ptr, i64:$incr))]>;
  263. def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
  264. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
  265. [(set i64:$dst, (atomic_load_or_64 ForceXForm:$ptr, i64:$incr))]>;
  266. def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
  267. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
  268. [(set i64:$dst, (atomic_load_xor_64 ForceXForm:$ptr, i64:$incr))]>;
  269. def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
  270. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
  271. [(set i64:$dst, (atomic_load_and_64 ForceXForm:$ptr, i64:$incr))]>;
  272. def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
  273. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
  274. [(set i64:$dst, (atomic_load_nand_64 ForceXForm:$ptr, i64:$incr))]>;
  275. def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
  276. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
  277. [(set i64:$dst, (atomic_load_min_64 ForceXForm:$ptr, i64:$incr))]>;
  278. def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
  279. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
  280. [(set i64:$dst, (atomic_load_max_64 ForceXForm:$ptr, i64:$incr))]>;
  281. def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
  282. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
  283. [(set i64:$dst, (atomic_load_umin_64 ForceXForm:$ptr, i64:$incr))]>;
  284. def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
  285. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
  286. [(set i64:$dst, (atomic_load_umax_64 ForceXForm:$ptr, i64:$incr))]>;
  287. def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
  288. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
  289. [(set i64:$dst, (atomic_cmp_swap_64 ForceXForm:$ptr, i64:$old, i64:$new))]>;
  290. def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
  291. (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
  292. [(set i64:$dst, (atomic_swap_64 ForceXForm:$ptr, i64:$new))]>;
  293. }
  294. // Instructions to support atomic operations
  295. let mayLoad = 1, hasSideEffects = 0 in {
  296. def LDARX : XForm_1_memOp<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
  297. "ldarx $rD, $ptr", IIC_LdStLDARX, []>;
  298. // TODO: Add scheduling info.
  299. let hasNoSchedulingInfo = 1 in
  300. def LQARX : XForm_1_memOp<31, 276, (outs g8prc:$RTp), (ins memrr:$ptr),
  301. "lqarx $RTp, $ptr", IIC_LdStLQARX, []>, isPPC64;
  302. // Instruction to support lock versions of atomics
  303. // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
  304. def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
  305. "ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isRecordForm;
  306. // TODO: Add scheduling info.
  307. let hasNoSchedulingInfo = 1 in
  308. // FIXME: We have to seek a way to remove isRecordForm since
  309. // LQARXL is not really altering CR0.
  310. def LQARXL : XForm_1<31, 276, (outs g8prc:$RTp), (ins memrr:$ptr),
  311. "lqarx $RTp, $ptr, 1", IIC_LdStLQARX, []>,
  312. isPPC64, isRecordForm;
  313. let hasExtraDefRegAllocReq = 1 in
  314. def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC),
  315. "ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64,
  316. Requires<[IsISA3_0]>;
  317. }
  318. let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
  319. def STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
  320. "stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isRecordForm;
  321. // TODO: Add scheduling info.
  322. let hasNoSchedulingInfo = 1 in
  323. def STQCX : XForm_1_memOp<31, 182, (outs), (ins g8prc:$RSp, memrr:$dst),
  324. "stqcx. $RSp, $dst", IIC_LdStSTQCX, []>,
  325. isPPC64, isRecordForm;
  326. }
  327. def SPLIT_QUADWORD : PPCCustomInserterPseudo<(outs g8rc:$lo, g8rc:$hi),
  328. (ins g8prc:$src),
  329. "#SPLIT_QUADWORD", []>;
  330. class AtomicRMW128<string asmstr>
  331. : PPCPostRAExpPseudo<(outs g8prc:$RTp, g8prc:$scratch),
  332. (ins memrr:$ptr, g8rc:$incr_lo, g8rc:$incr_hi),
  333. asmstr, []>;
  334. // We have to keep values in MI's uses during LL/SC looping as they are,
  335. // so set both $RTp and $scratch earlyclobber.
  336. let mayStore = 1, mayLoad = 1,
  337. Defs = [CR0],
  338. Constraints = "@earlyclobber $scratch,@earlyclobber $RTp" in {
  339. // Atomic pseudo instructions expanded post-ra.
  340. def ATOMIC_SWAP_I128 : AtomicRMW128<"#ATOMIC_SWAP_I128">;
  341. def ATOMIC_LOAD_ADD_I128 : AtomicRMW128<"#ATOMIC_LOAD_ADD_I128">;
  342. def ATOMIC_LOAD_SUB_I128 : AtomicRMW128<"#ATOMIC_LOAD_SUB_I128">;
  343. def ATOMIC_LOAD_AND_I128 : AtomicRMW128<"#ATOMIC_LOAD_AND_I128">;
  344. def ATOMIC_LOAD_XOR_I128 : AtomicRMW128<"#ATOMIC_LOAD_XOR_I128">;
  345. def ATOMIC_LOAD_OR_I128 : AtomicRMW128<"#ATOMIC_LOAD_OR_I128">;
  346. def ATOMIC_LOAD_NAND_I128 : AtomicRMW128<"#ATOMIC_LOAD_NAND_I128">;
  347. def ATOMIC_CMP_SWAP_I128 : PPCPostRAExpPseudo<
  348. (outs g8prc:$RTp, g8prc:$scratch),
  349. (ins memrr:$ptr, g8rc:$cmp_lo, g8rc:$cmp_hi,
  350. g8rc:$new_lo, g8rc:$new_hi),
  351. "#ATOMIC_CMP_SWAP_I128", []>;
  352. }
  353. def : Pat<(int_ppc_atomicrmw_add_i128 ForceXForm:$ptr,
  354. i64:$incr_lo,
  355. i64:$incr_hi),
  356. (SPLIT_QUADWORD (ATOMIC_LOAD_ADD_I128 memrr:$ptr,
  357. g8rc:$incr_lo,
  358. g8rc:$incr_hi))>;
  359. def : Pat<(int_ppc_atomicrmw_sub_i128 ForceXForm:$ptr,
  360. i64:$incr_lo,
  361. i64:$incr_hi),
  362. (SPLIT_QUADWORD (ATOMIC_LOAD_SUB_I128 memrr:$ptr,
  363. g8rc:$incr_lo,
  364. g8rc:$incr_hi))>;
  365. def : Pat<(int_ppc_atomicrmw_xor_i128 ForceXForm:$ptr,
  366. i64:$incr_lo,
  367. i64:$incr_hi),
  368. (SPLIT_QUADWORD (ATOMIC_LOAD_XOR_I128 memrr:$ptr,
  369. g8rc:$incr_lo,
  370. g8rc:$incr_hi))>;
  371. def : Pat<(int_ppc_atomicrmw_and_i128 ForceXForm:$ptr,
  372. i64:$incr_lo,
  373. i64:$incr_hi),
  374. (SPLIT_QUADWORD (ATOMIC_LOAD_AND_I128 memrr:$ptr,
  375. g8rc:$incr_lo,
  376. g8rc:$incr_hi))>;
  377. def : Pat<(int_ppc_atomicrmw_nand_i128 ForceXForm:$ptr,
  378. i64:$incr_lo,
  379. i64:$incr_hi),
  380. (SPLIT_QUADWORD (ATOMIC_LOAD_NAND_I128 memrr:$ptr,
  381. g8rc:$incr_lo,
  382. g8rc:$incr_hi))>;
  383. def : Pat<(int_ppc_atomicrmw_or_i128 ForceXForm:$ptr,
  384. i64:$incr_lo,
  385. i64:$incr_hi),
  386. (SPLIT_QUADWORD (ATOMIC_LOAD_OR_I128 memrr:$ptr,
  387. g8rc:$incr_lo,
  388. g8rc:$incr_hi))>;
  389. def : Pat<(int_ppc_atomicrmw_xchg_i128 ForceXForm:$ptr,
  390. i64:$incr_lo,
  391. i64:$incr_hi),
  392. (SPLIT_QUADWORD (ATOMIC_SWAP_I128 memrr:$ptr,
  393. g8rc:$incr_lo,
  394. g8rc:$incr_hi))>;
  395. def : Pat<(int_ppc_cmpxchg_i128 ForceXForm:$ptr,
  396. i64:$cmp_lo,
  397. i64:$cmp_hi,
  398. i64:$new_lo,
  399. i64:$new_hi),
  400. (SPLIT_QUADWORD (ATOMIC_CMP_SWAP_I128
  401. memrr:$ptr,
  402. g8rc:$cmp_lo,
  403. g8rc:$cmp_hi,
  404. g8rc:$new_lo,
  405. g8rc:$new_hi))>;
  406. let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
  407. def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC),
  408. "stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64,
  409. Requires<[IsISA3_0]>;
  410. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  411. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  412. def TCRETURNdi8 :PPCEmitTimePseudo< (outs),
  413. (ins calltarget:$dst, i32imm:$offset),
  414. "#TC_RETURNd8 $dst $offset",
  415. []>;
  416. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  417. def TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
  418. "#TC_RETURNa8 $func $offset",
  419. [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
  420. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
  421. def TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
  422. "#TC_RETURNr8 $dst $offset",
  423. []>;
  424. let hasSideEffects = 0 in {
  425. let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
  426. isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
  427. def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
  428. []>,
  429. Requires<[In64BitMode]>;
  430. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
  431. isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
  432. def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
  433. "b $dst", IIC_BrB,
  434. []>;
  435. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
  436. isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
  437. def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
  438. "ba $dst", IIC_BrB,
  439. []>;
  440. }
  441. } // Interpretation64Bit
  442. def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
  443. (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
  444. def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
  445. (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
  446. def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
  447. (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
  448. // 64-bit CR instructions
  449. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  450. let hasSideEffects = 0 in {
  451. // mtocrf's input needs to be prepared by shifting by an amount dependent
  452. // on the cr register selected. Thus, post-ra anti-dep breaking must not
  453. // later change that register assignment.
  454. let hasExtraDefRegAllocReq = 1 in {
  455. def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
  456. "mtocrf $FXM, $ST", IIC_BrMCRX>,
  457. PPC970_DGroup_First, PPC970_Unit_CRU;
  458. // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
  459. // is dependent on the cr fields being set.
  460. def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
  461. "mtcrf $FXM, $rS", IIC_BrMCRX>,
  462. PPC970_MicroCode, PPC970_Unit_CRU;
  463. } // hasExtraDefRegAllocReq = 1
  464. // mfocrf's input needs to be prepared by shifting by an amount dependent
  465. // on the cr register selected. Thus, post-ra anti-dep breaking must not
  466. // later change that register assignment.
  467. let hasExtraSrcRegAllocReq = 1 in {
  468. def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
  469. "mfocrf $rT, $FXM", IIC_SprMFCRF>,
  470. PPC970_DGroup_First, PPC970_Unit_CRU;
  471. // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
  472. // is dependent on the cr fields being copied.
  473. def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
  474. "mfcr $rT", IIC_SprMFCR>,
  475. PPC970_MicroCode, PPC970_Unit_CRU;
  476. } // hasExtraSrcRegAllocReq = 1
  477. } // hasSideEffects = 0
  478. // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
  479. // is not.
  480. let hasSideEffects = 1 in {
  481. let Defs = [CTR8] in
  482. def EH_SjLj_SetJmp64 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
  483. "#EH_SJLJ_SETJMP64",
  484. [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
  485. Requires<[In64BitMode]>;
  486. }
  487. let hasSideEffects = 1, isBarrier = 1 in {
  488. let isTerminator = 1 in
  489. def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
  490. "#EH_SJLJ_LONGJMP64",
  491. [(PPCeh_sjlj_longjmp addr:$buf)]>,
  492. Requires<[In64BitMode]>;
  493. }
  494. def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RT), (ins i32imm:$SPR),
  495. "mfspr $RT, $SPR", IIC_SprMFSPR>;
  496. def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RT),
  497. "mtspr $SPR, $RT", IIC_SprMTSPR>;
  498. //===----------------------------------------------------------------------===//
  499. // 64-bit SPR manipulation instrs.
  500. let Uses = [CTR8] in {
  501. def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
  502. "mfctr $rT", IIC_SprMFSPR>,
  503. PPC970_DGroup_First, PPC970_Unit_FXU;
  504. }
  505. let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
  506. def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
  507. "mtctr $rS", IIC_SprMTSPR>,
  508. PPC970_DGroup_First, PPC970_Unit_FXU;
  509. }
  510. let hasSideEffects = 1, Defs = [CTR8] in {
  511. let Pattern = [(int_set_loop_iterations i64:$rS)] in
  512. def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
  513. "mtctr $rS", IIC_SprMTSPR>,
  514. PPC970_DGroup_First, PPC970_Unit_FXU;
  515. }
  516. let Pattern = [(set i64:$rT, readcyclecounter)] in
  517. def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
  518. "mfspr $rT, 268", IIC_SprMFTB>,
  519. PPC970_DGroup_First, PPC970_Unit_FXU;
  520. // Note that encoding mftb using mfspr is now the preferred form,
  521. // and has been since at least ISA v2.03. The mftb instruction has
  522. // now been phased out. Using mfspr, however, is known not to work on
  523. // the POWER3.
  524. let Defs = [X1], Uses = [X1] in
  525. def DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
  526. [(set i64:$result,
  527. (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
  528. def DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
  529. [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
  530. // Probed alloca to support stack clash protection.
  531. let Defs = [X1], Uses = [X1], hasNoSchedulingInfo = 1 in {
  532. def PROBED_ALLOCA_64 : PPCCustomInserterPseudo<(outs g8rc:$result),
  533. (ins g8rc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_64",
  534. [(set i64:$result,
  535. (PPCprobedalloca i64:$negsize, iaddr:$fpsi))]>;
  536. def PREPARE_PROBED_ALLOCA_64 : PPCEmitTimePseudo<(outs
  537. g8rc:$fp, g8rc:$actual_negsize),
  538. (ins g8rc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_64", []>;
  539. def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 : PPCEmitTimePseudo<(outs
  540. g8rc:$fp, g8rc:$actual_negsize),
  541. (ins g8rc:$negsize, memri:$fpsi),
  542. "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64", []>,
  543. RegConstraint<"$actual_negsize = $negsize">;
  544. def PROBED_STACKALLOC_64 : PPCEmitTimePseudo<(outs g8rc:$scratch, g8rc:$temp),
  545. (ins i64imm:$stacksize),
  546. "#PROBED_STACKALLOC_64", []>;
  547. }
  548. let hasSideEffects = 0 in {
  549. let Defs = [LR8] in {
  550. def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
  551. "mtlr $rS", IIC_SprMTSPR>,
  552. PPC970_DGroup_First, PPC970_Unit_FXU;
  553. }
  554. let Uses = [LR8] in {
  555. def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
  556. "mflr $rT", IIC_SprMFSPR>,
  557. PPC970_DGroup_First, PPC970_Unit_FXU;
  558. }
  559. } // Interpretation64Bit
  560. }
  561. //===----------------------------------------------------------------------===//
  562. // Fixed point instructions.
  563. //
  564. let PPC970_Unit = 1 in { // FXU Operations.
  565. let Interpretation64Bit = 1 in {
  566. let hasSideEffects = 0 in {
  567. let isCodeGenOnly = 1 in {
  568. let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
  569. def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
  570. "li $rD, $imm", IIC_IntSimple,
  571. [(set i64:$rD, imm64SExt16:$imm)]>;
  572. def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
  573. "lis $rD, $imm", IIC_IntSimple,
  574. [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
  575. }
  576. // Logical ops.
  577. let isCommutable = 1 in {
  578. defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  579. "nand", "$rA, $rS, $rB", IIC_IntSimple,
  580. [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
  581. defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  582. "and", "$rA, $rS, $rB", IIC_IntSimple,
  583. [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
  584. } // isCommutable
  585. defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  586. "andc", "$rA, $rS, $rB", IIC_IntSimple,
  587. [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
  588. let isCommutable = 1 in {
  589. defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  590. "or", "$rA, $rS, $rB", IIC_IntSimple,
  591. [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
  592. defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  593. "nor", "$rA, $rS, $rB", IIC_IntSimple,
  594. [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
  595. } // isCommutable
  596. defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  597. "orc", "$rA, $rS, $rB", IIC_IntSimple,
  598. [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
  599. let isCommutable = 1 in {
  600. defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  601. "eqv", "$rA, $rS, $rB", IIC_IntSimple,
  602. [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
  603. defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  604. "xor", "$rA, $rS, $rB", IIC_IntSimple,
  605. [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
  606. } // let isCommutable = 1
  607. // Logical ops with immediate.
  608. let Defs = [CR0] in {
  609. def ANDI8_rec : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  610. "andi. $dst, $src1, $src2", IIC_IntGeneral,
  611. [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
  612. isRecordForm;
  613. def ANDIS8_rec : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  614. "andis. $dst, $src1, $src2", IIC_IntGeneral,
  615. [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
  616. isRecordForm;
  617. }
  618. def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  619. "ori $dst, $src1, $src2", IIC_IntSimple,
  620. [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
  621. def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  622. "oris $dst, $src1, $src2", IIC_IntSimple,
  623. [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
  624. def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  625. "xori $dst, $src1, $src2", IIC_IntSimple,
  626. [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
  627. def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  628. "xoris $dst, $src1, $src2", IIC_IntSimple,
  629. [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
  630. let isCommutable = 1 in
  631. defm ADD8 : XOForm_1rx<31, 266, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  632. "add", "$rT, $rA, $rB", IIC_IntSimple,
  633. [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
  634. // ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
  635. // initial-exec thread-local storage model. We need to forbid r0 here -
  636. // while it works for add just fine, the linker can relax this to local-exec
  637. // addi, which won't work for r0.
  638. def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc_nox0:$rA, tlsreg:$rB),
  639. "add $rT, $rA, $rB", IIC_IntSimple,
  640. [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
  641. let mayLoad = 1 in {
  642. def LBZXTLS : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  643. "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  644. def LHZXTLS : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  645. "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  646. def LWZXTLS : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  647. "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  648. def LDXTLS : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  649. "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
  650. def LBZXTLS_32 : XForm_1<31, 87, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  651. "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  652. def LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  653. "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  654. def LWZXTLS_32 : XForm_1<31, 23, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  655. "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  656. }
  657. let mayStore = 1 in {
  658. def STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  659. "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
  660. PPC970_DGroup_Cracked;
  661. def STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  662. "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
  663. PPC970_DGroup_Cracked;
  664. def STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  665. "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
  666. PPC970_DGroup_Cracked;
  667. def STDXTLS : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  668. "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
  669. PPC970_DGroup_Cracked;
  670. def STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  671. "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
  672. PPC970_DGroup_Cracked;
  673. def STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  674. "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
  675. PPC970_DGroup_Cracked;
  676. def STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  677. "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
  678. PPC970_DGroup_Cracked;
  679. }
  680. let isCommutable = 1 in
  681. defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  682. "addc", "$rT, $rA, $rB", IIC_IntGeneral,
  683. [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
  684. PPC970_DGroup_Cracked;
  685. let Defs = [CARRY] in
  686. def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
  687. "addic $rD, $rA, $imm", IIC_IntGeneral,
  688. [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
  689. def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
  690. "addi $rD, $rA, $imm", IIC_IntSimple,
  691. [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
  692. def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
  693. "addis $rD, $rA, $imm", IIC_IntSimple,
  694. [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
  695. def LA8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$sym),
  696. "la $rD, $sym($rA)", IIC_IntGeneral,
  697. [(set i64:$rD, (add i64:$rA,
  698. (PPClo tglobaladdr:$sym, 0)))]>;
  699. let Defs = [CARRY] in {
  700. def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
  701. "subfic $rD, $rA, $imm", IIC_IntGeneral,
  702. [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
  703. }
  704. defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  705. "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
  706. [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
  707. PPC970_DGroup_Cracked;
  708. defm SUBF8 : XOForm_1rx<31, 40, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  709. "subf", "$rT, $rA, $rB", IIC_IntGeneral,
  710. [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
  711. defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
  712. "neg", "$rT, $rA", IIC_IntSimple,
  713. [(set i64:$rT, (ineg i64:$rA))]>;
  714. let Uses = [CARRY] in {
  715. let isCommutable = 1 in
  716. defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  717. "adde", "$rT, $rA, $rB", IIC_IntGeneral,
  718. [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
  719. defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
  720. "addme", "$rT, $rA", IIC_IntGeneral,
  721. [(set i64:$rT, (adde i64:$rA, -1))]>;
  722. defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
  723. "addze", "$rT, $rA", IIC_IntGeneral,
  724. [(set i64:$rT, (adde i64:$rA, 0))]>;
  725. defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  726. "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
  727. [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
  728. defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
  729. "subfme", "$rT, $rA", IIC_IntGeneral,
  730. [(set i64:$rT, (sube -1, i64:$rA))]>;
  731. defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
  732. "subfze", "$rT, $rA", IIC_IntGeneral,
  733. [(set i64:$rT, (sube 0, i64:$rA))]>;
  734. }
  735. } // isCodeGenOnly
  736. // FIXME: Duplicating this for the asm parser should be unnecessary, but the
  737. // previous definition must be marked as CodeGen only to prevent decoding
  738. // conflicts.
  739. let isAsmParserOnly = 1 in {
  740. def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
  741. "add $rT, $rA, $rB", IIC_IntSimple, []>;
  742. let mayLoad = 1 in {
  743. def LBZXTLS_ : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  744. "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  745. def LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  746. "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  747. def LWZXTLS_ : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  748. "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
  749. def LDXTLS_ : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
  750. "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
  751. }
  752. let mayStore = 1 in {
  753. def STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  754. "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
  755. PPC970_DGroup_Cracked;
  756. def STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  757. "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
  758. PPC970_DGroup_Cracked;
  759. def STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  760. "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
  761. PPC970_DGroup_Cracked;
  762. def STDXTLS_ : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
  763. "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
  764. PPC970_DGroup_Cracked;
  765. }
  766. }
  767. let isCommutable = 1 in {
  768. defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  769. "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
  770. [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
  771. defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  772. "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
  773. [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
  774. } // isCommutable
  775. }
  776. } // Interpretation64Bit
  777. let isCompare = 1, hasSideEffects = 0 in {
  778. def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
  779. "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
  780. def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
  781. "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
  782. def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
  783. "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
  784. def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
  785. "cmpldi $dst, $src1, $src2",
  786. IIC_IntCompare>, isPPC64;
  787. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  788. def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
  789. (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
  790. "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
  791. Requires<[IsISA3_0]>;
  792. def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crrc:$BF),
  793. (ins g8rc:$rA, g8rc:$rB), "cmpeqb $BF, $rA, $rB",
  794. IIC_IntCompare, []>, Requires<[IsISA3_0]>;
  795. }
  796. let hasSideEffects = 0 in {
  797. defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
  798. "sld", "$rA, $rS, $rB", IIC_IntRotateD,
  799. [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
  800. defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
  801. "srd", "$rA, $rS, $rB", IIC_IntRotateD,
  802. [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
  803. defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
  804. "srad", "$rA, $rS, $rB", IIC_IntRotateD,
  805. [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
  806. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  807. defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS),
  808. "cntlzw", "$rA, $rS", IIC_IntGeneral, []>;
  809. defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$rA), (ins g8rc:$rS),
  810. "cnttzw", "$rA, $rS", IIC_IntGeneral, []>,
  811. Requires<[IsISA3_0]>;
  812. defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
  813. "extsb", "$rA, $rS", IIC_IntSimple,
  814. [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
  815. defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
  816. "extsh", "$rA, $rS", IIC_IntSimple,
  817. [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
  818. defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  819. "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
  820. defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  821. "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
  822. } // Interpretation64Bit
  823. // For fast-isel:
  824. let isCodeGenOnly = 1 in {
  825. def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
  826. "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
  827. def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
  828. "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
  829. } // isCodeGenOnly for fast-isel
  830. defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
  831. "extsw", "$rA, $rS", IIC_IntSimple,
  832. [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
  833. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  834. defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
  835. "extsw", "$rA, $rS", IIC_IntSimple,
  836. [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
  837. let isCodeGenOnly = 1 in
  838. def EXTSW_32 : XForm_11<31, 986, (outs gprc:$rA), (ins gprc:$rS),
  839. "extsw $rA, $rS", IIC_IntSimple,
  840. []>, isPPC64;
  841. defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
  842. "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
  843. [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
  844. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  845. defm EXTSWSLI_32_64 : XSForm_1r<31, 445, (outs g8rc:$rA),
  846. (ins gprc:$rS, u6imm:$SH),
  847. "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
  848. [(set i64:$rA,
  849. (PPCextswsli i32:$rS, (i32 imm:$SH)))]>,
  850. isPPC64, Requires<[IsISA3_0]>;
  851. defm EXTSWSLI : XSForm_1rc<31, 445, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
  852. "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
  853. []>, isPPC64, Requires<[IsISA3_0]>;
  854. // For fast-isel:
  855. let isCodeGenOnly = 1, Defs = [CARRY] in
  856. def SRADI_32 : XSForm_1<31, 413, (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH),
  857. "sradi $rA, $rS, $SH", IIC_IntRotateDI, []>, isPPC64;
  858. defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
  859. "cntlzd", "$rA, $rS", IIC_IntGeneral,
  860. [(set i64:$rA, (ctlz i64:$rS))]>;
  861. defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$rA), (ins g8rc:$rS),
  862. "cnttzd", "$rA, $rS", IIC_IntGeneral,
  863. [(set i64:$rA, (cttz i64:$rS))]>, Requires<[IsISA3_0]>;
  864. def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
  865. "popcntd $rA, $rS", IIC_IntGeneral,
  866. [(set i64:$rA, (ctpop i64:$rS))]>;
  867. def BPERMD : XForm_6<31, 252, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  868. "bpermd $rA, $rS, $rB", IIC_IntGeneral,
  869. [(set i64:$rA, (int_ppc_bpermd g8rc:$rS, g8rc:$rB))]>,
  870. isPPC64, Requires<[HasBPERMD]>;
  871. let isCodeGenOnly = 1, isCommutable = 1 in
  872. def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
  873. "cmpb $rA, $rS, $rB", IIC_IntGeneral,
  874. [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
  875. // popcntw also does a population count on the high 32 bits (storing the
  876. // results in the high 32-bits of the output). We'll ignore that here (which is
  877. // safe because we never separately use the high part of the 64-bit registers).
  878. def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
  879. "popcntw $rA, $rS", IIC_IntGeneral,
  880. [(set i32:$rA, (ctpop i32:$rS))]>;
  881. let isCodeGenOnly = 1 in
  882. def POPCNTB8 : XForm_11<31, 122, (outs g8rc:$rA), (ins g8rc:$rS),
  883. "popcntb $rA, $rS", IIC_IntGeneral,
  884. [(set i64:$rA, (int_ppc_popcntb i64:$rS))]>;
  885. defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  886. "divd", "$rT, $rA, $rB", IIC_IntDivD,
  887. [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64;
  888. defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  889. "divdu", "$rT, $rA, $rB", IIC_IntDivD,
  890. [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64;
  891. defm DIVDE : XOForm_1rcr<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  892. "divde", "$rT, $rA, $rB", IIC_IntDivD,
  893. [(set i64:$rT, (int_ppc_divde g8rc:$rA, g8rc:$rB))]>,
  894. isPPC64, Requires<[HasExtDiv]>;
  895. let Predicates = [IsISA3_0] in {
  896. def MADDHD : VAForm_1a<48, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
  897. "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
  898. def MADDHDU : VAForm_1a<49,
  899. (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
  900. "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
  901. def MADDLD : VAForm_1a<51, (outs gprc :$RT), (ins gprc:$RA, gprc:$RB, gprc:$RC),
  902. "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
  903. [(set i32:$RT, (add_without_simm16 (mul_without_simm16 i32:$RA, i32:$RB), i32:$RC))]>,
  904. isPPC64;
  905. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  906. def MADDLD8 : VAForm_1a<51,
  907. (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
  908. "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
  909. [(set i64:$RT, (add_without_simm16 (mul_without_simm16 i64:$RA, i64:$RB), i64:$RC))]>,
  910. isPPC64;
  911. def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
  912. "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
  913. }
  914. def DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins u2imm:$L),
  915. "darn $RT, $L", IIC_LdStLD>, isPPC64;
  916. def ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
  917. "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
  918. def MODSD : XForm_8<31, 777, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  919. "modsd $rT, $rA, $rB", IIC_IntDivW,
  920. [(set i64:$rT, (srem i64:$rA, i64:$rB))]>;
  921. def MODUD : XForm_8<31, 265, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  922. "modud $rT, $rA, $rB", IIC_IntDivW,
  923. [(set i64:$rT, (urem i64:$rA, i64:$rB))]>;
  924. }
  925. defm DIVDEU : XOForm_1rcr<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  926. "divdeu", "$rT, $rA, $rB", IIC_IntDivD,
  927. [(set i64:$rT, (int_ppc_divdeu g8rc:$rA, g8rc:$rB))]>,
  928. isPPC64, Requires<[HasExtDiv]>;
  929. let isCommutable = 1 in
  930. defm MULLD : XOForm_1rx<31, 233, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
  931. "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
  932. [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
  933. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  934. def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
  935. "mulli $rD, $rA, $imm", IIC_IntMulLI,
  936. [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
  937. }
  938. let hasSideEffects = 0 in {
  939. defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
  940. (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
  941. "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  942. []>, isPPC64, RegConstraint<"$rSi = $rA">,
  943. NoEncode<"$rSi">;
  944. // Rotate instructions.
  945. defm RLDCL : MDSForm_1r<30, 8,
  946. (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
  947. "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
  948. []>, isPPC64;
  949. defm RLDCR : MDSForm_1r<30, 9,
  950. (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
  951. "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
  952. []>, isPPC64;
  953. defm RLDICL : MDForm_1r<30, 0,
  954. (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
  955. "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  956. []>, isPPC64;
  957. // For fast-isel:
  958. let isCodeGenOnly = 1 in
  959. def RLDICL_32_64 : MDForm_1<30, 0,
  960. (outs g8rc:$rA),
  961. (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
  962. "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  963. []>, isPPC64;
  964. // End fast-isel.
  965. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  966. defm RLDICL_32 : MDForm_1r<30, 0,
  967. (outs gprc:$rA),
  968. (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
  969. "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  970. []>, isPPC64;
  971. defm RLDICR : MDForm_1r<30, 1,
  972. (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
  973. "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  974. []>, isPPC64;
  975. let isCodeGenOnly = 1 in
  976. def RLDICR_32 : MDForm_1<30, 1,
  977. (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
  978. "rldicr $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  979. []>, isPPC64;
  980. defm RLDIC : MDForm_1r<30, 2,
  981. (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
  982. "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
  983. []>, isPPC64;
  984. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  985. defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
  986. (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
  987. "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
  988. []>;
  989. defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
  990. (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
  991. "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
  992. []>;
  993. // RLWIMI can be commuted if the rotate amount is zero.
  994. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  995. defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
  996. (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
  997. u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
  998. IIC_IntRotate, []>, PPC970_DGroup_Cracked,
  999. RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
  1000. let isSelect = 1 in
  1001. def ISEL8 : AForm_4<31, 15,
  1002. (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
  1003. "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
  1004. []>;
  1005. } // Interpretation64Bit
  1006. } // hasSideEffects = 0
  1007. } // End FXU Operations.
  1008. def : InstAlias<"li $rD, $imm", (ADDI8 g8rc:$rD, ZERO8, s16imm64:$imm)>;
  1009. def : InstAlias<"lis $rD, $imm", (ADDIS8 g8rc:$rD, ZERO8, s17imm64:$imm)>;
  1010. def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
  1011. def : InstAlias<"mr. $rA, $rB", (OR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
  1012. def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
  1013. def : InstAlias<"not. $rA, $rB", (NOR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
  1014. def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
  1015. def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
  1016. def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
  1017. def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
  1018. def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
  1019. def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
  1020. def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
  1021. def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM8 g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
  1022. def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM8_rec g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
  1023. def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
  1024. def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
  1025. def : InstAlias<"isellt $rT, $rA, $rB",
  1026. (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0LT)>;
  1027. def : InstAlias<"iselgt $rT, $rA, $rB",
  1028. (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0GT)>;
  1029. def : InstAlias<"iseleq $rT, $rA, $rB",
  1030. (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0EQ)>;
  1031. def : InstAlias<"nop", (ORI8 X0, X0, 0)>;
  1032. def : InstAlias<"xnop", (XORI8 X0, X0, 0)>;
  1033. def : InstAlias<"cntlzw $rA, $rS", (CNTLZW8 g8rc:$rA, g8rc:$rS)>;
  1034. def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW8_rec g8rc:$rA, g8rc:$rS)>;
  1035. def : InstAlias<"mtxer $Rx", (MTSPR8 1, g8rc:$Rx)>;
  1036. def : InstAlias<"mfxer $Rx", (MFSPR8 g8rc:$Rx, 1)>;
  1037. //Disable this alias on AIX for now because as does not support them.
  1038. let Predicates = [ModernAs] in {
  1039. def : InstAlias<"mtudscr $Rx", (MTSPR8 3, g8rc:$Rx)>;
  1040. def : InstAlias<"mfudscr $Rx", (MFSPR8 g8rc:$Rx, 3)>;
  1041. def : InstAlias<"mfrtcu $Rx", (MFSPR8 g8rc:$Rx, 4)>;
  1042. def : InstAlias<"mfrtcl $Rx", (MFSPR8 g8rc:$Rx, 5)>;
  1043. def : InstAlias<"mtlr $Rx", (MTSPR8 8, g8rc:$Rx)>;
  1044. def : InstAlias<"mflr $Rx", (MFSPR8 g8rc:$Rx, 8)>;
  1045. def : InstAlias<"mtctr $Rx", (MTSPR8 9, g8rc:$Rx)>;
  1046. def : InstAlias<"mfctr $Rx", (MFSPR8 g8rc:$Rx, 9)>;
  1047. def : InstAlias<"mtuamr $Rx", (MTSPR8 13, g8rc:$Rx)>;
  1048. def : InstAlias<"mfuamr $Rx", (MFSPR8 g8rc:$Rx, 13)>;
  1049. def : InstAlias<"mtdscr $Rx", (MTSPR8 17, g8rc:$Rx)>;
  1050. def : InstAlias<"mfdscr $Rx", (MFSPR8 g8rc:$Rx, 17)>;
  1051. def : InstAlias<"mtdsisr $Rx", (MTSPR8 18, g8rc:$Rx)>;
  1052. def : InstAlias<"mfdsisr $Rx", (MFSPR8 g8rc:$Rx, 18)>;
  1053. def : InstAlias<"mtdar $Rx", (MTSPR8 19, g8rc:$Rx)>;
  1054. def : InstAlias<"mfdar $Rx", (MFSPR8 g8rc:$Rx, 19)>;
  1055. def : InstAlias<"mtdec $Rx", (MTSPR8 22, g8rc:$Rx)>;
  1056. def : InstAlias<"mfdec $Rx", (MFSPR8 g8rc:$Rx, 22)>;
  1057. def : InstAlias<"mtsdr1 $Rx", (MTSPR8 25, g8rc:$Rx)>;
  1058. def : InstAlias<"mfsdr1 $Rx", (MFSPR8 g8rc:$Rx, 25)>;
  1059. def : InstAlias<"mtsrr0 $Rx", (MTSPR8 26, g8rc:$Rx)>;
  1060. def : InstAlias<"mfsrr0 $Rx", (MFSPR8 g8rc:$Rx, 26)>;
  1061. def : InstAlias<"mtsrr1 $Rx", (MTSPR8 27, g8rc:$Rx)>;
  1062. def : InstAlias<"mfsrr1 $Rx", (MFSPR8 g8rc:$Rx, 27)>;
  1063. def : InstAlias<"mtcfar $Rx", (MTSPR8 28, g8rc:$Rx)>;
  1064. def : InstAlias<"mfcfar $Rx", (MFSPR8 g8rc:$Rx, 28)>;
  1065. def : InstAlias<"mtamr $Rx", (MTSPR8 29, g8rc:$Rx)>;
  1066. def : InstAlias<"mfamr $Rx", (MFSPR8 g8rc:$Rx, 29)>;
  1067. foreach SPRG = 0-3 in {
  1068. def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
  1069. def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
  1070. def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
  1071. def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
  1072. }
  1073. def : InstAlias<"mfasr $RT", (MFSPR8 g8rc:$RT, 280)>;
  1074. def : InstAlias<"mtasr $RT", (MTSPR8 280, g8rc:$RT)>;
  1075. def : InstAlias<"mttbl $Rx", (MTSPR8 284, g8rc:$Rx)>;
  1076. def : InstAlias<"mttbu $Rx", (MTSPR8 285, g8rc:$Rx)>;
  1077. def : InstAlias<"mfpvr $RT", (MFSPR8 g8rc:$RT, 287)>;
  1078. def : InstAlias<"mfspefscr $Rx", (MFSPR8 g8rc:$Rx, 512)>;
  1079. def : InstAlias<"mtspefscr $Rx", (MTSPR8 512, g8rc:$Rx)>;
  1080. }
  1081. //===----------------------------------------------------------------------===//
  1082. // Load/Store instructions.
  1083. //
  1084. // Sign extending loads.
  1085. let PPC970_Unit = 2 in {
  1086. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  1087. def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
  1088. "lha $rD, $src", IIC_LdStLHA,
  1089. [(set i64:$rD, (sextloadi16 DForm:$src))]>,
  1090. PPC970_DGroup_Cracked;
  1091. def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
  1092. "lwa $rD, $src", IIC_LdStLWA,
  1093. [(set i64:$rD,
  1094. (sextloadi32 DSForm:$src))]>, isPPC64,
  1095. PPC970_DGroup_Cracked;
  1096. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  1097. def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$rD), (ins memrr:$src),
  1098. "lhax $rD, $src", IIC_LdStLHA,
  1099. [(set i64:$rD, (sextloadi16 XForm:$src))]>,
  1100. PPC970_DGroup_Cracked;
  1101. def LWAX : XForm_1_memOp<31, 341, (outs g8rc:$rD), (ins memrr:$src),
  1102. "lwax $rD, $src", IIC_LdStLHA,
  1103. [(set i64:$rD, (sextloadi32 XForm:$src))]>, isPPC64,
  1104. PPC970_DGroup_Cracked;
  1105. // For fast-isel:
  1106. let isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0 in {
  1107. def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
  1108. "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
  1109. PPC970_DGroup_Cracked;
  1110. def LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$rD), (ins memrr:$src),
  1111. "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
  1112. PPC970_DGroup_Cracked;
  1113. } // end fast-isel isCodeGenOnly
  1114. // Update forms.
  1115. let mayLoad = 1, hasSideEffects = 0 in {
  1116. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  1117. def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1118. (ins memri:$addr),
  1119. "lhau $rD, $addr", IIC_LdStLHAU,
  1120. []>, RegConstraint<"$addr.reg = $ea_result">,
  1121. NoEncode<"$ea_result">;
  1122. // NO LWAU!
  1123. let Interpretation64Bit = 1, isCodeGenOnly = 1 in
  1124. def LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1125. (ins memrr:$addr),
  1126. "lhaux $rD, $addr", IIC_LdStLHAUX,
  1127. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1128. NoEncode<"$ea_result">;
  1129. def LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1130. (ins memrr:$addr),
  1131. "lwaux $rD, $addr", IIC_LdStLHAUX,
  1132. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1133. NoEncode<"$ea_result">, isPPC64;
  1134. }
  1135. }
  1136. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1137. // Zero extending loads.
  1138. let PPC970_Unit = 2 in {
  1139. def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
  1140. "lbz $rD, $src", IIC_LdStLoad,
  1141. [(set i64:$rD, (zextloadi8 DForm:$src))]>;
  1142. def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
  1143. "lhz $rD, $src", IIC_LdStLoad,
  1144. [(set i64:$rD, (zextloadi16 DForm:$src))]>;
  1145. def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
  1146. "lwz $rD, $src", IIC_LdStLoad,
  1147. [(set i64:$rD, (zextloadi32 DForm:$src))]>, isPPC64;
  1148. def LBZX8 : XForm_1_memOp<31, 87, (outs g8rc:$rD), (ins memrr:$src),
  1149. "lbzx $rD, $src", IIC_LdStLoad,
  1150. [(set i64:$rD, (zextloadi8 XForm:$src))]>;
  1151. def LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$rD), (ins memrr:$src),
  1152. "lhzx $rD, $src", IIC_LdStLoad,
  1153. [(set i64:$rD, (zextloadi16 XForm:$src))]>;
  1154. def LWZX8 : XForm_1_memOp<31, 23, (outs g8rc:$rD), (ins memrr:$src),
  1155. "lwzx $rD, $src", IIC_LdStLoad,
  1156. [(set i64:$rD, (zextloadi32 XForm:$src))]>;
  1157. // Update forms.
  1158. let mayLoad = 1, hasSideEffects = 0 in {
  1159. def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1160. (ins memri:$addr),
  1161. "lbzu $rD, $addr", IIC_LdStLoadUpd,
  1162. []>, RegConstraint<"$addr.reg = $ea_result">,
  1163. NoEncode<"$ea_result">;
  1164. def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1165. (ins memri:$addr),
  1166. "lhzu $rD, $addr", IIC_LdStLoadUpd,
  1167. []>, RegConstraint<"$addr.reg = $ea_result">,
  1168. NoEncode<"$ea_result">;
  1169. def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1170. (ins memri:$addr),
  1171. "lwzu $rD, $addr", IIC_LdStLoadUpd,
  1172. []>, RegConstraint<"$addr.reg = $ea_result">,
  1173. NoEncode<"$ea_result">;
  1174. def LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1175. (ins memrr:$addr),
  1176. "lbzux $rD, $addr", IIC_LdStLoadUpdX,
  1177. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1178. NoEncode<"$ea_result">;
  1179. def LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1180. (ins memrr:$addr),
  1181. "lhzux $rD, $addr", IIC_LdStLoadUpdX,
  1182. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1183. NoEncode<"$ea_result">;
  1184. def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1185. (ins memrr:$addr),
  1186. "lwzux $rD, $addr", IIC_LdStLoadUpdX,
  1187. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1188. NoEncode<"$ea_result">;
  1189. }
  1190. }
  1191. } // Interpretation64Bit
  1192. // Full 8-byte loads.
  1193. let PPC970_Unit = 2 in {
  1194. def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
  1195. "ld $rD, $src", IIC_LdStLD,
  1196. [(set i64:$rD, (load DSForm:$src))]>, isPPC64;
  1197. // The following four definitions are selected for small code model only.
  1198. // Otherwise, we need to create two instructions to form a 32-bit offset,
  1199. // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
  1200. def LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
  1201. "#LDtoc",
  1202. [(set i64:$rD,
  1203. (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
  1204. def LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
  1205. "#LDtocJTI",
  1206. [(set i64:$rD,
  1207. (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
  1208. def LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
  1209. "#LDtocCPT",
  1210. [(set i64:$rD,
  1211. (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
  1212. def LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
  1213. "#LDtocCPT",
  1214. [(set i64:$rD,
  1215. (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
  1216. def LDX : XForm_1_memOp<31, 21, (outs g8rc:$rD), (ins memrr:$src),
  1217. "ldx $rD, $src", IIC_LdStLD,
  1218. [(set i64:$rD, (load XForm:$src))]>, isPPC64;
  1219. let Predicates = [IsISA2_06] in {
  1220. def LDBRX : XForm_1_memOp<31, 532, (outs g8rc:$rD), (ins memrr:$src),
  1221. "ldbrx $rD, $src", IIC_LdStLoad,
  1222. [(set i64:$rD, (PPClbrx ForceXForm:$src, i64))]>, isPPC64;
  1223. }
  1224. let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
  1225. def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$rD), (ins memrr:$src),
  1226. "lhbrx $rD, $src", IIC_LdStLoad, []>;
  1227. def LWBRX8 : XForm_1_memOp<31, 534, (outs g8rc:$rD), (ins memrr:$src),
  1228. "lwbrx $rD, $src", IIC_LdStLoad, []>;
  1229. }
  1230. let mayLoad = 1, hasSideEffects = 0 in {
  1231. def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1232. (ins memrix:$addr),
  1233. "ldu $rD, $addr", IIC_LdStLDU,
  1234. []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
  1235. NoEncode<"$ea_result">;
  1236. def LDUX : XForm_1_memOp<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
  1237. (ins memrr:$addr),
  1238. "ldux $rD, $addr", IIC_LdStLDUX,
  1239. []>, RegConstraint<"$addr.ptrreg = $ea_result">,
  1240. NoEncode<"$ea_result">, isPPC64;
  1241. def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src),
  1242. "ldmx $rD, $src", IIC_LdStLD, []>, isPPC64,
  1243. Requires<[IsISA3_0]>;
  1244. }
  1245. let mayLoad = 1, hasNoSchedulingInfo = 1 in {
  1246. // Full 16-byte load.
  1247. // Early clobber $RTp to avoid assigned to the same register as RA.
  1248. // TODO: Add scheduling info.
  1249. def LQ : DQForm_RTp5_RA17_MEM<56, 0,
  1250. (outs g8prc:$RTp),
  1251. (ins memrix16:$src),
  1252. "lq $RTp, $src", IIC_LdStLQ,
  1253. []>,
  1254. RegConstraint<"@earlyclobber $RTp">,
  1255. isPPC64;
  1256. // We don't really have LQX in the ISA, make a pseudo one so that we can
  1257. // handle x-form during isel. Make it pre-ra may expose
  1258. // oppotunities to some opts(CSE, LICM and etc.) for the result of adding
  1259. // RA and RB.
  1260. def LQX_PSEUDO : PPCCustomInserterPseudo<(outs g8prc:$RTp),
  1261. (ins memrr:$src), "#LQX_PSEUDO", []>;
  1262. def RESTORE_QUADWORD : PPCEmitTimePseudo<(outs g8prc:$RTp), (ins memrix:$src),
  1263. "#RESTORE_QUADWORD", []>;
  1264. }
  1265. }
  1266. def : Pat<(int_ppc_atomic_load_i128 iaddrX16:$src),
  1267. (SPLIT_QUADWORD (LQ memrix16:$src))>;
  1268. def : Pat<(int_ppc_atomic_load_i128 ForceXForm:$src),
  1269. (SPLIT_QUADWORD (LQX_PSEUDO memrr:$src))>;
  1270. // Support for medium and large code model.
  1271. let hasSideEffects = 0 in {
  1272. let isReMaterializable = 1 in {
  1273. def ADDIStocHA8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
  1274. "#ADDIStocHA8", []>, isPPC64;
  1275. def ADDItocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
  1276. "#ADDItocL", []>, isPPC64;
  1277. }
  1278. // Local Data Transform
  1279. def ADDItoc8 : PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
  1280. "#ADDItoc8",
  1281. [(set i64:$rD,
  1282. (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
  1283. let mayLoad = 1 in
  1284. def LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
  1285. "#LDtocL", []>, isPPC64;
  1286. }
  1287. // Support for thread-local storage.
  1288. def ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1289. "#ADDISgotTprelHA",
  1290. [(set i64:$rD,
  1291. (PPCaddisGotTprelHA i64:$reg,
  1292. tglobaltlsaddr:$disp))]>,
  1293. isPPC64;
  1294. def LDgotTprelL: PPCEmitTimePseudo<(outs g8rc_nox0:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
  1295. "#LDgotTprelL",
  1296. [(set i64:$rD,
  1297. (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
  1298. isPPC64;
  1299. let Defs = [CR7], Itinerary = IIC_LdStSync in
  1300. def CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
  1301. def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
  1302. (ADD8TLS $in, tglobaltlsaddr:$g)>;
  1303. def ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1304. "#ADDIStlsgdHA",
  1305. [(set i64:$rD,
  1306. (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
  1307. isPPC64;
  1308. def ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1309. "#ADDItlsgdL",
  1310. [(set i64:$rD,
  1311. (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
  1312. isPPC64;
  1313. class GETtlsADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
  1314. asmstr,
  1315. [(set i64:$rD,
  1316. (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
  1317. isPPC64;
  1318. class GETtlsldADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
  1319. asmstr,
  1320. [(set i64:$rD,
  1321. (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
  1322. isPPC64;
  1323. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1 in {
  1324. // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
  1325. // explicitly defined when this op is created, so not mentioned here.
  1326. // This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
  1327. // correct because the branch select pass is relying on it.
  1328. let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
  1329. def GETtlsADDR : GETtlsADDRPseudo <"#GETtlsADDR">;
  1330. let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
  1331. def GETtlsADDRPCREL : GETtlsADDRPseudo <"#GETtlsADDRPCREL">;
  1332. // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
  1333. // explicitly defined when this op is created, so not mentioned here.
  1334. let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
  1335. def GETtlsldADDR : GETtlsldADDRPseudo <"#GETtlsldADDR">;
  1336. let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
  1337. def GETtlsldADDRPCREL : GETtlsldADDRPseudo <"#GETtlsldADDRPCREL">;
  1338. // On AIX, the call to __tls_get_addr needs two inputs in X3/X4 for the
  1339. // offset and region handle respectively. The call is not followed by a nop
  1340. // so we don't need to mark it with a size of 8 bytes. Finally, the assembly
  1341. // manual mentions this exact set of registers as the clobbered set, others
  1342. // are guaranteed not to be clobbered.
  1343. let Defs = [X0,X4,X5,X11,LR8,CR0] in
  1344. def GETtlsADDR64AIX :
  1345. PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$offset, g8rc:$handle),
  1346. "GETtlsADDR64AIX",
  1347. [(set i64:$rD,
  1348. (PPCgetTlsAddr i64:$offset, i64:$handle))]>, isPPC64;
  1349. }
  1350. // Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8
  1351. // are true defines while the rest of the Defs are clobbers.
  1352. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  1353. Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
  1354. in
  1355. def ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
  1356. (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
  1357. "#ADDItlsgdLADDR",
  1358. [(set i64:$rD,
  1359. (PPCaddiTlsgdLAddr i64:$reg,
  1360. tglobaltlsaddr:$disp,
  1361. tglobaltlsaddr:$sym))]>,
  1362. isPPC64;
  1363. def ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1364. "#ADDIStlsldHA",
  1365. [(set i64:$rD,
  1366. (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
  1367. isPPC64;
  1368. def ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1369. "#ADDItlsldL",
  1370. [(set i64:$rD,
  1371. (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
  1372. isPPC64;
  1373. // This pseudo is expanded to two copies to put the variable offset in R4 and
  1374. // the region handle in R3 and GETtlsADDR64AIX.
  1375. def TLSGDAIX8 :
  1376. PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$offset, g8rc:$handle),
  1377. "#TLSGDAIX8",
  1378. [(set i64:$rD,
  1379. (PPCTlsgdAIX i64:$offset, i64:$handle))]>;
  1380. // Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8
  1381. // are true defines, while the rest of the Defs are clobbers.
  1382. let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
  1383. Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
  1384. in
  1385. def ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
  1386. (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
  1387. "#ADDItlsldLADDR",
  1388. [(set i64:$rD,
  1389. (PPCaddiTlsldLAddr i64:$reg,
  1390. tglobaltlsaddr:$disp,
  1391. tglobaltlsaddr:$sym))]>,
  1392. isPPC64;
  1393. def ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1394. "#ADDISdtprelHA",
  1395. [(set i64:$rD,
  1396. (PPCaddisDtprelHA i64:$reg,
  1397. tglobaltlsaddr:$disp))]>,
  1398. isPPC64;
  1399. def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1400. "#ADDIdtprelL",
  1401. [(set i64:$rD,
  1402. (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
  1403. isPPC64;
  1404. def PADDIdtprel : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
  1405. "#PADDIdtprel",
  1406. [(set i64:$rD,
  1407. (PPCpaddiDtprel i64:$reg, tglobaltlsaddr:$disp))]>,
  1408. isPPC64;
  1409. let PPC970_Unit = 2 in {
  1410. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1411. // Truncating stores.
  1412. def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
  1413. "stb $rS, $src", IIC_LdStStore,
  1414. [(truncstorei8 i64:$rS, DForm:$src)]>;
  1415. def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
  1416. "sth $rS, $src", IIC_LdStStore,
  1417. [(truncstorei16 i64:$rS, DForm:$src)]>;
  1418. def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
  1419. "stw $rS, $src", IIC_LdStStore,
  1420. [(truncstorei32 i64:$rS, DForm:$src)]>;
  1421. def STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
  1422. "stbx $rS, $dst", IIC_LdStStore,
  1423. [(truncstorei8 i64:$rS, XForm:$dst)]>,
  1424. PPC970_DGroup_Cracked;
  1425. def STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
  1426. "sthx $rS, $dst", IIC_LdStStore,
  1427. [(truncstorei16 i64:$rS, XForm:$dst)]>,
  1428. PPC970_DGroup_Cracked;
  1429. def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
  1430. "stwx $rS, $dst", IIC_LdStStore,
  1431. [(truncstorei32 i64:$rS, XForm:$dst)]>,
  1432. PPC970_DGroup_Cracked;
  1433. } // Interpretation64Bit
  1434. // Normal 8-byte stores.
  1435. def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
  1436. "std $rS, $dst", IIC_LdStSTD,
  1437. [(store i64:$rS, DSForm:$dst)]>, isPPC64;
  1438. def STDX : XForm_8_memOp<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
  1439. "stdx $rS, $dst", IIC_LdStSTD,
  1440. [(store i64:$rS, XForm:$dst)]>, isPPC64,
  1441. PPC970_DGroup_Cracked;
  1442. let Predicates = [IsISA2_06] in {
  1443. def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
  1444. "stdbrx $rS, $dst", IIC_LdStStore,
  1445. [(PPCstbrx i64:$rS, ForceXForm:$dst, i64)]>, isPPC64,
  1446. PPC970_DGroup_Cracked;
  1447. }
  1448. let mayStore = 1, hasNoSchedulingInfo = 1 in {
  1449. // Normal 16-byte stores.
  1450. // TODO: Add scheduling info.
  1451. def STQ : DSForm_1<62, 2, (outs), (ins g8prc:$RSp, memrix:$dst),
  1452. "stq $RSp, $dst", IIC_LdStSTQ,
  1453. []>, isPPC64;
  1454. def STQX_PSEUDO : PPCCustomInserterPseudo<(outs),
  1455. (ins g8prc:$RSp, memrr:$dst),
  1456. "#STQX_PSEUDO", []>;
  1457. def SPILL_QUADWORD : PPCEmitTimePseudo<(outs), (ins g8prc:$RSp, memrix:$dst),
  1458. "#SPILL_QUADWORD", []>;
  1459. }
  1460. }
  1461. def BUILD_QUADWORD : PPCPostRAExpPseudo<
  1462. (outs g8prc:$RTp),
  1463. (ins g8rc:$lo, g8rc:$hi),
  1464. "#BUILD_QUADWORD", []>;
  1465. def : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, DSForm:$dst),
  1466. (STQ (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrix:$dst)>;
  1467. def : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, ForceXForm:$dst),
  1468. (STQX_PSEUDO (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrr:$dst)>;
  1469. // Stores with Update (pre-inc).
  1470. let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
  1471. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1472. def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
  1473. "stbu $rS, $dst", IIC_LdStSTU, []>,
  1474. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  1475. def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
  1476. "sthu $rS, $dst", IIC_LdStSTU, []>,
  1477. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  1478. def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
  1479. "stwu $rS, $dst", IIC_LdStSTU, []>,
  1480. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
  1481. def STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
  1482. (ins g8rc:$rS, memrr:$dst),
  1483. "stbux $rS, $dst", IIC_LdStSTUX, []>,
  1484. RegConstraint<"$dst.ptrreg = $ea_res">,
  1485. NoEncode<"$ea_res">,
  1486. PPC970_DGroup_Cracked;
  1487. def STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
  1488. (ins g8rc:$rS, memrr:$dst),
  1489. "sthux $rS, $dst", IIC_LdStSTUX, []>,
  1490. RegConstraint<"$dst.ptrreg = $ea_res">,
  1491. NoEncode<"$ea_res">,
  1492. PPC970_DGroup_Cracked;
  1493. def STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
  1494. (ins g8rc:$rS, memrr:$dst),
  1495. "stwux $rS, $dst", IIC_LdStSTUX, []>,
  1496. RegConstraint<"$dst.ptrreg = $ea_res">,
  1497. NoEncode<"$ea_res">,
  1498. PPC970_DGroup_Cracked;
  1499. } // Interpretation64Bit
  1500. def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
  1501. (ins g8rc:$rS, memrix:$dst),
  1502. "stdu $rS, $dst", IIC_LdStSTU, []>,
  1503. RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
  1504. isPPC64;
  1505. def STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
  1506. (ins g8rc:$rS, memrr:$dst),
  1507. "stdux $rS, $dst", IIC_LdStSTUX, []>,
  1508. RegConstraint<"$dst.ptrreg = $ea_res">,
  1509. NoEncode<"$ea_res">,
  1510. PPC970_DGroup_Cracked, isPPC64;
  1511. }
  1512. // Patterns to match the pre-inc stores. We can't put the patterns on
  1513. // the instruction definitions directly as ISel wants the address base
  1514. // and offset to be separate operands, not a single complex operand.
  1515. def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  1516. (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
  1517. def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  1518. (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
  1519. def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  1520. (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
  1521. def : Pat<(DSFormPreStore i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
  1522. (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
  1523. def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  1524. (STBUX8 $rS, $ptrreg, $ptroff)>;
  1525. def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  1526. (STHUX8 $rS, $ptrreg, $ptroff)>;
  1527. def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  1528. (STWUX8 $rS, $ptrreg, $ptroff)>;
  1529. def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
  1530. (STDUX $rS, $ptrreg, $ptroff)>;
  1531. //===----------------------------------------------------------------------===//
  1532. // Floating point instructions.
  1533. //
  1534. let PPC970_Unit = 3, hasSideEffects = 0, mayRaiseFPException = 1,
  1535. Uses = [RM] in { // FPU Operations.
  1536. defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
  1537. "fcfid", "$frD, $frB", IIC_FPGeneral,
  1538. [(set f64:$frD, (PPCany_fcfid f64:$frB))]>, isPPC64;
  1539. defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
  1540. "fctid", "$frD, $frB", IIC_FPGeneral,
  1541. []>, isPPC64;
  1542. defm FCTIDU : XForm_26r<63, 942, (outs f8rc:$frD), (ins f8rc:$frB),
  1543. "fctidu", "$frD, $frB", IIC_FPGeneral,
  1544. []>, isPPC64;
  1545. defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
  1546. "fctidz", "$frD, $frB", IIC_FPGeneral,
  1547. [(set f64:$frD, (PPCany_fctidz f64:$frB))]>, isPPC64;
  1548. defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
  1549. "fcfidu", "$frD, $frB", IIC_FPGeneral,
  1550. [(set f64:$frD, (PPCany_fcfidu f64:$frB))]>, isPPC64;
  1551. defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
  1552. "fcfids", "$frD, $frB", IIC_FPGeneral,
  1553. [(set f32:$frD, (PPCany_fcfids f64:$frB))]>, isPPC64;
  1554. defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
  1555. "fcfidus", "$frD, $frB", IIC_FPGeneral,
  1556. [(set f32:$frD, (PPCany_fcfidus f64:$frB))]>, isPPC64;
  1557. defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
  1558. "fctiduz", "$frD, $frB", IIC_FPGeneral,
  1559. [(set f64:$frD, (PPCany_fctiduz f64:$frB))]>, isPPC64;
  1560. defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
  1561. "fctiwuz", "$frD, $frB", IIC_FPGeneral,
  1562. [(set f64:$frD, (PPCany_fctiwuz f64:$frB))]>, isPPC64;
  1563. }
  1564. // These instructions store a hash computed from the value of the link register
  1565. // and the value of the stack pointer.
  1566. let mayStore = 1, Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1567. def HASHST8 : XForm_XD6_RA5_RB5<31, 722, (outs),
  1568. (ins g8rc:$RB, memrihash:$D_RA_XD),
  1569. "hashst $RB, $D_RA_XD", IIC_IntGeneral, []>;
  1570. def HASHSTP8 : XForm_XD6_RA5_RB5<31, 658, (outs),
  1571. (ins g8rc:$RB, memrihash:$D_RA_XD),
  1572. "hashstp $RB, $D_RA_XD", IIC_IntGeneral, []>;
  1573. }
  1574. // These instructions check a hash computed from the value of the link register
  1575. // and the value of the stack pointer. The hasSideEffects flag is needed as the
  1576. // instruction may TRAP if the hash does not match the hash stored at the
  1577. // specified address.
  1578. let mayLoad = 1, hasSideEffects = 1,
  1579. Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1580. def HASHCHK8 : XForm_XD6_RA5_RB5<31, 754, (outs),
  1581. (ins g8rc:$RB, memrihash:$D_RA_XD),
  1582. "hashchk $RB, $D_RA_XD", IIC_IntGeneral, []>;
  1583. def HASHCHKP8 : XForm_XD6_RA5_RB5<31, 690, (outs),
  1584. (ins g8rc:$RB, memrihash:$D_RA_XD),
  1585. "hashchkp $RB, $D_RA_XD", IIC_IntGeneral, []>;
  1586. }
  1587. let Interpretation64Bit = 1, isCodeGenOnly = 1, hasSideEffects = 1 in
  1588. def ADDEX8 : Z23Form_RTAB5_CY2<31, 170, (outs g8rc:$rT),
  1589. (ins g8rc:$rA, g8rc:$rB, u2imm:$CY),
  1590. "addex $rT, $rA, $rB, $CY", IIC_IntGeneral,
  1591. [(set i64:$rT, (int_ppc_addex i64:$rA, i64:$rB,
  1592. timm:$CY))]>;
  1593. //===----------------------------------------------------------------------===//
  1594. // Instruction Patterns
  1595. //
  1596. // Extensions and truncates to/from 32-bit regs.
  1597. def : Pat<(i64 (zext i32:$in)),
  1598. (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
  1599. 0, 32)>;
  1600. def : Pat<(i64 (anyext i32:$in)),
  1601. (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
  1602. def : Pat<(i32 (trunc i64:$in)),
  1603. (EXTRACT_SUBREG $in, sub_32)>;
  1604. // Implement the 'not' operation with the NOR instruction.
  1605. // (we could use the default xori pattern, but nor has lower latency on some
  1606. // cores (such as the A2)).
  1607. def i64not : OutPatFrag<(ops node:$in),
  1608. (NOR8 $in, $in)>;
  1609. def : Pat<(not i64:$in),
  1610. (i64not $in)>;
  1611. // Extending loads with i64 targets.
  1612. def : Pat<(zextloadi1 DForm:$src),
  1613. (LBZ8 DForm:$src)>;
  1614. def : Pat<(zextloadi1 XForm:$src),
  1615. (LBZX8 XForm:$src)>;
  1616. def : Pat<(extloadi1 DForm:$src),
  1617. (LBZ8 DForm:$src)>;
  1618. def : Pat<(extloadi1 XForm:$src),
  1619. (LBZX8 XForm:$src)>;
  1620. def : Pat<(extloadi8 DForm:$src),
  1621. (LBZ8 DForm:$src)>;
  1622. def : Pat<(extloadi8 XForm:$src),
  1623. (LBZX8 XForm:$src)>;
  1624. def : Pat<(extloadi16 DForm:$src),
  1625. (LHZ8 DForm:$src)>;
  1626. def : Pat<(extloadi16 XForm:$src),
  1627. (LHZX8 XForm:$src)>;
  1628. def : Pat<(extloadi32 DForm:$src),
  1629. (LWZ8 DForm:$src)>;
  1630. def : Pat<(extloadi32 XForm:$src),
  1631. (LWZX8 XForm:$src)>;
  1632. // Standard shifts. These are represented separately from the real shifts above
  1633. // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
  1634. // amounts.
  1635. def : Pat<(sra i64:$rS, i32:$rB),
  1636. (SRAD $rS, $rB)>;
  1637. def : Pat<(srl i64:$rS, i32:$rB),
  1638. (SRD $rS, $rB)>;
  1639. def : Pat<(shl i64:$rS, i32:$rB),
  1640. (SLD $rS, $rB)>;
  1641. // SUBFIC
  1642. def : Pat<(sub imm64SExt16:$imm, i64:$in),
  1643. (SUBFIC8 $in, imm:$imm)>;
  1644. // SHL/SRL
  1645. def : Pat<(shl i64:$in, (i32 imm:$imm)),
  1646. (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
  1647. def : Pat<(srl i64:$in, (i32 imm:$imm)),
  1648. (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
  1649. // ROTL
  1650. def : Pat<(rotl i64:$in, i32:$sh),
  1651. (RLDCL $in, $sh, 0)>;
  1652. def : Pat<(rotl i64:$in, (i32 imm:$imm)),
  1653. (RLDICL $in, imm:$imm, 0)>;
  1654. // Hi and Lo for Darwin Global Addresses.
  1655. def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
  1656. def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
  1657. def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
  1658. def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
  1659. def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
  1660. def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
  1661. def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
  1662. def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
  1663. def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
  1664. (ADDIS8 $in, tglobaltlsaddr:$g)>;
  1665. def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
  1666. (ADDI8 $in, tglobaltlsaddr:$g)>;
  1667. def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
  1668. (ADDIS8 $in, tglobaladdr:$g)>;
  1669. def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
  1670. (ADDIS8 $in, tconstpool:$g)>;
  1671. def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
  1672. (ADDIS8 $in, tjumptable:$g)>;
  1673. def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
  1674. (ADDIS8 $in, tblockaddress:$g)>;
  1675. // AIX 64-bit small code model TLS access.
  1676. def : Pat<(i64 (PPCtoc_entry tglobaltlsaddr:$disp, i64:$reg)),
  1677. (i64 (LDtoc tglobaltlsaddr:$disp, i64:$reg))>;
  1678. // 64-bits atomic loads and stores
  1679. def : Pat<(atomic_load_64 DSForm:$src), (LD memrix:$src)>;
  1680. def : Pat<(atomic_load_64 XForm:$src), (LDX memrr:$src)>;
  1681. def : Pat<(atomic_store_64 DSForm:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
  1682. def : Pat<(atomic_store_64 XForm:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;
  1683. let Predicates = [IsISA3_0, In64BitMode] in {
  1684. def : Pat<(i64 (int_ppc_cmpeqb g8rc:$a, g8rc:$b)),
  1685. (i64 (SETB8 (CMPEQB $a, $b)))>;
  1686. def : Pat<(i64 (int_ppc_setb g8rc:$a, g8rc:$b)),
  1687. (i64 (SETB8 (CMPD $a, $b)))>;
  1688. def : Pat<(i64 (int_ppc_maddhd g8rc:$a, g8rc:$b, g8rc:$c)),
  1689. (i64 (MADDHD $a, $b, $c))>;
  1690. def : Pat<(i64 (int_ppc_maddhdu g8rc:$a, g8rc:$b, g8rc:$c)),
  1691. (i64 (MADDHDU $a, $b, $c))>;
  1692. def : Pat<(i64 (int_ppc_maddld g8rc:$a, g8rc:$b, g8rc:$c)),
  1693. (i64 (MADDLD8 $a, $b, $c))>;
  1694. }
  1695. let Predicates = [In64BitMode] in {
  1696. def : Pat<(i64 (int_ppc_mulhd g8rc:$a, g8rc:$b)),
  1697. (i64 (MULHD $a, $b))>;
  1698. def : Pat<(i64 (int_ppc_mulhdu g8rc:$a, g8rc:$b)),
  1699. (i64 (MULHDU $a, $b))>;
  1700. def : Pat<(int_ppc_load8r ForceXForm:$ptr),
  1701. (LDBRX ForceXForm:$ptr)>;
  1702. def : Pat<(int_ppc_store8r g8rc:$a, ForceXForm:$ptr),
  1703. (STDBRX g8rc:$a, ForceXForm:$ptr)>;
  1704. }
  1705. def : Pat<(i64 (int_ppc_cmpb g8rc:$a, g8rc:$b)),
  1706. (i64 (CMPB8 $a, $b))>;
  1707. let Predicates = [IsISA3_0] in {
  1708. // DARN (deliver random number)
  1709. // L=0 for 32-bit, L=1 for conditioned random, L=2 for raw random
  1710. def : Pat<(int_ppc_darn32), (EXTRACT_SUBREG (DARN 0), sub_32)>;
  1711. def : Pat<(int_ppc_darn), (DARN 1)>;
  1712. def : Pat<(int_ppc_darnraw), (DARN 2)>;
  1713. class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
  1714. InstrItinClass itin, list<dag> pattern>
  1715. : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
  1716. !strconcat(opc, " $rA, $rB"), itin, pattern>{
  1717. let L = 1;
  1718. }
  1719. class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
  1720. InstrItinClass itin, list<dag> pattern>
  1721. : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
  1722. !strconcat(opc, " $rA, $rB, $L"), itin, pattern>;
  1723. let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
  1724. def CP_COPY8 : X_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>;
  1725. def CP_PASTE8_rec : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isRecordForm;
  1726. }
  1727. // SLB Invalidate Entry Global
  1728. def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RS, gprc:$RB),
  1729. "slbieg $RS, $RB", IIC_SprSLBIEG, []>;
  1730. // SLB Synchronize
  1731. def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;
  1732. } // IsISA3_0
  1733. def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
  1734. (STDCX g8rc:$A, ForceXForm:$dst)>;
  1735. // trapd
  1736. def : Pat<(int_ppc_trapd g8rc:$A),
  1737. (TDI 24, $A, 0)>;
  1738. def : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
  1739. (MFSPR8 $SPR)>;
  1740. def : Pat<(int_ppc_mtspr timm:$SPR, g8rc:$RT),
  1741. (MTSPR8 $SPR, $RT)>;