diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-21 00:21:46 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-31 18:29:45 -0700 |
commit | bdcb5b297f9919bdd1a1b6031a3b5c469e982d14 (patch) | |
tree | a9c411e8bd1dba295217d8aa28f23b56d4f39313 /riscv/insns | |
parent | 292fef830dad9d6d8b868ba27cf4ddd80bf9243a (diff) | |
download | riscv-isa-sim-bdcb5b297f9919bdd1a1b6031a3b5c469e982d14.zip riscv-isa-sim-bdcb5b297f9919bdd1a1b6031a3b5c469e982d14.tar.gz riscv-isa-sim-bdcb5b297f9919bdd1a1b6031a3b5c469e982d14.tar.bz2 |
New RV64C proposal
Diffstat (limited to 'riscv/insns')
-rw-r--r-- | riscv/insns/c_add.h | 7 | ||||
-rw-r--r-- | riscv/insns/c_add3.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_addi.h | 7 | ||||
-rw-r--r-- | riscv/insns/c_addi4spn.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_addiw.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_addw.h | 1 | ||||
-rw-r--r-- | riscv/insns/c_and3.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_jal.h | 4 | ||||
-rw-r--r-- | riscv/insns/c_ld.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_ldsp.h | 1 | ||||
-rw-r--r-- | riscv/insns/c_li.h | 10 | ||||
-rw-r--r-- | riscv/insns/c_lui.h | 9 | ||||
-rw-r--r-- | riscv/insns/c_lw.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_lwsp.h | 1 | ||||
-rw-r--r-- | riscv/insns/c_mv.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_or3.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_sdsp.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_slli.h | 5 | ||||
-rw-r--r-- | riscv/insns/c_slliw.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_srai.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_srli.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_sub.h | 3 | ||||
-rw-r--r-- | riscv/insns/c_sub3.h | 2 | ||||
-rw-r--r-- | riscv/insns/c_swsp.h | 2 |
24 files changed, 64 insertions, 17 deletions
diff --git a/riscv/insns/c_add.h b/riscv/insns/c_add.h index c349fc0..64bc5f7 100644 --- a/riscv/insns/c_add.h +++ b/riscv/insns/c_add.h @@ -1,2 +1,7 @@ require_extension('C'); -WRITE_RD(sext_xlen(RVC_RS1 + RVC_RS2)); +require(insn.rvc_rs2() != 0); +if (insn.rvc_rd() == 0) { // c.ebreak + throw trap_breakpoint(); +} else { + WRITE_RD(sext_xlen(RVC_RS1 + RVC_RS2)); +} diff --git a/riscv/insns/c_add3.h b/riscv/insns/c_add3.h new file mode 100644 index 0000000..fabf6dd --- /dev/null +++ b/riscv/insns/c_add3.h @@ -0,0 +1,2 @@ +require_extension('C'); +WRITE_RVC_RDS(sext_xlen(RVC_RS1S + RVC_RS2S)); diff --git a/riscv/insns/c_addi.h b/riscv/insns/c_addi.h index ad278f1..cea2a18 100644 --- a/riscv/insns/c_addi.h +++ b/riscv/insns/c_addi.h @@ -1,2 +1,7 @@ require_extension('C'); -WRITE_RD(sext_xlen(RVC_RS2 + insn.rvc_imm())); +if (insn.rvc_rd() == 0) { // c.addi16sp + WRITE_REG(X_SP, sext_xlen(RVC_SP + insn.rvc_addi16sp_imm())); +} else { + require(insn.rvc_imm() != 0); + WRITE_RD(sext_xlen(RVC_RS1 + insn.rvc_imm())); +} diff --git a/riscv/insns/c_addi4spn.h b/riscv/insns/c_addi4spn.h new file mode 100644 index 0000000..102fb25 --- /dev/null +++ b/riscv/insns/c_addi4spn.h @@ -0,0 +1,2 @@ +require_extension('C'); +WRITE_RVC_RS2S(sext_xlen(RVC_SP + insn.rvc_addi4spn_imm())); diff --git a/riscv/insns/c_addiw.h b/riscv/insns/c_addiw.h index 1b81834..27ffd8f 100644 --- a/riscv/insns/c_addiw.h +++ b/riscv/insns/c_addiw.h @@ -1,3 +1,4 @@ require_extension('C'); require_rv64; -WRITE_RD(sext32(RVC_RS2 + insn.rvc_imm())); +require(insn.rvc_rd() != 0); +WRITE_RD(sext32(RVC_RS1 + insn.rvc_imm())); diff --git a/riscv/insns/c_addw.h b/riscv/insns/c_addw.h index fef554d..36559b7 100644 --- a/riscv/insns/c_addw.h +++ b/riscv/insns/c_addw.h @@ -1,3 +1,4 @@ require_extension('C'); require_rv64; +require(insn.rvc_rd() != 0 && insn.rvc_rs2() != 0); WRITE_RD(sext32(RVC_RS1 + RVC_RS2)); diff --git a/riscv/insns/c_and3.h b/riscv/insns/c_and3.h new file mode 100644 index 0000000..5543950 --- /dev/null +++ b/riscv/insns/c_and3.h @@ -0,0 +1,2 @@ +require_extension('C'); +WRITE_RVC_RDS(RVC_RS1S & RVC_RS2S); diff --git a/riscv/insns/c_jal.h b/riscv/insns/c_jal.h new file mode 100644 index 0000000..b63967c --- /dev/null +++ b/riscv/insns/c_jal.h @@ -0,0 +1,4 @@ +require_extension('C'); +reg_t tmp = npc; +set_pc(pc + insn.rvc_j_imm()); +WRITE_REG(X_RA, tmp); diff --git a/riscv/insns/c_ld.h b/riscv/insns/c_ld.h index df0f5c3..876badd 100644 --- a/riscv/insns/c_ld.h +++ b/riscv/insns/c_ld.h @@ -1,3 +1,3 @@ require_extension('C'); require_rv64; -WRITE_RVC_RDS(MMU.load_int64(RVC_RS1S + insn.rvc_ld_imm())); +WRITE_RVC_RS2S(MMU.load_int64(RVC_RS1S + insn.rvc_ld_imm())); diff --git a/riscv/insns/c_ldsp.h b/riscv/insns/c_ldsp.h index 42665cf..7047d53 100644 --- a/riscv/insns/c_ldsp.h +++ b/riscv/insns/c_ldsp.h @@ -1,3 +1,4 @@ require_extension('C'); require_rv64; +require(insn.rvc_rd() != 0); WRITE_RD(MMU.load_int64(RVC_SP + insn.rvc_ldsp_imm())); diff --git a/riscv/insns/c_li.h b/riscv/insns/c_li.h index 06d7bf2..52e99c9 100644 --- a/riscv/insns/c_li.h +++ b/riscv/insns/c_li.h @@ -1,7 +1,7 @@ require_extension('C'); -if (insn.rvc_rd() == 0) { - if (insn.rvc_imm() == -32) // c.sbreak - throw trap_breakpoint(); - throw trap_illegal_instruction(); -} else // c.li +require(insn.rvc_rd() != 0); +if (insn.rvc_imm() == 0) { // c.jr + set_pc(RVC_RS1 & ~reg_t(1)); +} else { WRITE_RD(insn.rvc_imm()); +} diff --git a/riscv/insns/c_lui.h b/riscv/insns/c_lui.h index 4bd4f87..040d7ec 100644 --- a/riscv/insns/c_lui.h +++ b/riscv/insns/c_lui.h @@ -1,2 +1,9 @@ require_extension('C'); -WRITE_RD(insn.rvc_imm() << 12); +require(insn.rvc_rd() != 0); +if (insn.rvc_imm() == 0) { // c.jalr + reg_t tmp = npc; + set_pc(RVC_RS1 & ~reg_t(1)); + WRITE_REG(X_RA, tmp); +} else { + WRITE_RD(insn.rvc_imm() << 12); +} diff --git a/riscv/insns/c_lw.h b/riscv/insns/c_lw.h index f2fc299..ef49dd9 100644 --- a/riscv/insns/c_lw.h +++ b/riscv/insns/c_lw.h @@ -1,2 +1,2 @@ require_extension('C'); -WRITE_RVC_RDS(MMU.load_int32(RVC_RS1S + insn.rvc_lw_imm())); +WRITE_RVC_RS2S(MMU.load_int32(RVC_RS1S + insn.rvc_lw_imm())); diff --git a/riscv/insns/c_lwsp.h b/riscv/insns/c_lwsp.h index ed4dcf3..b3d74db 100644 --- a/riscv/insns/c_lwsp.h +++ b/riscv/insns/c_lwsp.h @@ -1,2 +1,3 @@ require_extension('C'); +require(insn.rvc_rd() != 0); WRITE_RD(MMU.load_int32(RVC_SP + insn.rvc_lwsp_imm())); diff --git a/riscv/insns/c_mv.h b/riscv/insns/c_mv.h index bc05cfe..df5cea6 100644 --- a/riscv/insns/c_mv.h +++ b/riscv/insns/c_mv.h @@ -1,2 +1,3 @@ require_extension('C'); -WRITE_RD(RVC_RS1); +require(insn.rvc_rd() != 0); +WRITE_RD(RVC_RS2); diff --git a/riscv/insns/c_or3.h b/riscv/insns/c_or3.h new file mode 100644 index 0000000..8596223 --- /dev/null +++ b/riscv/insns/c_or3.h @@ -0,0 +1,2 @@ +require_extension('C'); +WRITE_RVC_RDS(RVC_RS1S | RVC_RS2S); diff --git a/riscv/insns/c_sdsp.h b/riscv/insns/c_sdsp.h index e8b5170..e59e00b 100644 --- a/riscv/insns/c_sdsp.h +++ b/riscv/insns/c_sdsp.h @@ -1,3 +1,3 @@ require_extension('C'); require_rv64; -MMU.store_uint64(RVC_SP + insn.rvc_ldsp_imm(), RVC_RS2); +MMU.store_uint64(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2); diff --git a/riscv/insns/c_slli.h b/riscv/insns/c_slli.h index de3683b..6bbefb1 100644 --- a/riscv/insns/c_slli.h +++ b/riscv/insns/c_slli.h @@ -1,4 +1,3 @@ require_extension('C'); -if (insn.rvc_imm() >= xlen) - throw trap_illegal_instruction(); -WRITE_RD(sext_xlen(RVC_RS2 << insn.rvc_imm())); +require(insn.rvc_imm() < xlen); +WRITE_RD(sext_xlen(RVC_RS1 << insn.rvc_imm())); diff --git a/riscv/insns/c_slliw.h b/riscv/insns/c_slliw.h new file mode 100644 index 0000000..b2d87ef --- /dev/null +++ b/riscv/insns/c_slliw.h @@ -0,0 +1,3 @@ +require_extension('C'); +require_rv64; +WRITE_RD(sext_xlen(RVC_RS1 << insn.rvc_imm())); diff --git a/riscv/insns/c_srai.h b/riscv/insns/c_srai.h new file mode 100644 index 0000000..87d7b59 --- /dev/null +++ b/riscv/insns/c_srai.h @@ -0,0 +1,3 @@ +require_extension('C'); +require(insn.rvc_imm() < xlen); +WRITE_RD(sext_xlen(sext_xlen(RVC_RS1) >> insn.rvc_imm())); diff --git a/riscv/insns/c_srli.h b/riscv/insns/c_srli.h new file mode 100644 index 0000000..bf29f5f --- /dev/null +++ b/riscv/insns/c_srli.h @@ -0,0 +1,3 @@ +require_extension('C'); +require(insn.rvc_imm() < xlen); +WRITE_RD(sext_xlen(zext_xlen(RVC_RS1) >> insn.rvc_imm())); diff --git a/riscv/insns/c_sub.h b/riscv/insns/c_sub.h new file mode 100644 index 0000000..993fdd3 --- /dev/null +++ b/riscv/insns/c_sub.h @@ -0,0 +1,3 @@ +require_extension('C'); +require(insn.rvc_rd() != 0 && insn.rvc_rs2() != 0); +WRITE_RD(sext_xlen(RVC_RS1 - RVC_RS2)); diff --git a/riscv/insns/c_sub3.h b/riscv/insns/c_sub3.h new file mode 100644 index 0000000..50ed2c9 --- /dev/null +++ b/riscv/insns/c_sub3.h @@ -0,0 +1,2 @@ +require_extension('C'); +WRITE_RVC_RDS(sext_xlen(RVC_RS1S - RVC_RS2S)); diff --git a/riscv/insns/c_swsp.h b/riscv/insns/c_swsp.h index 6f3fef0..b8995ab 100644 --- a/riscv/insns/c_swsp.h +++ b/riscv/insns/c_swsp.h @@ -1,2 +1,2 @@ require_extension('C'); -MMU.store_uint32(RVC_SP + insn.rvc_lwsp_imm(), RVC_RS2); +MMU.store_uint32(RVC_SP + insn.rvc_swsp_imm(), RVC_RS2); |