pass sub-offset down through remap in sv_insn_t into reg_spec_t
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 Jun 2019 09:23:00 +0000 (10:23 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 27 Jun 2019 09:23:00 +0000 (10:23 +0100)
riscv/insn_template_sv.cc
riscv/sv.cc
riscv/sv_decode.h

index 8f14778937056c7144933ee935e6f6ffa141d721..a8dacd39ddeb69c4d206cfd573ff62ca6c6768e0 100644 (file)
@@ -103,10 +103,10 @@ reg_t sv_proc_t::FN(processor_t* p, insn_t s_insn, reg_t pc)
             s_insn.rd(), s_insn.rs1(), s_insn.rs2(),
             vlen);
 #ifdef INSN_TYPE_C_STACK_LD
-    sp = insn._remap(X_SP, true, src_offs);
+    sp = insn._remap(X_SP, true, src_offs, src_subo);
 #endif
 #ifdef INSN_TYPE_C_STACK_ST
-    sp = insn._remap(X_SP, true, dest_offs);
+    sp = insn._remap(X_SP, true, dest_offs, dest_subo);
 #endif
 #ifdef INSN_TYPE_BRANCH
     // all branch ops are rs1, rs2.  take target (dest) predicate from rs2.
index 99b0f7bdf01729434556c90b92b146b09c5ca207..66b494a9a09b55fdc82f0fa5a94d4cdb9f4a5402 100644 (file)
@@ -174,7 +174,7 @@ bool sv_insn_t::sv_check_reg(bool intreg, uint64_t reg)
  * of SV.  it's "supposed" to "just" be a vectorisation API. it isn't:
  * it's quite a bit more.
  */
-reg_spec_t sv_insn_t::remap(uint64_t reg, bool intreg, int *voffs)
+reg_spec_t sv_insn_t::remap(uint64_t reg, bool intreg, int *voffs, int *subo)
 {
   reg_spec_t spec = {reg, NULL};
   // okaay so first determine which map to use.  intreg is passed
@@ -210,6 +210,7 @@ reg_spec_t sv_insn_t::remap(uint64_t reg, bool intreg, int *voffs)
   // aaand now, as it's a "vector", FINALLY we can pass the loop-offset
   spec.reg = reg; //+ *voffs;
   spec.offset = voffs;
+  spec.suboff = subo;
   spec.isvec = r->isvec;
   spec.signextend = signextended;
   return spec;
@@ -300,6 +301,7 @@ reg_spec_t sv_insn_t::predicated(reg_spec_t const& spec, uint64_t pred)
     fprintf(stderr, "predication %ld %d %lx\n", spec.reg, (*spec.offset), pred);
     res.reg = 0;
     res.offset = 0;
+    res.suboff = 0;
     res.isvec = spec.isvec;
     return res;
 }
index 1f62ade949d2d808ec8102fed1bbf244bbf2ef1c..956653da46eea3fec1e311c7f8d2ac75a88bf253 100644 (file)
@@ -74,21 +74,30 @@ public:
   reg_spec_t rvc_sp  (bool use_offs=true)
                      { return predicated(_rvc_sp  (use_offs), psp ); }
 
-  reg_spec_t _rd () { return _remap(insn_t::rd (), fimap & REG_RD , offs_rd); }
-  reg_spec_t _rs1() { return _remap(insn_t::rs1(), fimap & REG_RS1, offs_rs1); }
-  reg_spec_t _rs2() { return _remap(insn_t::rs2(), fimap & REG_RS2, offs_rs2); }
-  reg_spec_t _rs3() { return _remap(insn_t::rs3(), fimap & REG_RS3, offs_rs3); }
-  reg_spec_t _rvc_rs1 () { return _remap(insn_t::rvc_rs1(), fimap & REG_RVC_RS1,
-                                       offs_rs1); }
-  reg_spec_t _rvc_rs1s() { return _remap(insn_t::rvc_rs1s(), fimap & REG_RVC_RS1S,
-                                       offs_rs1); }
-  reg_spec_t _rvc_rs2 () { return _remap(insn_t::rvc_rs2(), fimap & REG_RVC_RS2,
-                                       offs_rs2); }
-  reg_spec_t _rvc_rs2s() { return _remap(insn_t::rvc_rs2s(), fimap & REG_RVC_RS2S,
-                                       offs_rs2); }
+  reg_spec_t _rd () { return _remap(insn_t::rd (), fimap & REG_RD,
+                                    offs_rd, subo_rd); }
+  reg_spec_t _rs1() { return _remap(insn_t::rs1(), fimap & REG_RS1,
+                                    offs_rs1, subo_rs1); }
+  reg_spec_t _rs2() { return _remap(insn_t::rs2(), fimap & REG_RS2,
+                                    offs_rs2, subo_rs2); }
+  reg_spec_t _rs3() { return _remap(insn_t::rs3(), fimap & REG_RS3,
+                                    offs_rs3, subo_rs3); }
+  reg_spec_t _rvc_rs1 () { return _remap(insn_t::rvc_rs1(),
+                                    fimap & REG_RVC_RS1,
+                                    offs_rs1, subo_rs1); }
+  reg_spec_t _rvc_rs1s() { return _remap(insn_t::rvc_rs1s(),
+                                    fimap & REG_RVC_RS1S,
+                                    offs_rs1, subo_rs1); }
+  reg_spec_t _rvc_rs2 () { return _remap(insn_t::rvc_rs2(),
+                                    fimap & REG_RVC_RS2,
+                                    offs_rs2, subo_rs2); }
+  reg_spec_t _rvc_rs2s() { return _remap(insn_t::rvc_rs2s(),
+                                    fimap & REG_RVC_RS2S,
+                                    offs_rs2, subo_rs2); }
   reg_spec_t _rvc_sp  (bool use_offs=true)
                 { return _remap(2, true, // sp always 2, always int
-                                use_offs ? offs_sp : NULL); }
+                                use_offs ? offs_sp : NULL,
+                                use_offs ? subo_sp : NULL); }
 
   void setpc(int xlen, int vlen, reg_t &npc, reg_t addr, uint64_t offs,
              reg_t *target_reg, bool zeroing, bool inv);
@@ -116,13 +125,13 @@ public:
   // cached version of remap: if remap is called multiple times
   // by an emulated instruction it would increment the loop offset
   // before it's supposed to.
-  reg_spec_t _remap(uint64_t reg, bool isint, int *offs)
+  reg_spec_t _remap(uint64_t reg, bool isint, int *offs, int *subo)
   {
     if (sv_check_reg(isint, reg))
     {
         vloop_continue = true;
     }
-    return remap(reg, isint, offs);
+    return remap(reg, isint, offs, subo);
   }
 
   uint64_t get_saved_branch_addr() { return save_branch_addr; }
@@ -160,7 +169,7 @@ private:
 
   // remaps the register through the lookup table.
   // will need to take the current loop index/offset somehow
-  reg_spec_t remap(uint64_t reg, bool isint, int *offs);
+  reg_spec_t remap(uint64_t reg, bool isint, int *offs, int *subo);
 
   reg_spec_t predicated(reg_spec_t const& reg, uint64_t pred);
 };