diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -331,7 +331,7 @@ : RVInstB, - Sched<[WriteJmp]> { + Sched<[WriteJmp, ReadJmp, ReadJmp]> { let isBranch = 1; let isTerminator = 1; } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td @@ -49,8 +49,7 @@ class FPALUD_rr_frm funct7, string opcodestr> : RVInstRFrm, - Sched<[WriteFALU64, ReadFALU64, ReadFALU64]>; + "$rd, $rs1, $rs2, $funct3">; class FPALUDDynFrmAlias : InstAlias, - Sched<[WriteFLD64, ReadMemBase]>; + Sched<[WriteFLD64, ReadFMemBase]>; // Operands for stores are in the order srcreg, base, offset rather than // reflecting the order these fields are specified in the instruction @@ -81,7 +80,7 @@ def FSD : RVInstS<0b011, OPC_STORE_FP, (outs), (ins FPR64:$rs2, GPR:$rs1, simm12:$imm12), "fsd", "$rs2, ${imm12}(${rs1})">, - Sched<[WriteFST64, ReadStoreData, ReadMemBase]>; + Sched<[WriteFST64, ReadStoreData, ReadFMemBase]>; def FMADD_D : FPFMAD_rrr_frm, Sched<[WriteFMulAdd64, ReadFMulAdd64, ReadFMulAdd64, ReadFMulAdd64]>; @@ -96,26 +95,40 @@ Sched<[WriteFMulAdd64, ReadFMulAdd64, ReadFMulAdd64, ReadFMulAdd64]>; def : FPFMADDynFrmAlias; -def FADD_D : FPALUD_rr_frm<0b0000001, "fadd.d">; +def FADD_D : FPALUD_rr_frm<0b0000001, "fadd.d">, + Sched<[WriteFALU64, ReadFALU64, ReadFALU64]>; def : FPALUDDynFrmAlias; -def FSUB_D : FPALUD_rr_frm<0b0000101, "fsub.d">; +def FSUB_D : FPALUD_rr_frm<0b0000101, "fsub.d">, + Sched<[WriteFALU64, ReadFALU64, ReadFALU64]>; def : FPALUDDynFrmAlias; -def FMUL_D : FPALUD_rr_frm<0b0001001, "fmul.d">; +def FMUL_D : FPALUD_rr_frm<0b0001001, "fmul.d">, + Sched<[WriteFMul64, ReadFMul64, ReadFMul64]>; def : FPALUDDynFrmAlias; -def FDIV_D : FPALUD_rr_frm<0b0001101, "fdiv.d">; +def FDIV_D : FPALUD_rr_frm<0b0001101, "fdiv.d">, + Sched<[WriteFDiv64, ReadFDiv64, ReadFDiv64]>; def : FPALUDDynFrmAlias; def FSQRT_D : FPUnaryOp_r_frm<0b0101101, FPR64, FPR64, "fsqrt.d">, - Sched<[WriteFSqrt32, ReadFSqrt32]> { + Sched<[WriteFSqrt64, ReadFSqrt64]> { let rs2 = 0b00000; } def : FPUnaryOpDynFrmAlias; -def FSGNJ_D : FPALUD_rr<0b0010001, 0b000, "fsgnj.d">; -def FSGNJN_D : FPALUD_rr<0b0010001, 0b001, "fsgnjn.d">; -def FSGNJX_D : FPALUD_rr<0b0010001, 0b010, "fsgnjx.d">; -def FMIN_D : FPALUD_rr<0b0010101, 0b000, "fmin.d">; -def FMAX_D : FPALUD_rr<0b0010101, 0b001, "fmax.d">; +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class FPALUD_rr_no_sched funct7, bits<3> funct3, string opcodestr> + : RVInstR; + +def FSGNJ_D : FPALUD_rr_no_sched<0b0010001, 0b000, "fsgnj.d">, + Sched<[WriteFSGNJ64, ReadFSGNJ64, ReadFSGNJ64]>; +def FSGNJN_D : FPALUD_rr_no_sched<0b0010001, 0b001, "fsgnjn.d">, + Sched<[WriteFSGNJ64, ReadFSGNJ64, ReadFSGNJ64]>; +def FSGNJX_D : FPALUD_rr_no_sched<0b0010001, 0b010, "fsgnjx.d">, + Sched<[WriteFSGNJ64, ReadFSGNJ64, ReadFSGNJ64]>; +def FMIN_D : FPALUD_rr_no_sched<0b0010101, 0b000, "fmin.d">, + Sched<[WriteFMinMax64, ReadFMinMax64, ReadFMinMax64]>; +def FMAX_D : FPALUD_rr_no_sched<0b0010101, 0b001, "fmax.d">, + Sched<[WriteFMinMax64, ReadFMinMax64, ReadFMinMax64]>; def FCVT_S_D : FPUnaryOp_r_frm<0b0100000, FPR32, FPR64, "fcvt.s.d">, Sched<[WriteFCvtF64ToF32, ReadFCvtF64ToF32]> { diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td @@ -106,7 +106,7 @@ def FLW : RVInstI<0b010, OPC_LOAD_FP, (outs FPR32:$rd), (ins GPR:$rs1, simm12:$imm12), "flw", "$rd, ${imm12}(${rs1})">, - Sched<[WriteFLD32, ReadMemBase]>; + Sched<[WriteFLD32, ReadFMemBase]>; // Operands for stores are in the order srcreg, base, offset rather than // reflecting the order these fields are specified in the instruction @@ -115,7 +115,7 @@ def FSW : RVInstS<0b010, OPC_STORE_FP, (outs), (ins FPR32:$rs2, GPR:$rs1, simm12:$imm12), "fsw", "$rs2, ${imm12}(${rs1})">, - Sched<[WriteFST32, ReadStoreData, ReadMemBase]>; + Sched<[WriteFST32, ReadStoreData, ReadFMemBase]>; def FMADD_S : FPFMAS_rrr_frm, Sched<[WriteFMulAdd32, ReadFMulAdd32, ReadFMulAdd32, ReadFMulAdd32]>; @@ -149,11 +149,21 @@ } def : FPUnaryOpDynFrmAlias; -def FSGNJ_S : FPALUS_rr<0b0010000, 0b000, "fsgnj.s">; -def FSGNJN_S : FPALUS_rr<0b0010000, 0b001, "fsgnjn.s">; -def FSGNJX_S : FPALUS_rr<0b0010000, 0b010, "fsgnjx.s">; -def FMIN_S : FPALUS_rr<0b0010100, 0b000, "fmin.s">; -def FMAX_S : FPALUS_rr<0b0010100, 0b001, "fmax.s">; +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class FPALUS_rr_no_sched funct7, bits<3> funct3, string opcodestr> + : RVInstR; + +def FSGNJ_S : FPALUS_rr_no_sched<0b0010000, 0b000, "fsgnj.s">, + Sched<[WriteFSGNJ32, ReadFSGNJ32, ReadFSGNJ32]>; +def FSGNJN_S : FPALUS_rr_no_sched<0b0010000, 0b001, "fsgnjn.s">, + Sched<[WriteFSGNJ32, ReadFSGNJ32, ReadFSGNJ32]>; +def FSGNJX_S : FPALUS_rr_no_sched<0b0010000, 0b010, "fsgnjx.s">, + Sched<[WriteFSGNJ32, ReadFSGNJ32, ReadFSGNJ32]>; +def FMIN_S : FPALUS_rr_no_sched<0b0010100, 0b000, "fmin.s">, + Sched<[WriteFMinMax32, ReadFMinMax32, ReadFMinMax32]>; +def FMAX_S : FPALUS_rr_no_sched<0b0010100, 0b001, "fmax.s">, + Sched<[WriteFMinMax32, ReadFMinMax32, ReadFMinMax32]>; def FCVT_W_S : FPUnaryOp_r_frm<0b1100000, GPR, FPR32, "fcvt.w.s">, Sched<[WriteFCvtF32ToI32, ReadFCvtF32ToI32]> { diff --git a/llvm/lib/Target/RISCV/RISCVSchedRocket32.td b/llvm/lib/Target/RISCV/RISCVSchedRocket32.td --- a/llvm/lib/Target/RISCV/RISCVSchedRocket32.td +++ b/llvm/lib/Target/RISCV/RISCVSchedRocket32.td @@ -89,9 +89,13 @@ // Most FP single precision operations are 4 cycles def : WriteRes { let Latency = 4; } +def : WriteRes { let Latency = 4; } +def : WriteRes { let Latency = 4; } // Most FP double precision operations are 6 cycles def : WriteRes { let Latency = 6; } +def : WriteRes { let Latency = 6; } +def : WriteRes { let Latency = 6; } let Latency = 2 in { def : WriteRes; @@ -180,6 +184,7 @@ def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; +def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; @@ -194,6 +199,10 @@ def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; diff --git a/llvm/lib/Target/RISCV/RISCVSchedRocket64.td b/llvm/lib/Target/RISCV/RISCVSchedRocket64.td --- a/llvm/lib/Target/RISCV/RISCVSchedRocket64.td +++ b/llvm/lib/Target/RISCV/RISCVSchedRocket64.td @@ -102,9 +102,13 @@ // Most FP single precision operations are 4 cycles def : WriteRes { let Latency = 4; } +def : WriteRes { let Latency = 4; } +def : WriteRes { let Latency = 4; } // Most FP double precision operations are 6 cycles def : WriteRes { let Latency = 6; } +def : WriteRes { let Latency = 6; } +def : WriteRes { let Latency = 6; } // Conversion instructions let Latency = 2 in { @@ -181,6 +185,7 @@ def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; +def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; @@ -195,6 +200,10 @@ def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; +def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; diff --git a/llvm/lib/Target/RISCV/RISCVSchedule.td b/llvm/lib/Target/RISCV/RISCVSchedule.td --- a/llvm/lib/Target/RISCV/RISCVSchedule.td +++ b/llvm/lib/Target/RISCV/RISCVSchedule.td @@ -71,6 +71,10 @@ def WriteFClass64 : SchedWrite; // 64-bit floating point classify def WriteFCmp32 : SchedWrite; // 32-bit floating point compare def WriteFCmp64 : SchedWrite; // 64-bit floating point compare +def WriteFSGNJ32 : SchedWrite; // 32-bit floating point sign-injection +def WriteFSGNJ64 : SchedWrite; // 64-bit floating point sign-injection +def WriteFMinMax32 : SchedWrite; // 32-bit floating point min or max +def WriteFMinMax64 : SchedWrite; // 64-bit floating point min or max def WriteFMovF32ToI32 : SchedWrite; def WriteFMovI32ToF32 : SchedWrite; @@ -89,6 +93,7 @@ def ReadJalr : SchedRead; def ReadCSR : SchedRead; def ReadMemBase : SchedRead; +def ReadFMemBase : SchedRead; def ReadStoreData : SchedRead; def ReadIALU : SchedRead; def ReadIALU32 : SchedRead; // 32-bit integer ALU operations on RV64I @@ -120,6 +125,10 @@ def ReadFSqrt64 : SchedRead; // 64-bit floating point sqrt def ReadFCmp32 : SchedRead; def ReadFCmp64 : SchedRead; +def ReadFSGNJ32 : SchedRead; +def ReadFSGNJ64 : SchedRead; +def ReadFMinMax32 : SchedRead; +def ReadFMinMax64 : SchedRead; def ReadFCvtF32ToI32 : SchedRead; def ReadFCvtF32ToI64 : SchedRead; def ReadFCvtF64ToI32 : SchedRead;