forked from OSchip/llvm-project
[RISCV] Reduce repetitive codes in flw, fsw
Trying to improve code reuse in F,D,Zfh *.td files. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D116089
This commit is contained in:
parent
7924b3814f
commit
70a98008ea
|
@ -30,21 +30,12 @@ def RISCVSplitF64 : SDNode<"RISCVISD::SplitF64", SDT_RISCVSplitF64>;
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
let Predicates = [HasStdExtD] in {
|
||||
|
||||
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
|
||||
def FLD : RVInstI<0b011, OPC_LOAD_FP, (outs FPR64:$rd),
|
||||
(ins GPR:$rs1, simm12:$imm12),
|
||||
"fld", "$rd, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFLD64, ReadFMemBase]>;
|
||||
def FLD : FPLoad_r<0b011, "fld", FPR64, WriteFLD64>;
|
||||
|
||||
// Operands for stores are in the order srcreg, base, offset rather than
|
||||
// reflecting the order these fields are specified in the instruction
|
||||
// encoding.
|
||||
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
|
||||
def FSD : RVInstS<0b011, OPC_STORE_FP, (outs),
|
||||
(ins FPR64:$rs2, GPR:$rs1, simm12:$imm12),
|
||||
"fsd", "$rs2, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFST64, ReadStoreData, ReadFMemBase]>;
|
||||
def FSD : FPStore_r<0b011, "fsd", FPR64, WriteFST64>;
|
||||
|
||||
let SchedRW = [WriteFMA64, ReadFMA64, ReadFMA64, ReadFMA64] in {
|
||||
def FMADD_D : FPFMA_rrr_frm<OPC_MADD, 0b01, "fmadd.d", FPR64>;
|
||||
|
|
|
@ -73,6 +73,22 @@ def frmarg : Operand<XLenVT> {
|
|||
// Instruction class templates
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
|
||||
class FPLoad_r<bits<3> funct3, string opcodestr, RegisterClass rty,
|
||||
SchedWrite sw>
|
||||
: RVInstI<funct3, OPC_LOAD_FP, (outs rty:$rd),
|
||||
(ins GPR:$rs1, simm12:$imm12),
|
||||
opcodestr, "$rd, ${imm12}(${rs1})">,
|
||||
Sched<[sw, ReadFMemBase]>;
|
||||
|
||||
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
|
||||
class FPStore_r<bits<3> funct3, string opcodestr, RegisterClass rty,
|
||||
SchedWrite sw>
|
||||
: RVInstS<funct3, OPC_STORE_FP, (outs),
|
||||
(ins rty:$rs2, GPR:$rs1, simm12:$imm12),
|
||||
opcodestr, "$rs2, ${imm12}(${rs1})">,
|
||||
Sched<[sw, ReadStoreData, ReadFMemBase]>;
|
||||
|
||||
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, mayRaiseFPException = 1,
|
||||
UseNamedOperandTable = 1, hasPostISelHook = 1 in
|
||||
class FPFMA_rrr_frm<RISCVOpcode opcode, bits<2> funct2, string opcodestr,
|
||||
|
@ -138,20 +154,12 @@ class FPCmp_rr<bits<7> funct7, bits<3> funct3, string opcodestr,
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
let Predicates = [HasStdExtF] in {
|
||||
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
|
||||
def FLW : RVInstI<0b010, OPC_LOAD_FP, (outs FPR32:$rd),
|
||||
(ins GPR:$rs1, simm12:$imm12),
|
||||
"flw", "$rd, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFLD32, ReadFMemBase]>;
|
||||
def FLW : FPLoad_r<0b010, "flw", FPR32, WriteFLD32>;
|
||||
|
||||
// Operands for stores are in the order srcreg, base, offset rather than
|
||||
// reflecting the order these fields are specified in the instruction
|
||||
// encoding.
|
||||
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
|
||||
def FSW : RVInstS<0b010, OPC_STORE_FP, (outs),
|
||||
(ins FPR32:$rs2, GPR:$rs1, simm12:$imm12),
|
||||
"fsw", "$rs2, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFST32, ReadStoreData, ReadFMemBase]>;
|
||||
def FSW : FPStore_r<0b010, "fsw", FPR32, WriteFST32>;
|
||||
|
||||
let SchedRW = [WriteFMA32, ReadFMA32, ReadFMA32, ReadFMA32] in {
|
||||
def FMADD_S : FPFMA_rrr_frm<OPC_MADD, 0b00, "fmadd.s", FPR32>;
|
||||
|
|
|
@ -32,20 +32,12 @@ def riscv_fmv_x_anyexth
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
let Predicates = [HasStdExtZfhmin] in {
|
||||
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
|
||||
def FLH : RVInstI<0b001, OPC_LOAD_FP, (outs FPR16:$rd),
|
||||
(ins GPR:$rs1, simm12:$imm12),
|
||||
"flh", "$rd, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFLD16, ReadFMemBase]>;
|
||||
def FLH : FPLoad_r<0b001, "flh", FPR16, WriteFLD16>;
|
||||
|
||||
// Operands for stores are in the order srcreg, base, offset rather than
|
||||
// reflecting the order these fields are specified in the instruction
|
||||
// encoding.
|
||||
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
|
||||
def FSH : RVInstS<0b001, OPC_STORE_FP, (outs),
|
||||
(ins FPR16:$rs2, GPR:$rs1, simm12:$imm12),
|
||||
"fsh", "$rs2, ${imm12}(${rs1})">,
|
||||
Sched<[WriteFST16, ReadStoreData, ReadFMemBase]>;
|
||||
def FSH : FPStore_r<0b001, "fsh", FPR16, WriteFST16>;
|
||||
} // Predicates = [HasStdExtZfhmin]
|
||||
|
||||
let Predicates = [HasStdExtZfh] in {
|
||||
|
|
Loading…
Reference in New Issue