[opcodes, pk, sim, xcc] made jumps shorter and PC-relative
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>
Tue, 2 Nov 2010 19:19:52 +0000 (12:19 -0700)
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>
Mon, 22 Nov 2010 00:54:32 +0000 (16:54 -0800)
riscv/decode.h
riscv/execute.h

index 3db82daf4201349e905eaba493cd00845e7c397a..9278a35c4b50cac095654d9735978d9aa15f18c5 100644 (file)
@@ -27,7 +27,6 @@ typedef uint64_t reg_t;
 typedef uint64_t freg_t;
 
 const int OPCODE_BITS = 7;
-const int JTYPE_OPCODE_BITS = 5;
 
 const int GPR_BITS = 8*sizeof(reg_t);
 const int GPRID_BITS = 5;
@@ -38,7 +37,7 @@ const int FPRID_BITS = 5;
 const int NFPR = 1 << FPRID_BITS;
 
 const int IMM_BITS = 12;
-const int TARGET_BITS = 27;
+const int TARGET_BITS = 25;
 const int SHAMT_BITS = 6;
 const int FUNCT_BITS = 3;
 const int FUNCTR_BITS = 7;
@@ -93,8 +92,8 @@ struct itype_t
 
 struct jtype_t
 {
-  unsigned target : TARGET_BITS;
-  unsigned jump_opcode : JTYPE_OPCODE_BITS;
+  signed target : TARGET_BITS;
+  unsigned jump_opcode : OPCODE_BITS;
 };
 
 struct rtype_t
@@ -174,7 +173,7 @@ private:
 #define SHAMTW (insn.itype.imm12 & 0x1F)
 #define TARGET insn.jtype.target
 #define BRANCH_TARGET (npc + (SIMM << BRANCH_ALIGN_BITS))
-#define JUMP_TARGET ((npc & ~((1<<(TARGET_BITS+JUMP_ALIGN_BITS))-1)) + (TARGET << JUMP_ALIGN_BITS))
+#define JUMP_TARGET (npc + (TARGET << JUMP_ALIGN_BITS))
 #define RM ((insn.ftype.ffunct >> 1) & 3)
 
 #define require_supervisor if(!(sr & SR_S)) throw trap_privileged_instruction
index 8e583fd770d998527492d09a9f8f9f198f65f3d1..d80c12fee948d91a5a69fcf0ef0b80828c51e091 100644 (file)
@@ -27,36 +27,6 @@ switch((insn.bits >> 0x19) & 0x7f)
     break;
   }
   case 0x61:
-  {
-    #include "insns/j.h"
-    break;
-  }
-  case 0x62:
-  {
-    #include "insns/j.h"
-    break;
-  }
-  case 0x63:
-  {
-    #include "insns/j.h"
-    break;
-  }
-  case 0x64:
-  {
-    #include "insns/jal.h"
-    break;
-  }
-  case 0x65:
-  {
-    #include "insns/jal.h"
-    break;
-  }
-  case 0x66:
-  {
-    #include "insns/jal.h"
-    break;
-  }
-  case 0x67:
   {
     #include "insns/jal.h"
     break;