redirect obtaining registers through a common function, get_intreg
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Oct 2018 13:52:15 +0000 (14:52 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Oct 2018 13:52:15 +0000 (14:52 +0100)
riscv/sv_insn_redirect.cc
riscv/sv_insn_redirect.h

index c34d291f56cd22835d41ad2f6e8067316f59d1e9..19df7b71605966d8752dd47c6abf869ff3a4441d 100644 (file)
@@ -100,13 +100,18 @@ sv_reg_t (sv_proc_t::READ_REG)(uint64_t i)
 }
 */
 
+sv_reg_t sv_proc_t::get_intreg(reg_t reg)
+{
+    uint8_t elwidth = _insn->reg_elwidth(reg, true);
+    uint64_t data = _insn->p->get_state()->XPR[reg];
+    return sv_reg_t(data, elwidth);
+}
+
 #define GET_REG(name) \
     sv_reg_t sv_proc_t::get_##name() \
     { \
         reg_t reg = _insn->name (); \
-        uint8_t elwidth = _insn->reg_elwidth(reg, true); \
-        uint64_t data = _insn->p->get_state()->XPR[reg]; \
-        return sv_reg_t(data, elwidth); \
+        return get_intreg(reg); \
     }
 
 GET_REG(rs1)
@@ -129,12 +134,12 @@ freg_t sv_proc_t::get_frs2()
 
 sv_reg_t sv_proc_t::get_shamt()
 {
-    return sv_reg_t(_insn->i_imm() & 0x3F);
+    return sv_reg_t(_insn->i_imm() & 0x3F); // XXX TODO: has to be elwidth'd
 }
 
 sv_reg_t sv_proc_t::get_rvc_sp()
 {
-    return (_insn->p->get_state()->XPR[X_SP]);
+    return get_intreg(X_SP); // XXX TODO: work out redirection
 }
 
 sv_reg_t sv_proc_t::uint64_max()
index 9d09eb7fb34aa8b7ce213f0edb7cfa77dba1ef55..4e132f332ebee73af72bb0f9c2c60c3a91759e56 100644 (file)
@@ -87,6 +87,10 @@ public:
         this->insn._insn = i;
     }
 
+private:
+    sv_reg_t get_intreg(reg_t reg);
+
+public:
     sv_reg_t get_rs1();
     sv_reg_t get_rs2();
     sv_reg_t get_rs3();