2010-08-18 00:20:04 +08:00
|
|
|
//===- MBlazeInstrFPU.td - MBlaze FPU Instruction defs -----*- tablegen -*-===//
|
2010-02-24 03:15:24 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze profiles and nodes
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MBlaze Operand, Complex Patterns and Transformations Definitions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Memory Access Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
class LoadFM<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, 0x000, (outs GPR:$dst), (ins memrr:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2011-04-12 06:31:52 +08:00
|
|
|
[(set (f32 GPR:$dst), (OpNode xaddr:$addr))], IIC_MEMl>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class LoadFMI<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins memri:$addr),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2011-04-12 06:31:52 +08:00
|
|
|
[(set (f32 GPR:$dst), (OpNode iaddr:$addr))], IIC_MEMl>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class StoreFM<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, 0x000, (outs), (ins GPR:$dst, memrr:$addr),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2011-04-12 06:31:52 +08:00
|
|
|
[(OpNode (f32 GPR:$dst), xaddr:$addr)], IIC_MEMs>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class StoreFMI<bits<6> op, string instr_asm, PatFrag OpNode> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs), (ins GPR:$dst, memrr:$addr),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $addr"),
|
2011-04-12 06:31:52 +08:00
|
|
|
[(OpNode (f32 GPR:$dst), iaddr:$addr)], IIC_MEMs>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class ArithF<bits<6> op, bits<11> flags, string instr_asm, SDNode OpNode,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2010-10-22 03:48:38 +08:00
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, GPR:$c))], itin>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class CmpFN<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
2010-02-24 03:15:24 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class ArithFR<bits<6> op, bits<11> flags, string instr_asm, SDNode OpNode,
|
|
|
|
InstrItinClass itin> :
|
2010-11-13 07:30:17 +08:00
|
|
|
TAR<op, flags, (outs GPR:$dst), (ins GPR:$b, GPR:$c),
|
|
|
|
!strconcat(instr_asm, " $dst, $c, $b"),
|
|
|
|
[(set GPR:$dst, (OpNode GPR:$b, GPR:$c))], itin>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
class LogicFI<bits<6> op, string instr_asm> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TB<op, (outs GPR:$dst), (ins GPR:$b, fimm:$c),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b, $c"),
|
2011-04-12 06:31:52 +08:00
|
|
|
[], IIC_ALU>;
|
2010-10-21 11:57:26 +08:00
|
|
|
|
|
|
|
let rb=0 in {
|
|
|
|
class ArithF2<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b"),
|
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class ArithIF<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b"),
|
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class ArithFI<bits<6> op, bits<11> flags, string instr_asm,
|
|
|
|
InstrItinClass itin> :
|
2010-10-22 03:48:38 +08:00
|
|
|
TA<op, flags, (outs GPR:$dst), (ins GPR:$b),
|
2010-10-21 11:57:26 +08:00
|
|
|
!strconcat(instr_asm, " $dst, $b"),
|
|
|
|
[], itin>;
|
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pseudo instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FPU Arithmetic Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
let Predicates=[HasFPU] in {
|
|
|
|
def FORI : LogicFI<0x28, "ori ">;
|
2011-04-12 06:31:52 +08:00
|
|
|
def FADD : ArithF<0x16, 0x000, "fadd ", fadd, IIC_FPU>;
|
|
|
|
def FRSUB : ArithFR<0x16, 0x080, "frsub ", fsub, IIC_FPU>;
|
|
|
|
def FMUL : ArithF<0x16, 0x100, "fmul ", fmul, IIC_FPU>;
|
|
|
|
def FDIV : ArithF<0x16, 0x180, "fdiv ", fdiv, IIC_FPUd>;
|
2010-11-13 07:30:17 +08:00
|
|
|
}
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-11-13 07:30:17 +08:00
|
|
|
let Predicates=[HasFPU], isCodeGenOnly=1 in {
|
2010-11-09 03:40:01 +08:00
|
|
|
def LWF : LoadFM<0x32, "lw ", load>;
|
2010-11-13 07:30:17 +08:00
|
|
|
def LWFI : LoadFMI<0x3A, "lwi ", load>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
2010-11-13 07:30:17 +08:00
|
|
|
def SWF : StoreFM<0x36, "sw ", store>;
|
|
|
|
def SWFI : StoreFMI<0x3E, "swi ", store>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates=[HasFPU,HasSqrt] in {
|
2011-04-12 06:31:52 +08:00
|
|
|
def FLT : ArithIF<0x16, 0x280, "flt ", IIC_FPUf>;
|
|
|
|
def FINT : ArithFI<0x16, 0x300, "fint ", IIC_FPUi>;
|
|
|
|
def FSQRT : ArithF2<0x16, 0x380, "fsqrt ", IIC_FPUs>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isAsCheapAsAMove = 1 in {
|
2011-04-12 06:31:52 +08:00
|
|
|
def FCMP_UN : CmpFN<0x16, 0x200, "fcmp.un", IIC_FPUc>;
|
|
|
|
def FCMP_LT : CmpFN<0x16, 0x210, "fcmp.lt", IIC_FPUc>;
|
|
|
|
def FCMP_EQ : CmpFN<0x16, 0x220, "fcmp.eq", IIC_FPUc>;
|
|
|
|
def FCMP_LE : CmpFN<0x16, 0x230, "fcmp.le", IIC_FPUc>;
|
|
|
|
def FCMP_GT : CmpFN<0x16, 0x240, "fcmp.gt", IIC_FPUc>;
|
|
|
|
def FCMP_NE : CmpFN<0x16, 0x250, "fcmp.ne", IIC_FPUc>;
|
|
|
|
def FCMP_GE : CmpFN<0x16, 0x260, "fcmp.ge", IIC_FPUc>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 07:57:05 +08:00
|
|
|
let usesCustomInserter = 1 in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def Select_FCC : MBlazePseudo<(outs GPR:$dst),
|
|
|
|
(ins GPR:$T, GPR:$F, GPR:$CMP, i32imm:$CC),
|
2010-02-24 03:15:24 +08:00
|
|
|
"; SELECT_FCC PSEUDO!",
|
|
|
|
[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Floating point conversions
|
|
|
|
let Predicates=[HasFPU] in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(sint_to_fp GPR:$V), (FLT GPR:$V)>;
|
|
|
|
def : Pat<(fp_to_sint GPR:$V), (FINT GPR:$V)>;
|
|
|
|
def : Pat<(fsqrt GPR:$V), (FSQRT GPR:$V)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// SET_CC operations
|
|
|
|
let Predicates=[HasFPU] in {
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETEQ),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_EQ GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETNE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_EQ GPR:$L, GPR:$R), 1)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETOEQ),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_EQ GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETONE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(XOR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_EQ GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETONE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_EQ GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETGT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_GT GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETLT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_LT GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETGE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_GE GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETLE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_LE GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETOGT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_GT GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETOLT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_LT GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETOGE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_GE GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETOLE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_LE GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETUEQ),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_EQ GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETUNE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_NE GPR:$L, GPR:$R), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETUGT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_GT GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETULT),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_LT GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETUGE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_GE GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETULE),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(OR (FCMP_UN GPR:$L, GPR:$R),
|
|
|
|
(FCMP_LE GPR:$L, GPR:$R)), 2)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETO),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_UN GPR:$L, GPR:$R), 1)>;
|
|
|
|
def : Pat<(setcc (f32 GPR:$L), (f32 GPR:$R), SETUO),
|
2010-12-13 06:02:31 +08:00
|
|
|
(Select_CC (ADDIK (i32 R0), 1), (ADDIK (i32 R0), 0),
|
2010-10-22 03:48:38 +08:00
|
|
|
(FCMP_UN GPR:$L, GPR:$R), 2)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// SELECT operations
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(select (i32 GPR:$C), (f32 GPR:$T), (f32 GPR:$F)),
|
|
|
|
(Select_FCC GPR:$T, GPR:$F, GPR:$C, 2)>;
|
2010-02-24 03:15:24 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Patterns for Floating Point Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-10-22 03:48:38 +08:00
|
|
|
def : Pat<(f32 fpimm:$imm), (FORI (i32 R0), fpimm:$imm)>;
|