mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
Move class and instruction definitions for conditional moves to a seperate file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142220 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eea367ec97
commit
8f3af87e99
107
lib/Target/Mips/MipsCondMov.td
Normal file
107
lib/Target/Mips/MipsCondMov.td
Normal file
@ -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>;
|
||||
}
|
||||
|
@ -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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user