xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/Mips/MipsCondMov.td (revision 5b27928474e6a4103d65b347544705c40c9618fd)
10b57cec5SDimitry Andric//===-- MipsCondMov.td - Describe Mips Conditional Moves --*- 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 is the Conditional Moves implementation.
100b57cec5SDimitry Andric//
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric// Conditional moves:
140b57cec5SDimitry Andric// These instructions are expanded in
150b57cec5SDimitry Andric// MipsISelLowering::EmitInstrWithCustomInserter if target does not have
160b57cec5SDimitry Andric// conditional move instructions.
170b57cec5SDimitry Andric// cond:int, data:int
180b57cec5SDimitry Andricclass CMov_I_I_FT<string opstr, RegisterOperand CRC, RegisterOperand DRC,
190b57cec5SDimitry Andric                  InstrItinClass Itin> :
200b57cec5SDimitry Andric  InstSE<(outs DRC:$rd), (ins DRC:$rs, CRC:$rt, DRC:$F),
210b57cec5SDimitry Andric         !strconcat(opstr, "\t$rd, $rs, $rt"), [], Itin, FrmFR, opstr> {
220b57cec5SDimitry Andric  let Constraints = "$F = $rd";
230b57cec5SDimitry Andric}
240b57cec5SDimitry Andric
250b57cec5SDimitry Andric// cond:int, data:float
260b57cec5SDimitry Andricclass CMov_I_F_FT<string opstr, RegisterOperand CRC, RegisterOperand DRC,
270b57cec5SDimitry Andric                  InstrItinClass Itin> :
280b57cec5SDimitry Andric  InstSE<(outs DRC:$fd), (ins DRC:$fs, CRC:$rt, DRC:$F),
290b57cec5SDimitry Andric         !strconcat(opstr, "\t$fd, $fs, $rt"), [], Itin, FrmFR, opstr>,
300b57cec5SDimitry Andric  HARDFLOAT {
310b57cec5SDimitry Andric  let Constraints = "$F = $fd";
320b57cec5SDimitry Andric}
330b57cec5SDimitry Andric
340b57cec5SDimitry Andric// cond:float, data:int
350b57cec5SDimitry Andricclass CMov_F_I_FT<string opstr, RegisterOperand RC, InstrItinClass Itin,
360b57cec5SDimitry Andric                  SDPatternOperator OpNode = null_frag> :
370b57cec5SDimitry Andric  InstSE<(outs RC:$rd), (ins RC:$rs, FCCRegsOpnd:$fcc, RC:$F),
380b57cec5SDimitry Andric         !strconcat(opstr, "\t$rd, $rs, $fcc"),
390b57cec5SDimitry Andric         [(set RC:$rd, (OpNode RC:$rs, FCCRegsOpnd:$fcc, RC:$F))],
400b57cec5SDimitry Andric         Itin, FrmFR, opstr>, HARDFLOAT {
410b57cec5SDimitry Andric  let Constraints = "$F = $rd";
420b57cec5SDimitry Andric}
430b57cec5SDimitry Andric
440b57cec5SDimitry Andric// cond:float, data:float
450b57cec5SDimitry Andricclass CMov_F_F_FT<string opstr, RegisterOperand RC, InstrItinClass Itin,
460b57cec5SDimitry Andric                  SDPatternOperator OpNode = null_frag> :
470b57cec5SDimitry Andric  InstSE<(outs RC:$fd), (ins RC:$fs, FCCRegsOpnd:$fcc, RC:$F),
480b57cec5SDimitry Andric         !strconcat(opstr, "\t$fd, $fs, $fcc"),
490b57cec5SDimitry Andric         [(set RC:$fd, (OpNode RC:$fs, FCCRegsOpnd:$fcc, RC:$F))],
500b57cec5SDimitry Andric         Itin, FrmFR, opstr>, HARDFLOAT {
510b57cec5SDimitry Andric  let Constraints = "$F = $fd";
520b57cec5SDimitry Andric}
530b57cec5SDimitry Andric
540b57cec5SDimitry Andric// select patterns
550b57cec5SDimitry Andricmulticlass MovzPats0<RegisterClass CRC, RegisterClass DRC,
560b57cec5SDimitry Andric                     Instruction MOVZInst, Instruction SLTOp,
570b57cec5SDimitry Andric                     Instruction SLTuOp, Instruction SLTiOp,
580b57cec5SDimitry Andric                     Instruction SLTiuOp> {
590b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setge CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
600b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTOp CRC:$lhs, CRC:$rhs), DRC:$F)>;
610b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setuge CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
620b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTuOp CRC:$lhs, CRC:$rhs), DRC:$F)>;
630b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setge CRC:$lhs, immSExt16:$rhs)), DRC:$T, DRC:$F),
640b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTiOp CRC:$lhs, immSExt16:$rhs), DRC:$F)>;
650b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setuge CRC:$lh, immSExt16:$rh)), DRC:$T, DRC:$F),
660b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTiuOp CRC:$lh, immSExt16:$rh), DRC:$F)>;
670b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setle CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
680b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTOp CRC:$rhs, CRC:$lhs), DRC:$F)>;
690b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setule CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
700b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTuOp CRC:$rhs, CRC:$lhs), DRC:$F)>;
710b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setgt CRC:$lhs, immSExt16Plus1:$rhs)),
720b57cec5SDimitry Andric                        DRC:$T, DRC:$F),
730b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTiOp CRC:$lhs, (Plus1 imm:$rhs)), DRC:$F)>;
740b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setugt CRC:$lhs, immSExt16Plus1:$rhs)),
750b57cec5SDimitry Andric                        DRC:$T, DRC:$F),
760b57cec5SDimitry Andric                (MOVZInst DRC:$T, (SLTiuOp CRC:$lhs, (Plus1 imm:$rhs)),
770b57cec5SDimitry Andric                          DRC:$F)>;
780b57cec5SDimitry Andric}
790b57cec5SDimitry Andric
800b57cec5SDimitry Andricmulticlass MovzPats1<RegisterClass CRC, RegisterClass DRC,
810b57cec5SDimitry Andric                     Instruction MOVZInst, Instruction XOROp> {
820b57cec5SDimitry Andric  def : MipsPat<(select (i32 (seteq CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
830b57cec5SDimitry Andric                (MOVZInst DRC:$T, (XOROp CRC:$lhs, CRC:$rhs), DRC:$F)>;
840b57cec5SDimitry Andric  def : MipsPat<(select (i32 (seteq CRC:$lhs, 0)), DRC:$T, DRC:$F),
850b57cec5SDimitry Andric                (MOVZInst DRC:$T, CRC:$lhs, DRC:$F)>;
860b57cec5SDimitry Andric}
870b57cec5SDimitry Andric
880b57cec5SDimitry Andricmulticlass MovzPats2<RegisterClass CRC, RegisterClass DRC,
890b57cec5SDimitry Andric                     Instruction MOVZInst, Instruction XORiOp> {
900b57cec5SDimitry Andric  def : MipsPat<
910b57cec5SDimitry Andric            (select (i32 (seteq CRC:$lhs, immZExt16:$uimm16)), DRC:$T, DRC:$F),
920b57cec5SDimitry Andric            (MOVZInst DRC:$T, (XORiOp CRC:$lhs, immZExt16:$uimm16), DRC:$F)>;
930b57cec5SDimitry Andric}
940b57cec5SDimitry Andric
950b57cec5SDimitry Andricmulticlass MovnPats<RegisterClass CRC, RegisterClass DRC, Instruction MOVNInst,
960b57cec5SDimitry Andric                    Instruction XOROp> {
970b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setne CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F),
980b57cec5SDimitry Andric                (MOVNInst DRC:$T, (XOROp CRC:$lhs, CRC:$rhs), DRC:$F)>;
990b57cec5SDimitry Andric  def : MipsPat<(select CRC:$cond, DRC:$T, DRC:$F),
1000b57cec5SDimitry Andric                (MOVNInst DRC:$T, CRC:$cond, DRC:$F)>;
1010b57cec5SDimitry Andric  def : MipsPat<(select (i32 (setne CRC:$lhs, 0)),DRC:$T, DRC:$F),
1020b57cec5SDimitry Andric                (MOVNInst DRC:$T, CRC:$lhs, DRC:$F)>;
1030b57cec5SDimitry Andric}
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andric// Instantiation of instructions.
1060b57cec5SDimitry Andriclet AdditionalPredicates = [NotInMicroMips] in {
1070b57cec5SDimitry Andric  def MOVZ_I_I : MMRel, CMov_I_I_FT<"movz", GPR32Opnd, GPR32Opnd, II_MOVZ>,
1080b57cec5SDimitry Andric                 ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6;
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andric  let isCodeGenOnly = 1 in {
1110b57cec5SDimitry Andric    def MOVZ_I_I64   : CMov_I_I_FT<"movz", GPR32Opnd, GPR64Opnd, II_MOVZ>,
1120b57cec5SDimitry Andric                       ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1130b57cec5SDimitry Andric    def MOVZ_I64_I   : CMov_I_I_FT<"movz", GPR64Opnd, GPR32Opnd, II_MOVZ>,
1140b57cec5SDimitry Andric                       ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1150b57cec5SDimitry Andric    def MOVZ_I64_I64 : CMov_I_I_FT<"movz", GPR64Opnd, GPR64Opnd, II_MOVZ>,
1160b57cec5SDimitry Andric                       ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1170b57cec5SDimitry Andric  }
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric  def MOVN_I_I     : MMRel, CMov_I_I_FT<"movn", GPR32Opnd, GPR32Opnd, II_MOVN>,
1200b57cec5SDimitry Andric                     ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6;
1210b57cec5SDimitry Andric
1220b57cec5SDimitry Andric  let isCodeGenOnly = 1 in {
1230b57cec5SDimitry Andric    def MOVN_I_I64   : CMov_I_I_FT<"movn", GPR32Opnd, GPR64Opnd, II_MOVN>,
1240b57cec5SDimitry Andric                       ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1250b57cec5SDimitry Andric    def MOVN_I64_I   : CMov_I_I_FT<"movn", GPR64Opnd, GPR32Opnd, II_MOVN>,
1260b57cec5SDimitry Andric                       ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1270b57cec5SDimitry Andric    def MOVN_I64_I64 : CMov_I_I_FT<"movn", GPR64Opnd, GPR64Opnd, II_MOVN>,
1280b57cec5SDimitry Andric                       ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1290b57cec5SDimitry Andric  }
1300b57cec5SDimitry Andric  def MOVZ_I_S : MMRel, CMov_I_F_FT<"movz.s", GPR32Opnd, FGR32Opnd, II_MOVZ_S>,
1310b57cec5SDimitry Andric                 CMov_I_F_FM<18, 16>, INSN_MIPS4_32_NOT_32R6_64R6;
1320b57cec5SDimitry Andric
1330b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
1340b57cec5SDimitry Andric  def MOVZ_I64_S : CMov_I_F_FT<"movz.s", GPR64Opnd, FGR32Opnd, II_MOVZ_S>,
1350b57cec5SDimitry Andric                   CMov_I_F_FM<18, 16>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1360b57cec5SDimitry Andric
1370b57cec5SDimitry Andric  def MOVN_I_S : MMRel, CMov_I_F_FT<"movn.s", GPR32Opnd, FGR32Opnd, II_MOVN_S>,
1380b57cec5SDimitry Andric                 CMov_I_F_FM<19, 16>, INSN_MIPS4_32_NOT_32R6_64R6;
1390b57cec5SDimitry Andric
1400b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
1410b57cec5SDimitry Andric  def MOVN_I64_S : CMov_I_F_FT<"movn.s", GPR64Opnd, FGR32Opnd, II_MOVN_S>,
1420b57cec5SDimitry Andric                   CMov_I_F_FM<19, 16>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andric  def MOVZ_I_D32 : MMRel, CMov_I_F_FT<"movz.d", GPR32Opnd, AFGR64Opnd,
1450b57cec5SDimitry Andric                                      II_MOVZ_D>, CMov_I_F_FM<18, 17>,
1460b57cec5SDimitry Andric                   INSN_MIPS4_32_NOT_32R6_64R6, FGR_32;
1470b57cec5SDimitry Andric  def MOVN_I_D32 : MMRel, CMov_I_F_FT<"movn.d", GPR32Opnd, AFGR64Opnd,
1480b57cec5SDimitry Andric                                      II_MOVN_D>, CMov_I_F_FM<19, 17>,
1490b57cec5SDimitry Andric                   INSN_MIPS4_32_NOT_32R6_64R6, FGR_32;
1500b57cec5SDimitry Andric
1510b57cec5SDimitry Andric  let DecoderNamespace = "MipsFP64" in {
1520b57cec5SDimitry Andric    def MOVZ_I_D64 : CMov_I_F_FT<"movz.d", GPR32Opnd, FGR64Opnd, II_MOVZ_D>,
1530b57cec5SDimitry Andric                     CMov_I_F_FM<18, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
1540b57cec5SDimitry Andric    def MOVN_I_D64 : CMov_I_F_FT<"movn.d", GPR32Opnd, FGR64Opnd, II_MOVN_D>,
1550b57cec5SDimitry Andric                     CMov_I_F_FM<19, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
1560b57cec5SDimitry Andric    let isCodeGenOnly = 1 in {
1570b57cec5SDimitry Andric      def MOVZ_I64_D64 : CMov_I_F_FT<"movz.d", GPR64Opnd, FGR64Opnd, II_MOVZ_D>,
1580b57cec5SDimitry Andric                         CMov_I_F_FM<18, 17>,
1590b57cec5SDimitry Andric                         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64, FGR_64;
1600b57cec5SDimitry Andric      def MOVN_I64_D64 : CMov_I_F_FT<"movn.d", GPR64Opnd, FGR64Opnd, II_MOVN_D>,
1610b57cec5SDimitry Andric                         CMov_I_F_FM<19, 17>,
1620b57cec5SDimitry Andric                         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64, FGR_64;
1630b57cec5SDimitry Andric    }
1640b57cec5SDimitry Andric  }
1650b57cec5SDimitry Andric
1660b57cec5SDimitry Andric  def MOVT_I : MMRel, CMov_F_I_FT<"movt", GPR32Opnd, II_MOVT, MipsCMovFP_T>,
1670b57cec5SDimitry Andric               CMov_F_I_FM<1>, INSN_MIPS4_32_NOT_32R6_64R6;
1680b57cec5SDimitry Andric
1690b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
1700b57cec5SDimitry Andric  def MOVT_I64 : CMov_F_I_FT<"movt", GPR64Opnd, II_MOVT, MipsCMovFP_T>,
1710b57cec5SDimitry Andric                 CMov_F_I_FM<1>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1720b57cec5SDimitry Andric
1730b57cec5SDimitry Andric  def MOVF_I : MMRel, CMov_F_I_FT<"movf", GPR32Opnd, II_MOVF, MipsCMovFP_F>,
1740b57cec5SDimitry Andric               CMov_F_I_FM<0>, INSN_MIPS4_32_NOT_32R6_64R6;
1750b57cec5SDimitry Andric
1760b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
1770b57cec5SDimitry Andric  def MOVF_I64 : CMov_F_I_FT<"movf", GPR64Opnd, II_MOVF, MipsCMovFP_F>,
1780b57cec5SDimitry Andric                 CMov_F_I_FM<0>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
1790b57cec5SDimitry Andric  def MOVT_S : MMRel, CMov_F_F_FT<"movt.s", FGR32Opnd, II_MOVT_S, MipsCMovFP_T>,
1800b57cec5SDimitry Andric               CMov_F_F_FM<16, 1>, INSN_MIPS4_32_NOT_32R6_64R6;
1810b57cec5SDimitry Andric  def MOVF_S : MMRel, CMov_F_F_FT<"movf.s", FGR32Opnd, II_MOVF_S, MipsCMovFP_F>,
1820b57cec5SDimitry Andric               CMov_F_F_FM<16, 0>, INSN_MIPS4_32_NOT_32R6_64R6;
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andric  def MOVT_D32 : MMRel, CMov_F_F_FT<"movt.d", AFGR64Opnd, II_MOVT_D,
1850b57cec5SDimitry Andric                                    MipsCMovFP_T>, CMov_F_F_FM<17, 1>,
1860b57cec5SDimitry Andric                 INSN_MIPS4_32_NOT_32R6_64R6, FGR_32;
1870b57cec5SDimitry Andric  def MOVF_D32 : MMRel, CMov_F_F_FT<"movf.d", AFGR64Opnd, II_MOVF_D,
1880b57cec5SDimitry Andric                                    MipsCMovFP_F>, CMov_F_F_FM<17, 0>,
1890b57cec5SDimitry Andric                 INSN_MIPS4_32_NOT_32R6_64R6, FGR_32;
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andric  let DecoderNamespace = "MipsFP64" in {
1920b57cec5SDimitry Andric    def MOVT_D64 : CMov_F_F_FT<"movt.d", FGR64Opnd, II_MOVT_D, MipsCMovFP_T>,
1930b57cec5SDimitry Andric                   CMov_F_F_FM<17, 1>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
1940b57cec5SDimitry Andric    def MOVF_D64 : CMov_F_F_FT<"movf.d", FGR64Opnd, II_MOVF_D, MipsCMovFP_F>,
1950b57cec5SDimitry Andric                   CMov_F_F_FM<17, 0>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
1960b57cec5SDimitry Andric  }
1970b57cec5SDimitry Andric
1980b57cec5SDimitry Andric  // Instantiation of conditional move patterns.
1990b57cec5SDimitry Andric  defm : MovzPats0<GPR32, GPR32, MOVZ_I_I, SLT, SLTu, SLTi, SLTiu>,
2000b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6;
2010b57cec5SDimitry Andric  defm : MovzPats1<GPR32, GPR32, MOVZ_I_I, XOR>, INSN_MIPS4_32_NOT_32R6_64R6;
2020b57cec5SDimitry Andric  defm : MovzPats2<GPR32, GPR32, MOVZ_I_I, XORi>, INSN_MIPS4_32_NOT_32R6_64R6;
2030b57cec5SDimitry Andric
2040b57cec5SDimitry Andric  defm : MovzPats0<GPR32, GPR64, MOVZ_I_I64, SLT, SLTu, SLTi, SLTiu>,
2050b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2060b57cec5SDimitry Andric  defm : MovzPats0<GPR64, GPR32, MOVZ_I_I, SLT64, SLTu64, SLTi64, SLTiu64>,
2070b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2080b57cec5SDimitry Andric  defm : MovzPats0<GPR64, GPR64, MOVZ_I_I64, SLT64, SLTu64, SLTi64, SLTiu64>,
2090b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2100b57cec5SDimitry Andric  defm : MovzPats1<GPR32, GPR64, MOVZ_I_I64, XOR>,
2110b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2120b57cec5SDimitry Andric  defm : MovzPats1<GPR64, GPR32, MOVZ_I64_I, XOR64>,
2130b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2140b57cec5SDimitry Andric  defm : MovzPats1<GPR64, GPR64, MOVZ_I64_I64, XOR64>,
2150b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2160b57cec5SDimitry Andric  defm : MovzPats2<GPR32, GPR64, MOVZ_I_I64, XORi>,
2170b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2180b57cec5SDimitry Andric  defm : MovzPats2<GPR64, GPR32, MOVZ_I64_I, XORi64>,
2190b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2200b57cec5SDimitry Andric  defm : MovzPats2<GPR64, GPR64, MOVZ_I64_I64, XORi64>,
2210b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2220b57cec5SDimitry Andric
2230b57cec5SDimitry Andric  defm : MovnPats<GPR32, GPR32, MOVN_I_I, XOR>, INSN_MIPS4_32_NOT_32R6_64R6;
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric  defm : MovnPats<GPR32, GPR64, MOVN_I_I64, XOR>, INSN_MIPS4_32_NOT_32R6_64R6,
2260b57cec5SDimitry Andric         GPR_64;
2270b57cec5SDimitry Andric  defm : MovnPats<GPR64, GPR32, MOVN_I64_I, XOR64>, INSN_MIPS4_32_NOT_32R6_64R6,
2280b57cec5SDimitry Andric         GPR_64;
229*480093f4SDimitry Andric  defm : MovnPats<GPR64, GPR64, MOVN_I64_I64, XOR64>,
230*480093f4SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2310b57cec5SDimitry Andric
2320b57cec5SDimitry Andric  defm : MovzPats0<GPR32, FGR32, MOVZ_I_S, SLT, SLTu, SLTi, SLTiu>,
2330b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6;
2340b57cec5SDimitry Andric  defm : MovzPats1<GPR32, FGR32, MOVZ_I_S, XOR>, INSN_MIPS4_32_NOT_32R6_64R6;
2350b57cec5SDimitry Andric  defm : MovnPats<GPR32, FGR32, MOVN_I_S, XOR>, INSN_MIPS4_32_NOT_32R6_64R6;
2360b57cec5SDimitry Andric
2370b57cec5SDimitry Andric  defm : MovzPats0<GPR64, FGR32, MOVZ_I_S, SLT64, SLTu64, SLTi64, SLTiu64>,
2380b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
239*480093f4SDimitry Andric  defm : MovzPats1<GPR64, FGR32, MOVZ_I64_S, XOR64>,
240*480093f4SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, GPR_64;
2410b57cec5SDimitry Andric  defm : MovnPats<GPR64, FGR32, MOVN_I64_S, XOR64>, INSN_MIPS4_32_NOT_32R6_64R6,
2420b57cec5SDimitry Andric         GPR_64;
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andric  defm : MovzPats0<GPR32, AFGR64, MOVZ_I_D32, SLT, SLTu, SLTi, SLTiu>,
2450b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, FGR_32;
2460b57cec5SDimitry Andric  defm : MovzPats1<GPR32, AFGR64, MOVZ_I_D32, XOR>, INSN_MIPS4_32_NOT_32R6_64R6,
2470b57cec5SDimitry Andric         FGR_32;
2480b57cec5SDimitry Andric  defm : MovnPats<GPR32, AFGR64, MOVN_I_D32, XOR>, INSN_MIPS4_32_NOT_32R6_64R6,
2490b57cec5SDimitry Andric         FGR_32;
2500b57cec5SDimitry Andric
2510b57cec5SDimitry Andric  defm : MovzPats0<GPR32, FGR64, MOVZ_I_D64, SLT, SLTu, SLTi, SLTiu>,
2520b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
2530b57cec5SDimitry Andric  defm : MovzPats0<GPR64, FGR64, MOVZ_I_D64, SLT64, SLTu64, SLTi64, SLTiu64>,
2540b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
2550b57cec5SDimitry Andric  defm : MovzPats1<GPR32, FGR64, MOVZ_I_D64, XOR>, INSN_MIPS4_32_NOT_32R6_64R6,
2560b57cec5SDimitry Andric         FGR_64;
2570b57cec5SDimitry Andric  defm : MovzPats1<GPR64, FGR64, MOVZ_I64_D64, XOR64>,
2580b57cec5SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
2590b57cec5SDimitry Andric  defm : MovnPats<GPR32, FGR64, MOVN_I_D64, XOR>, INSN_MIPS4_32_NOT_32R6_64R6,
2600b57cec5SDimitry Andric         FGR_64;
261*480093f4SDimitry Andric  defm : MovnPats<GPR64, FGR64, MOVN_I64_D64, XOR64>,
262*480093f4SDimitry Andric         INSN_MIPS4_32_NOT_32R6_64R6, FGR_64;
2630b57cec5SDimitry Andric}
2640b57cec5SDimitry Andric// For targets that don't have conditional-move instructions
2650b57cec5SDimitry Andric// we have to match SELECT nodes with pseudo instructions.
2660b57cec5SDimitry Andriclet usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
2670b57cec5SDimitry Andric  class Select_Pseudo<RegisterOperand RC> :
2680b57cec5SDimitry Andric    PseudoSE<(outs RC:$dst), (ins GPR32Opnd:$cond, RC:$T, RC:$F),
2690b57cec5SDimitry Andric            [(set RC:$dst, (select GPR32Opnd:$cond, RC:$T, RC:$F))]>,
2700b57cec5SDimitry Andric    ISA_MIPS1_NOT_4_32;
2710b57cec5SDimitry Andric
2720b57cec5SDimitry Andric  class SelectFP_Pseudo_T<RegisterOperand RC> :
2730b57cec5SDimitry Andric    PseudoSE<(outs RC:$dst), (ins FCCRegsOpnd:$cond, RC:$T, RC:$F),
2740b57cec5SDimitry Andric             [(set RC:$dst, (MipsCMovFP_T RC:$T, FCCRegsOpnd:$cond, RC:$F))]>,
2750b57cec5SDimitry Andric    ISA_MIPS1_NOT_4_32;
2760b57cec5SDimitry Andric
2770b57cec5SDimitry Andric  class SelectFP_Pseudo_F<RegisterOperand RC> :
2780b57cec5SDimitry Andric    PseudoSE<(outs RC:$dst), (ins FCCRegsOpnd:$cond, RC:$T, RC:$F),
2790b57cec5SDimitry Andric             [(set RC:$dst, (MipsCMovFP_F RC:$T, FCCRegsOpnd:$cond, RC:$F))]>,
2800b57cec5SDimitry Andric    ISA_MIPS1_NOT_4_32;
2810b57cec5SDimitry Andric}
2820b57cec5SDimitry Andric
2830b57cec5SDimitry Andricdef PseudoSELECT_I : Select_Pseudo<GPR32Opnd>;
2840b57cec5SDimitry Andricdef PseudoSELECT_I64 : Select_Pseudo<GPR64Opnd>;
2850b57cec5SDimitry Andricdef PseudoSELECT_S : Select_Pseudo<FGR32Opnd>;
2860b57cec5SDimitry Andricdef PseudoSELECT_D32 : Select_Pseudo<AFGR64Opnd>, FGR_32;
2870b57cec5SDimitry Andricdef PseudoSELECT_D64 : Select_Pseudo<FGR64Opnd>, FGR_64;
2880b57cec5SDimitry Andric
2890b57cec5SDimitry Andricdef PseudoSELECTFP_T_I : SelectFP_Pseudo_T<GPR32Opnd>;
2900b57cec5SDimitry Andricdef PseudoSELECTFP_T_I64 : SelectFP_Pseudo_T<GPR64Opnd>;
2910b57cec5SDimitry Andricdef PseudoSELECTFP_T_S : SelectFP_Pseudo_T<FGR32Opnd>;
2920b57cec5SDimitry Andricdef PseudoSELECTFP_T_D32 : SelectFP_Pseudo_T<AFGR64Opnd>, FGR_32;
2930b57cec5SDimitry Andricdef PseudoSELECTFP_T_D64 : SelectFP_Pseudo_T<FGR64Opnd>, FGR_64;
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andricdef PseudoSELECTFP_F_I : SelectFP_Pseudo_F<GPR32Opnd>;
2960b57cec5SDimitry Andricdef PseudoSELECTFP_F_I64 : SelectFP_Pseudo_F<GPR64Opnd>;
2970b57cec5SDimitry Andricdef PseudoSELECTFP_F_S : SelectFP_Pseudo_F<FGR32Opnd>;
2980b57cec5SDimitry Andricdef PseudoSELECTFP_F_D32 : SelectFP_Pseudo_F<AFGR64Opnd>, FGR_32;
2990b57cec5SDimitry Andricdef PseudoSELECTFP_F_D64 : SelectFP_Pseudo_F<FGR64Opnd>, FGR_64;
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andriclet usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
3020b57cec5SDimitry Andricclass D_SELECT_CLASS<RegisterOperand RC> :
3030b57cec5SDimitry Andric  PseudoSE<(outs RC:$dst1, RC:$dst2),
3040b57cec5SDimitry Andric           (ins GPR32Opnd:$cond, RC:$a1, RC:$a2, RC:$b1, RC:$b2), []>,
3050b57cec5SDimitry Andric  ISA_MIPS1_NOT_4_32;
3060b57cec5SDimitry Andric}
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andricdef PseudoD_SELECT_I   : D_SELECT_CLASS<GPR32Opnd>;
3090b57cec5SDimitry Andricdef PseudoD_SELECT_I64 : D_SELECT_CLASS<GPR64Opnd>;
310