From 0325be55596b0e7386a792580d8fca2e9bb74c35 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 10 Jun 2024 18:34:08 -0700 Subject: Separate RV32 and RV64 C instructions into separate files --- riscv/insns/c_flw.h | 11 +++-------- riscv/insns/c_flwsp.h | 12 +++--------- riscv/insns/c_fsw.h | 11 +++-------- riscv/insns/c_fswsp.h | 11 +++-------- riscv/insns/c_ld.h | 2 ++ riscv/insns/c_ldsp.h | 3 +++ riscv/insns/c_sd.h | 2 ++ riscv/insns/c_sdsp.h | 2 ++ riscv/overlap_list.h | 6 ++++++ riscv/riscv.mk.in | 4 ++++ 10 files changed, 31 insertions(+), 33 deletions(-) create mode 100644 riscv/insns/c_ld.h create mode 100644 riscv/insns/c_ldsp.h create mode 100644 riscv/insns/c_sd.h create mode 100644 riscv/insns/c_sdsp.h diff --git a/riscv/insns/c_flw.h b/riscv/insns/c_flw.h index 95ae260..aa64bf1 100644 --- a/riscv/insns/c_flw.h +++ b/riscv/insns/c_flw.h @@ -1,8 +1,3 @@ -if (xlen == 32) { - require_extension(EXT_ZCF); - require_fp; - WRITE_RVC_FRS2S(f32(MMU.load(RVC_RS1S + insn.rvc_lw_imm()))); -} else { // c.ld - require_extension(EXT_ZCA); - WRITE_RVC_RS2S(MMU.load(RVC_RS1S + insn.rvc_ld_imm())); -} +require_extension(EXT_ZCF); +require_fp; +WRITE_RVC_FRS2S(f32(MMU.load(RVC_RS1S + insn.rvc_lw_imm()))); diff --git a/riscv/insns/c_flwsp.h b/riscv/insns/c_flwsp.h index eea0ec5..caea77c 100644 --- a/riscv/insns/c_flwsp.h +++ b/riscv/insns/c_flwsp.h @@ -1,9 +1,3 @@ -if (xlen == 32) { - require_extension(EXT_ZCF); - require_fp; - WRITE_FRD(f32(MMU.load(RVC_SP + insn.rvc_lwsp_imm()))); -} else { // c.ldsp - require_extension(EXT_ZCA); - require(insn.rvc_rd() != 0); - WRITE_RD(MMU.load(RVC_SP + insn.rvc_ldsp_imm())); -} +require_extension(EXT_ZCF); +require_fp; +WRITE_FRD(f32(MMU.load(RVC_SP + insn.rvc_lwsp_imm()))); diff --git a/riscv/insns/c_fsw.h b/riscv/insns/c_fsw.h index d7d6fed..dda411a 100644 --- a/riscv/insns/c_fsw.h +++ b/riscv/insns/c_fsw.h @@ -1,8 +1,3 @@ -if (xlen == 32) { - require_extension(EXT_ZCF); - require_fp; - MMU.store(RVC_RS1S + insn.rvc_lw_imm(), RVC_FRS2S.v[0]); -} else { // c.sd - require_extension(EXT_ZCA); - MMU.store(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S); -} +require_extension(EXT_ZCF); +require_fp; +MMU.store(RVC_RS1S + insn.rvc_lw_imm(), RVC_FRS2S.v[0]); diff --git a/riscv/insns/c_fswsp.h b/riscv/insns/c_fswsp.h index 5952251..6ea5c05 100644 --- a/riscv/insns/c_fswsp.h +++ b/riscv/insns/c_fswsp.h @@ -1,8 +1,3 @@ -if (xlen == 32) { - require_extension(EXT_ZCF); - require_fp; - MMU.store(RVC_SP + insn.rvc_swsp_imm(), RVC_FRS2.v[0]); -} else { // c.sdsp - require_extension(EXT_ZCA); - MMU.store(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2); -} +require_extension(EXT_ZCF); +require_fp; +MMU.store(RVC_SP + insn.rvc_swsp_imm(), RVC_FRS2.v[0]); diff --git a/riscv/insns/c_ld.h b/riscv/insns/c_ld.h new file mode 100644 index 0000000..988ea98 --- /dev/null +++ b/riscv/insns/c_ld.h @@ -0,0 +1,2 @@ +require_extension(EXT_ZCA); +WRITE_RVC_RS2S(MMU.load(RVC_RS1S + insn.rvc_ld_imm())); diff --git a/riscv/insns/c_ldsp.h b/riscv/insns/c_ldsp.h new file mode 100644 index 0000000..f196040 --- /dev/null +++ b/riscv/insns/c_ldsp.h @@ -0,0 +1,3 @@ +require_extension(EXT_ZCA); +require(insn.rvc_rd() != 0); +WRITE_RD(MMU.load(RVC_SP + insn.rvc_ldsp_imm())); diff --git a/riscv/insns/c_sd.h b/riscv/insns/c_sd.h new file mode 100644 index 0000000..ff8f77d --- /dev/null +++ b/riscv/insns/c_sd.h @@ -0,0 +1,2 @@ +require_extension(EXT_ZCA); +MMU.store(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S); diff --git a/riscv/insns/c_sdsp.h b/riscv/insns/c_sdsp.h new file mode 100644 index 0000000..f7b8a28 --- /dev/null +++ b/riscv/insns/c_sdsp.h @@ -0,0 +1,2 @@ +require_extension(EXT_ZCA); +MMU.store(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2); diff --git a/riscv/overlap_list.h b/riscv/overlap_list.h index 7468e87..253be45 100644 --- a/riscv/overlap_list.h +++ b/riscv/overlap_list.h @@ -1,3 +1,9 @@ +// these overlap c.ld[sp]/c.sd[sp] +DECLARE_OVERLAP_INSN(c_flw, EXT_ZCF) +DECLARE_OVERLAP_INSN(c_flwsp, EXT_ZCF) +DECLARE_OVERLAP_INSN(c_fsw, EXT_ZCF) +DECLARE_OVERLAP_INSN(c_fswsp, EXT_ZCF) + // these overlap c.fsdsp DECLARE_OVERLAP_INSN(cm_push, EXT_ZCMP) DECLARE_OVERLAP_INSN(cm_pop, EXT_ZCMP) diff --git a/riscv/riscv.mk.in b/riscv/riscv.mk.in index 689a198..60723b5 100644 --- a/riscv/riscv.mk.in +++ b/riscv/riscv.mk.in @@ -182,6 +182,8 @@ riscv_insn_ext_c = \ c_jr \ c_li \ c_lui \ + c_ld \ + c_ldsp \ c_lw \ c_lwsp \ c_mv \ @@ -191,6 +193,8 @@ riscv_insn_ext_c = \ c_srli \ c_sub \ c_subw \ + c_sd \ + c_sdsp \ c_sw \ c_swsp \ c_xor \ -- cgit v1.1