xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCInstr64Bit.td (revision 6c4b055cfb6bf549e9145dde6454cc6b178c35e4)
10b57cec5SDimitry Andric//===-- PPCInstr64Bit.td - The PowerPC 64-bit Support ------*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric//
90b57cec5SDimitry Andric// This file describes the PowerPC 64-bit instructions.  These patterns are used
100b57cec5SDimitry Andric// both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode.
110b57cec5SDimitry Andric//
120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric
140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
150b57cec5SDimitry Andric// 64-bit operands.
160b57cec5SDimitry Andric//
170b57cec5SDimitry Andricdef s16imm64 : Operand<i64> {
180b57cec5SDimitry Andric  let PrintMethod = "printS16ImmOperand";
190b57cec5SDimitry Andric  let EncoderMethod = "getImm16Encoding";
200b57cec5SDimitry Andric  let ParserMatchClass = PPCS16ImmAsmOperand;
210b57cec5SDimitry Andric  let DecoderMethod = "decodeSImmOperand<16>";
22e8d8bef9SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
230b57cec5SDimitry Andric}
240b57cec5SDimitry Andricdef u16imm64 : Operand<i64> {
250b57cec5SDimitry Andric  let PrintMethod = "printU16ImmOperand";
260b57cec5SDimitry Andric  let EncoderMethod = "getImm16Encoding";
270b57cec5SDimitry Andric  let ParserMatchClass = PPCU16ImmAsmOperand;
280b57cec5SDimitry Andric  let DecoderMethod = "decodeUImmOperand<16>";
29e8d8bef9SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
300b57cec5SDimitry Andric}
310b57cec5SDimitry Andricdef s17imm64 : Operand<i64> {
320b57cec5SDimitry Andric  // This operand type is used for addis/lis to allow the assembler parser
330b57cec5SDimitry Andric  // to accept immediates in the range -65536..65535 for compatibility with
340b57cec5SDimitry Andric  // the GNU assembler.  The operand is treated as 16-bit otherwise.
350b57cec5SDimitry Andric  let PrintMethod = "printS16ImmOperand";
360b57cec5SDimitry Andric  let EncoderMethod = "getImm16Encoding";
370b57cec5SDimitry Andric  let ParserMatchClass = PPCS17ImmAsmOperand;
380b57cec5SDimitry Andric  let DecoderMethod = "decodeSImmOperand<16>";
39e8d8bef9SDimitry Andric  let OperandType = "OPERAND_IMMEDIATE";
400b57cec5SDimitry Andric}
410b57cec5SDimitry Andricdef tocentry : Operand<iPTR> {
420b57cec5SDimitry Andric  let MIOperandInfo = (ops i64imm:$imm);
430b57cec5SDimitry Andric}
440b57cec5SDimitry Andricdef tlsreg : Operand<i64> {
450b57cec5SDimitry Andric  let EncoderMethod = "getTLSRegEncoding";
460b57cec5SDimitry Andric  let ParserMatchClass = PPCTLSRegOperand;
470b57cec5SDimitry Andric}
480b57cec5SDimitry Andricdef tlsgd : Operand<i64> {}
490b57cec5SDimitry Andricdef tlscall : Operand<i64> {
500b57cec5SDimitry Andric  let PrintMethod = "printTLSCall";
510b57cec5SDimitry Andric  let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym);
520b57cec5SDimitry Andric  let EncoderMethod = "getTLSCallEncoding";
530b57cec5SDimitry Andric}
540b57cec5SDimitry Andric
550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
560b57cec5SDimitry Andric// 64-bit transformation functions.
570b57cec5SDimitry Andric//
580b57cec5SDimitry Andric
590b57cec5SDimitry Andricdef SHL64 : SDNodeXForm<imm, [{
600b57cec5SDimitry Andric  // Transformation function: 63 - imm
610b57cec5SDimitry Andric  return getI32Imm(63 - N->getZExtValue(), SDLoc(N));
620b57cec5SDimitry Andric}]>;
630b57cec5SDimitry Andric
640b57cec5SDimitry Andricdef SRL64 : SDNodeXForm<imm, [{
650b57cec5SDimitry Andric  // Transformation function: 64 - imm
660b57cec5SDimitry Andric  return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue(), SDLoc(N))
670b57cec5SDimitry Andric                           : getI32Imm(0, SDLoc(N));
680b57cec5SDimitry Andric}]>;
690b57cec5SDimitry Andric
700b57cec5SDimitry Andric
710b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
720b57cec5SDimitry Andric// Calls.
730b57cec5SDimitry Andric//
740b57cec5SDimitry Andric
750b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
76349cc55cSDimitry Andriclet isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
77480093f4SDimitry Andric  let isReturn = 1, isPredicable = 1, Uses = [LR8, RM] in
780b57cec5SDimitry Andric    def BLR8 : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
790fca6ea1SDimitry Andric                            [(PPCretglue)]>, Requires<[In64BitMode]>;
800b57cec5SDimitry Andric  let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in {
81480093f4SDimitry Andric    let isPredicable = 1 in
820b57cec5SDimitry Andric      def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
830b57cec5SDimitry Andric                               []>,
840b57cec5SDimitry Andric          Requires<[In64BitMode]>;
8506c3fb27SDimitry Andric    def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins (pred $BIBO, $CR):$cond),
860b57cec5SDimitry Andric                              "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
870b57cec5SDimitry Andric                              []>,
880b57cec5SDimitry Andric        Requires<[In64BitMode]>;
890b57cec5SDimitry Andric
9006c3fb27SDimitry Andric    def BCCTR8  : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$BI),
9106c3fb27SDimitry Andric                               "bcctr 12, $BI, 0", IIC_BrB, []>,
920b57cec5SDimitry Andric        Requires<[In64BitMode]>;
9306c3fb27SDimitry Andric    def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$BI),
9406c3fb27SDimitry Andric                               "bcctr 4, $BI, 0", IIC_BrB, []>,
950b57cec5SDimitry Andric        Requires<[In64BitMode]>;
960b57cec5SDimitry Andric  }
970b57cec5SDimitry Andric}
980b57cec5SDimitry Andric
990b57cec5SDimitry Andriclet Defs = [LR8] in
1000b57cec5SDimitry Andric  def MovePCtoLR8 : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR8", []>,
1010b57cec5SDimitry Andric                    PPC970_Unit_BRU;
1020b57cec5SDimitry Andric
103349cc55cSDimitry Andriclet isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
1040b57cec5SDimitry Andric  let Defs = [CTR8], Uses = [CTR8] in {
10506c3fb27SDimitry Andric    def BDZ8  : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$BD),
10606c3fb27SDimitry Andric                        "bdz $BD">;
10706c3fb27SDimitry Andric    def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$BD),
10806c3fb27SDimitry Andric                        "bdnz $BD">;
1090b57cec5SDimitry Andric  }
1100b57cec5SDimitry Andric
1110b57cec5SDimitry Andric  let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in {
1120b57cec5SDimitry Andric    def BDZLR8  : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1130b57cec5SDimitry Andric                              "bdzlr", IIC_BrB, []>;
1140b57cec5SDimitry Andric    def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1150b57cec5SDimitry Andric                              "bdnzlr", IIC_BrB, []>;
1160b57cec5SDimitry Andric  }
1170b57cec5SDimitry Andric}
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric
1200b57cec5SDimitry Andric
121349cc55cSDimitry Andriclet isCall = 1, PPC970_Unit = 7, Defs = [LR8], hasSideEffects = 0 in {
1220b57cec5SDimitry Andric  // Convenient aliases for call instructions
1230b57cec5SDimitry Andric  let Uses = [RM] in {
12406c3fb27SDimitry Andric    def BL8  : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
12506c3fb27SDimitry Andric                     "bl $LI", IIC_BrB, []>;  // See Pat patterns below.
1260b57cec5SDimitry Andric
12706c3fb27SDimitry Andric    def BL8_TLS  : IForm<18, 0, 1, (outs), (ins tlscall:$LI),
12806c3fb27SDimitry Andric                         "bl $LI", IIC_BrB, []>;
1290b57cec5SDimitry Andric
13006c3fb27SDimitry Andric    def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
13106c3fb27SDimitry Andric                     "bla $LI", IIC_BrB, [(PPCcall (i64 imm:$LI))]>;
1320b57cec5SDimitry Andric  }
1330b57cec5SDimitry Andric  let Uses = [RM], isCodeGenOnly = 1 in {
1340b57cec5SDimitry Andric    def BL8_NOP  : IForm_and_DForm_4_zero<18, 0, 1, 24,
13506c3fb27SDimitry Andric                             (outs), (ins calltarget:$LI),
13606c3fb27SDimitry Andric                             "bl $LI\n\tnop", IIC_BrB, []>;
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andric    def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
13906c3fb27SDimitry Andric                                  (outs), (ins tlscall:$LI),
14006c3fb27SDimitry Andric                                  "bl $LI\n\tnop", IIC_BrB, []>;
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric    def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
14306c3fb27SDimitry Andric                             (outs), (ins abscalltarget:$LI),
14406c3fb27SDimitry Andric                             "bla $LI\n\tnop", IIC_BrB,
14506c3fb27SDimitry Andric                             [(PPCcall_nop (i64 imm:$LI))]>;
1465ffd83dbSDimitry Andric    let Predicates = [PCRelativeMemops] in {
1475ffd83dbSDimitry Andric      // BL8_NOTOC means that the caller does not use the TOC pointer and if
1485ffd83dbSDimitry Andric      // it does use R2 then it is just a caller saved register. Therefore it is
1495ffd83dbSDimitry Andric      // safe to emit only the bl and not the nop for this instruction. The
1505ffd83dbSDimitry Andric      // linker will not try to restore R2 after the call.
1515ffd83dbSDimitry Andric      def BL8_NOTOC : IForm<18, 0, 1, (outs),
15206c3fb27SDimitry Andric                            (ins calltarget:$LI),
15306c3fb27SDimitry Andric                            "bl $LI", IIC_BrB, []>;
154e8d8bef9SDimitry Andric      def BL8_NOTOC_TLS : IForm<18, 0, 1, (outs),
15506c3fb27SDimitry Andric                                (ins tlscall:$LI),
15606c3fb27SDimitry Andric                                "bl $LI", IIC_BrB, []>;
1575ffd83dbSDimitry Andric    }
1580b57cec5SDimitry Andric  }
1590b57cec5SDimitry Andric  let Uses = [CTR8, RM] in {
160480093f4SDimitry Andric    let isPredicable = 1 in
1610b57cec5SDimitry Andric      def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1620b57cec5SDimitry Andric                                "bctrl", IIC_BrB, [(PPCbctrl)]>,
1630b57cec5SDimitry Andric                   Requires<[In64BitMode]>;
1640b57cec5SDimitry Andric
1650b57cec5SDimitry Andric    let isCodeGenOnly = 1 in {
16606c3fb27SDimitry Andric      def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins (pred $BIBO, $CR):$cond),
1670b57cec5SDimitry Andric                                 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1680b57cec5SDimitry Andric                                 []>,
1690b57cec5SDimitry Andric          Requires<[In64BitMode]>;
1700b57cec5SDimitry Andric
17106c3fb27SDimitry Andric      def BCCTRL8  : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$BI),
17206c3fb27SDimitry Andric                                  "bcctrl 12, $BI, 0", IIC_BrB, []>,
1730b57cec5SDimitry Andric          Requires<[In64BitMode]>;
17406c3fb27SDimitry Andric      def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$BI),
17506c3fb27SDimitry Andric                                  "bcctrl 4, $BI, 0", IIC_BrB, []>,
1760b57cec5SDimitry Andric          Requires<[In64BitMode]>;
1770b57cec5SDimitry Andric    }
1780b57cec5SDimitry Andric  }
1790b57cec5SDimitry Andric}
1800b57cec5SDimitry Andric
181349cc55cSDimitry Andriclet isCall = 1, PPC970_Unit = 7, Defs = [LR8, RM], hasSideEffects = 0,
182349cc55cSDimitry Andric    isCodeGenOnly = 1, Uses = [RM] in {
183349cc55cSDimitry Andric  // Convenient aliases for call instructions
18406c3fb27SDimitry Andric  def BL8_RM  : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
18506c3fb27SDimitry Andric                      "bl $LI", IIC_BrB, []>;  // See Pat patterns below.
186349cc55cSDimitry Andric
18706c3fb27SDimitry Andric  def BLA8_RM : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
18806c3fb27SDimitry Andric                      "bla $LI", IIC_BrB, [(PPCcall_rm (i64 imm:$LI))]>;
189349cc55cSDimitry Andric  def BL8_NOP_RM  : IForm_and_DForm_4_zero<18, 0, 1, 24,
19006c3fb27SDimitry Andric                           (outs), (ins calltarget:$LI),
19106c3fb27SDimitry Andric                           "bl $LI\n\tnop", IIC_BrB, []>;
192349cc55cSDimitry Andric
193349cc55cSDimitry Andric  def BLA8_NOP_RM : IForm_and_DForm_4_zero<18, 1, 1, 24,
19406c3fb27SDimitry Andric                           (outs), (ins abscalltarget:$LI),
19506c3fb27SDimitry Andric                           "bla $LI\n\tnop", IIC_BrB,
19606c3fb27SDimitry Andric                           [(PPCcall_nop_rm (i64 imm:$LI))]>;
197349cc55cSDimitry Andric  let Predicates = [PCRelativeMemops] in {
198349cc55cSDimitry Andric    // BL8_NOTOC means that the caller does not use the TOC pointer and if
199349cc55cSDimitry Andric    // it does use R2 then it is just a caller saved register. Therefore it is
200349cc55cSDimitry Andric    // safe to emit only the bl and not the nop for this instruction. The
201349cc55cSDimitry Andric    // linker will not try to restore R2 after the call.
202349cc55cSDimitry Andric    def BL8_NOTOC_RM : IForm<18, 0, 1, (outs),
20306c3fb27SDimitry Andric                             (ins calltarget:$LI),
20406c3fb27SDimitry Andric                             "bl $LI", IIC_BrB, []>;
205349cc55cSDimitry Andric  }
206349cc55cSDimitry Andric  let Uses = [CTR8, RM] in {
207349cc55cSDimitry Andric    let isPredicable = 1 in
208349cc55cSDimitry Andric      def BCTRL8_RM : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
209349cc55cSDimitry Andric                                   "bctrl", IIC_BrB, [(PPCbctrl_rm)]>,
210349cc55cSDimitry Andric                   Requires<[In64BitMode]>;
211349cc55cSDimitry Andric  }
212349cc55cSDimitry Andric}
213349cc55cSDimitry Andric
2140b57cec5SDimitry Andriclet isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
2150b57cec5SDimitry Andric    Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
2160b57cec5SDimitry Andric  def BCTRL8_LDinto_toc :
2170b57cec5SDimitry Andric    XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
21806c3fb27SDimitry Andric                              (ins (memrix $D, $RA):$src),
2190b57cec5SDimitry Andric                              "bctrl\n\tld 2, $src", IIC_BrB,
2200b57cec5SDimitry Andric                              [(PPCbctrl_load_toc iaddrX4:$src)]>,
2210b57cec5SDimitry Andric    Requires<[In64BitMode]>;
2220b57cec5SDimitry Andric}
2230b57cec5SDimitry Andric
224349cc55cSDimitry Andriclet isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
225349cc55cSDimitry Andric    Defs = [LR8, X2, RM], Uses = [CTR8, RM], RST = 2 in {
226349cc55cSDimitry Andric  def BCTRL8_LDinto_toc_RM :
227349cc55cSDimitry Andric    XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
22806c3fb27SDimitry Andric                              (ins (memrix $D, $RA):$src),
229349cc55cSDimitry Andric                              "bctrl\n\tld 2, $src", IIC_BrB,
230349cc55cSDimitry Andric                              [(PPCbctrl_load_toc_rm iaddrX4:$src)]>,
231349cc55cSDimitry Andric    Requires<[In64BitMode]>;
232349cc55cSDimitry Andric}
233349cc55cSDimitry Andric
2340b57cec5SDimitry Andric} // Interpretation64Bit
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andric// FIXME: Duplicating this for the asm parser should be unnecessary, but the
2370b57cec5SDimitry Andric// previous definition must be marked as CodeGen only to prevent decoding
2380b57cec5SDimitry Andric// conflicts.
239349cc55cSDimitry Andriclet Interpretation64Bit = 1, isAsmParserOnly = 1, hasSideEffects = 0 in
2400b57cec5SDimitry Andriclet isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
24106c3fb27SDimitry Andricdef BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$LI),
24206c3fb27SDimitry Andric                     "bl $LI", IIC_BrB, []>;
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andric// Calls
2450b57cec5SDimitry Andricdef : Pat<(PPCcall (i64 tglobaladdr:$dst)),
2460b57cec5SDimitry Andric          (BL8 tglobaladdr:$dst)>;
2470b57cec5SDimitry Andricdef : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
2480b57cec5SDimitry Andric          (BL8_NOP tglobaladdr:$dst)>;
2490b57cec5SDimitry Andric
2500b57cec5SDimitry Andricdef : Pat<(PPCcall (i64 texternalsym:$dst)),
2510b57cec5SDimitry Andric          (BL8 texternalsym:$dst)>;
2520b57cec5SDimitry Andricdef : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
2530b57cec5SDimitry Andric          (BL8_NOP texternalsym:$dst)>;
2540b57cec5SDimitry Andric
2555ffd83dbSDimitry Andricdef : Pat<(PPCcall_notoc (i64 tglobaladdr:$dst)),
2565ffd83dbSDimitry Andric          (BL8_NOTOC tglobaladdr:$dst)>;
2575ffd83dbSDimitry Andricdef : Pat<(PPCcall_notoc (i64 texternalsym:$dst)),
2585ffd83dbSDimitry Andric          (BL8_NOTOC texternalsym:$dst)>;
2595ffd83dbSDimitry Andric
260349cc55cSDimitry Andricdef : Pat<(PPCcall_rm (i64 tglobaladdr:$dst)),
261349cc55cSDimitry Andric          (BL8_RM tglobaladdr:$dst)>;
262349cc55cSDimitry Andricdef : Pat<(PPCcall_nop_rm (i64 tglobaladdr:$dst)),
263349cc55cSDimitry Andric          (BL8_NOP_RM tglobaladdr:$dst)>;
264349cc55cSDimitry Andric
265349cc55cSDimitry Andricdef : Pat<(PPCcall_rm (i64 texternalsym:$dst)),
266349cc55cSDimitry Andric          (BL8_RM texternalsym:$dst)>;
267349cc55cSDimitry Andricdef : Pat<(PPCcall_nop_rm (i64 texternalsym:$dst)),
268349cc55cSDimitry Andric          (BL8_NOP_RM texternalsym:$dst)>;
269349cc55cSDimitry Andric
270349cc55cSDimitry Andricdef : Pat<(PPCcall_notoc_rm (i64 tglobaladdr:$dst)),
271349cc55cSDimitry Andric          (BL8_NOTOC_RM tglobaladdr:$dst)>;
272349cc55cSDimitry Andricdef : Pat<(PPCcall_notoc_rm (i64 texternalsym:$dst)),
273349cc55cSDimitry Andric          (BL8_NOTOC_RM texternalsym:$dst)>;
274349cc55cSDimitry Andric
2750b57cec5SDimitry Andric// Calls for AIX
2760b57cec5SDimitry Andricdef : Pat<(PPCcall (i64 mcsym:$dst)),
2770b57cec5SDimitry Andric          (BL8 mcsym:$dst)>;
2780b57cec5SDimitry Andricdef : Pat<(PPCcall_nop (i64 mcsym:$dst)),
2790b57cec5SDimitry Andric          (BL8_NOP mcsym:$dst)>;
2800b57cec5SDimitry Andric
281349cc55cSDimitry Andricdef : Pat<(PPCcall_rm (i64 mcsym:$dst)),
282349cc55cSDimitry Andric          (BL8_RM mcsym:$dst)>;
283349cc55cSDimitry Andricdef : Pat<(PPCcall_nop_rm (i64 mcsym:$dst)),
284349cc55cSDimitry Andric          (BL8_NOP_RM mcsym:$dst)>;
285349cc55cSDimitry Andric
2860b57cec5SDimitry Andric// Atomic operations
2870b57cec5SDimitry Andric// FIXME: some of these might be used with constant operands. This will result
2880b57cec5SDimitry Andric// in constant materialization instructions that may be redundant. We currently
2890b57cec5SDimitry Andric// clean this up in PPCMIPeephole with calls to
2900b57cec5SDimitry Andric// PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
2910b57cec5SDimitry Andric// in the first place.
2920b57cec5SDimitry Andriclet Defs = [CR0] in {
2930b57cec5SDimitry Andric  def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
2940b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
2950fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_add_i64 ForceXForm:$ptr, i64:$incr))]>;
2960b57cec5SDimitry Andric  def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
2970b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
2980fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_sub_i64 ForceXForm:$ptr, i64:$incr))]>;
2990b57cec5SDimitry Andric  def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
3000b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
3010fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_or_i64 ForceXForm:$ptr, i64:$incr))]>;
3020b57cec5SDimitry Andric  def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
3030b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
3040fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_xor_i64 ForceXForm:$ptr, i64:$incr))]>;
3050b57cec5SDimitry Andric  def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
3060b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
3070fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_and_i64 ForceXForm:$ptr, i64:$incr))]>;
3080b57cec5SDimitry Andric  def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
3090b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
3100fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_nand_i64 ForceXForm:$ptr, i64:$incr))]>;
3110b57cec5SDimitry Andric  def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
3120b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
3130fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_min_i64 ForceXForm:$ptr, i64:$incr))]>;
3140b57cec5SDimitry Andric  def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
3150b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
3160fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_max_i64 ForceXForm:$ptr, i64:$incr))]>;
3170b57cec5SDimitry Andric  def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
3180b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
3190fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_umin_i64 ForceXForm:$ptr, i64:$incr))]>;
3200b57cec5SDimitry Andric  def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
3210b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
3220fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_load_umax_i64 ForceXForm:$ptr, i64:$incr))]>;
3230b57cec5SDimitry Andric
3240b57cec5SDimitry Andric  def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
3250b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
3260fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_cmp_swap_i64 ForceXForm:$ptr, i64:$old, i64:$new))]>;
3270b57cec5SDimitry Andric
3280b57cec5SDimitry Andric  def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
3290b57cec5SDimitry Andric    (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
3300fca6ea1SDimitry Andric    [(set i64:$dst, (atomic_swap_i64 ForceXForm:$ptr, i64:$new))]>;
3310b57cec5SDimitry Andric}
3320b57cec5SDimitry Andric
3330b57cec5SDimitry Andric// Instructions to support atomic operations
3340b57cec5SDimitry Andriclet mayLoad = 1, hasSideEffects = 0 in {
33506c3fb27SDimitry Andricdef LDARX : XForm_1_memOp<31,  84, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
33606c3fb27SDimitry Andric                          "ldarx $RST, $addr", IIC_LdStLDARX, []>;
337fe6060f1SDimitry Andric// TODO: Add scheduling info.
338fe6060f1SDimitry Andriclet hasNoSchedulingInfo = 1 in
33906c3fb27SDimitry Andricdef LQARX : XForm_1_memOp<31, 276, (outs g8prc:$RST), (ins (memrr $RA, $RB):$addr),
34006c3fb27SDimitry Andric                          "lqarx $RST, $addr", IIC_LdStLQARX, []>, isPPC64;
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric// Instruction to support lock versions of atomics
3430b57cec5SDimitry Andric// (EH=1 - see Power ISA 2.07 Book II 4.4.2)
34406c3fb27SDimitry Andricdef LDARXL : XForm_1<31,  84, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
34506c3fb27SDimitry Andric                     "ldarx $RST, $addr, 1", IIC_LdStLDARX, []>, isRecordForm;
346fe6060f1SDimitry Andric// TODO: Add scheduling info.
347fe6060f1SDimitry Andriclet hasNoSchedulingInfo = 1 in
348fe6060f1SDimitry Andric// FIXME: We have to seek a way to remove isRecordForm since
349fe6060f1SDimitry Andric// LQARXL is not really altering CR0.
35006c3fb27SDimitry Andricdef LQARXL : XForm_1<31, 276, (outs g8prc:$RST), (ins (memrr $RA, $RB):$addr),
35106c3fb27SDimitry Andric                     "lqarx $RST, $addr, 1", IIC_LdStLQARX, []>,
352fe6060f1SDimitry Andric                     isPPC64, isRecordForm;
3530b57cec5SDimitry Andric
3540b57cec5SDimitry Andriclet hasExtraDefRegAllocReq = 1 in
35506c3fb27SDimitry Andricdef LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$RST), (ins g8rc:$RA, u5imm:$RB),
35606c3fb27SDimitry Andric                         "ldat $RST, $RA, $RB", IIC_LdStLoad>, isPPC64,
3570b57cec5SDimitry Andric           Requires<[IsISA3_0]>;
3580b57cec5SDimitry Andric}
3590b57cec5SDimitry Andric
360fe6060f1SDimitry Andriclet Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
36106c3fb27SDimitry Andricdef STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
36206c3fb27SDimitry Andric                          "stdcx. $RST, $addr", IIC_LdStSTDCX, []>, isRecordForm;
363fe6060f1SDimitry Andric// TODO: Add scheduling info.
364fe6060f1SDimitry Andriclet hasNoSchedulingInfo = 1 in
36506c3fb27SDimitry Andricdef STQCX : XForm_1_memOp<31, 182, (outs), (ins g8prc:$RST, (memrr $RA, $RB):$addr),
36606c3fb27SDimitry Andric                          "stqcx. $RST, $addr", IIC_LdStSTQCX, []>,
367fe6060f1SDimitry Andric                          isPPC64, isRecordForm;
368fe6060f1SDimitry Andric}
369fe6060f1SDimitry Andric
370fe6060f1SDimitry Andricdef SPLIT_QUADWORD : PPCCustomInserterPseudo<(outs g8rc:$lo, g8rc:$hi),
371fe6060f1SDimitry Andric                                             (ins g8prc:$src),
372fe6060f1SDimitry Andric                                             "#SPLIT_QUADWORD", []>;
373fe6060f1SDimitry Andricclass AtomicRMW128<string asmstr>
374fe6060f1SDimitry Andric  : PPCPostRAExpPseudo<(outs g8prc:$RTp, g8prc:$scratch),
375fe6060f1SDimitry Andric                       (ins memrr:$ptr, g8rc:$incr_lo, g8rc:$incr_hi),
376fe6060f1SDimitry Andric                       asmstr, []>;
377fe6060f1SDimitry Andric// We have to keep values in MI's uses during LL/SC looping as they are,
378fe6060f1SDimitry Andric// so set both $RTp and $scratch earlyclobber.
379fe6060f1SDimitry Andriclet mayStore = 1, mayLoad = 1,
380fe6060f1SDimitry Andric    Defs = [CR0],
381fe6060f1SDimitry Andric    Constraints = "@earlyclobber $scratch,@earlyclobber $RTp" in {
382fe6060f1SDimitry Andric// Atomic pseudo instructions expanded post-ra.
383fe6060f1SDimitry Andricdef ATOMIC_SWAP_I128      : AtomicRMW128<"#ATOMIC_SWAP_I128">;
384fe6060f1SDimitry Andricdef ATOMIC_LOAD_ADD_I128  : AtomicRMW128<"#ATOMIC_LOAD_ADD_I128">;
385fe6060f1SDimitry Andricdef ATOMIC_LOAD_SUB_I128  : AtomicRMW128<"#ATOMIC_LOAD_SUB_I128">;
386fe6060f1SDimitry Andricdef ATOMIC_LOAD_AND_I128  : AtomicRMW128<"#ATOMIC_LOAD_AND_I128">;
387fe6060f1SDimitry Andricdef ATOMIC_LOAD_XOR_I128  : AtomicRMW128<"#ATOMIC_LOAD_XOR_I128">;
388fe6060f1SDimitry Andricdef ATOMIC_LOAD_OR_I128   : AtomicRMW128<"#ATOMIC_LOAD_OR_I128">;
389fe6060f1SDimitry Andricdef ATOMIC_LOAD_NAND_I128 : AtomicRMW128<"#ATOMIC_LOAD_NAND_I128">;
390fe6060f1SDimitry Andric
391fe6060f1SDimitry Andricdef ATOMIC_CMP_SWAP_I128 : PPCPostRAExpPseudo<
392fe6060f1SDimitry Andric                              (outs g8prc:$RTp, g8prc:$scratch),
393fe6060f1SDimitry Andric                              (ins memrr:$ptr, g8rc:$cmp_lo, g8rc:$cmp_hi,
394fe6060f1SDimitry Andric                                   g8rc:$new_lo, g8rc:$new_hi),
395fe6060f1SDimitry Andric                              "#ATOMIC_CMP_SWAP_I128", []>;
396fe6060f1SDimitry Andric}
397fe6060f1SDimitry Andric
3985f757f3fSDimitry Andricclass PatAtomicRMWI128<SDPatternOperator OpNode, AtomicRMW128 Inst> :
3995f757f3fSDimitry Andric      Pat<(OpNode ForceXForm:$ptr,
400fe6060f1SDimitry Andric                  i64:$incr_lo,
401fe6060f1SDimitry Andric                  i64:$incr_hi),
4025f757f3fSDimitry Andric          (SPLIT_QUADWORD (Inst memrr:$ptr,
403fe6060f1SDimitry Andric                                g8rc:$incr_lo,
404fe6060f1SDimitry Andric                                g8rc:$incr_hi))>;
4055f757f3fSDimitry Andric
4065f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_add_i128,  ATOMIC_LOAD_ADD_I128>;
4075f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_sub_i128,  ATOMIC_LOAD_SUB_I128>;
4085f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_xor_i128,  ATOMIC_LOAD_XOR_I128>;
4095f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_and_i128,  ATOMIC_LOAD_AND_I128>;
4105f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_nand_i128, ATOMIC_LOAD_NAND_I128>;
4115f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_or_i128,   ATOMIC_LOAD_OR_I128>;
4125f757f3fSDimitry Andricdef : PatAtomicRMWI128<int_ppc_atomicrmw_xchg_i128, ATOMIC_SWAP_I128>;
413fe6060f1SDimitry Andricdef : Pat<(int_ppc_cmpxchg_i128 ForceXForm:$ptr,
414fe6060f1SDimitry Andric                                i64:$cmp_lo,
415fe6060f1SDimitry Andric                                i64:$cmp_hi,
416fe6060f1SDimitry Andric                                i64:$new_lo,
417fe6060f1SDimitry Andric                                i64:$new_hi),
418fe6060f1SDimitry Andric          (SPLIT_QUADWORD (ATOMIC_CMP_SWAP_I128
419fe6060f1SDimitry Andric                           memrr:$ptr,
420fe6060f1SDimitry Andric                           g8rc:$cmp_lo,
421fe6060f1SDimitry Andric                           g8rc:$cmp_hi,
422fe6060f1SDimitry Andric                           g8rc:$new_lo,
423fe6060f1SDimitry Andric                           g8rc:$new_hi))>;
4240b57cec5SDimitry Andric
4250b57cec5SDimitry Andriclet mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
42606c3fb27SDimitry Andricdef STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$RST, g8rc:$RA, u5imm:$RB),
42706c3fb27SDimitry Andric                          "stdat $RST, $RA, $RB", IIC_LdStStore>, isPPC64,
4280b57cec5SDimitry Andric            Requires<[IsISA3_0]>;
4290b57cec5SDimitry Andric
4300b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
4310b57cec5SDimitry Andriclet isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
4320b57cec5SDimitry Andricdef TCRETURNdi8 :PPCEmitTimePseudo< (outs),
4330b57cec5SDimitry Andric                        (ins calltarget:$dst, i32imm:$offset),
4340b57cec5SDimitry Andric                 "#TC_RETURNd8 $dst $offset",
4350b57cec5SDimitry Andric                 []>;
4360b57cec5SDimitry Andric
4370b57cec5SDimitry Andriclet isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
4380b57cec5SDimitry Andricdef TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
4390b57cec5SDimitry Andric                 "#TC_RETURNa8 $func $offset",
4400b57cec5SDimitry Andric                 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
4410b57cec5SDimitry Andric
4420b57cec5SDimitry Andriclet isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
4430b57cec5SDimitry Andricdef TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
4440b57cec5SDimitry Andric                 "#TC_RETURNr8 $dst $offset",
4450b57cec5SDimitry Andric                 []>;
4460b57cec5SDimitry Andric
447349cc55cSDimitry Andriclet hasSideEffects = 0 in {
4480b57cec5SDimitry Andriclet isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
4490b57cec5SDimitry Andric    isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
4500b57cec5SDimitry Andricdef TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
4510b57cec5SDimitry Andric                             []>,
4520b57cec5SDimitry Andric    Requires<[In64BitMode]>;
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andriclet isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
4550b57cec5SDimitry Andric    isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
45606c3fb27SDimitry Andricdef TAILB8   : IForm<18, 0, 0, (outs), (ins calltarget:$LI),
45706c3fb27SDimitry Andric                  "b $LI", IIC_BrB,
4580b57cec5SDimitry Andric                  []>;
4590b57cec5SDimitry Andric
4600b57cec5SDimitry Andriclet isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
4610b57cec5SDimitry Andric    isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
46206c3fb27SDimitry Andricdef TAILBA8   : IForm<18, 0, 0, (outs), (ins abscalltarget:$LI),
46306c3fb27SDimitry Andric                  "ba $LI", IIC_BrB,
4640b57cec5SDimitry Andric                  []>;
465349cc55cSDimitry Andric}
4660b57cec5SDimitry Andric} // Interpretation64Bit
4670b57cec5SDimitry Andric
4680b57cec5SDimitry Andricdef : Pat<(PPCtc_return (i64 tglobaladdr:$dst),  imm:$imm),
4690b57cec5SDimitry Andric          (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
4700b57cec5SDimitry Andric
4710b57cec5SDimitry Andricdef : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
4720b57cec5SDimitry Andric          (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
4730b57cec5SDimitry Andric
4740b57cec5SDimitry Andricdef : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
4750b57cec5SDimitry Andric          (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andric
4780b57cec5SDimitry Andric// 64-bit CR instructions
4790b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
4800b57cec5SDimitry Andriclet hasSideEffects = 0 in {
4810b57cec5SDimitry Andric// mtocrf's input needs to be prepared by shifting by an amount dependent
4820b57cec5SDimitry Andric// on the cr register selected. Thus, post-ra anti-dep breaking must not
4830b57cec5SDimitry Andric// later change that register assignment.
4840b57cec5SDimitry Andriclet hasExtraDefRegAllocReq = 1 in {
48506c3fb27SDimitry Andricdef MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$RST),
48606c3fb27SDimitry Andric                        "mtocrf $FXM, $RST", IIC_BrMCRX>,
4870b57cec5SDimitry Andric            PPC970_DGroup_First, PPC970_Unit_CRU;
4880b57cec5SDimitry Andric
4890b57cec5SDimitry Andric// Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
4900b57cec5SDimitry Andric// is dependent on the cr fields being set.
49106c3fb27SDimitry Andricdef MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$RST),
49206c3fb27SDimitry Andric                      "mtcrf $FXM, $RST", IIC_BrMCRX>,
4930b57cec5SDimitry Andric            PPC970_MicroCode, PPC970_Unit_CRU;
4940b57cec5SDimitry Andric} // hasExtraDefRegAllocReq = 1
4950b57cec5SDimitry Andric
4960b57cec5SDimitry Andric// mfocrf's input needs to be prepared by shifting by an amount dependent
4970b57cec5SDimitry Andric// on the cr register selected. Thus, post-ra anti-dep breaking must not
4980b57cec5SDimitry Andric// later change that register assignment.
4990b57cec5SDimitry Andriclet hasExtraSrcRegAllocReq = 1 in {
50006c3fb27SDimitry Andricdef MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$RST), (ins crbitm:$FXM),
50106c3fb27SDimitry Andric                        "mfocrf $RST, $FXM", IIC_SprMFCRF>,
5020b57cec5SDimitry Andric             PPC970_DGroup_First, PPC970_Unit_CRU;
5030b57cec5SDimitry Andric
5040b57cec5SDimitry Andric// Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
5050b57cec5SDimitry Andric// is dependent on the cr fields being copied.
50606c3fb27SDimitry Andricdef MFCR8 : XFXForm_3<31, 19, (outs g8rc:$RT), (ins),
50706c3fb27SDimitry Andric                     "mfcr $RT", IIC_SprMFCR>,
5080b57cec5SDimitry Andric                     PPC970_MicroCode, PPC970_Unit_CRU;
5090b57cec5SDimitry Andric} // hasExtraSrcRegAllocReq = 1
5100b57cec5SDimitry Andric} // hasSideEffects = 0
5110b57cec5SDimitry Andric
5120b57cec5SDimitry Andric// While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
5130b57cec5SDimitry Andric// is not.
5140b57cec5SDimitry Andriclet hasSideEffects = 1 in {
5150b57cec5SDimitry Andric  let Defs = [CTR8] in
5160b57cec5SDimitry Andric  def EH_SjLj_SetJmp64  : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
5170b57cec5SDimitry Andric                            "#EH_SJLJ_SETJMP64",
5180b57cec5SDimitry Andric                            [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
5190b57cec5SDimitry Andric                          Requires<[In64BitMode]>;
5200b57cec5SDimitry Andric}
5210b57cec5SDimitry Andric
5220b57cec5SDimitry Andriclet hasSideEffects = 1, isBarrier = 1 in {
5230b57cec5SDimitry Andric  let isTerminator = 1 in
5240b57cec5SDimitry Andric  def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
5250b57cec5SDimitry Andric                            "#EH_SJLJ_LONGJMP64",
5260b57cec5SDimitry Andric                            [(PPCeh_sjlj_longjmp addr:$buf)]>,
5270b57cec5SDimitry Andric                          Requires<[In64BitMode]>;
5280b57cec5SDimitry Andric}
5290b57cec5SDimitry Andric
53006c3fb27SDimitry Andricdef MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RST), (ins i32imm:$SPR),
53106c3fb27SDimitry Andric                       "mfspr $RST, $SPR", IIC_SprMFSPR>;
53206c3fb27SDimitry Andricdef MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RST),
53306c3fb27SDimitry Andric                       "mtspr $SPR, $RST", IIC_SprMTSPR>;
5340b57cec5SDimitry Andric
5350b57cec5SDimitry Andric
5360b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5370b57cec5SDimitry Andric// 64-bit SPR manipulation instrs.
5380b57cec5SDimitry Andric
5390b57cec5SDimitry Andriclet Uses = [CTR8] in {
54006c3fb27SDimitry Andricdef MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$RST), (ins),
54106c3fb27SDimitry Andric                           "mfctr $RST", IIC_SprMFSPR>,
5420b57cec5SDimitry Andric             PPC970_DGroup_First, PPC970_Unit_FXU;
5430b57cec5SDimitry Andric}
54406c3fb27SDimitry Andriclet Pattern = [(PPCmtctr i64:$RST)], Defs = [CTR8] in {
54506c3fb27SDimitry Andricdef MTCTR8 : XFXForm_1_ext<31, 467, 9, (outs), (ins g8rc:$RST),
54606c3fb27SDimitry Andric                           "mtctr $RST", IIC_SprMTSPR>,
5470b57cec5SDimitry Andric             PPC970_DGroup_First, PPC970_Unit_FXU;
5480b57cec5SDimitry Andric}
549bdd1243dSDimitry Andric// MTCTR[8|]loop must be inside a loop-preheader, duplicating
550bdd1243dSDimitry Andric// the loop-preheader block will break this assumption.
551bdd1243dSDimitry Andriclet hasSideEffects = 1, isNotDuplicable = 1, Defs = [CTR8] in {
55206c3fb27SDimitry Andriclet Pattern = [(int_set_loop_iterations i64:$RST)] in
55306c3fb27SDimitry Andricdef MTCTR8loop : XFXForm_1_ext<31, 467, 9, (outs), (ins g8rc:$RST),
55406c3fb27SDimitry Andric                               "mtctr $RST", IIC_SprMTSPR>,
5550b57cec5SDimitry Andric                 PPC970_DGroup_First, PPC970_Unit_FXU;
5560b57cec5SDimitry Andric}
5570b57cec5SDimitry Andric
558bdd1243dSDimitry Andriclet hasSideEffects = 1, hasNoSchedulingInfo = 1, isNotDuplicable = 1, Uses = [CTR8], Defs = [CTR8] in
559bdd1243dSDimitry Andricdef DecreaseCTR8loop : PPCEmitTimePseudo<(outs crbitrc:$rT), (ins i64imm:$stride),
560bdd1243dSDimitry Andric                                        "#DecreaseCTR8loop", [(set i1:$rT, (int_loop_decrement (i64 imm:$stride)))]>;
56181ad6265SDimitry Andric
56206c3fb27SDimitry Andriclet Pattern = [(set i64:$RST, readcyclecounter)] in
56306c3fb27SDimitry Andricdef MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$RST), (ins),
56406c3fb27SDimitry Andric                          "mfspr $RST, 268", IIC_SprMFTB>,
5650b57cec5SDimitry Andric            PPC970_DGroup_First, PPC970_Unit_FXU;
5660b57cec5SDimitry Andric// Note that encoding mftb using mfspr is now the preferred form,
5670b57cec5SDimitry Andric// and has been since at least ISA v2.03. The mftb instruction has
5680b57cec5SDimitry Andric// now been phased out. Using mfspr, however, is known not to work on
5690b57cec5SDimitry Andric// the POWER3.
5700b57cec5SDimitry Andric
5710b57cec5SDimitry Andriclet Defs = [X1], Uses = [X1] in
5720b57cec5SDimitry Andricdef DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
5730b57cec5SDimitry Andric                       [(set i64:$result,
5740b57cec5SDimitry Andric                             (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
5750b57cec5SDimitry Andricdef DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
5760b57cec5SDimitry Andric                       [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
5775ffd83dbSDimitry Andric// Probed alloca to support stack clash protection.
5785ffd83dbSDimitry Andriclet Defs = [X1], Uses = [X1], hasNoSchedulingInfo = 1 in {
5795ffd83dbSDimitry Andricdef PROBED_ALLOCA_64 : PPCCustomInserterPseudo<(outs g8rc:$result),
5805ffd83dbSDimitry Andric                         (ins g8rc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_64",
5815ffd83dbSDimitry Andric                           [(set i64:$result,
5825ffd83dbSDimitry Andric                             (PPCprobedalloca i64:$negsize, iaddr:$fpsi))]>;
583590d96feSDimitry Andricdef PREPARE_PROBED_ALLOCA_64 : PPCEmitTimePseudo<(outs
584590d96feSDimitry Andric    g8rc:$fp, g8rc:$actual_negsize),
5855ffd83dbSDimitry Andric    (ins g8rc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_64", []>;
586590d96feSDimitry Andricdef PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 : PPCEmitTimePseudo<(outs
587590d96feSDimitry Andric    g8rc:$fp, g8rc:$actual_negsize),
588590d96feSDimitry Andric    (ins g8rc:$negsize, memri:$fpsi),
589590d96feSDimitry Andric    "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64", []>,
590590d96feSDimitry Andric    RegConstraint<"$actual_negsize = $negsize">;
5915ffd83dbSDimitry Andricdef PROBED_STACKALLOC_64 : PPCEmitTimePseudo<(outs g8rc:$scratch, g8rc:$temp),
5925ffd83dbSDimitry Andric    (ins i64imm:$stacksize),
5935ffd83dbSDimitry Andric    "#PROBED_STACKALLOC_64", []>;
5945ffd83dbSDimitry Andric}
5950b57cec5SDimitry Andric
596480093f4SDimitry Andriclet hasSideEffects = 0 in {
5970b57cec5SDimitry Andriclet Defs = [LR8] in {
59806c3fb27SDimitry Andricdef MTLR8  : XFXForm_1_ext<31, 467, 8, (outs), (ins g8rc:$RST),
59906c3fb27SDimitry Andric                           "mtlr $RST", IIC_SprMTSPR>,
6000b57cec5SDimitry Andric             PPC970_DGroup_First, PPC970_Unit_FXU;
6010b57cec5SDimitry Andric}
6020b57cec5SDimitry Andriclet Uses = [LR8] in {
60306c3fb27SDimitry Andricdef MFLR8  : XFXForm_1_ext<31, 339, 8, (outs g8rc:$RST), (ins),
60406c3fb27SDimitry Andric                           "mflr $RST", IIC_SprMFSPR>,
6050b57cec5SDimitry Andric             PPC970_DGroup_First, PPC970_Unit_FXU;
6060b57cec5SDimitry Andric}
6070b57cec5SDimitry Andric} // Interpretation64Bit
608480093f4SDimitry Andric}
6090b57cec5SDimitry Andric
6100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6110b57cec5SDimitry Andric// Fixed point instructions.
6120b57cec5SDimitry Andric//
6130b57cec5SDimitry Andric
6140b57cec5SDimitry Andriclet PPC970_Unit = 1 in {  // FXU Operations.
6150b57cec5SDimitry Andriclet Interpretation64Bit = 1 in {
6160b57cec5SDimitry Andriclet hasSideEffects = 0 in {
6170b57cec5SDimitry Andriclet isCodeGenOnly = 1 in {
6180b57cec5SDimitry Andric
6190b57cec5SDimitry Andriclet isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
62006c3fb27SDimitry Andricdef LI8  : DForm_2_r0<14, (outs g8rc:$RST), (ins s16imm64:$D),
62106c3fb27SDimitry Andric                      "li $RST, $D", IIC_IntSimple,
62206c3fb27SDimitry Andric                      [(set i64:$RST, imm64SExt16:$D)]>, SExt32To64;
62306c3fb27SDimitry Andricdef LIS8 : DForm_2_r0<15, (outs g8rc:$RST), (ins s17imm64:$D),
62406c3fb27SDimitry Andric                      "lis $RST, $D", IIC_IntSimple,
62506c3fb27SDimitry Andric                      [(set i64:$RST, imm16ShiftedSExt:$D)]>, SExt32To64;
6260b57cec5SDimitry Andric}
6270b57cec5SDimitry Andric
6280b57cec5SDimitry Andric// Logical ops.
6290b57cec5SDimitry Andriclet isCommutable = 1 in {
63006c3fb27SDimitry Andricdefm NAND8: XForm_6r<31, 476, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
63106c3fb27SDimitry Andric                     "nand", "$RA, $RST, $RB", IIC_IntSimple,
63206c3fb27SDimitry Andric                     [(set i64:$RA, (not (and i64:$RST, i64:$RB)))]>;
63306c3fb27SDimitry Andricdefm AND8 : XForm_6r<31,  28, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
63406c3fb27SDimitry Andric                     "and", "$RA, $RST, $RB", IIC_IntSimple,
63506c3fb27SDimitry Andric                     [(set i64:$RA, (and i64:$RST, i64:$RB))]>;
6360b57cec5SDimitry Andric} // isCommutable
63706c3fb27SDimitry Andricdefm ANDC8: XForm_6r<31,  60, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
63806c3fb27SDimitry Andric                     "andc", "$RA, $RST, $RB", IIC_IntSimple,
63906c3fb27SDimitry Andric                     [(set i64:$RA, (and i64:$RST, (not i64:$RB)))]>;
6400b57cec5SDimitry Andriclet isCommutable = 1 in {
64106c3fb27SDimitry Andricdefm OR8  : XForm_6r<31, 444, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
64206c3fb27SDimitry Andric                     "or", "$RA, $RST, $RB", IIC_IntSimple,
64306c3fb27SDimitry Andric                     [(set i64:$RA, (or i64:$RST, i64:$RB))]>;
64406c3fb27SDimitry Andricdefm NOR8 : XForm_6r<31, 124, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
64506c3fb27SDimitry Andric                     "nor", "$RA, $RST, $RB", IIC_IntSimple,
64606c3fb27SDimitry Andric                     [(set i64:$RA, (not (or i64:$RST, i64:$RB)))]>;
6470b57cec5SDimitry Andric} // isCommutable
64806c3fb27SDimitry Andricdefm ORC8 : XForm_6r<31, 412, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
64906c3fb27SDimitry Andric                     "orc", "$RA, $RST, $RB", IIC_IntSimple,
65006c3fb27SDimitry Andric                     [(set i64:$RA, (or i64:$RST, (not i64:$RB)))]>;
6510b57cec5SDimitry Andriclet isCommutable = 1 in {
65206c3fb27SDimitry Andricdefm EQV8 : XForm_6r<31, 284, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
65306c3fb27SDimitry Andric                     "eqv", "$RA, $RST, $RB", IIC_IntSimple,
65406c3fb27SDimitry Andric                     [(set i64:$RA, (not (xor i64:$RST, i64:$RB)))]>;
65506c3fb27SDimitry Andricdefm XOR8 : XForm_6r<31, 316, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
65606c3fb27SDimitry Andric                     "xor", "$RA, $RST, $RB", IIC_IntSimple,
65706c3fb27SDimitry Andric                     [(set i64:$RA, (xor i64:$RST, i64:$RB))]>;
6580b57cec5SDimitry Andric} // let isCommutable = 1
6590b57cec5SDimitry Andric
6600b57cec5SDimitry Andric// Logical ops with immediate.
6610b57cec5SDimitry Andriclet Defs = [CR0] in {
66206c3fb27SDimitry Andricdef ANDI8_rec  : DForm_4<28, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
66306c3fb27SDimitry Andric                      "andi. $RA, $RST, $D", IIC_IntGeneral,
66406c3fb27SDimitry Andric                      [(set i64:$RA, (and i64:$RST, immZExt16:$D))]>,
665bdd1243dSDimitry Andric                      isRecordForm, SExt32To64, ZExt32To64;
66606c3fb27SDimitry Andricdef ANDIS8_rec : DForm_4<29, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
66706c3fb27SDimitry Andric                     "andis. $RA, $RST, $D", IIC_IntGeneral,
66806c3fb27SDimitry Andric                    [(set i64:$RA, (and i64:$RST, imm16ShiftedZExt:$D))]>,
669bdd1243dSDimitry Andric                     isRecordForm, ZExt32To64;
6700b57cec5SDimitry Andric}
67106c3fb27SDimitry Andricdef ORI8    : DForm_4<24, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
67206c3fb27SDimitry Andric                      "ori $RA, $RST, $D", IIC_IntSimple,
67306c3fb27SDimitry Andric                      [(set i64:$RA, (or i64:$RST, immZExt16:$D))]>;
67406c3fb27SDimitry Andricdef ORIS8   : DForm_4<25, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
67506c3fb27SDimitry Andric                      "oris $RA, $RST, $D", IIC_IntSimple,
67606c3fb27SDimitry Andric                    [(set i64:$RA, (or i64:$RST, imm16ShiftedZExt:$D))]>;
67706c3fb27SDimitry Andricdef XORI8   : DForm_4<26, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
67806c3fb27SDimitry Andric                      "xori $RA, $RST, $D", IIC_IntSimple,
67906c3fb27SDimitry Andric                      [(set i64:$RA, (xor i64:$RST, immZExt16:$D))]>;
68006c3fb27SDimitry Andricdef XORIS8  : DForm_4<27, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
68106c3fb27SDimitry Andric                      "xoris $RA, $RST, $D", IIC_IntSimple,
68206c3fb27SDimitry Andric                   [(set i64:$RA, (xor i64:$RST, imm16ShiftedZExt:$D))]>;
6830b57cec5SDimitry Andric
6840b57cec5SDimitry Andriclet isCommutable = 1 in
68506c3fb27SDimitry Andricdefm ADD8  : XOForm_1rx<31, 266, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
68606c3fb27SDimitry Andric                        "add", "$RT, $RA, $RB", IIC_IntSimple,
68706c3fb27SDimitry Andric                        [(set i64:$RT, (add i64:$RA, i64:$RB))]>;
6880b57cec5SDimitry Andric// ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
6890b57cec5SDimitry Andric// initial-exec thread-local storage model.  We need to forbid r0 here -
6900b57cec5SDimitry Andric// while it works for add just fine, the linker can relax this to local-exec
6910b57cec5SDimitry Andric// addi, which won't work for r0.
69206c3fb27SDimitry Andricdef ADD8TLS  : XOForm_1<31, 266, 0, (outs g8rc:$RT), (ins g8rc_nox0:$RA, tlsreg:$RB),
69306c3fb27SDimitry Andric                        "add $RT, $RA, $RB", IIC_IntSimple,
69406c3fb27SDimitry Andric                        [(set i64:$RT, (add i64:$RA, tglobaltlsaddr:$RB))]>;
6950b57cec5SDimitry Andriclet mayLoad = 1 in {
69606c3fb27SDimitry Andricdef LBZXTLS : XForm_1<31,  87, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
69706c3fb27SDimitry Andric                      "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
69806c3fb27SDimitry Andricdef LHZXTLS : XForm_1<31, 279, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
69906c3fb27SDimitry Andric                      "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
70006c3fb27SDimitry Andricdef LHAXTLS : XForm_1<31, 343, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
70106c3fb27SDimitry Andric                      "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
70206c3fb27SDimitry Andricdef LWZXTLS : XForm_1<31,  23, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
70306c3fb27SDimitry Andric                      "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
70406c3fb27SDimitry Andricdef LWAXTLS : XForm_1<31, 341, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
70506c3fb27SDimitry Andric                      "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
70606c3fb27SDimitry Andricdef LDXTLS  : XForm_1<31,  21, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
70706c3fb27SDimitry Andric                      "ldx $RST, $RA, $RB", IIC_LdStLD, []>, isPPC64;
70806c3fb27SDimitry Andricdef LBZXTLS_32 : XForm_1<31,  87, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
70906c3fb27SDimitry Andric                         "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
71006c3fb27SDimitry Andricdef LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
71106c3fb27SDimitry Andric                         "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
71206c3fb27SDimitry Andricdef LHAXTLS_32 : XForm_1<31, 343, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
71306c3fb27SDimitry Andric                         "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
71406c3fb27SDimitry Andricdef LWZXTLS_32 : XForm_1<31,  23, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
71506c3fb27SDimitry Andric                         "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
71606c3fb27SDimitry Andricdef LWAXTLS_32 : XForm_1<31, 341, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
71706c3fb27SDimitry Andric                         "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
7180b57cec5SDimitry Andric
7190b57cec5SDimitry Andric}
72006c3fb27SDimitry Andriclet mayLoad = 1, Predicates = [HasFPU] in {
72106c3fb27SDimitry Andricdef LFSXTLS : XForm_25<31, 535, (outs f4rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
72206c3fb27SDimitry Andric                       "lfsx $RST, $RA, $RB", IIC_LdStLFD, []>;
72306c3fb27SDimitry Andricdef LFDXTLS : XForm_25<31, 599, (outs f8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
72406c3fb27SDimitry Andric                       "lfdx $RST, $RA, $RB", IIC_LdStLFD, []>;
72506c3fb27SDimitry Andric}
7260b57cec5SDimitry Andric
7270b57cec5SDimitry Andriclet mayStore = 1 in {
72806c3fb27SDimitry Andricdef STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
72906c3fb27SDimitry Andric                      "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
7300b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
73106c3fb27SDimitry Andricdef STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
73206c3fb27SDimitry Andric                      "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
7330b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
73406c3fb27SDimitry Andricdef STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
73506c3fb27SDimitry Andric                      "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
7360b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
73706c3fb27SDimitry Andricdef STDXTLS  : XForm_8<31, 149, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
73806c3fb27SDimitry Andric                       "stdx $RST, $RA, $RB", IIC_LdStSTD, []>, isPPC64,
7390b57cec5SDimitry Andric                       PPC970_DGroup_Cracked;
74006c3fb27SDimitry Andricdef STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
74106c3fb27SDimitry Andric                         "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
7420b57cec5SDimitry Andric                         PPC970_DGroup_Cracked;
74306c3fb27SDimitry Andricdef STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
74406c3fb27SDimitry Andric                         "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
7450b57cec5SDimitry Andric                         PPC970_DGroup_Cracked;
74606c3fb27SDimitry Andricdef STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
74706c3fb27SDimitry Andric                         "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
7480b57cec5SDimitry Andric                         PPC970_DGroup_Cracked;
7490b57cec5SDimitry Andric
7500b57cec5SDimitry Andric}
75106c3fb27SDimitry Andriclet mayStore = 1, Predicates = [HasFPU] in {
75206c3fb27SDimitry Andricdef STFSXTLS : XForm_8<31, 663, (outs), (ins f4rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
75306c3fb27SDimitry Andric                       "stfsx $RST, $RA, $RB", IIC_LdStSTFD, []>,
75406c3fb27SDimitry Andric                       PPC970_DGroup_Cracked;
75506c3fb27SDimitry Andricdef STFDXTLS : XForm_8<31, 727, (outs), (ins f8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
75606c3fb27SDimitry Andric                       "stfdx $RST, $RA, $RB", IIC_LdStSTFD, []>,
75706c3fb27SDimitry Andric                       PPC970_DGroup_Cracked;
75806c3fb27SDimitry Andric}
7590b57cec5SDimitry Andric
7600b57cec5SDimitry Andriclet isCommutable = 1 in
76106c3fb27SDimitry Andricdefm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
76206c3fb27SDimitry Andric                        "addc", "$RT, $RA, $RB", IIC_IntGeneral,
76306c3fb27SDimitry Andric                        [(set i64:$RT, (addc i64:$RA, i64:$RB))]>,
7640b57cec5SDimitry Andric                        PPC970_DGroup_Cracked;
7650b57cec5SDimitry Andric
7660b57cec5SDimitry Andriclet Defs = [CARRY] in
76706c3fb27SDimitry Andricdef ADDIC8 : DForm_2<12, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
76806c3fb27SDimitry Andric                     "addic $RST, $RA, $D", IIC_IntGeneral,
76906c3fb27SDimitry Andric                     [(set i64:$RST, (addc i64:$RA, imm64SExt16:$D))]>;
77006c3fb27SDimitry Andricdef ADDI8  : DForm_2<14, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s16imm64:$D),
77106c3fb27SDimitry Andric                     "addi $RST, $RA, $D", IIC_IntSimple,
77206c3fb27SDimitry Andric                     [(set i64:$RST, (add i64:$RA, imm64SExt16:$D))]>;
77306c3fb27SDimitry Andricdef ADDIS8 : DForm_2<15, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s17imm64:$D),
77406c3fb27SDimitry Andric                     "addis $RST, $RA, $D", IIC_IntSimple,
77506c3fb27SDimitry Andric                     [(set i64:$RST, (add i64:$RA, imm16ShiftedSExt:$D))]>;
7760b57cec5SDimitry Andric
77706c3fb27SDimitry Andricdef LA8     : DForm_2<14, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s16imm64:$D),
77806c3fb27SDimitry Andric                     "la $RST, $D($RA)", IIC_IntGeneral,
77906c3fb27SDimitry Andric                     [(set i64:$RST, (add i64:$RA,
78006c3fb27SDimitry Andric                                    (PPClo tglobaladdr:$D, 0)))]>;
7814824e7fdSDimitry Andric
7820b57cec5SDimitry Andriclet Defs = [CARRY] in {
78306c3fb27SDimitry Andricdef SUBFIC8: DForm_2< 8, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
78406c3fb27SDimitry Andric                     "subfic $RST, $RA, $D", IIC_IntGeneral,
78506c3fb27SDimitry Andric                     [(set i64:$RST, (subc imm64SExt16:$D, i64:$RA))]>;
7860b57cec5SDimitry Andric}
78706c3fb27SDimitry Andricdefm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
78806c3fb27SDimitry Andric                        "subfc", "$RT, $RA, $RB", IIC_IntGeneral,
78906c3fb27SDimitry Andric                        [(set i64:$RT, (subc i64:$RB, i64:$RA))]>,
7900b57cec5SDimitry Andric                        PPC970_DGroup_Cracked;
79106c3fb27SDimitry Andricdefm SUBF8 : XOForm_1rx<31, 40, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
79206c3fb27SDimitry Andric                        "subf", "$RT, $RA, $RB", IIC_IntGeneral,
79306c3fb27SDimitry Andric                        [(set i64:$RT, (sub i64:$RB, i64:$RA))]>;
79406c3fb27SDimitry Andricdefm NEG8    : XOForm_3r<31, 104, 0, (outs g8rc:$RT), (ins g8rc:$RA),
79506c3fb27SDimitry Andric                        "neg", "$RT, $RA", IIC_IntSimple,
79606c3fb27SDimitry Andric                        [(set i64:$RT, (ineg i64:$RA))]>;
7970b57cec5SDimitry Andriclet Uses = [CARRY] in {
7980b57cec5SDimitry Andriclet isCommutable = 1 in
79906c3fb27SDimitry Andricdefm ADDE8   : XOForm_1rc<31, 138, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
80006c3fb27SDimitry Andric                          "adde", "$RT, $RA, $RB", IIC_IntGeneral,
80106c3fb27SDimitry Andric                          [(set i64:$RT, (adde i64:$RA, i64:$RB))]>;
80206c3fb27SDimitry Andricdefm ADDME8  : XOForm_3rc<31, 234, 0, (outs g8rc:$RT), (ins g8rc:$RA),
80306c3fb27SDimitry Andric                          "addme", "$RT, $RA", IIC_IntGeneral,
80406c3fb27SDimitry Andric                          [(set i64:$RT, (adde i64:$RA, -1))]>;
80506c3fb27SDimitry Andricdefm ADDZE8  : XOForm_3rc<31, 202, 0, (outs g8rc:$RT), (ins g8rc:$RA),
80606c3fb27SDimitry Andric                          "addze", "$RT, $RA", IIC_IntGeneral,
80706c3fb27SDimitry Andric                          [(set i64:$RT, (adde i64:$RA, 0))]>;
80806c3fb27SDimitry Andricdefm SUBFE8  : XOForm_1rc<31, 136, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
80906c3fb27SDimitry Andric                          "subfe", "$RT, $RA, $RB", IIC_IntGeneral,
81006c3fb27SDimitry Andric                          [(set i64:$RT, (sube i64:$RB, i64:$RA))]>;
81106c3fb27SDimitry Andricdefm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$RT), (ins g8rc:$RA),
81206c3fb27SDimitry Andric                          "subfme", "$RT, $RA", IIC_IntGeneral,
81306c3fb27SDimitry Andric                          [(set i64:$RT, (sube -1, i64:$RA))]>;
81406c3fb27SDimitry Andricdefm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$RT), (ins g8rc:$RA),
81506c3fb27SDimitry Andric                          "subfze", "$RT, $RA", IIC_IntGeneral,
81606c3fb27SDimitry Andric                          [(set i64:$RT, (sube 0, i64:$RA))]>;
8170b57cec5SDimitry Andric}
8180b57cec5SDimitry Andric} // isCodeGenOnly
8190b57cec5SDimitry Andric
8200b57cec5SDimitry Andric// FIXME: Duplicating this for the asm parser should be unnecessary, but the
8210b57cec5SDimitry Andric// previous definition must be marked as CodeGen only to prevent decoding
8220b57cec5SDimitry Andric// conflicts.
8230b57cec5SDimitry Andriclet isAsmParserOnly = 1 in {
82406c3fb27SDimitry Andricdef ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$RT), (ins g8rc:$RA, tlsreg:$RB),
82506c3fb27SDimitry Andric                        "add $RT, $RA, $RB", IIC_IntSimple, []>;
8260b57cec5SDimitry Andric
8270b57cec5SDimitry Andriclet mayLoad = 1 in {
82806c3fb27SDimitry Andricdef LBZXTLS_ : XForm_1<31,  87, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
82906c3fb27SDimitry Andric                      "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
83006c3fb27SDimitry Andricdef LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
83106c3fb27SDimitry Andric                      "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
83206c3fb27SDimitry Andricdef LHAXTLS_ : XForm_1<31, 343, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
83306c3fb27SDimitry Andric                       "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
83406c3fb27SDimitry Andricdef LWZXTLS_ : XForm_1<31,  23, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
83506c3fb27SDimitry Andric                      "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
83606c3fb27SDimitry Andricdef LWAXTLS_ : XForm_1<31, 341, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
83706c3fb27SDimitry Andric                       "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
83806c3fb27SDimitry Andricdef LDXTLS_  : XForm_1<31,  21, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
83906c3fb27SDimitry Andric                      "ldx $RST, $RA, $RB", IIC_LdStLD, []>, isPPC64;
84006c3fb27SDimitry Andric}
84106c3fb27SDimitry Andric
84206c3fb27SDimitry Andriclet mayLoad = 1, Predicates = [HasFPU] in {
84306c3fb27SDimitry Andricdef LFSXTLS_ : XForm_25<31, 535, (outs f4rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
84406c3fb27SDimitry Andric                        "lfsx $RST, $RA, $RB", IIC_LdStLFD, []>;
84506c3fb27SDimitry Andricdef LFDXTLS_ : XForm_25<31, 599, (outs f8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
84606c3fb27SDimitry Andric                        "lfdx $RST, $RA, $RB", IIC_LdStLFD, []>;
8470b57cec5SDimitry Andric}
8480b57cec5SDimitry Andric
8490b57cec5SDimitry Andriclet mayStore = 1 in {
85006c3fb27SDimitry Andricdef STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
85106c3fb27SDimitry Andric                      "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
8520b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
85306c3fb27SDimitry Andricdef STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
85406c3fb27SDimitry Andric                      "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
8550b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
85606c3fb27SDimitry Andricdef STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
85706c3fb27SDimitry Andric                      "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
8580b57cec5SDimitry Andric                      PPC970_DGroup_Cracked;
85906c3fb27SDimitry Andricdef STDXTLS_  : XForm_8<31, 149, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
86006c3fb27SDimitry Andric                       "stdx $RST, $RA, $RB", IIC_LdStSTD, []>, isPPC64,
86106c3fb27SDimitry Andric                       PPC970_DGroup_Cracked;
86206c3fb27SDimitry Andric}
86306c3fb27SDimitry Andric
86406c3fb27SDimitry Andriclet mayStore = 1, Predicates = [HasFPU] in {
86506c3fb27SDimitry Andricdef STFSXTLS_ : XForm_8<31, 663, (outs), (ins f4rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
86606c3fb27SDimitry Andric                        "stfsx $RST, $RA, $RB", IIC_LdStSTFD, []>,
86706c3fb27SDimitry Andric                        PPC970_DGroup_Cracked;
86806c3fb27SDimitry Andricdef STFDXTLS_ : XForm_8<31, 727, (outs), (ins f8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
86906c3fb27SDimitry Andric                        "stfdx $RST, $RA, $RB", IIC_LdStSTFD, []>,
8700b57cec5SDimitry Andric                        PPC970_DGroup_Cracked;
8710b57cec5SDimitry Andric}
8720b57cec5SDimitry Andric}
8730b57cec5SDimitry Andric
8740b57cec5SDimitry Andriclet isCommutable = 1 in {
87506c3fb27SDimitry Andricdefm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
87606c3fb27SDimitry Andric                       "mulhd", "$RT, $RA, $RB", IIC_IntMulHW,
87706c3fb27SDimitry Andric                       [(set i64:$RT, (mulhs i64:$RA, i64:$RB))]>;
87806c3fb27SDimitry Andricdefm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
87906c3fb27SDimitry Andric                       "mulhdu", "$RT, $RA, $RB", IIC_IntMulHWU,
88006c3fb27SDimitry Andric                       [(set i64:$RT, (mulhu i64:$RA, i64:$RB))]>;
8810b57cec5SDimitry Andric} // isCommutable
8820b57cec5SDimitry Andric}
8830b57cec5SDimitry Andric} // Interpretation64Bit
8840b57cec5SDimitry Andric
8850b57cec5SDimitry Andriclet isCompare = 1, hasSideEffects = 0 in {
88606c3fb27SDimitry Andric  def CMPD   : XForm_16_ext<31, 0, (outs crrc:$BF), (ins g8rc:$RA, g8rc:$RB),
88706c3fb27SDimitry Andric                            "cmpd $BF, $RA, $RB", IIC_IntCompare>, isPPC64;
88806c3fb27SDimitry Andric  def CMPLD  : XForm_16_ext<31, 32, (outs crrc:$BF), (ins g8rc:$RA, g8rc:$RB),
88906c3fb27SDimitry Andric                            "cmpld $BF, $RA, $RB", IIC_IntCompare>, isPPC64;
89006c3fb27SDimitry Andric  def CMPDI  : DForm_5_ext<11, (outs crrc:$BF), (ins g8rc:$RA, s16imm64:$D),
89106c3fb27SDimitry Andric                           "cmpdi $BF, $RA, $D", IIC_IntCompare>, isPPC64;
89206c3fb27SDimitry Andric  def CMPLDI : DForm_6_ext<10, (outs crrc:$BF), (ins g8rc:$RA, u16imm64:$D),
89306c3fb27SDimitry Andric                           "cmpldi $BF, $RA, $D",
8940b57cec5SDimitry Andric                           IIC_IntCompare>, isPPC64;
8950b57cec5SDimitry Andric  let Interpretation64Bit = 1, isCodeGenOnly = 1 in
896fe6060f1SDimitry Andric  def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
89706c3fb27SDimitry Andric                                (ins u1imm:$L, g8rc:$RA, g8rc:$RB),
89806c3fb27SDimitry Andric                                "cmprb $BF, $L, $RA, $RB", IIC_IntCompare, []>,
8990b57cec5SDimitry Andric               Requires<[IsISA3_0]>;
900fe6060f1SDimitry Andric  def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crrc:$BF),
90106c3fb27SDimitry Andric                             (ins g8rc:$RA, g8rc:$RB), "cmpeqb $BF, $RA, $RB",
9020b57cec5SDimitry Andric                             IIC_IntCompare, []>, Requires<[IsISA3_0]>;
9030b57cec5SDimitry Andric}
9040b57cec5SDimitry Andric
9050b57cec5SDimitry Andriclet hasSideEffects = 0 in {
90606c3fb27SDimitry Andricdefm SLD  : XForm_6r<31,  27, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
90706c3fb27SDimitry Andric                     "sld", "$RA, $RST, $RB", IIC_IntRotateD,
90806c3fb27SDimitry Andric                     [(set i64:$RA, (PPCshl i64:$RST, i32:$RB))]>, isPPC64;
90906c3fb27SDimitry Andricdefm SRD  : XForm_6r<31, 539, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
91006c3fb27SDimitry Andric                     "srd", "$RA, $RST, $RB", IIC_IntRotateD,
91106c3fb27SDimitry Andric                     [(set i64:$RA, (PPCsrl i64:$RST, i32:$RB))]>, isPPC64;
91206c3fb27SDimitry Andricdefm SRAD : XForm_6rc<31, 794, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
91306c3fb27SDimitry Andric                      "srad", "$RA, $RST, $RB", IIC_IntRotateD,
91406c3fb27SDimitry Andric                      [(set i64:$RA, (PPCsra i64:$RST, i32:$RB))]>, isPPC64;
9150b57cec5SDimitry Andric
9160b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
91706c3fb27SDimitry Andricdefm CNTLZW8 : XForm_11r<31,  26, (outs g8rc:$RA), (ins g8rc:$RST),
91806c3fb27SDimitry Andric                        "cntlzw", "$RA, $RST", IIC_IntGeneral, []>,
919bdd1243dSDimitry Andric                        ZExt32To64, SExt32To64;
92006c3fb27SDimitry Andricdefm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$RA), (ins g8rc:$RST),
92106c3fb27SDimitry Andric                        "cnttzw", "$RA, $RST", IIC_IntGeneral, []>,
922bdd1243dSDimitry Andric               Requires<[IsISA3_0]>, ZExt32To64, SExt32To64;
9230b57cec5SDimitry Andric
92406c3fb27SDimitry Andricdefm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$RA), (ins g8rc:$RST),
92506c3fb27SDimitry Andric                        "extsb", "$RA, $RST", IIC_IntSimple,
92606c3fb27SDimitry Andric                        [(set i64:$RA, (sext_inreg i64:$RST, i8))]>, SExt32To64;
92706c3fb27SDimitry Andricdefm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$RA), (ins g8rc:$RST),
92806c3fb27SDimitry Andric                        "extsh", "$RA, $RST", IIC_IntSimple,
92906c3fb27SDimitry Andric                        [(set i64:$RA, (sext_inreg i64:$RST, i16))]>, SExt32To64;
9300b57cec5SDimitry Andric
93106c3fb27SDimitry Andricdefm SLW8  : XForm_6r<31,  24, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
93206c3fb27SDimitry Andric                      "slw", "$RA, $RST, $RB", IIC_IntGeneral, []>, ZExt32To64;
93306c3fb27SDimitry Andricdefm SRW8  : XForm_6r<31, 536, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
93406c3fb27SDimitry Andric                      "srw", "$RA, $RST, $RB", IIC_IntGeneral, []>, ZExt32To64;
9350b57cec5SDimitry Andric} // Interpretation64Bit
9360b57cec5SDimitry Andric
9370b57cec5SDimitry Andric// For fast-isel:
9380b57cec5SDimitry Andriclet isCodeGenOnly = 1 in {
93906c3fb27SDimitry Andricdef EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$RA), (ins gprc:$RST),
94006c3fb27SDimitry Andric                           "extsb $RA, $RST", IIC_IntSimple, []>, isPPC64,
941bdd1243dSDimitry Andric                           SExt32To64;
94206c3fb27SDimitry Andricdef EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$RA), (ins gprc:$RST),
94306c3fb27SDimitry Andric                           "extsh $RA, $RST", IIC_IntSimple, []>, isPPC64,
944bdd1243dSDimitry Andric                           SExt32To64;
9450b57cec5SDimitry Andric} // isCodeGenOnly for fast-isel
9460b57cec5SDimitry Andric
94706c3fb27SDimitry Andricdefm EXTSW  : XForm_11r<31, 986, (outs g8rc:$RA), (ins g8rc:$RST),
94806c3fb27SDimitry Andric                        "extsw", "$RA, $RST", IIC_IntSimple,
94906c3fb27SDimitry Andric                        [(set i64:$RA, (sext_inreg i64:$RST, i32))]>, isPPC64,
950bdd1243dSDimitry Andric                        SExt32To64;
9510b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
95206c3fb27SDimitry Andricdefm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$RA), (ins gprc:$RST),
95306c3fb27SDimitry Andric                             "extsw", "$RA, $RST", IIC_IntSimple,
95406c3fb27SDimitry Andric                             [(set i64:$RA, (sext i32:$RST))]>, isPPC64,
955bdd1243dSDimitry Andric                             SExt32To64;
9560b57cec5SDimitry Andriclet isCodeGenOnly = 1 in
95706c3fb27SDimitry Andricdef EXTSW_32 : XForm_11<31, 986, (outs gprc:$RA), (ins gprc:$RST),
95806c3fb27SDimitry Andric                        "extsw $RA, $RST", IIC_IntSimple,
9590b57cec5SDimitry Andric                        []>, isPPC64;
9600b57cec5SDimitry Andric
96106c3fb27SDimitry Andricdefm SRADI  : XSForm_1rc<31, 413, (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH),
96206c3fb27SDimitry Andric                         "sradi", "$RA, $RS, $SH", IIC_IntRotateDI,
96306c3fb27SDimitry Andric                         [(set i64:$RA, (sra i64:$RS, (i32 imm:$SH)))]>, isPPC64;
9640b57cec5SDimitry Andric
9650b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
96606c3fb27SDimitry Andricdefm EXTSWSLI_32_64 : XSForm_1r<31, 445, (outs g8rc:$RA),
96706c3fb27SDimitry Andric                                (ins gprc:$RS, u6imm:$SH),
96806c3fb27SDimitry Andric                                "extswsli", "$RA, $RS, $SH", IIC_IntRotateDI,
96906c3fb27SDimitry Andric                                [(set i64:$RA,
97006c3fb27SDimitry Andric                                      (PPCextswsli i32:$RS, (i32 imm:$SH)))]>,
9710b57cec5SDimitry Andric                                isPPC64, Requires<[IsISA3_0]>;
9720b57cec5SDimitry Andric
97306c3fb27SDimitry Andricdefm EXTSWSLI : XSForm_1rc<31, 445, (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH),
97406c3fb27SDimitry Andric                           "extswsli", "$RA, $RS, $SH", IIC_IntRotateDI,
9750b57cec5SDimitry Andric                           []>, isPPC64, Requires<[IsISA3_0]>;
9760b57cec5SDimitry Andric
9770b57cec5SDimitry Andric// For fast-isel:
9780b57cec5SDimitry Andriclet isCodeGenOnly = 1, Defs = [CARRY] in
97906c3fb27SDimitry Andricdef SRADI_32  : XSForm_1<31, 413, (outs gprc:$RA), (ins gprc:$RS, u6imm:$SH),
98006c3fb27SDimitry Andric                         "sradi $RA, $RS, $SH", IIC_IntRotateDI, []>, isPPC64;
9810b57cec5SDimitry Andric
98206c3fb27SDimitry Andricdefm CNTLZD : XForm_11r<31,  58, (outs g8rc:$RA), (ins g8rc:$RST),
98306c3fb27SDimitry Andric                        "cntlzd", "$RA, $RST", IIC_IntGeneral,
98406c3fb27SDimitry Andric                        [(set i64:$RA, (ctlz i64:$RST))]>,
985bdd1243dSDimitry Andric                        ZExt32To64, SExt32To64;
98606c3fb27SDimitry Andricdefm CNTTZD : XForm_11r<31, 570, (outs g8rc:$RA), (ins g8rc:$RST),
98706c3fb27SDimitry Andric                        "cnttzd", "$RA, $RST", IIC_IntGeneral,
98806c3fb27SDimitry Andric                        [(set i64:$RA, (cttz i64:$RST))]>, Requires<[IsISA3_0]>,
989bdd1243dSDimitry Andric                        ZExt32To64, SExt32To64;
99006c3fb27SDimitry Andricdef POPCNTD : XForm_11<31, 506, (outs g8rc:$RA), (ins g8rc:$RST),
99106c3fb27SDimitry Andric                       "popcntd $RA, $RST", IIC_IntGeneral,
99206c3fb27SDimitry Andric                       [(set i64:$RA, (ctpop i64:$RST))]>,
993bdd1243dSDimitry Andric                       ZExt32To64, SExt32To64;
99406c3fb27SDimitry Andricdef BPERMD : XForm_6<31, 252, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
99506c3fb27SDimitry Andric                     "bpermd $RA, $RST, $RB", IIC_IntGeneral,
99606c3fb27SDimitry Andric                     [(set i64:$RA, (int_ppc_bpermd g8rc:$RST, g8rc:$RB))]>,
9970b57cec5SDimitry Andric                     isPPC64, Requires<[HasBPERMD]>;
9980b57cec5SDimitry Andric
9990b57cec5SDimitry Andriclet isCodeGenOnly = 1, isCommutable = 1 in
100006c3fb27SDimitry Andricdef CMPB8 : XForm_6<31, 508, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
100106c3fb27SDimitry Andric                    "cmpb $RA, $RST, $RB", IIC_IntGeneral,
100206c3fb27SDimitry Andric                    [(set i64:$RA, (PPCcmpb i64:$RST, i64:$RB))]>;
10030b57cec5SDimitry Andric
10040b57cec5SDimitry Andric// popcntw also does a population count on the high 32 bits (storing the
10050b57cec5SDimitry Andric// results in the high 32-bits of the output). We'll ignore that here (which is
10060b57cec5SDimitry Andric// safe because we never separately use the high part of the 64-bit registers).
100706c3fb27SDimitry Andricdef POPCNTW : XForm_11<31, 378, (outs gprc:$RA), (ins gprc:$RST),
100806c3fb27SDimitry Andric                       "popcntw $RA, $RST", IIC_IntGeneral,
100906c3fb27SDimitry Andric                       [(set i32:$RA, (ctpop i32:$RST))]>;
10100b57cec5SDimitry Andric
101106c3fb27SDimitry Andriclet isCodeGenOnly = 1 in {
101206c3fb27SDimitry Andricdef POPCNTB8 : XForm_11<31, 122, (outs g8rc:$RA), (ins g8rc:$RST),
101306c3fb27SDimitry Andric                        "popcntb $RA, $RST", IIC_IntGeneral,
101406c3fb27SDimitry Andric                        [(set i64:$RA, (int_ppc_popcntb i64:$RST))]>;
10150b57cec5SDimitry Andric
101606c3fb27SDimitry Andricdef CDTBCD8 : XForm_11<31, 282, (outs g8rc:$RA), (ins g8rc:$RST),
101706c3fb27SDimitry Andric                       "cdtbcd $RA, $RST", IIC_IntGeneral, []>;
101806c3fb27SDimitry Andricdef CBCDTD8 : XForm_11<31, 314, (outs g8rc:$RA), (ins g8rc:$RST),
101906c3fb27SDimitry Andric                       "cbcdtd $RA, $RST", IIC_IntGeneral, []>;
102006c3fb27SDimitry Andric
102106c3fb27SDimitry Andricdef ADDG6S8 : XOForm_1<31, 74, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
102206c3fb27SDimitry Andric                       "addg6s $RT, $RA, $RB", IIC_IntGeneral, []>;
102306c3fb27SDimitry Andric}
102406c3fb27SDimitry Andric
102506c3fb27SDimitry Andricdefm DIVD  : XOForm_1rcr<31, 489, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
102606c3fb27SDimitry Andric                          "divd", "$RT, $RA, $RB", IIC_IntDivD,
102706c3fb27SDimitry Andric                          [(set i64:$RT, (sdiv i64:$RA, i64:$RB))]>, isPPC64;
102806c3fb27SDimitry Andricdefm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
102906c3fb27SDimitry Andric                          "divdu", "$RT, $RA, $RB", IIC_IntDivD,
103006c3fb27SDimitry Andric                          [(set i64:$RT, (udiv i64:$RA, i64:$RB))]>, isPPC64;
103106c3fb27SDimitry Andricdefm DIVDE : XOForm_1rcr<31, 425, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
103206c3fb27SDimitry Andric                         "divde", "$RT, $RA, $RB", IIC_IntDivD,
103306c3fb27SDimitry Andric                         [(set i64:$RT, (int_ppc_divde g8rc:$RA, g8rc:$RB))]>,
10340b57cec5SDimitry Andric                         isPPC64, Requires<[HasExtDiv]>;
10350b57cec5SDimitry Andric
10360b57cec5SDimitry Andriclet Predicates = [IsISA3_0] in {
10370b57cec5SDimitry Andricdef MADDHD : VAForm_1a<48, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
10380b57cec5SDimitry Andric                       "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
10390b57cec5SDimitry Andricdef MADDHDU : VAForm_1a<49,
10400b57cec5SDimitry Andric                       (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
10410b57cec5SDimitry Andric                       "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
10420b57cec5SDimitry Andricdef MADDLD : VAForm_1a<51, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB, gprc:$RC),
10430b57cec5SDimitry Andric                       "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
10440b57cec5SDimitry Andric                       [(set i32:$RT, (add_without_simm16 (mul_without_simm16 i32:$RA, i32:$RB), i32:$RC))]>,
10450b57cec5SDimitry Andric                       isPPC64;
10460b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
10470b57cec5SDimitry Andric  def MADDLD8 : VAForm_1a<51,
10480b57cec5SDimitry Andric                       (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
10490b57cec5SDimitry Andric                       "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
10500b57cec5SDimitry Andric                       [(set i64:$RT, (add_without_simm16 (mul_without_simm16 i64:$RA, i64:$RB), i64:$RC))]>,
10510b57cec5SDimitry Andric                       isPPC64;
10520b57cec5SDimitry Andric  def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
1053bdd1243dSDimitry Andric                       "setb $RT, $BFA", IIC_IntGeneral>, isPPC64, SExt32To64;
10540b57cec5SDimitry Andric}
10550b57cec5SDimitry Andricdef ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
10560b57cec5SDimitry Andric                     "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
105706c3fb27SDimitry Andricdef MODSD : XForm_8<31, 777, (outs g8rc:$RST), (ins g8rc:$RA, g8rc:$RB),
105806c3fb27SDimitry Andric                        "modsd $RST, $RA, $RB", IIC_IntDivW,
105906c3fb27SDimitry Andric                        [(set i64:$RST, (srem i64:$RA, i64:$RB))]>;
106006c3fb27SDimitry Andricdef MODUD : XForm_8<31, 265, (outs g8rc:$RST), (ins g8rc:$RA, g8rc:$RB),
106106c3fb27SDimitry Andric                        "modud $RST, $RA, $RB", IIC_IntDivW,
106206c3fb27SDimitry Andric                        [(set i64:$RST, (urem i64:$RA, i64:$RB))]>;
10630b57cec5SDimitry Andric}
10640b57cec5SDimitry Andric
106506c3fb27SDimitry Andricdefm DIVDEU : XOForm_1rcr<31, 393, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
106606c3fb27SDimitry Andric                          "divdeu", "$RT, $RA, $RB", IIC_IntDivD,
106706c3fb27SDimitry Andric                          [(set i64:$RT, (int_ppc_divdeu g8rc:$RA, g8rc:$RB))]>,
10680b57cec5SDimitry Andric                          isPPC64, Requires<[HasExtDiv]>;
10690b57cec5SDimitry Andriclet isCommutable = 1 in
107006c3fb27SDimitry Andricdefm MULLD : XOForm_1rx<31, 233, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
107106c3fb27SDimitry Andric                        "mulld", "$RT, $RA, $RB", IIC_IntMulHD,
107206c3fb27SDimitry Andric                        [(set i64:$RT, (mul i64:$RA, i64:$RB))]>, isPPC64;
10730b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
107406c3fb27SDimitry Andricdef MULLI8 : DForm_2<7, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
107506c3fb27SDimitry Andric                       "mulli $RST, $RA, $D", IIC_IntMulLI,
107606c3fb27SDimitry Andric                       [(set i64:$RST, (mul i64:$RA, imm64SExt16:$D))]>;
10770b57cec5SDimitry Andric}
10780b57cec5SDimitry Andric
107981ad6265SDimitry Andriclet hasSideEffects = 1 in {
108081ad6265SDimitry Andricdef DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins u2imm:$L),
108181ad6265SDimitry Andric                    "darn $RT, $L", IIC_LdStLD>, isPPC64;
108281ad6265SDimitry Andric}
108381ad6265SDimitry Andric
10840b57cec5SDimitry Andriclet hasSideEffects = 0 in {
108506c3fb27SDimitry Andricdefm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$RA),
108606c3fb27SDimitry Andric                        (ins g8rc:$RAi, g8rc:$RS, u6imm:$SH, u6imm:$MBE),
108706c3fb27SDimitry Andric                        "rldimi", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
108806c3fb27SDimitry Andric                        []>, isPPC64, RegConstraint<"$RAi = $RA">,
108906c3fb27SDimitry Andric                        NoEncode<"$RAi">;
10900b57cec5SDimitry Andric
10910b57cec5SDimitry Andric// Rotate instructions.
10920b57cec5SDimitry Andricdefm RLDCL  : MDSForm_1r<30, 8,
109306c3fb27SDimitry Andric                        (outs g8rc:$RA), (ins g8rc:$RS, gprc:$RB, u6imm:$MBE),
109406c3fb27SDimitry Andric                        "rldcl", "$RA, $RS, $RB, $MBE", IIC_IntRotateD,
10950b57cec5SDimitry Andric                        []>, isPPC64;
10960b57cec5SDimitry Andricdefm RLDCR  : MDSForm_1r<30, 9,
109706c3fb27SDimitry Andric                        (outs g8rc:$RA), (ins g8rc:$RS, gprc:$RB, u6imm:$MBE),
109806c3fb27SDimitry Andric                        "rldcr", "$RA, $RS, $RB, $MBE", IIC_IntRotateD,
10990b57cec5SDimitry Andric                        []>, isPPC64;
11000b57cec5SDimitry Andricdefm RLDICL : MDForm_1r<30, 0,
110106c3fb27SDimitry Andric                        (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
110206c3fb27SDimitry Andric                        "rldicl", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11030b57cec5SDimitry Andric                        []>, isPPC64;
11040b57cec5SDimitry Andric// For fast-isel:
11050b57cec5SDimitry Andriclet isCodeGenOnly = 1 in
11060b57cec5SDimitry Andricdef RLDICL_32_64 : MDForm_1<30, 0,
110706c3fb27SDimitry Andric                            (outs g8rc:$RA),
110806c3fb27SDimitry Andric                            (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
110906c3fb27SDimitry Andric                            "rldicl $RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11100b57cec5SDimitry Andric                            []>, isPPC64;
11110b57cec5SDimitry Andric// End fast-isel.
11120b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
11130b57cec5SDimitry Andricdefm RLDICL_32 : MDForm_1r<30, 0,
111406c3fb27SDimitry Andric                           (outs gprc:$RA),
111506c3fb27SDimitry Andric                           (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
111606c3fb27SDimitry Andric                           "rldicl", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11170b57cec5SDimitry Andric                           []>, isPPC64;
11180b57cec5SDimitry Andricdefm RLDICR : MDForm_1r<30, 1,
111906c3fb27SDimitry Andric                        (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
112006c3fb27SDimitry Andric                        "rldicr", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11210b57cec5SDimitry Andric                        []>, isPPC64;
11220b57cec5SDimitry Andriclet isCodeGenOnly = 1 in
11230b57cec5SDimitry Andricdef RLDICR_32 : MDForm_1<30, 1,
112406c3fb27SDimitry Andric                         (outs gprc:$RA), (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
112506c3fb27SDimitry Andric                         "rldicr $RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11260b57cec5SDimitry Andric                         []>, isPPC64;
11270b57cec5SDimitry Andricdefm RLDIC  : MDForm_1r<30, 2,
112806c3fb27SDimitry Andric                        (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
112906c3fb27SDimitry Andric                        "rldic", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
11300b57cec5SDimitry Andric                        []>, isPPC64;
11310b57cec5SDimitry Andric
11320b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
113306c3fb27SDimitry Andricdefm RLWINM8 : MForm_2r<21, (outs g8rc:$RA),
113406c3fb27SDimitry Andric                        (ins g8rc:$RS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
113506c3fb27SDimitry Andric                        "rlwinm", "$RA, $RS, $SH, $MB, $ME", IIC_IntGeneral,
11360b57cec5SDimitry Andric                        []>;
11370b57cec5SDimitry Andric
113806c3fb27SDimitry Andricdefm RLWNM8  : MForm_1r<23, (outs g8rc:$RA),
113906c3fb27SDimitry Andric                        (ins g8rc:$RS, g8rc:$RB, u5imm:$MB, u5imm:$ME),
114006c3fb27SDimitry Andric                        "rlwnm", "$RA, $RS, $RB, $MB, $ME", IIC_IntGeneral,
11410b57cec5SDimitry Andric                        []>;
11420b57cec5SDimitry Andric
11430b57cec5SDimitry Andric// RLWIMI can be commuted if the rotate amount is zero.
11440b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
114506c3fb27SDimitry Andricdefm RLWIMI8 : MForm_2r<20, (outs g8rc:$RA),
114606c3fb27SDimitry Andric                        (ins g8rc:$RAi, g8rc:$RS, u5imm:$SH, u5imm:$MB,
114706c3fb27SDimitry Andric                        u5imm:$ME), "rlwimi", "$RA, $RS, $SH, $MB, $ME",
11480b57cec5SDimitry Andric                        IIC_IntRotate, []>, PPC970_DGroup_Cracked,
114906c3fb27SDimitry Andric                        RegConstraint<"$RAi = $RA">, NoEncode<"$RAi">;
11500b57cec5SDimitry Andric
11510b57cec5SDimitry Andriclet isSelect = 1 in
11520b57cec5SDimitry Andricdef ISEL8   : AForm_4<31, 15,
115306c3fb27SDimitry Andric                     (outs g8rc:$RT), (ins g8rc_nox0:$RA, g8rc:$RB, crbitrc:$COND),
115406c3fb27SDimitry Andric                     "isel $RT, $RA, $RB, $COND", IIC_IntISEL,
11550b57cec5SDimitry Andric                     []>;
11560b57cec5SDimitry Andric}  // Interpretation64Bit
11570b57cec5SDimitry Andric}  // hasSideEffects = 0
11580b57cec5SDimitry Andric}  // End FXU Operations.
11590b57cec5SDimitry Andric
11605ffd83dbSDimitry Andricdef : InstAlias<"li $rD, $imm", (ADDI8 g8rc:$rD, ZERO8, s16imm64:$imm)>;
11615ffd83dbSDimitry Andricdef : InstAlias<"lis $rD, $imm", (ADDIS8 g8rc:$rD, ZERO8, s17imm64:$imm)>;
11625ffd83dbSDimitry Andric
11635ffd83dbSDimitry Andricdef : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
11645ffd83dbSDimitry Andricdef : InstAlias<"mr. $rA, $rB", (OR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
11655ffd83dbSDimitry Andric
11665ffd83dbSDimitry Andricdef : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
11675ffd83dbSDimitry Andricdef : InstAlias<"not. $rA, $rB", (NOR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
11685ffd83dbSDimitry Andric
11695ffd83dbSDimitry Andricdef : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
11705ffd83dbSDimitry Andric
11715ffd83dbSDimitry Andricdef : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
11725ffd83dbSDimitry Andricdef : InstAlias<"sub. $rA, $rB, $rC", (SUBF8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
11735ffd83dbSDimitry Andricdef : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
11745ffd83dbSDimitry Andricdef : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
11755ffd83dbSDimitry Andric
11765ffd83dbSDimitry Andricdef : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
11775ffd83dbSDimitry Andricdef : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
11785ffd83dbSDimitry Andricdef : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM8 g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
11795ffd83dbSDimitry Andricdef : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM8_rec g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
11805ffd83dbSDimitry Andricdef : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
11815ffd83dbSDimitry Andricdef : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
11825ffd83dbSDimitry Andric
11835ffd83dbSDimitry Andricdef : InstAlias<"isellt $rT, $rA, $rB",
11845ffd83dbSDimitry Andric                (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0LT)>;
11855ffd83dbSDimitry Andricdef : InstAlias<"iselgt $rT, $rA, $rB",
11865ffd83dbSDimitry Andric                (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0GT)>;
11875ffd83dbSDimitry Andricdef : InstAlias<"iseleq $rT, $rA, $rB",
11885ffd83dbSDimitry Andric                (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0EQ)>;
11895ffd83dbSDimitry Andric
11905ffd83dbSDimitry Andricdef : InstAlias<"nop", (ORI8 X0, X0, 0)>;
11915ffd83dbSDimitry Andricdef : InstAlias<"xnop", (XORI8 X0, X0, 0)>;
11925ffd83dbSDimitry Andric
11935ffd83dbSDimitry Andricdef : InstAlias<"cntlzw $rA, $rS", (CNTLZW8 g8rc:$rA, g8rc:$rS)>;
11945ffd83dbSDimitry Andricdef : InstAlias<"cntlzw. $rA, $rS", (CNTLZW8_rec g8rc:$rA, g8rc:$rS)>;
11955ffd83dbSDimitry Andric
11965ffd83dbSDimitry Andricdef : InstAlias<"mtxer $Rx", (MTSPR8 1, g8rc:$Rx)>;
11975ffd83dbSDimitry Andricdef : InstAlias<"mfxer $Rx", (MFSPR8 g8rc:$Rx, 1)>;
11985ffd83dbSDimitry Andric
1199e8d8bef9SDimitry Andric//Disable this alias on AIX for now because as does not support them.
1200e8d8bef9SDimitry Andriclet Predicates = [ModernAs] in {
1201fe6060f1SDimitry Andric
12025ffd83dbSDimitry Andricdef : InstAlias<"mtudscr $Rx", (MTSPR8 3, g8rc:$Rx)>;
12035ffd83dbSDimitry Andricdef : InstAlias<"mfudscr $Rx", (MFSPR8 g8rc:$Rx, 3)>;
12045ffd83dbSDimitry Andric
12055ffd83dbSDimitry Andricdef : InstAlias<"mfrtcu $Rx", (MFSPR8 g8rc:$Rx, 4)>;
12065ffd83dbSDimitry Andricdef : InstAlias<"mfrtcl $Rx", (MFSPR8 g8rc:$Rx, 5)>;
12075ffd83dbSDimitry Andric
12085ffd83dbSDimitry Andricdef : InstAlias<"mtlr $Rx", (MTSPR8 8, g8rc:$Rx)>;
12095ffd83dbSDimitry Andricdef : InstAlias<"mflr $Rx", (MFSPR8 g8rc:$Rx, 8)>;
12105ffd83dbSDimitry Andric
12115ffd83dbSDimitry Andricdef : InstAlias<"mtctr $Rx", (MTSPR8 9, g8rc:$Rx)>;
12125ffd83dbSDimitry Andricdef : InstAlias<"mfctr $Rx", (MFSPR8 g8rc:$Rx, 9)>;
12135ffd83dbSDimitry Andric
12145ffd83dbSDimitry Andricdef : InstAlias<"mtuamr $Rx", (MTSPR8 13, g8rc:$Rx)>;
12155ffd83dbSDimitry Andricdef : InstAlias<"mfuamr $Rx", (MFSPR8 g8rc:$Rx, 13)>;
12165ffd83dbSDimitry Andric
12175ffd83dbSDimitry Andricdef : InstAlias<"mtdscr $Rx", (MTSPR8 17, g8rc:$Rx)>;
12185ffd83dbSDimitry Andricdef : InstAlias<"mfdscr $Rx", (MFSPR8 g8rc:$Rx, 17)>;
12195ffd83dbSDimitry Andric
12205ffd83dbSDimitry Andricdef : InstAlias<"mtdsisr $Rx", (MTSPR8 18, g8rc:$Rx)>;
12215ffd83dbSDimitry Andricdef : InstAlias<"mfdsisr $Rx", (MFSPR8 g8rc:$Rx, 18)>;
12225ffd83dbSDimitry Andric
12235ffd83dbSDimitry Andricdef : InstAlias<"mtdar $Rx", (MTSPR8 19, g8rc:$Rx)>;
12245ffd83dbSDimitry Andricdef : InstAlias<"mfdar $Rx", (MFSPR8 g8rc:$Rx, 19)>;
12255ffd83dbSDimitry Andric
12265ffd83dbSDimitry Andricdef : InstAlias<"mtdec $Rx", (MTSPR8 22, g8rc:$Rx)>;
12275ffd83dbSDimitry Andricdef : InstAlias<"mfdec $Rx", (MFSPR8 g8rc:$Rx, 22)>;
12285ffd83dbSDimitry Andric
12295ffd83dbSDimitry Andricdef : InstAlias<"mtsdr1 $Rx", (MTSPR8 25, g8rc:$Rx)>;
12305ffd83dbSDimitry Andricdef : InstAlias<"mfsdr1 $Rx", (MFSPR8 g8rc:$Rx, 25)>;
12315ffd83dbSDimitry Andric
12325ffd83dbSDimitry Andricdef : InstAlias<"mtsrr0 $Rx", (MTSPR8 26, g8rc:$Rx)>;
12335ffd83dbSDimitry Andricdef : InstAlias<"mfsrr0 $Rx", (MFSPR8 g8rc:$Rx, 26)>;
12345ffd83dbSDimitry Andric
12355ffd83dbSDimitry Andricdef : InstAlias<"mtsrr1 $Rx", (MTSPR8 27, g8rc:$Rx)>;
12365ffd83dbSDimitry Andricdef : InstAlias<"mfsrr1 $Rx", (MFSPR8 g8rc:$Rx, 27)>;
12375ffd83dbSDimitry Andric
12385ffd83dbSDimitry Andricdef : InstAlias<"mtcfar $Rx", (MTSPR8 28, g8rc:$Rx)>;
12395ffd83dbSDimitry Andricdef : InstAlias<"mfcfar $Rx", (MFSPR8 g8rc:$Rx, 28)>;
12405ffd83dbSDimitry Andric
12415ffd83dbSDimitry Andricdef : InstAlias<"mtamr $Rx", (MTSPR8 29, g8rc:$Rx)>;
12425ffd83dbSDimitry Andricdef : InstAlias<"mfamr $Rx", (MFSPR8 g8rc:$Rx, 29)>;
12435ffd83dbSDimitry Andric
12445ffd83dbSDimitry Andricforeach SPRG = 0-3 in {
12455ffd83dbSDimitry Andric  def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
12465ffd83dbSDimitry Andric  def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
12472a99bea5SDimitry Andric  def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
12482a99bea5SDimitry Andric  def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
12495ffd83dbSDimitry Andric}
12505ffd83dbSDimitry Andric
12515ffd83dbSDimitry Andricdef : InstAlias<"mfasr $RT", (MFSPR8 g8rc:$RT, 280)>;
12525ffd83dbSDimitry Andricdef : InstAlias<"mtasr $RT", (MTSPR8 280, g8rc:$RT)>;
12535ffd83dbSDimitry Andric
12545ffd83dbSDimitry Andricdef : InstAlias<"mttbl $Rx", (MTSPR8 284, g8rc:$Rx)>;
12555ffd83dbSDimitry Andricdef : InstAlias<"mttbu $Rx", (MTSPR8 285, g8rc:$Rx)>;
12565ffd83dbSDimitry Andric
12575ffd83dbSDimitry Andricdef : InstAlias<"mfpvr $RT", (MFSPR8 g8rc:$RT, 287)>;
12585ffd83dbSDimitry Andric
12595ffd83dbSDimitry Andricdef : InstAlias<"mfspefscr $Rx", (MFSPR8 g8rc:$Rx, 512)>;
12605ffd83dbSDimitry Andricdef : InstAlias<"mtspefscr $Rx", (MTSPR8 512, g8rc:$Rx)>;
12610b57cec5SDimitry Andric
1262fe6060f1SDimitry Andric}
1263fe6060f1SDimitry Andric
12640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12650b57cec5SDimitry Andric// Load/Store instructions.
12660b57cec5SDimitry Andric//
12670b57cec5SDimitry Andric
12680b57cec5SDimitry Andric
12690b57cec5SDimitry Andric// Sign extending loads.
12700b57cec5SDimitry Andriclet PPC970_Unit = 2 in {
12710b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
127206c3fb27SDimitry Andricdef LHA8: DForm_1<42, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
127306c3fb27SDimitry Andric                  "lha $RST, $addr", IIC_LdStLHA,
127406c3fb27SDimitry Andric                  [(set i64:$RST, (sextloadi16 DForm:$addr))]>,
1275bdd1243dSDimitry Andric                  PPC970_DGroup_Cracked, SExt32To64;
127606c3fb27SDimitry Andricdef LWA  : DSForm_1<58, 2, (outs g8rc:$RST), (ins (memrix $D, $RA):$addr),
127706c3fb27SDimitry Andric                    "lwa $RST, $addr", IIC_LdStLWA,
127806c3fb27SDimitry Andric                    [(set i64:$RST,
127906c3fb27SDimitry Andric                          (sextloadi32 DSForm:$addr))]>, isPPC64,
1280bdd1243dSDimitry Andric                    PPC970_DGroup_Cracked, SExt32To64;
12810b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
128206c3fb27SDimitry Andricdef LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
128306c3fb27SDimitry Andric                        "lhax $RST, $addr", IIC_LdStLHA,
128406c3fb27SDimitry Andric                        [(set i64:$RST, (sextloadi16 XForm:$addr))]>,
1285bdd1243dSDimitry Andric                        PPC970_DGroup_Cracked, SExt32To64;
128606c3fb27SDimitry Andricdef LWAX : XForm_1_memOp<31, 341, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
128706c3fb27SDimitry Andric                        "lwax $RST, $addr", IIC_LdStLHA,
128806c3fb27SDimitry Andric                        [(set i64:$RST, (sextloadi32 XForm:$addr))]>, isPPC64,
1289bdd1243dSDimitry Andric                        PPC970_DGroup_Cracked, SExt32To64;
12900b57cec5SDimitry Andric// For fast-isel:
1291480093f4SDimitry Andriclet isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0 in {
129206c3fb27SDimitry Andricdef LWA_32  : DSForm_1<58, 2, (outs gprc:$RST), (ins (memrix $D, $RA):$addr),
129306c3fb27SDimitry Andric                      "lwa $RST, $addr", IIC_LdStLWA, []>, isPPC64,
1294bdd1243dSDimitry Andric                      PPC970_DGroup_Cracked, SExt32To64;
129506c3fb27SDimitry Andricdef LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
129606c3fb27SDimitry Andric                            "lwax $RST, $addr", IIC_LdStLHA, []>, isPPC64,
1297bdd1243dSDimitry Andric                            PPC970_DGroup_Cracked, SExt32To64;
12980b57cec5SDimitry Andric} // end fast-isel isCodeGenOnly
12990b57cec5SDimitry Andric
13000b57cec5SDimitry Andric// Update forms.
13010b57cec5SDimitry Andriclet mayLoad = 1, hasSideEffects = 0 in {
13020b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
130306c3fb27SDimitry Andricdef LHAU8 : DForm_1<43, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
130406c3fb27SDimitry Andric                    (ins (memri $D, $RA):$addr),
130506c3fb27SDimitry Andric                    "lhau $RST, $addr", IIC_LdStLHAU,
13060b57cec5SDimitry Andric                    []>, RegConstraint<"$addr.reg = $ea_result">,
13070b57cec5SDimitry Andric                    NoEncode<"$ea_result">;
13080b57cec5SDimitry Andric// NO LWAU!
13090b57cec5SDimitry Andric
13100b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in
131106c3fb27SDimitry Andricdef LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
131206c3fb27SDimitry Andric                          (ins (memrr $RA, $RB):$addr),
131306c3fb27SDimitry Andric                          "lhaux $RST, $addr", IIC_LdStLHAUX,
13140b57cec5SDimitry Andric                          []>, RegConstraint<"$addr.ptrreg = $ea_result">,
13150b57cec5SDimitry Andric                          NoEncode<"$ea_result">;
131606c3fb27SDimitry Andricdef LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
131706c3fb27SDimitry Andric                          (ins (memrr $RA, $RB):$addr),
131806c3fb27SDimitry Andric                          "lwaux $RST, $addr", IIC_LdStLHAUX,
13190b57cec5SDimitry Andric                          []>, RegConstraint<"$addr.ptrreg = $ea_result">,
13200b57cec5SDimitry Andric                          NoEncode<"$ea_result">, isPPC64;
13210b57cec5SDimitry Andric}
13220b57cec5SDimitry Andric}
13230b57cec5SDimitry Andric
13240b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
13250b57cec5SDimitry Andric// Zero extending loads.
13260b57cec5SDimitry Andriclet PPC970_Unit = 2 in {
132706c3fb27SDimitry Andricdef LBZ8 : DForm_1<34, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
132806c3fb27SDimitry Andric                  "lbz $RST, $addr", IIC_LdStLoad,
132906c3fb27SDimitry Andric                  [(set i64:$RST, (zextloadi8 DForm:$addr))]>, ZExt32To64,
1330bdd1243dSDimitry Andric                  SExt32To64;
133106c3fb27SDimitry Andricdef LHZ8 : DForm_1<40, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
133206c3fb27SDimitry Andric                  "lhz $RST, $addr", IIC_LdStLoad,
133306c3fb27SDimitry Andric                  [(set i64:$RST, (zextloadi16 DForm:$addr))]>, ZExt32To64,
1334bdd1243dSDimitry Andric                  SExt32To64;
133506c3fb27SDimitry Andricdef LWZ8 : DForm_1<32, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
133606c3fb27SDimitry Andric                  "lwz $RST, $addr", IIC_LdStLoad,
133706c3fb27SDimitry Andric                  [(set i64:$RST, (zextloadi32 DForm:$addr))]>, isPPC64,
1338bdd1243dSDimitry Andric                  ZExt32To64;
13390b57cec5SDimitry Andric
134006c3fb27SDimitry Andricdef LBZX8 : XForm_1_memOp<31,  87, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
134106c3fb27SDimitry Andric                          "lbzx $RST, $addr", IIC_LdStLoad,
134206c3fb27SDimitry Andric                          [(set i64:$RST, (zextloadi8 XForm:$addr))]>, ZExt32To64,
1343bdd1243dSDimitry Andric                          SExt32To64;
134406c3fb27SDimitry Andricdef LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
134506c3fb27SDimitry Andric                          "lhzx $RST, $addr", IIC_LdStLoad,
134606c3fb27SDimitry Andric                          [(set i64:$RST, (zextloadi16 XForm:$addr))]>,
1347bdd1243dSDimitry Andric                          ZExt32To64, SExt32To64;
134806c3fb27SDimitry Andricdef LWZX8 : XForm_1_memOp<31,  23, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
134906c3fb27SDimitry Andric                          "lwzx $RST, $addr", IIC_LdStLoad,
135006c3fb27SDimitry Andric                          [(set i64:$RST, (zextloadi32 XForm:$addr))]>,
1351bdd1243dSDimitry Andric                          ZExt32To64;
13520b57cec5SDimitry Andric
13530b57cec5SDimitry Andric
13540b57cec5SDimitry Andric// Update forms.
13550b57cec5SDimitry Andriclet mayLoad = 1, hasSideEffects = 0 in {
135606c3fb27SDimitry Andricdef LBZU8 : DForm_1<35, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
135706c3fb27SDimitry Andric                    (ins (memri $D, $RA):$addr),
135806c3fb27SDimitry Andric                    "lbzu $RST, $addr", IIC_LdStLoadUpd,
13590b57cec5SDimitry Andric                    []>, RegConstraint<"$addr.reg = $ea_result">,
13600b57cec5SDimitry Andric                    NoEncode<"$ea_result">;
136106c3fb27SDimitry Andricdef LHZU8 : DForm_1<41, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
136206c3fb27SDimitry Andric                    (ins (memri $D, $RA):$addr),
136306c3fb27SDimitry Andric                    "lhzu $RST, $addr", IIC_LdStLoadUpd,
13640b57cec5SDimitry Andric                    []>, RegConstraint<"$addr.reg = $ea_result">,
13650b57cec5SDimitry Andric                    NoEncode<"$ea_result">;
136606c3fb27SDimitry Andricdef LWZU8 : DForm_1<33, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
136706c3fb27SDimitry Andric                    (ins (memri $D, $RA):$addr),
136806c3fb27SDimitry Andric                    "lwzu $RST, $addr", IIC_LdStLoadUpd,
13690b57cec5SDimitry Andric                    []>, RegConstraint<"$addr.reg = $ea_result">,
13700b57cec5SDimitry Andric                    NoEncode<"$ea_result">;
13710b57cec5SDimitry Andric
137206c3fb27SDimitry Andricdef LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
137306c3fb27SDimitry Andric                          (ins (memrr $RA, $RB):$addr),
137406c3fb27SDimitry Andric                          "lbzux $RST, $addr", IIC_LdStLoadUpdX,
13750b57cec5SDimitry Andric                          []>, RegConstraint<"$addr.ptrreg = $ea_result">,
13760b57cec5SDimitry Andric                          NoEncode<"$ea_result">;
137706c3fb27SDimitry Andricdef LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
137806c3fb27SDimitry Andric                          (ins (memrr $RA, $RB):$addr),
137906c3fb27SDimitry Andric                          "lhzux $RST, $addr", IIC_LdStLoadUpdX,
13800b57cec5SDimitry Andric                          []>, RegConstraint<"$addr.ptrreg = $ea_result">,
13810b57cec5SDimitry Andric                          NoEncode<"$ea_result">;
138206c3fb27SDimitry Andricdef LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
138306c3fb27SDimitry Andric                          (ins (memrr $RA, $RB):$addr),
138406c3fb27SDimitry Andric                          "lwzux $RST, $addr", IIC_LdStLoadUpdX,
13850b57cec5SDimitry Andric                          []>, RegConstraint<"$addr.ptrreg = $ea_result">,
13860b57cec5SDimitry Andric                          NoEncode<"$ea_result">;
13870b57cec5SDimitry Andric}
13880b57cec5SDimitry Andric}
13890b57cec5SDimitry Andric} // Interpretation64Bit
13900b57cec5SDimitry Andric
13910b57cec5SDimitry Andric
13920b57cec5SDimitry Andric// Full 8-byte loads.
13930b57cec5SDimitry Andriclet PPC970_Unit = 2 in {
139406c3fb27SDimitry Andricdef LD   : DSForm_1<58, 0, (outs g8rc:$RST), (ins (memrix $D, $RA):$addr),
139506c3fb27SDimitry Andric                    "ld $RST, $addr", IIC_LdStLD,
139606c3fb27SDimitry Andric                    [(set i64:$RST, (load DSForm:$addr))]>, isPPC64;
13970b57cec5SDimitry Andric// The following four definitions are selected for small code model only.
13980b57cec5SDimitry Andric// Otherwise, we need to create two instructions to form a 32-bit offset,
13990b57cec5SDimitry Andric// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
14000b57cec5SDimitry Andricdef LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
14010b57cec5SDimitry Andric                  "#LDtoc",
14020b57cec5SDimitry Andric                  [(set i64:$rD,
14030b57cec5SDimitry Andric                     (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
14040b57cec5SDimitry Andricdef LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
14050b57cec5SDimitry Andric                  "#LDtocJTI",
14060b57cec5SDimitry Andric                  [(set i64:$rD,
14070b57cec5SDimitry Andric                     (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
14080b57cec5SDimitry Andricdef LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
14090b57cec5SDimitry Andric                  "#LDtocCPT",
14100b57cec5SDimitry Andric                  [(set i64:$rD,
14110b57cec5SDimitry Andric                     (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
14120b57cec5SDimitry Andricdef LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
14130b57cec5SDimitry Andric                  "#LDtocCPT",
14140b57cec5SDimitry Andric                  [(set i64:$rD,
14150b57cec5SDimitry Andric                     (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
14160b57cec5SDimitry Andric
141706c3fb27SDimitry Andricdef LDX  : XForm_1_memOp<31,  21, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
141806c3fb27SDimitry Andric                        "ldx $RST, $addr", IIC_LdStLD,
141906c3fb27SDimitry Andric                        [(set i64:$RST, (load XForm:$addr))]>, isPPC64;
1420349cc55cSDimitry Andric
1421349cc55cSDimitry Andriclet Predicates = [IsISA2_06] in {
142206c3fb27SDimitry Andricdef LDBRX : XForm_1_memOp<31,  532, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
142306c3fb27SDimitry Andric                          "ldbrx $RST, $addr", IIC_LdStLoad,
142406c3fb27SDimitry Andric                          [(set i64:$RST, (PPClbrx ForceXForm:$addr, i64))]>, isPPC64;
1425349cc55cSDimitry Andric}
14260b57cec5SDimitry Andric
14270b57cec5SDimitry Andriclet mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
142806c3fb27SDimitry Andricdef LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
142906c3fb27SDimitry Andric                          "lhbrx $RST, $addr", IIC_LdStLoad, []>, ZExt32To64;
143006c3fb27SDimitry Andricdef LWBRX8 : XForm_1_memOp<31,  534, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
143106c3fb27SDimitry Andric                          "lwbrx $RST, $addr", IIC_LdStLoad, []>, ZExt32To64;
14320b57cec5SDimitry Andric}
14330b57cec5SDimitry Andric
14340b57cec5SDimitry Andriclet mayLoad = 1, hasSideEffects = 0 in {
143506c3fb27SDimitry Andricdef LDU  : DSForm_1<58, 1, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
143606c3fb27SDimitry Andric                    (ins (memrix $D, $RA):$addr),
143706c3fb27SDimitry Andric                    "ldu $RST, $addr", IIC_LdStLDU,
14380b57cec5SDimitry Andric                    []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
14390b57cec5SDimitry Andric                    NoEncode<"$ea_result">;
14400b57cec5SDimitry Andric
144106c3fb27SDimitry Andricdef LDUX : XForm_1_memOp<31, 53, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
144206c3fb27SDimitry Andric                        (ins (memrr $RA, $RB):$addr),
144306c3fb27SDimitry Andric                        "ldux $RST, $addr", IIC_LdStLDUX,
14440b57cec5SDimitry Andric                        []>, RegConstraint<"$addr.ptrreg = $ea_result">,
14450b57cec5SDimitry Andric                        NoEncode<"$ea_result">, isPPC64;
14460b57cec5SDimitry Andric}
1447fe6060f1SDimitry Andric
1448fe6060f1SDimitry Andriclet mayLoad = 1, hasNoSchedulingInfo = 1 in {
1449fe6060f1SDimitry Andric// Full 16-byte load.
1450fe6060f1SDimitry Andric// Early clobber $RTp to avoid assigned to the same register as RA.
1451fe6060f1SDimitry Andric// TODO: Add scheduling info.
1452fe6060f1SDimitry Andricdef LQ   : DQForm_RTp5_RA17_MEM<56, 0,
1453fe6060f1SDimitry Andric                                (outs g8prc:$RTp),
145406c3fb27SDimitry Andric                                (ins (memrix16 $DQ, $RA):$addr),
145506c3fb27SDimitry Andric                                "lq $RTp, $addr", IIC_LdStLQ,
1456fe6060f1SDimitry Andric                                []>,
1457fe6060f1SDimitry Andric                                RegConstraint<"@earlyclobber $RTp">,
1458fe6060f1SDimitry Andric                                isPPC64;
1459349cc55cSDimitry Andric// We don't really have LQX in the ISA, make a pseudo one so that we can
1460349cc55cSDimitry Andric// handle x-form during isel. Make it pre-ra may expose
1461349cc55cSDimitry Andric// oppotunities to some opts(CSE, LICM and etc.) for the result of adding
1462349cc55cSDimitry Andric// RA and RB.
1463349cc55cSDimitry Andricdef LQX_PSEUDO : PPCCustomInserterPseudo<(outs g8prc:$RTp),
1464349cc55cSDimitry Andric                                         (ins memrr:$src), "#LQX_PSEUDO", []>;
1465349cc55cSDimitry Andric
1466fe6060f1SDimitry Andricdef RESTORE_QUADWORD : PPCEmitTimePseudo<(outs g8prc:$RTp), (ins memrix:$src),
1467fe6060f1SDimitry Andric                                         "#RESTORE_QUADWORD", []>;
1468fe6060f1SDimitry Andric}
1469fe6060f1SDimitry Andric
14700b57cec5SDimitry Andric}
14710b57cec5SDimitry Andric
1472349cc55cSDimitry Andricdef : Pat<(int_ppc_atomic_load_i128 iaddrX16:$src),
1473349cc55cSDimitry Andric          (SPLIT_QUADWORD (LQ memrix16:$src))>;
1474349cc55cSDimitry Andric
1475349cc55cSDimitry Andricdef : Pat<(int_ppc_atomic_load_i128 ForceXForm:$src),
1476349cc55cSDimitry Andric          (SPLIT_QUADWORD (LQX_PSEUDO memrr:$src))>;
1477349cc55cSDimitry Andric
14780b57cec5SDimitry Andric// Support for medium and large code model.
14790b57cec5SDimitry Andriclet hasSideEffects = 0 in {
14800b57cec5SDimitry Andriclet isReMaterializable = 1 in {
14818bcb0991SDimitry Andricdef ADDIStocHA8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
14828bcb0991SDimitry Andric                       "#ADDIStocHA8", []>, isPPC64;
14830fca6ea1SDimitry Andricdef ADDItocL8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
14840fca6ea1SDimitry Andric                     "#ADDItocL8", []>, isPPC64;
14850b57cec5SDimitry Andric}
14864824e7fdSDimitry Andric
14874824e7fdSDimitry Andric// Local Data Transform
14880fca6ea1SDimitry Andricdef ADDItoc8 : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
14894824e7fdSDimitry Andric                   "#ADDItoc8",
14900fca6ea1SDimitry Andric                   []>, isPPC64;
14910b57cec5SDimitry Andriclet mayLoad = 1 in
14920b57cec5SDimitry Andricdef LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
14930b57cec5SDimitry Andric                   "#LDtocL", []>, isPPC64;
14940b57cec5SDimitry Andric}
14950b57cec5SDimitry Andric
14960b57cec5SDimitry Andric// Support for thread-local storage.
14970b57cec5SDimitry Andricdef ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
14980b57cec5SDimitry Andric                         "#ADDISgotTprelHA",
14990b57cec5SDimitry Andric                         [(set i64:$rD,
15000b57cec5SDimitry Andric                           (PPCaddisGotTprelHA i64:$reg,
15010b57cec5SDimitry Andric                                               tglobaltlsaddr:$disp))]>,
15020b57cec5SDimitry Andric                  isPPC64;
15036dce2be1SDimitry Andricdef LDgotTprelL: PPCEmitTimePseudo<(outs g8rc_nox0:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
15040b57cec5SDimitry Andric                        "#LDgotTprelL",
15050b57cec5SDimitry Andric                        [(set i64:$rD,
15060b57cec5SDimitry Andric                          (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
15070b57cec5SDimitry Andric                 isPPC64;
15080b57cec5SDimitry Andric
15090b57cec5SDimitry Andriclet Defs = [CR7], Itinerary = IIC_LdStSync in
15100b57cec5SDimitry Andricdef CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
15110b57cec5SDimitry Andric
15120b57cec5SDimitry Andricdef : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
15130b57cec5SDimitry Andric          (ADD8TLS $in, tglobaltlsaddr:$g)>;
15140b57cec5SDimitry Andricdef ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
15150b57cec5SDimitry Andric                         "#ADDIStlsgdHA",
15160b57cec5SDimitry Andric                         [(set i64:$rD,
15170b57cec5SDimitry Andric                           (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
15180b57cec5SDimitry Andric                  isPPC64;
15190b57cec5SDimitry Andricdef ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
15200b57cec5SDimitry Andric                       "#ADDItlsgdL",
15210b57cec5SDimitry Andric                       [(set i64:$rD,
15220b57cec5SDimitry Andric                         (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
15230b57cec5SDimitry Andric                 isPPC64;
1524e8d8bef9SDimitry Andric
1525e8d8bef9SDimitry Andricclass GETtlsADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1526e8d8bef9SDimitry Andric                                             asmstr,
1527e8d8bef9SDimitry Andric                                             [(set i64:$rD,
1528e8d8bef9SDimitry Andric                                               (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1529e8d8bef9SDimitry Andric                                      isPPC64;
1530e8d8bef9SDimitry Andricclass GETtlsldADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1531e8d8bef9SDimitry Andric                                             asmstr,
1532e8d8bef9SDimitry Andric                                             [(set i64:$rD,
1533e8d8bef9SDimitry Andric                                               (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1534e8d8bef9SDimitry Andric                                      isPPC64;
1535e8d8bef9SDimitry Andric
1536e8d8bef9SDimitry Andriclet hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1 in {
15370b57cec5SDimitry Andric// LR8 is a true define, while the rest of the Defs are clobbers. X3 is
15380b57cec5SDimitry Andric// explicitly defined when this op is created, so not mentioned here.
15390b57cec5SDimitry Andric// This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
15400b57cec5SDimitry Andric// correct because the branch select pass is relying on it.
1541e8d8bef9SDimitry Andriclet Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1542e8d8bef9SDimitry Andricdef GETtlsADDR : GETtlsADDRPseudo <"#GETtlsADDR">;
1543e8d8bef9SDimitry Andriclet Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1544e8d8bef9SDimitry Andricdef GETtlsADDRPCREL : GETtlsADDRPseudo <"#GETtlsADDRPCREL">;
1545e8d8bef9SDimitry Andric
1546e8d8bef9SDimitry Andric// LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1547e8d8bef9SDimitry Andric// explicitly defined when this op is created, so not mentioned here.
1548e8d8bef9SDimitry Andriclet Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1549e8d8bef9SDimitry Andricdef GETtlsldADDR : GETtlsldADDRPseudo <"#GETtlsldADDR">;
1550e8d8bef9SDimitry Andriclet Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1551e8d8bef9SDimitry Andricdef GETtlsldADDRPCREL : GETtlsldADDRPseudo <"#GETtlsldADDRPCREL">;
1552fe6060f1SDimitry Andric
1553fe6060f1SDimitry Andric// On AIX, the call to __tls_get_addr needs two inputs in X3/X4 for the
1554fe6060f1SDimitry Andric// offset and region handle respectively. The call is not followed by a nop
1555fe6060f1SDimitry Andric// so we don't need to mark it with a size of 8 bytes. Finally, the assembly
1556fe6060f1SDimitry Andric// manual mentions this exact set of registers as the clobbered set, others
1557fe6060f1SDimitry Andric// are guaranteed not to be clobbered.
15580fca6ea1SDimitry Andriclet Defs = [X0,X4,X5,X11,LR8,CR0] in {
1559fe6060f1SDimitry Andricdef GETtlsADDR64AIX :
1560fe6060f1SDimitry Andric  PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$offset, g8rc:$handle),
1561fe6060f1SDimitry Andric                    "GETtlsADDR64AIX",
1562fe6060f1SDimitry Andric                    [(set i64:$rD,
1563fe6060f1SDimitry Andric                      (PPCgetTlsAddr i64:$offset, i64:$handle))]>, isPPC64;
15640fca6ea1SDimitry Andric// On AIX, the call to .__tls_get_mod needs one input in X3 for the module handle.
15650fca6ea1SDimitry Andricdef GETtlsMOD64AIX :
15660fca6ea1SDimitry Andric  PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$handle),
15670fca6ea1SDimitry Andric                    "GETtlsMOD64AIX",
15680fca6ea1SDimitry Andric                    [(set i64:$rD,
15690fca6ea1SDimitry Andric                      (PPCgetTlsMod i64:$handle))]>, isPPC64;
15700fca6ea1SDimitry Andric}
1571e8d8bef9SDimitry Andric}
1572e8d8bef9SDimitry Andric
15730b57cec5SDimitry Andric// Combined op for ADDItlsgdL and GETtlsADDR, late expanded.  X3 and LR8
15740b57cec5SDimitry Andric// are true defines while the rest of the Defs are clobbers.
15750b57cec5SDimitry Andriclet hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
15760b57cec5SDimitry Andric    Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
15770b57cec5SDimitry Andric    in
15780b57cec5SDimitry Andricdef ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
15790b57cec5SDimitry Andric                            (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
15800b57cec5SDimitry Andric                            "#ADDItlsgdLADDR",
15810b57cec5SDimitry Andric                            [(set i64:$rD,
15820b57cec5SDimitry Andric                              (PPCaddiTlsgdLAddr i64:$reg,
15830b57cec5SDimitry Andric                                                 tglobaltlsaddr:$disp,
15840b57cec5SDimitry Andric                                                 tglobaltlsaddr:$sym))]>,
15850b57cec5SDimitry Andric                     isPPC64;
15860b57cec5SDimitry Andricdef ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
15870b57cec5SDimitry Andric                         "#ADDIStlsldHA",
15880b57cec5SDimitry Andric                         [(set i64:$rD,
15890b57cec5SDimitry Andric                           (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
15900b57cec5SDimitry Andric                  isPPC64;
15910b57cec5SDimitry Andricdef ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
15920b57cec5SDimitry Andric                       "#ADDItlsldL",
15930b57cec5SDimitry Andric                       [(set i64:$rD,
15940b57cec5SDimitry Andric                         (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
15950b57cec5SDimitry Andric                 isPPC64;
1596fe6060f1SDimitry Andric// This pseudo is expanded to two copies to put the variable offset in R4 and
1597fe6060f1SDimitry Andric// the region handle in R3 and GETtlsADDR64AIX.
1598fe6060f1SDimitry Andricdef TLSGDAIX8 :
1599fe6060f1SDimitry Andric  PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$offset, g8rc:$handle),
1600fe6060f1SDimitry Andric                     "#TLSGDAIX8",
1601fe6060f1SDimitry Andric                     [(set i64:$rD,
1602fe6060f1SDimitry Andric                       (PPCTlsgdAIX i64:$offset, i64:$handle))]>;
16030fca6ea1SDimitry Andric// This pseudo is expanded to the call to GETtlsMOD64AIX.
16040fca6ea1SDimitry Andricdef TLSLDAIX8 : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$handle),
16050fca6ea1SDimitry Andric                     "#TLSLDAIX8", [(set i64:$rD, (PPCTlsldAIX i64:$handle))]>;
16060b57cec5SDimitry Andric// Combined op for ADDItlsldL and GETtlsADDR, late expanded.  X3 and LR8
16070b57cec5SDimitry Andric// are true defines, while the rest of the Defs are clobbers.
16080b57cec5SDimitry Andriclet hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
16090b57cec5SDimitry Andric    Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
16100b57cec5SDimitry Andric    in
16110b57cec5SDimitry Andricdef ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
16120b57cec5SDimitry Andric                            (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
16130b57cec5SDimitry Andric                            "#ADDItlsldLADDR",
16140b57cec5SDimitry Andric                            [(set i64:$rD,
16150b57cec5SDimitry Andric                              (PPCaddiTlsldLAddr i64:$reg,
16160b57cec5SDimitry Andric                                                 tglobaltlsaddr:$disp,
16170b57cec5SDimitry Andric                                                 tglobaltlsaddr:$sym))]>,
16180b57cec5SDimitry Andric                     isPPC64;
16190b57cec5SDimitry Andricdef ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
16200b57cec5SDimitry Andric                          "#ADDISdtprelHA",
16210b57cec5SDimitry Andric                          [(set i64:$rD,
16220b57cec5SDimitry Andric                            (PPCaddisDtprelHA i64:$reg,
16230b57cec5SDimitry Andric                                              tglobaltlsaddr:$disp))]>,
16240b57cec5SDimitry Andric                   isPPC64;
16250b57cec5SDimitry Andricdef ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
16260b57cec5SDimitry Andric                         "#ADDIdtprelL",
16270b57cec5SDimitry Andric                         [(set i64:$rD,
16280b57cec5SDimitry Andric                           (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
16290b57cec5SDimitry Andric                  isPPC64;
1630e8d8bef9SDimitry Andricdef PADDIdtprel : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1631e8d8bef9SDimitry Andric                          "#PADDIdtprel",
1632e8d8bef9SDimitry Andric                          [(set i64:$rD,
1633e8d8bef9SDimitry Andric                            (PPCpaddiDtprel i64:$reg, tglobaltlsaddr:$disp))]>,
1634e8d8bef9SDimitry Andric                  isPPC64;
16350b57cec5SDimitry Andric
16360b57cec5SDimitry Andriclet PPC970_Unit = 2 in {
16370b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
16380b57cec5SDimitry Andric// Truncating stores.
163906c3fb27SDimitry Andricdef STB8 : DForm_1<38, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
164006c3fb27SDimitry Andric                   "stb $RST, $addr", IIC_LdStStore,
164106c3fb27SDimitry Andric                   [(truncstorei8 i64:$RST, DForm:$addr)]>;
164206c3fb27SDimitry Andricdef STH8 : DForm_1<44, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
164306c3fb27SDimitry Andric                   "sth $RST, $addr", IIC_LdStStore,
164406c3fb27SDimitry Andric                   [(truncstorei16 i64:$RST, DForm:$addr)]>;
164506c3fb27SDimitry Andricdef STW8 : DForm_1<36, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
164606c3fb27SDimitry Andric                   "stw $RST, $addr", IIC_LdStStore,
164706c3fb27SDimitry Andric                   [(truncstorei32 i64:$RST, DForm:$addr)]>;
164806c3fb27SDimitry Andricdef STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
164906c3fb27SDimitry Andric                          "stbx $RST, $addr", IIC_LdStStore,
165006c3fb27SDimitry Andric                          [(truncstorei8 i64:$RST, XForm:$addr)]>,
16510b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
165206c3fb27SDimitry Andricdef STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
165306c3fb27SDimitry Andric                          "sthx $RST, $addr", IIC_LdStStore,
165406c3fb27SDimitry Andric                          [(truncstorei16 i64:$RST, XForm:$addr)]>,
16550b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
165606c3fb27SDimitry Andricdef STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
165706c3fb27SDimitry Andric                          "stwx $RST, $addr", IIC_LdStStore,
165806c3fb27SDimitry Andric                          [(truncstorei32 i64:$RST, XForm:$addr)]>,
16590b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
16600b57cec5SDimitry Andric} // Interpretation64Bit
16610b57cec5SDimitry Andric
16620b57cec5SDimitry Andric// Normal 8-byte stores.
166306c3fb27SDimitry Andricdef STD  : DSForm_1<62, 0, (outs), (ins g8rc:$RST, (memrix $D, $RA):$addr),
166406c3fb27SDimitry Andric                    "std $RST, $addr", IIC_LdStSTD,
166506c3fb27SDimitry Andric                    [(store i64:$RST, DSForm:$addr)]>, isPPC64;
166606c3fb27SDimitry Andricdef STDX  : XForm_8_memOp<31, 149, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
166706c3fb27SDimitry Andric                          "stdx $RST, $addr", IIC_LdStSTD,
166806c3fb27SDimitry Andric                          [(store i64:$RST, XForm:$addr)]>, isPPC64,
16690b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
1670349cc55cSDimitry Andric
1671349cc55cSDimitry Andriclet Predicates = [IsISA2_06] in {
167206c3fb27SDimitry Andricdef STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
167306c3fb27SDimitry Andric                          "stdbrx $RST, $addr", IIC_LdStStore,
167406c3fb27SDimitry Andric                          [(PPCstbrx i64:$RST, ForceXForm:$addr, i64)]>, isPPC64,
16750b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
1676349cc55cSDimitry Andric}
1677fe6060f1SDimitry Andric
1678fe6060f1SDimitry Andriclet mayStore = 1, hasNoSchedulingInfo = 1 in {
1679fe6060f1SDimitry Andric// Normal 16-byte stores.
1680fe6060f1SDimitry Andric// TODO: Add scheduling info.
168106c3fb27SDimitry Andricdef STQ : DSForm_1<62, 2, (outs), (ins g8prc:$RST, (memrix $D, $RA):$addr),
168206c3fb27SDimitry Andric                   "stq $RST, $addr", IIC_LdStSTQ,
1683fe6060f1SDimitry Andric                   []>, isPPC64;
1684349cc55cSDimitry Andric
1685349cc55cSDimitry Andricdef STQX_PSEUDO : PPCCustomInserterPseudo<(outs),
1686349cc55cSDimitry Andric                                          (ins g8prc:$RSp, memrr:$dst),
1687349cc55cSDimitry Andric                                          "#STQX_PSEUDO", []>;
1688349cc55cSDimitry Andric
1689fe6060f1SDimitry Andricdef SPILL_QUADWORD : PPCEmitTimePseudo<(outs), (ins g8prc:$RSp, memrix:$dst),
1690fe6060f1SDimitry Andric                                       "#SPILL_QUADWORD", []>;
1691fe6060f1SDimitry Andric}
1692fe6060f1SDimitry Andric
16930b57cec5SDimitry Andric}
16940b57cec5SDimitry Andric
1695349cc55cSDimitry Andricdef BUILD_QUADWORD : PPCPostRAExpPseudo<
1696349cc55cSDimitry Andric                       (outs g8prc:$RTp),
1697349cc55cSDimitry Andric                       (ins g8rc:$lo, g8rc:$hi),
1698349cc55cSDimitry Andric                       "#BUILD_QUADWORD", []>;
1699349cc55cSDimitry Andric
1700349cc55cSDimitry Andricdef : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, DSForm:$dst),
1701349cc55cSDimitry Andric          (STQ (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrix:$dst)>;
1702349cc55cSDimitry Andric
1703349cc55cSDimitry Andricdef : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, ForceXForm:$dst),
1704349cc55cSDimitry Andric          (STQX_PSEUDO (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrr:$dst)>;
1705349cc55cSDimitry Andric
17060b57cec5SDimitry Andric// Stores with Update (pre-inc).
17070b57cec5SDimitry Andriclet PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
17080b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
170906c3fb27SDimitry Andricdef STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
171006c3fb27SDimitry Andric                   "stbu $RST, $addr", IIC_LdStSTU, []>,
171106c3fb27SDimitry Andric                   RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
171206c3fb27SDimitry Andricdef STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
171306c3fb27SDimitry Andric                   "sthu $RST, $addr", IIC_LdStSTU, []>,
171406c3fb27SDimitry Andric                   RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
171506c3fb27SDimitry Andricdef STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
171606c3fb27SDimitry Andric                   "stwu $RST, $addr", IIC_LdStSTU, []>,
171706c3fb27SDimitry Andric                   RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
17180b57cec5SDimitry Andric
17190b57cec5SDimitry Andricdef STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
172006c3fb27SDimitry Andric                          (ins g8rc:$RST, (memrr $RA, $RB):$addr),
172106c3fb27SDimitry Andric                          "stbux $RST, $addr", IIC_LdStSTUX, []>,
172206c3fb27SDimitry Andric                          RegConstraint<"$addr.ptrreg = $ea_res">,
17230b57cec5SDimitry Andric                          NoEncode<"$ea_res">,
17240b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
17250b57cec5SDimitry Andricdef STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
172606c3fb27SDimitry Andric                          (ins g8rc:$RST, (memrr $RA, $RB):$addr),
172706c3fb27SDimitry Andric                          "sthux $RST, $addr", IIC_LdStSTUX, []>,
172806c3fb27SDimitry Andric                          RegConstraint<"$addr.ptrreg = $ea_res">,
17290b57cec5SDimitry Andric                          NoEncode<"$ea_res">,
17300b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
17310b57cec5SDimitry Andricdef STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
173206c3fb27SDimitry Andric                          (ins g8rc:$RST, (memrr $RA, $RB):$addr),
173306c3fb27SDimitry Andric                          "stwux $RST, $addr", IIC_LdStSTUX, []>,
173406c3fb27SDimitry Andric                          RegConstraint<"$addr.ptrreg = $ea_res">,
17350b57cec5SDimitry Andric                          NoEncode<"$ea_res">,
17360b57cec5SDimitry Andric                          PPC970_DGroup_Cracked;
17370b57cec5SDimitry Andric} // Interpretation64Bit
17380b57cec5SDimitry Andric
17390b57cec5SDimitry Andricdef STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
174006c3fb27SDimitry Andric                   (ins g8rc:$RST, (memrix $D, $RA):$addr),
174106c3fb27SDimitry Andric                   "stdu $RST, $addr", IIC_LdStSTU, []>,
174206c3fb27SDimitry Andric                   RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">,
17430b57cec5SDimitry Andric                   isPPC64;
17440b57cec5SDimitry Andric
17450b57cec5SDimitry Andricdef STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
174606c3fb27SDimitry Andric                          (ins g8rc:$RST, (memrr $RA, $RB):$addr),
174706c3fb27SDimitry Andric                          "stdux $RST, $addr", IIC_LdStSTUX, []>,
174806c3fb27SDimitry Andric                          RegConstraint<"$addr.ptrreg = $ea_res">,
17490b57cec5SDimitry Andric                          NoEncode<"$ea_res">,
17500b57cec5SDimitry Andric                          PPC970_DGroup_Cracked, isPPC64;
17510b57cec5SDimitry Andric}
17520b57cec5SDimitry Andric
17530b57cec5SDimitry Andric// Patterns to match the pre-inc stores.  We can't put the patterns on
17540b57cec5SDimitry Andric// the instruction definitions directly as ISel wants the address base
17550b57cec5SDimitry Andric// and offset to be separate operands, not a single complex operand.
17560b57cec5SDimitry Andricdef : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
17570b57cec5SDimitry Andric          (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
17580b57cec5SDimitry Andricdef : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
17590b57cec5SDimitry Andric          (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
17600b57cec5SDimitry Andricdef : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
17610b57cec5SDimitry Andric          (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1762e8d8bef9SDimitry Andricdef : Pat<(DSFormPreStore i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
17630b57cec5SDimitry Andric          (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
17640b57cec5SDimitry Andric
17650b57cec5SDimitry Andricdef : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
17660b57cec5SDimitry Andric          (STBUX8 $rS, $ptrreg, $ptroff)>;
17670b57cec5SDimitry Andricdef : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
17680b57cec5SDimitry Andric          (STHUX8 $rS, $ptrreg, $ptroff)>;
17690b57cec5SDimitry Andricdef : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
17700b57cec5SDimitry Andric          (STWUX8 $rS, $ptrreg, $ptroff)>;
17710b57cec5SDimitry Andricdef : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
17720b57cec5SDimitry Andric          (STDUX $rS, $ptrreg, $ptroff)>;
17730b57cec5SDimitry Andric
17740b57cec5SDimitry Andric
17750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17760b57cec5SDimitry Andric// Floating point instructions.
17770b57cec5SDimitry Andric//
17780b57cec5SDimitry Andric
17790b57cec5SDimitry Andric
1780e8d8bef9SDimitry Andriclet PPC970_Unit = 3, hasSideEffects = 0, mayRaiseFPException = 1,
17810b57cec5SDimitry Andric    Uses = [RM] in {  // FPU Operations.
178206c3fb27SDimitry Andricdefm FCFID  : XForm_26r<63, 846, (outs f8rc:$RST), (ins f8rc:$RB),
178306c3fb27SDimitry Andric                        "fcfid", "$RST, $RB", IIC_FPGeneral,
178406c3fb27SDimitry Andric                        [(set f64:$RST, (PPCany_fcfid f64:$RB))]>, isPPC64;
178506c3fb27SDimitry Andricdefm FCTID  : XForm_26r<63, 814, (outs f8rc:$RST), (ins f8rc:$RB),
178606c3fb27SDimitry Andric                        "fctid", "$RST, $RB", IIC_FPGeneral,
17870b57cec5SDimitry Andric                        []>, isPPC64;
178806c3fb27SDimitry Andricdefm FCTIDU : XForm_26r<63, 942, (outs f8rc:$RST), (ins f8rc:$RB),
178906c3fb27SDimitry Andric                        "fctidu", "$RST, $RB", IIC_FPGeneral,
17900b57cec5SDimitry Andric                        []>, isPPC64;
179106c3fb27SDimitry Andricdefm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$RST), (ins f8rc:$RB),
179206c3fb27SDimitry Andric                        "fctidz", "$RST, $RB", IIC_FPGeneral,
179306c3fb27SDimitry Andric                        [(set f64:$RST, (PPCany_fctidz f64:$RB))]>, isPPC64;
17940b57cec5SDimitry Andric
179506c3fb27SDimitry Andricdefm FCFIDU  : XForm_26r<63, 974, (outs f8rc:$RST), (ins f8rc:$RB),
179606c3fb27SDimitry Andric                        "fcfidu", "$RST, $RB", IIC_FPGeneral,
179706c3fb27SDimitry Andric                        [(set f64:$RST, (PPCany_fcfidu f64:$RB))]>, isPPC64;
179806c3fb27SDimitry Andricdefm FCFIDS  : XForm_26r<59, 846, (outs f4rc:$RST), (ins f8rc:$RB),
179906c3fb27SDimitry Andric                        "fcfids", "$RST, $RB", IIC_FPGeneral,
180006c3fb27SDimitry Andric                        [(set f32:$RST, (PPCany_fcfids f64:$RB))]>, isPPC64;
180106c3fb27SDimitry Andricdefm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$RST), (ins f8rc:$RB),
180206c3fb27SDimitry Andric                        "fcfidus", "$RST, $RB", IIC_FPGeneral,
180306c3fb27SDimitry Andric                        [(set f32:$RST, (PPCany_fcfidus f64:$RB))]>, isPPC64;
180406c3fb27SDimitry Andricdefm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$RST), (ins f8rc:$RB),
180506c3fb27SDimitry Andric                        "fctiduz", "$RST, $RB", IIC_FPGeneral,
180606c3fb27SDimitry Andric                        [(set f64:$RST, (PPCany_fctiduz f64:$RB))]>, isPPC64;
180706c3fb27SDimitry Andricdefm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$RST), (ins f8rc:$RB),
180806c3fb27SDimitry Andric                        "fctiwuz", "$RST, $RB", IIC_FPGeneral,
180906c3fb27SDimitry Andric                        [(set f64:$RST, (PPCany_fctiwuz f64:$RB))]>, isPPC64;
18100b57cec5SDimitry Andric}
18110b57cec5SDimitry Andric
1812fe6060f1SDimitry Andric// These instructions store a hash computed from the value of the link register
1813fe6060f1SDimitry Andric// and the value of the stack pointer.
181404eeddc0SDimitry Andriclet mayStore = 1, Interpretation64Bit = 1, isCodeGenOnly = 1 in {
181504eeddc0SDimitry Andricdef HASHST8 : XForm_XD6_RA5_RB5<31, 722, (outs),
181606c3fb27SDimitry Andric                                (ins g8rc:$RB, (memrihash $D, $RA):$addr),
181706c3fb27SDimitry Andric                                "hashst $RB, $addr", IIC_IntGeneral, []>;
181804eeddc0SDimitry Andricdef HASHSTP8 : XForm_XD6_RA5_RB5<31, 658, (outs),
181906c3fb27SDimitry Andric                                 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
182006c3fb27SDimitry Andric                                 "hashstp $RB, $addr", IIC_IntGeneral, []>;
1821fe6060f1SDimitry Andric}
1822fe6060f1SDimitry Andric
1823fe6060f1SDimitry Andric// These instructions check a hash computed from the value of the link register
1824fe6060f1SDimitry Andric// and the value of the stack pointer. The hasSideEffects flag is needed as the
1825fe6060f1SDimitry Andric// instruction may TRAP if the hash does not match the hash stored at the
1826fe6060f1SDimitry Andric// specified address.
182704eeddc0SDimitry Andriclet mayLoad = 1, hasSideEffects = 1,
182804eeddc0SDimitry Andric    Interpretation64Bit = 1, isCodeGenOnly = 1 in {
182904eeddc0SDimitry Andricdef HASHCHK8 : XForm_XD6_RA5_RB5<31, 754, (outs),
183006c3fb27SDimitry Andric                                 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
183106c3fb27SDimitry Andric                                 "hashchk $RB, $addr", IIC_IntGeneral, []>;
183204eeddc0SDimitry Andricdef HASHCHKP8 : XForm_XD6_RA5_RB5<31, 690, (outs),
183306c3fb27SDimitry Andric                                  (ins g8rc:$RB, (memrihash $D, $RA):$addr),
183406c3fb27SDimitry Andric                                  "hashchkp $RB, $addr", IIC_IntGeneral, []>;
1835fe6060f1SDimitry Andric}
18360b57cec5SDimitry Andric
1837349cc55cSDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1, hasSideEffects = 1 in
183806c3fb27SDimitry Andricdef ADDEX8 : Z23Form_RTAB5_CY2<31, 170, (outs g8rc:$RT),
183906c3fb27SDimitry Andric                              (ins g8rc:$RA, g8rc:$RB, u2imm:$CY),
184006c3fb27SDimitry Andric                              "addex $RT, $RA, $RB, $CY", IIC_IntGeneral,
184106c3fb27SDimitry Andric                              [(set i64:$RT, (int_ppc_addex i64:$RA, i64:$RB,
1842349cc55cSDimitry Andric                                                            timm:$CY))]>;
1843349cc55cSDimitry Andric
18440b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18450b57cec5SDimitry Andric// Instruction Patterns
18460b57cec5SDimitry Andric//
18470b57cec5SDimitry Andric
18480b57cec5SDimitry Andric// Extensions and truncates to/from 32-bit regs.
18490b57cec5SDimitry Andricdef : Pat<(i64 (zext i32:$in)),
18500b57cec5SDimitry Andric          (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
18510b57cec5SDimitry Andric                  0, 32)>;
18520b57cec5SDimitry Andricdef : Pat<(i64 (anyext i32:$in)),
18530b57cec5SDimitry Andric          (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
18540b57cec5SDimitry Andricdef : Pat<(i32 (trunc i64:$in)),
18550b57cec5SDimitry Andric          (EXTRACT_SUBREG $in, sub_32)>;
18560b57cec5SDimitry Andric
18570b57cec5SDimitry Andric// Implement the 'not' operation with the NOR instruction.
18580b57cec5SDimitry Andric// (we could use the default xori pattern, but nor has lower latency on some
18590b57cec5SDimitry Andric// cores (such as the A2)).
18600b57cec5SDimitry Andricdef i64not : OutPatFrag<(ops node:$in),
18610b57cec5SDimitry Andric                        (NOR8 $in, $in)>;
18620b57cec5SDimitry Andricdef        : Pat<(not i64:$in),
18630b57cec5SDimitry Andric                 (i64not $in)>;
18640b57cec5SDimitry Andric
18650b57cec5SDimitry Andric// Extending loads with i64 targets.
1866fe6060f1SDimitry Andricdef : Pat<(zextloadi1 DForm:$src),
1867fe6060f1SDimitry Andric          (LBZ8 DForm:$src)>;
1868fe6060f1SDimitry Andricdef : Pat<(zextloadi1 XForm:$src),
1869fe6060f1SDimitry Andric          (LBZX8 XForm:$src)>;
1870fe6060f1SDimitry Andricdef : Pat<(extloadi1 DForm:$src),
1871fe6060f1SDimitry Andric          (LBZ8 DForm:$src)>;
1872fe6060f1SDimitry Andricdef : Pat<(extloadi1 XForm:$src),
1873fe6060f1SDimitry Andric          (LBZX8 XForm:$src)>;
1874fe6060f1SDimitry Andricdef : Pat<(extloadi8 DForm:$src),
1875fe6060f1SDimitry Andric          (LBZ8 DForm:$src)>;
1876fe6060f1SDimitry Andricdef : Pat<(extloadi8 XForm:$src),
1877fe6060f1SDimitry Andric          (LBZX8 XForm:$src)>;
1878fe6060f1SDimitry Andricdef : Pat<(extloadi16 DForm:$src),
1879fe6060f1SDimitry Andric          (LHZ8 DForm:$src)>;
1880fe6060f1SDimitry Andricdef : Pat<(extloadi16 XForm:$src),
1881fe6060f1SDimitry Andric          (LHZX8 XForm:$src)>;
1882fe6060f1SDimitry Andricdef : Pat<(extloadi32 DForm:$src),
1883fe6060f1SDimitry Andric          (LWZ8 DForm:$src)>;
1884fe6060f1SDimitry Andricdef : Pat<(extloadi32 XForm:$src),
1885fe6060f1SDimitry Andric          (LWZX8 XForm:$src)>;
18860b57cec5SDimitry Andric
18870b57cec5SDimitry Andric// Standard shifts.  These are represented separately from the real shifts above
18880b57cec5SDimitry Andric// so that we can distinguish between shifts that allow 6-bit and 7-bit shift
18890b57cec5SDimitry Andric// amounts.
18900b57cec5SDimitry Andricdef : Pat<(sra i64:$rS, i32:$rB),
18910b57cec5SDimitry Andric          (SRAD $rS, $rB)>;
18920b57cec5SDimitry Andricdef : Pat<(srl i64:$rS, i32:$rB),
18930b57cec5SDimitry Andric          (SRD $rS, $rB)>;
18940b57cec5SDimitry Andricdef : Pat<(shl i64:$rS, i32:$rB),
18950b57cec5SDimitry Andric          (SLD $rS, $rB)>;
18960b57cec5SDimitry Andric
18970b57cec5SDimitry Andric// SUBFIC
18980b57cec5SDimitry Andricdef : Pat<(sub imm64SExt16:$imm, i64:$in),
18990b57cec5SDimitry Andric          (SUBFIC8 $in, imm:$imm)>;
19000b57cec5SDimitry Andric
19010b57cec5SDimitry Andric// SHL/SRL
19020b57cec5SDimitry Andricdef : Pat<(shl i64:$in, (i32 imm:$imm)),
19030b57cec5SDimitry Andric          (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
19040b57cec5SDimitry Andricdef : Pat<(srl i64:$in, (i32 imm:$imm)),
19050b57cec5SDimitry Andric          (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
19060b57cec5SDimitry Andric
19070b57cec5SDimitry Andric// ROTL
19080b57cec5SDimitry Andricdef : Pat<(rotl i64:$in, i32:$sh),
19090b57cec5SDimitry Andric          (RLDCL $in, $sh, 0)>;
19100b57cec5SDimitry Andricdef : Pat<(rotl i64:$in, (i32 imm:$imm)),
19110b57cec5SDimitry Andric          (RLDICL $in, imm:$imm, 0)>;
19120b57cec5SDimitry Andric
19130b57cec5SDimitry Andric// Hi and Lo for Darwin Global Addresses.
19140b57cec5SDimitry Andricdef : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
19150b57cec5SDimitry Andricdef : Pat<(PPClo tglobaladdr:$in, 0), (LI8  tglobaladdr:$in)>;
19160b57cec5SDimitry Andricdef : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
19170b57cec5SDimitry Andricdef : Pat<(PPClo tconstpool:$in , 0), (LI8  tconstpool:$in)>;
19180b57cec5SDimitry Andricdef : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
19190b57cec5SDimitry Andricdef : Pat<(PPClo tjumptable:$in , 0), (LI8  tjumptable:$in)>;
19200b57cec5SDimitry Andricdef : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
19210b57cec5SDimitry Andricdef : Pat<(PPClo tblockaddress:$in, 0), (LI8  tblockaddress:$in)>;
19220b57cec5SDimitry Andricdef : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
19230b57cec5SDimitry Andric          (ADDIS8 $in, tglobaltlsaddr:$g)>;
19240b57cec5SDimitry Andricdef : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
19250b57cec5SDimitry Andric          (ADDI8 $in, tglobaltlsaddr:$g)>;
19260b57cec5SDimitry Andricdef : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
19270b57cec5SDimitry Andric          (ADDIS8 $in, tglobaladdr:$g)>;
19280b57cec5SDimitry Andricdef : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
19290b57cec5SDimitry Andric          (ADDIS8 $in, tconstpool:$g)>;
19300b57cec5SDimitry Andricdef : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
19310b57cec5SDimitry Andric          (ADDIS8 $in, tjumptable:$g)>;
19320b57cec5SDimitry Andricdef : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
19330b57cec5SDimitry Andric          (ADDIS8 $in, tblockaddress:$g)>;
19340b57cec5SDimitry Andric
1935fe6060f1SDimitry Andric// AIX 64-bit small code model TLS access.
193606c3fb27SDimitry Andric// This is used for global dynamic accesses when loading the region handle and
193706c3fb27SDimitry Andric// variable offset, and also for local-exec accesses to load the offset of a
193806c3fb27SDimitry Andric// TLS variable from the TOC, prior to adding it to r13.
1939fe6060f1SDimitry Andricdef : Pat<(i64 (PPCtoc_entry tglobaltlsaddr:$disp, i64:$reg)),
1940fe6060f1SDimitry Andric          (i64 (LDtoc tglobaltlsaddr:$disp, i64:$reg))>;
19410b57cec5SDimitry Andric
19425f757f3fSDimitry Andric// The following pattern matches 64-bit local- and initial-exec TLS accesses on AIX.
19435f757f3fSDimitry Andric// PPCaddTls is used in local- and initial-exec accesses in order to:
194406c3fb27SDimitry Andric//   - Get the address of a variable (adding the variable offset to the thread
194506c3fb27SDimitry Andric//     pointer in r13).
194606c3fb27SDimitry Andric//   - Create an opportunity to optimize the user of the loaded address.
194706c3fb27SDimitry Andricdef : Pat<(PPCaddTls i64:$in, i64:$addr),
194806c3fb27SDimitry Andric          (ADD8TLS $in, $addr)>;
194906c3fb27SDimitry Andric
19500b57cec5SDimitry Andric// 64-bits atomic loads and stores
1951fe6060f1SDimitry Andricdef : Pat<(atomic_load_64 DSForm:$src), (LD  memrix:$src)>;
1952fe6060f1SDimitry Andricdef : Pat<(atomic_load_64 XForm:$src),  (LDX memrr:$src)>;
19530b57cec5SDimitry Andric
19545f757f3fSDimitry Andricdef : Pat<(atomic_store_64 i64:$val, DSForm:$ptr), (STD  g8rc:$val, memrix:$ptr)>;
19555f757f3fSDimitry Andricdef : Pat<(atomic_store_64 i64:$val, XForm:$ptr), (STDX g8rc:$val, memrr:$ptr)>;
1956fe6060f1SDimitry Andric
1957fe6060f1SDimitry Andriclet Predicates = [IsISA3_0, In64BitMode] in {
1958fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_cmpeqb g8rc:$a, g8rc:$b)),
1959fe6060f1SDimitry Andric          (i64 (SETB8 (CMPEQB $a, $b)))>;
1960fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_setb g8rc:$a, g8rc:$b)),
1961fe6060f1SDimitry Andric          (i64 (SETB8 (CMPD $a, $b)))>;
1962fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_maddhd g8rc:$a, g8rc:$b, g8rc:$c)),
1963fe6060f1SDimitry Andric          (i64 (MADDHD $a, $b, $c))>;
1964fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_maddhdu g8rc:$a, g8rc:$b, g8rc:$c)),
1965fe6060f1SDimitry Andric          (i64 (MADDHDU $a, $b, $c))>;
1966fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_maddld g8rc:$a, g8rc:$b, g8rc:$c)),
1967fe6060f1SDimitry Andric          (i64 (MADDLD8 $a, $b, $c))>;
1968fe6060f1SDimitry Andric}
1969fe6060f1SDimitry Andric
1970fe6060f1SDimitry Andriclet Predicates = [In64BitMode] in {
1971fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_mulhd g8rc:$a, g8rc:$b)),
1972fe6060f1SDimitry Andric          (i64 (MULHD $a, $b))>;
1973fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_mulhdu g8rc:$a, g8rc:$b)),
1974fe6060f1SDimitry Andric          (i64 (MULHDU $a, $b))>;
1975fe6060f1SDimitry Andricdef : Pat<(int_ppc_load8r ForceXForm:$ptr),
1976fe6060f1SDimitry Andric          (LDBRX ForceXForm:$ptr)>;
1977fe6060f1SDimitry Andricdef : Pat<(int_ppc_store8r g8rc:$a, ForceXForm:$ptr),
1978fe6060f1SDimitry Andric          (STDBRX g8rc:$a, ForceXForm:$ptr)>;
1979fe6060f1SDimitry Andric}
1980fe6060f1SDimitry Andric
1981fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_cmpb g8rc:$a, g8rc:$b)),
1982fe6060f1SDimitry Andric          (i64 (CMPB8 $a, $b))>;
19830b57cec5SDimitry Andric
19840b57cec5SDimitry Andriclet Predicates = [IsISA3_0] in {
1985e8d8bef9SDimitry Andric// DARN (deliver random number)
1986e8d8bef9SDimitry Andric// L=0 for 32-bit, L=1 for conditioned random, L=2 for raw random
1987e8d8bef9SDimitry Andricdef : Pat<(int_ppc_darn32), (EXTRACT_SUBREG (DARN 0), sub_32)>;
1988e8d8bef9SDimitry Andricdef : Pat<(int_ppc_darn), (DARN 1)>;
1989e8d8bef9SDimitry Andricdef : Pat<(int_ppc_darnraw), (DARN 2)>;
19900b57cec5SDimitry Andric
1991fe6060f1SDimitry Andricclass X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1992fe6060f1SDimitry Andric                   InstrItinClass itin, list<dag> pattern>
199306c3fb27SDimitry Andric  : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
199406c3fb27SDimitry Andric                 !strconcat(opc, " $RA, $RB"), itin, pattern>{
1995fe6060f1SDimitry Andric   let L = 1;
1996fe6060f1SDimitry Andric}
1997fe6060f1SDimitry Andric
19980b57cec5SDimitry Andricclass X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
19990b57cec5SDimitry Andric                   InstrItinClass itin, list<dag> pattern>
200006c3fb27SDimitry Andric  : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
200106c3fb27SDimitry Andric                 !strconcat(opc, " $RA, $RB, $L"), itin, pattern>;
20020b57cec5SDimitry Andric
20030b57cec5SDimitry Andriclet Interpretation64Bit = 1, isCodeGenOnly = 1 in {
2004fe6060f1SDimitry Andricdef CP_COPY8   : X_RA5_RB5<31, 774, "copy"  , g8rc, IIC_LdStCOPY, []>;
2005480093f4SDimitry Andricdef CP_PASTE8_rec : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isRecordForm;
20060b57cec5SDimitry Andric}
20070b57cec5SDimitry Andric
20080b57cec5SDimitry Andric// SLB Invalidate Entry Global
200906c3fb27SDimitry Andricdef SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RST, gprc:$RB),
201006c3fb27SDimitry Andric                      "slbieg $RST, $RB", IIC_SprSLBIEG, []>;
20110b57cec5SDimitry Andric// SLB Synchronize
20120b57cec5SDimitry Andricdef SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;
20130b57cec5SDimitry Andric
20140b57cec5SDimitry Andric} // IsISA3_0
2015fe6060f1SDimitry Andric
2016fe6060f1SDimitry Andricdef : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
2017*6c4b055cSDimitry Andric          (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
2018bdd1243dSDimitry Andricdef : Pat<(PPCStoreCond ForceXForm:$dst, g8rc:$A, 8),
2019*6c4b055cSDimitry Andric          (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
2020fe6060f1SDimitry Andric
2021fe6060f1SDimitry Andricdef : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
2022fe6060f1SDimitry Andric          (MFSPR8 $SPR)>;
2023fe6060f1SDimitry Andricdef : Pat<(int_ppc_mtspr timm:$SPR, g8rc:$RT),
2024fe6060f1SDimitry Andric          (MTSPR8 $SPR, $RT)>;
2025