diff options
| author | Akira Hatanaka <ahatanaka@mips.com> | 2011-10-17 18:43:19 +0000 | 
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@mips.com> | 2011-10-17 18:43:19 +0000 | 
| commit | 975bfc9b45ef7384a4d744fb5f7fdf61325001bf (patch) | |
| tree | 138c9b80036fa760ad64f3bb8795f1f47bdcd185 /llvm/lib/Target/Mips | |
| parent | 4124c4924d6349e2d8ddfe2b4df57030d23e4c4e (diff) | |
| download | bcm5719-llvm-975bfc9b45ef7384a4d744fb5f7fdf61325001bf.tar.gz bcm5719-llvm-975bfc9b45ef7384a4d744fb5f7fdf61325001bf.zip  | |
Move class and instruction definitions for conditional moves to a seperate file.
llvm-svn: 142220
Diffstat (limited to 'llvm/lib/Target/Mips')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsCondMov.td | 107 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstrFPU.td | 53 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstrFormats.td | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstrInfo.td | 50 | 
4 files changed, 112 insertions, 106 deletions
diff --git a/llvm/lib/Target/Mips/MipsCondMov.td b/llvm/lib/Target/Mips/MipsCondMov.td new file mode 100644 index 00000000000..92ab7b0da33 --- /dev/null +++ b/llvm/lib/Target/Mips/MipsCondMov.td @@ -0,0 +1,107 @@ +// Conditional moves: +// These instructions are expanded in +// MipsISelLowering::EmitInstrWithCustomInserter if target does not have +// conditional move instructions. +// cond:int, data:int +class CondMovIntInt<bits<6> funct, string instr_asm> : +  FR<0, funct, (outs CPURegs:$rd), (ins CPURegs:$rs, CPURegs:$rt, CPURegs:$F), +     !strconcat(instr_asm, "\t$rd, $rs, $rt"), [], NoItinerary> { +  let shamt = 0; +  let usesCustomInserter = 1; +  let Constraints = "$F = $rd"; +} + +// cond:int, data:float +class CondMovIntFP<RegisterClass RC, bits<5> fmt, bits<6> func, +                   string instr_asm> : +  FFR<0x11, func, fmt, (outs RC:$fd), (ins RC:$fs, CPURegs:$rt, RC:$F), +      !strconcat(instr_asm, "\t$fd, $fs, $rt"), []> { +  let usesCustomInserter = 1; +  let Constraints = "$F = $fd"; +} + +// cond:float, data:int +class CondMovFPInt<SDNode cmov, bits<1> tf, string instr_asm> : +  FCMOV<tf, (outs CPURegs:$rd), (ins CPURegs:$rs, CPURegs:$F), +        !strconcat(instr_asm, "\t$rd, $rs, $$fcc0"), +        [(set CPURegs:$rd, (cmov CPURegs:$rs, CPURegs:$F))]> { +  let cc = 0; +  let usesCustomInserter = 1; +  let Uses = [FCR31]; +  let Constraints = "$F = $rd"; +} + +// cond:float, data:float +class CondMovFPFP<RegisterClass RC, SDNode cmov, bits<5> fmt, bits<1> tf, +                  string instr_asm> : +  FFCMOV<fmt, tf, (outs RC:$fd), (ins RC:$fs, RC:$F), +         !strconcat(instr_asm, "\t$fd, $fs, $$fcc0"), +         [(set RC:$fd, (cmov RC:$fs, RC:$F))]> { +  let cc = 0; +  let usesCustomInserter = 1; +  let Uses = [FCR31]; +  let Constraints = "$F = $fd"; +} + +// select patterns +multiclass MovzPats<RegisterClass RC, Instruction MOVZInst> { +  def : Pat<(select (i32 (setge CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLT CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; +  def : Pat<(select (i32 (setuge CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLTu CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; +  def : Pat<(select (i32 (setge CPURegs:$lhs, immSExt16:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLTi CPURegs:$lhs, immSExt16:$rhs), RC:$F)>; +  def : Pat<(select (i32 (setuge CPURegs:$lh, immSExt16:$rh)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLTiu CPURegs:$lh, immSExt16:$rh), RC:$F)>; +  def : Pat<(select (i32 (setle CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLT CPURegs:$rhs, CPURegs:$lhs), RC:$F)>; +  def : Pat<(select (i32 (setule CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (SLTu CPURegs:$rhs, CPURegs:$lhs), RC:$F)>; +  def : Pat<(select (i32 (seteq CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVZInst RC:$T, (XOR CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; +  def : Pat<(select (i32 (seteq CPURegs:$lhs, 0)), RC:$T, RC:$F), +            (MOVZInst RC:$T, CPURegs:$lhs, RC:$F)>; +} + +multiclass MovnPats<RegisterClass RC, Instruction MOVNInst> { +  def : Pat<(select (i32 (setne CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), +            (MOVNInst RC:$T, (XOR CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; +  def : Pat<(select CPURegs:$cond, RC:$T, RC:$F), +            (MOVNInst RC:$T, CPURegs:$cond, RC:$F)>; +  def : Pat<(select (i32 (setne CPURegs:$lhs, 0)), RC:$T, RC:$F), +            (MOVNInst RC:$T, CPURegs:$lhs, RC:$F)>; +} + +// Instantiation of instructions. +def MOVZ_I : CondMovIntInt<0x0a, "movz">; +def MOVN_I : CondMovIntInt<0x0b, "movn">; + +def MOVZ_S : CondMovIntFP<FGR32, 16, 18, "movz.s">; +def MOVN_S : CondMovIntFP<FGR32, 16, 19, "movn.s">; +let Predicates = [NotFP64bit] in { +  def MOVZ_D : CondMovIntFP<AFGR64, 17, 18, "movz.d">; +  def MOVN_D : CondMovIntFP<AFGR64, 17, 19, "movn.d">; +} + +def MOVT : CondMovFPInt<MipsCMovFP_T, 1, "movt">; +def MOVF : CondMovFPInt<MipsCMovFP_F, 0, "movf">; + +def MOVT_S : CondMovFPFP<FGR32, MipsCMovFP_T, 16, 1, "movt.s">; +def MOVF_S : CondMovFPFP<FGR32, MipsCMovFP_F, 16, 0, "movf.s">; +let Predicates = [NotFP64bit] in { +  def MOVT_D : CondMovFPFP<AFGR64, MipsCMovFP_T, 17, 1, "movt.d">; +  def MOVF_D : CondMovFPFP<AFGR64, MipsCMovFP_F, 17, 0, "movf.d">; +} + +// Instantiation of conditional move patterns. +defm : MovzPats<CPURegs, MOVZ_I>; +defm : MovnPats<CPURegs, MOVN_I>; + +defm : MovzPats<FGR32, MOVZ_S>; +defm : MovnPats<FGR32, MOVN_S>; + +let Predicates = [NotFP64bit] in { +  defm : MovzPats<AFGR64, MOVZ_D>; +  defm : MovnPats<AFGR64, MOVN_D>; +} + diff --git a/llvm/lib/Target/Mips/MipsInstrFPU.td b/llvm/lib/Target/Mips/MipsInstrFPU.td index 2fb9d184b2b..78846a2bbc2 100644 --- a/llvm/lib/Target/Mips/MipsInstrFPU.td +++ b/llvm/lib/Target/Mips/MipsInstrFPU.td @@ -259,59 +259,6 @@ let Defs=[FCR31] in {                       Requires<[NotFP64bit]>;  } - -// Conditional moves: -// These instructions are expanded in -// MipsISelLowering::EmitInstrWithCustomInserter if target does not have -// conditional move instructions. -// flag:int, data:float -let usesCustomInserter = 1, Constraints = "$F = $dst" in -class CondMovIntFP<RegisterClass RC, bits<5> fmt, bits<6> func, -                   string instr_asm> : -  FFR<0x11, func, fmt, (outs RC:$dst), (ins RC:$T, CPURegs:$cond, RC:$F), -      !strconcat(instr_asm, "\t$dst, $T, $cond"), []>; - -def MOVZ_S : CondMovIntFP<FGR32, 16, 18, "movz.s">; -def MOVN_S : CondMovIntFP<FGR32, 16, 19, "movn.s">; - -let Predicates = [NotFP64bit] in { -  def MOVZ_D : CondMovIntFP<AFGR64, 17, 18, "movz.d">; -  def MOVN_D : CondMovIntFP<AFGR64, 17, 19, "movn.d">; -} - -defm : MovzPats<FGR32, MOVZ_S>; -defm : MovnPats<FGR32, MOVN_S>; - -let Predicates = [NotFP64bit] in { -  defm : MovzPats<AFGR64, MOVZ_D>; -  defm : MovnPats<AFGR64, MOVN_D>; -} - -let usesCustomInserter = 1, Uses = [FCR31], Constraints = "$F = $dst" in { -// flag:float, data:int -class CondMovFPInt<SDNode cmov, bits<1> tf, string instr_asm> : -  FCMOV<tf, (outs CPURegs:$dst), (ins CPURegs:$T, CPURegs:$F), -        !strconcat(instr_asm, "\t$dst, $T, $$fcc0"), -        [(set CPURegs:$dst, (cmov CPURegs:$T, CPURegs:$F))]>; - -// flag:float, data:float -class CondMovFPFP<RegisterClass RC, SDNode cmov, bits<5> fmt, bits<1> tf, -                  string instr_asm> : -  FFCMOV<fmt, tf, (outs RC:$dst), (ins RC:$T, RC:$F), -         !strconcat(instr_asm, "\t$dst, $T, $$fcc0"), -         [(set RC:$dst, (cmov RC:$T, RC:$F))]>; -} - -def MOVT : CondMovFPInt<MipsCMovFP_T, 1, "movt">; -def MOVF : CondMovFPInt<MipsCMovFP_F, 0, "movf">; -def MOVT_S : CondMovFPFP<FGR32, MipsCMovFP_T, 16, 1, "movt.s">; -def MOVF_S : CondMovFPFP<FGR32, MipsCMovFP_F, 16, 0, "movf.s">; - -let Predicates = [NotFP64bit] in { -  def MOVT_D : CondMovFPFP<AFGR64, MipsCMovFP_T, 17, 1, "movt.d">; -  def MOVF_D : CondMovFPFP<AFGR64, MipsCMovFP_F, 17, 0, "movf.d">; -} -  //===----------------------------------------------------------------------===//  // Floating Point Pseudo-Instructions  //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/Mips/MipsInstrFormats.td b/llvm/lib/Target/Mips/MipsInstrFormats.td index d246a26eb23..6dd82c88786 100644 --- a/llvm/lib/Target/Mips/MipsInstrFormats.td +++ b/llvm/lib/Target/Mips/MipsInstrFormats.td @@ -205,14 +205,14 @@ class FCMOV<bits<1> _tf, dag outs, dag ins, string asmstr,  {    bits<5>  rd;    bits<5>  rs; -  bits<3>  N; +  bits<3>  cc;    bits<1>  tf;    let opcode = 0;    let tf = _tf;    let Inst{25-21} = rs; -  let Inst{20-18} = N; +  let Inst{20-18} = cc;    let Inst{17} = 0;    let Inst{16} = tf;    let Inst{15-11} = rd; @@ -226,7 +226,7 @@ class FFCMOV<bits<5> _fmt, bits<1> _tf, dag outs, dag ins, string asmstr,  {    bits<5>  fd;    bits<5>  fs; -  bits<3>  N; +  bits<3>  cc;    bits<5>  fmt;    bits<1>  tf; @@ -235,7 +235,7 @@ class FFCMOV<bits<5> _fmt, bits<1> _tf, dag outs, dag ins, string asmstr,    let tf = _tf;    let Inst{25-21} = fmt; -  let Inst{20-18} = N; +  let Inst{20-18} = cc;    let Inst{17} = 0;    let Inst{16} = tf;    let Inst{15-11} = fs; diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td index a93bc18e85a..92fa18fa65d 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MipsInstrInfo.td @@ -769,23 +769,6 @@ def CLO : CountLeading1<0x21, "clo", CPURegs>;  /// Byte Swap  def WSBW : ByteSwap<0x20, 0x2, "wsbw">; -// Conditional moves: -// These instructions are expanded in -// MipsISelLowering::EmitInstrWithCustomInserter if target does not have -// conditional move instructions. -// flag:int, data:int -class CondMovIntInt<bits<6> funct, string instr_asm> : -  FR<0, funct, (outs CPURegs:$rd), -     (ins CPURegs:$rs, CPURegs:$rt, CPURegs:$F), -     !strconcat(instr_asm, "\t$rd, $rs, $rt"), [], NoItinerary> { -  let shamt = 0; -  let usesCustomInserter = 1; -  let Constraints = "$F = $rd"; -} - -def MOVZ_I : CondMovIntInt<0x0a, "movz">; -def MOVN_I : CondMovIntInt<0x0b, "movn">; -  /// No operation  let addr=0 in    def NOP   : FJ<0, (outs), (ins), "nop", [], IIAlu>; @@ -948,38 +931,6 @@ def : Pat<(brcond RC:$cond, bb:$dst),  defm : BrcondPats<CPURegs, BEQ, BNE, SLT, SLTu, SLTi, SLTiu, ZERO>; -// select patterns -multiclass MovzPats<RegisterClass RC, Instruction MOVZInst> { -  def : Pat<(select (i32 (setge CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLT CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; -  def : Pat<(select (i32 (setuge CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLTu CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; -  def : Pat<(select (i32 (setge CPURegs:$lhs, immSExt16:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLTi CPURegs:$lhs, immSExt16:$rhs), RC:$F)>; -  def : Pat<(select (i32 (setuge CPURegs:$lh, immSExt16:$rh)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLTiu CPURegs:$lh, immSExt16:$rh), RC:$F)>; -  def : Pat<(select (i32 (setle CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLT CPURegs:$rhs, CPURegs:$lhs), RC:$F)>; -  def : Pat<(select (i32 (setule CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (SLTu CPURegs:$rhs, CPURegs:$lhs), RC:$F)>; -  def : Pat<(select (i32 (seteq CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVZInst RC:$T, (XOR CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; -  def : Pat<(select (i32 (seteq CPURegs:$lhs, 0)), RC:$T, RC:$F), -            (MOVZInst RC:$T, CPURegs:$lhs, RC:$F)>; -} - -multiclass MovnPats<RegisterClass RC, Instruction MOVNInst> { -  def : Pat<(select (i32 (setne CPURegs:$lhs, CPURegs:$rhs)), RC:$T, RC:$F), -            (MOVNInst RC:$T, (XOR CPURegs:$lhs, CPURegs:$rhs), RC:$F)>; -  def : Pat<(select CPURegs:$cond, RC:$T, RC:$F), -            (MOVNInst RC:$T, CPURegs:$cond, RC:$F)>; -  def : Pat<(select (i32 (setne CPURegs:$lhs, 0)), RC:$T, RC:$F), -            (MOVNInst RC:$T, CPURegs:$lhs, RC:$F)>; -} - -defm : MovzPats<CPURegs, MOVZ_I>; -defm : MovnPats<CPURegs, MOVN_I>; -  // setcc patterns  multiclass SeteqPats<RegisterClass RC, Instruction SLTiuOp, Instruction XOROp,                       Instruction SLTuOp, Register ZEROReg> { @@ -1032,5 +983,6 @@ def : Pat<(MipsDynAlloc addr:$f), (DynAlloc addr:$f)>;  //===----------------------------------------------------------------------===//  include "MipsInstrFPU.td" +include "MipsCondMov.td"  include "Mips64InstrInfo.td"  | 

