From e8cb50da87f3f609e388e6eb80d8bf1c2858d3de Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Mon, 17 Oct 2011 18:43:19 +0000 Subject: [PATCH] Move class and instruction definitions for conditional moves to a seperate file. llvm-svn: 142220 --- lib/Target/Mips/MipsCondMov.td | 107 ++++++++++++++++++++++++++++ lib/Target/Mips/MipsInstrFPU.td | 53 -------------- lib/Target/Mips/MipsInstrFormats.td | 8 +-- lib/Target/Mips/MipsInstrInfo.td | 50 +------------ 4 files changed, 112 insertions(+), 106 deletions(-) create mode 100644 lib/Target/Mips/MipsCondMov.td diff --git a/lib/Target/Mips/MipsCondMov.td b/lib/Target/Mips/MipsCondMov.td new file mode 100644 index 00000000000..92ab7b0da33 --- /dev/null +++ b/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 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 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 tf, string instr_asm> : + FCMOV { + let cc = 0; + let usesCustomInserter = 1; + let Uses = [FCR31]; + let Constraints = "$F = $rd"; +} + +// cond:float, data:float +class CondMovFPFP fmt, bits<1> tf, + string instr_asm> : + FFCMOV { + let cc = 0; + let usesCustomInserter = 1; + let Uses = [FCR31]; + let Constraints = "$F = $fd"; +} + +// select patterns +multiclass MovzPats { + 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 { + 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; +def MOVN_S : CondMovIntFP; +let Predicates = [NotFP64bit] in { + def MOVZ_D : CondMovIntFP; + def MOVN_D : CondMovIntFP; +} + +def MOVT : CondMovFPInt; +def MOVF : CondMovFPInt; + +def MOVT_S : CondMovFPFP; +def MOVF_S : CondMovFPFP; +let Predicates = [NotFP64bit] in { + def MOVT_D : CondMovFPFP; + def MOVF_D : CondMovFPFP; +} + +// Instantiation of conditional move patterns. +defm : MovzPats; +defm : MovnPats; + +defm : MovzPats; +defm : MovnPats; + +let Predicates = [NotFP64bit] in { + defm : MovzPats; + defm : MovnPats; +} + diff --git a/lib/Target/Mips/MipsInstrFPU.td b/lib/Target/Mips/MipsInstrFPU.td index 2fb9d184b2b..78846a2bbc2 100644 --- a/lib/Target/Mips/MipsInstrFPU.td +++ b/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 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; -def MOVN_S : CondMovIntFP; - -let Predicates = [NotFP64bit] in { - def MOVZ_D : CondMovIntFP; - def MOVN_D : CondMovIntFP; -} - -defm : MovzPats; -defm : MovnPats; - -let Predicates = [NotFP64bit] in { - defm : MovzPats; - defm : MovnPats; -} - -let usesCustomInserter = 1, Uses = [FCR31], Constraints = "$F = $dst" in { -// flag:float, data:int -class CondMovFPInt tf, string instr_asm> : - FCMOV; - -// flag:float, data:float -class CondMovFPFP fmt, bits<1> tf, - string instr_asm> : - FFCMOV; -} - -def MOVT : CondMovFPInt; -def MOVF : CondMovFPInt; -def MOVT_S : CondMovFPFP; -def MOVF_S : CondMovFPFP; - -let Predicates = [NotFP64bit] in { - def MOVT_D : CondMovFPFP; - def MOVF_D : CondMovFPFP; -} - //===----------------------------------------------------------------------===// // Floating Point Pseudo-Instructions //===----------------------------------------------------------------------===// diff --git a/lib/Target/Mips/MipsInstrFormats.td b/lib/Target/Mips/MipsInstrFormats.td index d246a26eb23..6dd82c88786 100644 --- a/lib/Target/Mips/MipsInstrFormats.td +++ b/lib/Target/Mips/MipsInstrFormats.td @@ -205,14 +205,14 @@ class FCMOV _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 _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 _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/lib/Target/Mips/MipsInstrInfo.td b/lib/Target/Mips/MipsInstrInfo.td index a93bc18e85a..92fa18fa65d 100644 --- a/lib/Target/Mips/MipsInstrInfo.td +++ b/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 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; -// select patterns -multiclass MovzPats { - 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 { - 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; -defm : MovnPats; - // setcc patterns multiclass SeteqPats { @@ -1032,5 +983,6 @@ def : Pat<(MipsDynAlloc addr:$f), (DynAlloc addr:$f)>; //===----------------------------------------------------------------------===// include "MipsInstrFPU.td" +include "MipsCondMov.td" include "Mips64InstrInfo.td"