//===-- MipsCondMov.td - Describe Mips Conditional Moves --*- tablegen -*--===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This is the Conditional Moves implementation. // //===----------------------------------------------------------------------===// // Conditional moves: // These instructions are expanded in // MipsISelLowering::EmitInstrWithCustomInserter if target does not have // conditional move instructions. // cond:int, data:int class CMov_I_I_FT : InstSE<(outs DRC:$rd), (ins DRC:$rs, CRC:$rt, DRC:$F), !strconcat(opstr, "\t$rd, $rs, $rt"), [], Itin, FrmFR, opstr> { let Constraints = "$F = $rd"; } // cond:int, data:float class CMov_I_F_FT : InstSE<(outs DRC:$fd), (ins DRC:$fs, CRC:$rt, DRC:$F), !strconcat(opstr, "\t$fd, $fs, $rt"), [], Itin, FrmFR, opstr>, HARDFLOAT { let Constraints = "$F = $fd"; } // cond:float, data:int class CMov_F_I_FT : InstSE<(outs RC:$rd), (ins RC:$rs, FCCRegsOpnd:$fcc, RC:$F), !strconcat(opstr, "\t$rd, $rs, $fcc"), [(set RC:$rd, (OpNode RC:$rs, FCCRegsOpnd:$fcc, RC:$F))], Itin, FrmFR, opstr>, HARDFLOAT { let Constraints = "$F = $rd"; } // cond:float, data:float class CMov_F_F_FT : InstSE<(outs RC:$fd), (ins RC:$fs, FCCRegsOpnd:$fcc, RC:$F), !strconcat(opstr, "\t$fd, $fs, $fcc"), [(set RC:$fd, (OpNode RC:$fs, FCCRegsOpnd:$fcc, RC:$F))], Itin, FrmFR, opstr>, HARDFLOAT { let Constraints = "$F = $fd"; } // select patterns multiclass MovzPats0 { def : MipsPat<(select (i32 (setge CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTOp CRC:$lhs, CRC:$rhs), DRC:$F)>; def : MipsPat<(select (i32 (setuge CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTuOp CRC:$lhs, CRC:$rhs), DRC:$F)>; def : MipsPat<(select (i32 (setge CRC:$lhs, immSExt16:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTiOp CRC:$lhs, immSExt16:$rhs), DRC:$F)>; def : MipsPat<(select (i32 (setuge CRC:$lh, immSExt16:$rh)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTiuOp CRC:$lh, immSExt16:$rh), DRC:$F)>; def : MipsPat<(select (i32 (setle CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTOp CRC:$rhs, CRC:$lhs), DRC:$F)>; def : MipsPat<(select (i32 (setule CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTuOp CRC:$rhs, CRC:$lhs), DRC:$F)>; def : MipsPat<(select (i32 (setgt CRC:$lhs, immSExt16Plus1:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTiOp CRC:$lhs, (Plus1 imm:$rhs)), DRC:$F)>; def : MipsPat<(select (i32 (setugt CRC:$lhs, immSExt16Plus1:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (SLTiuOp CRC:$lhs, (Plus1 imm:$rhs)), DRC:$F)>; } multiclass MovzPats1 { def : MipsPat<(select (i32 (seteq CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (XOROp CRC:$lhs, CRC:$rhs), DRC:$F)>; def : MipsPat<(select (i32 (seteq CRC:$lhs, 0)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, CRC:$lhs, DRC:$F)>; } multiclass MovzPats2 { def : MipsPat< (select (i32 (seteq CRC:$lhs, immZExt16:$uimm16)), DRC:$T, DRC:$F), (MOVZInst DRC:$T, (XORiOp CRC:$lhs, immZExt16:$uimm16), DRC:$F)>; } multiclass MovnPats { def : MipsPat<(select (i32 (setne CRC:$lhs, CRC:$rhs)), DRC:$T, DRC:$F), (MOVNInst DRC:$T, (XOROp CRC:$lhs, CRC:$rhs), DRC:$F)>; def : MipsPat<(select CRC:$cond, DRC:$T, DRC:$F), (MOVNInst DRC:$T, CRC:$cond, DRC:$F)>; def : MipsPat<(select (i32 (setne CRC:$lhs, 0)),DRC:$T, DRC:$F), (MOVNInst DRC:$T, CRC:$lhs, DRC:$F)>; } // Instantiation of instructions. let AdditionalPredicates = [NotInMicroMips] in { def MOVZ_I_I : MMRel, CMov_I_I_FT<"movz", GPR32Opnd, GPR32Opnd, II_MOVZ>, ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in { def MOVZ_I_I64 : CMov_I_I_FT<"movz", GPR32Opnd, GPR64Opnd, II_MOVZ>, ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVZ_I64_I : CMov_I_I_FT<"movz", GPR64Opnd, GPR32Opnd, II_MOVZ>, ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVZ_I64_I64 : CMov_I_I_FT<"movz", GPR64Opnd, GPR64Opnd, II_MOVZ>, ADD_FM<0, 0xa>, INSN_MIPS4_32_NOT_32R6_64R6; } def MOVN_I_I : MMRel, CMov_I_I_FT<"movn", GPR32Opnd, GPR32Opnd, II_MOVN>, ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in { def MOVN_I_I64 : CMov_I_I_FT<"movn", GPR32Opnd, GPR64Opnd, II_MOVN>, ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVN_I64_I : CMov_I_I_FT<"movn", GPR64Opnd, GPR32Opnd, II_MOVN>, ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVN_I64_I64 : CMov_I_I_FT<"movn", GPR64Opnd, GPR64Opnd, II_MOVN>, ADD_FM<0, 0xb>, INSN_MIPS4_32_NOT_32R6_64R6; } def MOVZ_I_S : MMRel, CMov_I_F_FT<"movz.s", GPR32Opnd, FGR32Opnd, II_MOVZ_S>, CMov_I_F_FM<18, 16>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in def MOVZ_I64_S : CMov_I_F_FT<"movz.s", GPR64Opnd, FGR32Opnd, II_MOVZ_S>, CMov_I_F_FM<18, 16>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; def MOVN_I_S : MMRel, CMov_I_F_FT<"movn.s", GPR32Opnd, FGR32Opnd, II_MOVN_S>, CMov_I_F_FM<19, 16>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in def MOVN_I64_S : CMov_I_F_FT<"movn.s", GPR64Opnd, FGR32Opnd, II_MOVN_S>, CMov_I_F_FM<19, 16>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; def MOVZ_I_D32 : MMRel, CMov_I_F_FT<"movz.d", GPR32Opnd, AFGR64Opnd, II_MOVZ_D>, CMov_I_F_FM<18, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; def MOVN_I_D32 : MMRel, CMov_I_F_FT<"movn.d", GPR32Opnd, AFGR64Opnd, II_MOVN_D>, CMov_I_F_FM<19, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; let DecoderNamespace = "MipsFP64" in { def MOVZ_I_D64 : CMov_I_F_FT<"movz.d", GPR32Opnd, FGR64Opnd, II_MOVZ_D>, CMov_I_F_FM<18, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; def MOVN_I_D64 : CMov_I_F_FT<"movn.d", GPR32Opnd, FGR64Opnd, II_MOVN_D>, CMov_I_F_FM<19, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; let isCodeGenOnly = 1 in { def MOVZ_I64_D64 : CMov_I_F_FT<"movz.d", GPR64Opnd, FGR64Opnd, II_MOVZ_D>, CMov_I_F_FM<18, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; def MOVN_I64_D64 : CMov_I_F_FT<"movn.d", GPR64Opnd, FGR64Opnd, II_MOVN_D>, CMov_I_F_FM<19, 17>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; } } def MOVT_I : MMRel, CMov_F_I_FT<"movt", GPR32Opnd, II_MOVT, MipsCMovFP_T>, CMov_F_I_FM<1>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in def MOVT_I64 : CMov_F_I_FT<"movt", GPR64Opnd, II_MOVT, MipsCMovFP_T>, CMov_F_I_FM<1>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; def MOVF_I : MMRel, CMov_F_I_FT<"movf", GPR32Opnd, II_MOVF, MipsCMovFP_F>, CMov_F_I_FM<0>, INSN_MIPS4_32_NOT_32R6_64R6; let isCodeGenOnly = 1 in def MOVF_I64 : CMov_F_I_FT<"movf", GPR64Opnd, II_MOVF, MipsCMovFP_F>, CMov_F_I_FM<0>, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; def MOVT_S : MMRel, CMov_F_F_FT<"movt.s", FGR32Opnd, II_MOVT_S, MipsCMovFP_T>, CMov_F_F_FM<16, 1>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVF_S : MMRel, CMov_F_F_FT<"movf.s", FGR32Opnd, II_MOVF_S, MipsCMovFP_F>, CMov_F_F_FM<16, 0>, INSN_MIPS4_32_NOT_32R6_64R6; def MOVT_D32 : MMRel, CMov_F_F_FT<"movt.d", AFGR64Opnd, II_MOVT_D, MipsCMovFP_T>, CMov_F_F_FM<17, 1>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; def MOVF_D32 : MMRel, CMov_F_F_FT<"movf.d", AFGR64Opnd, II_MOVF_D, MipsCMovFP_F>, CMov_F_F_FM<17, 0>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; let DecoderNamespace = "MipsFP64" in { def MOVT_D64 : CMov_F_F_FT<"movt.d", FGR64Opnd, II_MOVT_D, MipsCMovFP_T>, CMov_F_F_FM<17, 1>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; def MOVF_D64 : CMov_F_F_FT<"movf.d", FGR64Opnd, II_MOVF_D, MipsCMovFP_F>, CMov_F_F_FM<17, 0>, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; } // Instantiation of conditional move patterns. defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovzPats2, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats2, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats2, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats2, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, GPR_64; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, FGR_32; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; defm : MovzPats0, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; defm : MovzPats1, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; defm : MovnPats, INSN_MIPS4_32_NOT_32R6_64R6, FGR_64; } // For targets that don't have conditional-move instructions // we have to match SELECT nodes with pseudo instructions. let usesCustomInserter = 1 in { class Select_Pseudo : PseudoSE<(outs RC:$dst), (ins GPR32Opnd:$cond, RC:$T, RC:$F), [(set RC:$dst, (select GPR32Opnd:$cond, RC:$T, RC:$F))]>, ISA_MIPS1_NOT_4_32; class SelectFP_Pseudo_T : PseudoSE<(outs RC:$dst), (ins FCCRegsOpnd:$cond, RC:$T, RC:$F), [(set RC:$dst, (MipsCMovFP_T RC:$T, FCCRegsOpnd:$cond, RC:$F))]>, ISA_MIPS1_NOT_4_32; class SelectFP_Pseudo_F : PseudoSE<(outs RC:$dst), (ins FCCRegsOpnd:$cond, RC:$T, RC:$F), [(set RC:$dst, (MipsCMovFP_F RC:$T, FCCRegsOpnd:$cond, RC:$F))]>, ISA_MIPS1_NOT_4_32; } def PseudoSELECT_I : Select_Pseudo; def PseudoSELECT_I64 : Select_Pseudo; def PseudoSELECT_S : Select_Pseudo; def PseudoSELECT_D32 : Select_Pseudo, FGR_32; def PseudoSELECT_D64 : Select_Pseudo, FGR_64; def PseudoSELECTFP_T_I : SelectFP_Pseudo_T; def PseudoSELECTFP_T_I64 : SelectFP_Pseudo_T; def PseudoSELECTFP_T_S : SelectFP_Pseudo_T; def PseudoSELECTFP_T_D32 : SelectFP_Pseudo_T, FGR_32; def PseudoSELECTFP_T_D64 : SelectFP_Pseudo_T, FGR_64; def PseudoSELECTFP_F_I : SelectFP_Pseudo_F; def PseudoSELECTFP_F_I64 : SelectFP_Pseudo_F; def PseudoSELECTFP_F_S : SelectFP_Pseudo_F; def PseudoSELECTFP_F_D32 : SelectFP_Pseudo_F, FGR_32; def PseudoSELECTFP_F_D64 : SelectFP_Pseudo_F, FGR_64;