aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-09-04 13:39:42 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-09-04 13:39:42 -0700
commit784e9891af88db221b57bdffbea74d1c6bf99971 (patch)
tree3124895bbb1ed876d9951415696c7dd1bb06b208 /riscv/insns
parent84b15dac7035f7e23fa821091ce97ae30ce2b0d8 (diff)
downloadriscv-isa-sim-784e9891af88db221b57bdffbea74d1c6bf99971.zip
riscv-isa-sim-784e9891af88db221b57bdffbea74d1c6bf99971.tar.gz
riscv-isa-sim-784e9891af88db221b57bdffbea74d1c6bf99971.tar.bz2
Move towards RVC v1.8
Diffstat (limited to 'riscv/insns')
-rw-r--r--riscv/insns/c_add.h11
-rw-r--r--riscv/insns/c_add3.h2
-rw-r--r--riscv/insns/c_addi.h7
-rw-r--r--riscv/insns/c_addiw.h7
-rw-r--r--riscv/insns/c_addw.h1
-rw-r--r--riscv/insns/c_and3.h2
-rw-r--r--riscv/insns/c_fld.h4
-rw-r--r--riscv/insns/c_fldsp.h4
-rw-r--r--riscv/insns/c_flw.h8
-rw-r--r--riscv/insns/c_flwsp.h (renamed from riscv/insns/c_ldsp.h)5
-rw-r--r--riscv/insns/c_fsd.h4
-rw-r--r--riscv/insns/c_fsdsp.h4
-rw-r--r--riscv/insns/c_fsw.h8
-rw-r--r--riscv/insns/c_fswsp.h (renamed from riscv/insns/c_sdsp.h)5
-rw-r--r--riscv/insns/c_ld.h3
-rw-r--r--riscv/insns/c_li.h6
-rw-r--r--riscv/insns/c_lui.h7
-rw-r--r--riscv/insns/c_mv.h8
-rw-r--r--riscv/insns/c_or3.h2
-rw-r--r--riscv/insns/c_sd.h38
-rw-r--r--riscv/insns/c_slliw.h13
-rw-r--r--riscv/insns/c_srai.h3
-rw-r--r--riscv/insns/c_srli.h3
-rw-r--r--riscv/insns/c_sub.h3
-rw-r--r--riscv/insns/c_sub3.h2
25 files changed, 57 insertions, 103 deletions
diff --git a/riscv/insns/c_add.h b/riscv/insns/c_add.h
index 64bc5f7..c13385e 100644
--- a/riscv/insns/c_add.h
+++ b/riscv/insns/c_add.h
@@ -1,7 +1,12 @@
require_extension('C');
-require(insn.rvc_rs2() != 0);
-if (insn.rvc_rd() == 0) { // c.ebreak
- throw trap_breakpoint();
+if (insn.rvc_rs2() == 0) {
+ if (insn.rvc_rs1() == 0) { // c.ebreak
+ throw trap_breakpoint();
+ } else { // c.jalr
+ reg_t tmp = npc;
+ set_pc(RVC_RS1 & ~reg_t(1));
+ WRITE_REG(X_RA, tmp);
+ }
} else {
WRITE_RD(sext_xlen(RVC_RS1 + RVC_RS2));
}
diff --git a/riscv/insns/c_add3.h b/riscv/insns/c_add3.h
deleted file mode 100644
index fabf6dd..0000000
--- a/riscv/insns/c_add3.h
+++ /dev/null
@@ -1,2 +0,0 @@
-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 cea2a18..eb98344 100644
--- a/riscv/insns/c_addi.h
+++ b/riscv/insns/c_addi.h
@@ -1,7 +1,2 @@
require_extension('C');
-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()));
-}
+WRITE_RD(sext_xlen(RVC_RS1 + insn.rvc_imm()));
diff --git a/riscv/insns/c_addiw.h b/riscv/insns/c_addiw.h
index ae4980e..fe87872 100644
--- a/riscv/insns/c_addiw.h
+++ b/riscv/insns/c_addiw.h
@@ -1,7 +1,2 @@
require_extension('C');
-if (xlen == 32) {
- WRITE_RD(RVC_RS1 & insn.rvc_imm()); // c.andi
-} else {
- require(insn.rvc_rd() != 0);
- WRITE_RD(sext32(RVC_RS1 + insn.rvc_imm()));
-}
+WRITE_RD(sext32(RVC_RS1 + insn.rvc_imm()));
diff --git a/riscv/insns/c_addw.h b/riscv/insns/c_addw.h
index 36559b7..fef554d 100644
--- a/riscv/insns/c_addw.h
+++ b/riscv/insns/c_addw.h
@@ -1,4 +1,3 @@
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
deleted file mode 100644
index 5543950..0000000
--- a/riscv/insns/c_and3.h
+++ /dev/null
@@ -1,2 +0,0 @@
-require_extension('C');
-WRITE_RVC_RDS(RVC_RS1S & RVC_RS2S);
diff --git a/riscv/insns/c_fld.h b/riscv/insns/c_fld.h
new file mode 100644
index 0000000..10d14f8
--- /dev/null
+++ b/riscv/insns/c_fld.h
@@ -0,0 +1,4 @@
+require_extension('C');
+require_extension('D');
+require_fp;
+WRITE_RVC_FRS2S(MMU.load_int64(RVC_RS1S + insn.rvc_ld_imm()));
diff --git a/riscv/insns/c_fldsp.h b/riscv/insns/c_fldsp.h
new file mode 100644
index 0000000..8b1e19f
--- /dev/null
+++ b/riscv/insns/c_fldsp.h
@@ -0,0 +1,4 @@
+require_extension('C');
+require_extension('D');
+require_fp;
+WRITE_FRD(MMU.load_int64(RVC_SP + insn.rvc_ldsp_imm()));
diff --git a/riscv/insns/c_flw.h b/riscv/insns/c_flw.h
new file mode 100644
index 0000000..ad737aa
--- /dev/null
+++ b/riscv/insns/c_flw.h
@@ -0,0 +1,8 @@
+require_extension('C');
+if (xlen == 32) {
+ require_extension('F');
+ require_fp;
+ WRITE_RVC_FRS2S(MMU.load_int32(RVC_RS1S + insn.rvc_lw_imm()));
+} else {
+ WRITE_RVC_RS2S(MMU.load_int64(RVC_RS1S + insn.rvc_ld_imm()));
+}
diff --git a/riscv/insns/c_ldsp.h b/riscv/insns/c_flwsp.h
index aa98f33..2d2dd5c 100644
--- a/riscv/insns/c_ldsp.h
+++ b/riscv/insns/c_flwsp.h
@@ -1,7 +1,8 @@
require_extension('C');
if (xlen == 32) {
- if (sreg_t(RVC_RS1S) >= 0) // c.bgez
- set_pc(pc + insn.rvc_b_imm());
+ require_extension('F');
+ require_fp;
+ WRITE_FRD(MMU.load_int32(RVC_SP + insn.rvc_lwsp_imm()));
} else {
require(insn.rvc_rd() != 0);
WRITE_RD(MMU.load_int64(RVC_SP + insn.rvc_ldsp_imm()));
diff --git a/riscv/insns/c_fsd.h b/riscv/insns/c_fsd.h
new file mode 100644
index 0000000..84f1a7f
--- /dev/null
+++ b/riscv/insns/c_fsd.h
@@ -0,0 +1,4 @@
+require_extension('C');
+require_extension('D');
+require_fp;
+MMU.store_uint64(RVC_RS1S + insn.rvc_ld_imm(), RVC_FRS2S);
diff --git a/riscv/insns/c_fsdsp.h b/riscv/insns/c_fsdsp.h
new file mode 100644
index 0000000..5c5c680
--- /dev/null
+++ b/riscv/insns/c_fsdsp.h
@@ -0,0 +1,4 @@
+require_extension('C');
+require_extension('D');
+require_fp;
+MMU.store_uint64(RVC_SP + insn.rvc_sdsp_imm(), RVC_FRS2);
diff --git a/riscv/insns/c_fsw.h b/riscv/insns/c_fsw.h
new file mode 100644
index 0000000..4089e3d
--- /dev/null
+++ b/riscv/insns/c_fsw.h
@@ -0,0 +1,8 @@
+require_extension('C');
+if (xlen == 32) {
+ require_extension('F');
+ require_fp;
+ MMU.store_uint32(RVC_RS1S + insn.rvc_lw_imm(), RVC_FRS2S);
+} else {
+ MMU.store_uint64(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S);
+}
diff --git a/riscv/insns/c_sdsp.h b/riscv/insns/c_fswsp.h
index db504ec..8e2fedc 100644
--- a/riscv/insns/c_sdsp.h
+++ b/riscv/insns/c_fswsp.h
@@ -1,7 +1,8 @@
require_extension('C');
if (xlen == 32) {
- if (sreg_t(RVC_RS1S) < 0) // c.bltz
- set_pc(pc + insn.rvc_b_imm());
+ require_extension('F');
+ require_fp;
+ MMU.store_uint32(RVC_SP + insn.rvc_swsp_imm(), RVC_FRS2);
} else {
MMU.store_uint64(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2);
}
diff --git a/riscv/insns/c_ld.h b/riscv/insns/c_ld.h
deleted file mode 100644
index 876badd..0000000
--- a/riscv/insns/c_ld.h
+++ /dev/null
@@ -1,3 +0,0 @@
-require_extension('C');
-require_rv64;
-WRITE_RVC_RS2S(MMU.load_int64(RVC_RS1S + insn.rvc_ld_imm()));
diff --git a/riscv/insns/c_li.h b/riscv/insns/c_li.h
index 52e99c9..844686d 100644
--- a/riscv/insns/c_li.h
+++ b/riscv/insns/c_li.h
@@ -1,7 +1,3 @@
require_extension('C');
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());
-}
+WRITE_RD(insn.rvc_imm());
diff --git a/riscv/insns/c_lui.h b/riscv/insns/c_lui.h
index 040d7ec..cb76c61 100644
--- a/riscv/insns/c_lui.h
+++ b/riscv/insns/c_lui.h
@@ -1,9 +1,6 @@
require_extension('C');
-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);
+if (insn.rvc_rd() == 0) { // c.addi16sp
+ WRITE_REG(X_SP, sext_xlen(RVC_SP + insn.rvc_addi16sp_imm()));
} else {
WRITE_RD(insn.rvc_imm() << 12);
}
diff --git a/riscv/insns/c_mv.h b/riscv/insns/c_mv.h
index df5cea6..4a23063 100644
--- a/riscv/insns/c_mv.h
+++ b/riscv/insns/c_mv.h
@@ -1,3 +1,7 @@
require_extension('C');
-require(insn.rvc_rd() != 0);
-WRITE_RD(RVC_RS2);
+if (insn.rvc_rs2() == 0) {
+ require(insn.rvc_rd() != 0);
+ set_pc(RVC_RS1 & ~reg_t(1));
+} else {
+ WRITE_RD(RVC_RS2);
+}
diff --git a/riscv/insns/c_or3.h b/riscv/insns/c_or3.h
deleted file mode 100644
index 8596223..0000000
--- a/riscv/insns/c_or3.h
+++ /dev/null
@@ -1,2 +0,0 @@
-require_extension('C');
-WRITE_RVC_RDS(RVC_RS1S | RVC_RS2S);
diff --git a/riscv/insns/c_sd.h b/riscv/insns/c_sd.h
deleted file mode 100644
index 4551ced..0000000
--- a/riscv/insns/c_sd.h
+++ /dev/null
@@ -1,38 +0,0 @@
-require_extension('C');
-if (xlen == 32) {
- int32_t res;
- switch ((insn.bits() >> 10) & 7) {
- case 0:
- switch ((insn.bits() >> 5) & 3) {
- case 0: res = RVC_RS1S ^ RVC_RS2S; // c.xor
- case 1: res = int32_t(RVC_RS1S) >> (RVC_RS2S & 0x1f); // c.sra
- default: require(0);
- }
- WRITE_RVC_RS1S(res);
- break;
-
- case 1:
- switch ((insn.bits() >> 5) & 3) {
- case 0: res = RVC_RS1S << (RVC_RS2S & 0x1f); // c.sll
- case 1: res = uint32_t(RVC_RS1S) >> (RVC_RS2S & 0x1f); // c.srl
- case 2: res = int32_t(RVC_RS1S) < int32_t(RVC_RS2S); // c.slt
- case 3: res = uint32_t(RVC_RS1S) < uint32_t(RVC_RS2S); // c.sltu
- }
- WRITE_RVC_RS1S(res);
- break;
-
- case 3:
- switch ((insn.bits() >> 5) & 3) {
- case 0: res = RVC_RS1S << (RVC_RS2S & 0x1f); // c.sllr
- case 1: res = uint32_t(RVC_RS1S) >> (RVC_RS2S & 0x1f); // c.srlr
- case 2: res = int32_t(RVC_RS1S) < int32_t(RVC_RS2S); // c.sltr
- case 3: res = uint32_t(RVC_RS1S) < uint32_t(RVC_RS2S); // c.sltur
- }
- WRITE_RVC_RS2S(res);
- break;
-
- default: require(0);
- }
-} else {
- MMU.store_uint64(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S);
-}
diff --git a/riscv/insns/c_slliw.h b/riscv/insns/c_slliw.h
deleted file mode 100644
index 643bf74..0000000
--- a/riscv/insns/c_slliw.h
+++ /dev/null
@@ -1,13 +0,0 @@
-require_extension('C');
-if (xlen == 32) {
- switch ((insn.bits() >> 5) & 3) {
- case 0: WRITE_RVC_RS2S(sext_xlen(RVC_RS1S + insn.rvc_simm3())); // c.addin
- case 1: WRITE_RVC_RS2S(sext_xlen(RVC_RS1S ^ insn.rvc_simm3())); // c.xorin
- case 2: WRITE_RVC_RS2S(sext_xlen(RVC_RS1S | insn.rvc_simm3())); // c.orin
- case 3: WRITE_RVC_RS2S(sext_xlen(RVC_RS1S & insn.rvc_simm3())); // c.andin
- }
-} else {
- require(insn.rvc_rd() != 0);
- require(insn.rvc_imm() < 32);
- WRITE_RD(sext32(RVC_RS1 << insn.rvc_imm()));
-}
diff --git a/riscv/insns/c_srai.h b/riscv/insns/c_srai.h
deleted file mode 100644
index 87d7b59..0000000
--- a/riscv/insns/c_srai.h
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index bf29f5f..0000000
--- a/riscv/insns/c_srli.h
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 993fdd3..0000000
--- a/riscv/insns/c_sub.h
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 50ed2c9..0000000
--- a/riscv/insns/c_sub3.h
+++ /dev/null
@@ -1,2 +0,0 @@
-require_extension('C');
-WRITE_RVC_RDS(sext_xlen(RVC_RS1S - RVC_RS2S));