[xcc,sim] fixed RM field
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>
Wed, 13 Apr 2011 01:22:07 +0000 (18:22 -0700)
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>
Wed, 13 Apr 2011 01:22:07 +0000 (18:22 -0700)
riscv/decode.h

index af6b57fe8e84e714c5aec2045695332c1bec5596..e6d0e8a4e487991a8f44cba92590940cc3f66b71 100644 (file)
@@ -182,8 +182,10 @@ private:
 #define TARGET insn.jtype.target
 #define BRANCH_TARGET (pc + (BIMM << BRANCH_ALIGN_BITS))
 #define JUMP_TARGET (pc + (TARGET << JUMP_ALIGN_BITS))
-#define RM ((insn.ftype.rm != 7) ? insn.ftype.rm : \
-            ((fsr & FSR_RD) >> FSR_RD_SHIFT))
+#define RM ({ int rm = insn.ftype.rm; \
+              if(rm == 7) rm = (fsr & FSR_RD) >> FSR_RD_SHIFT; \
+              if(rm > 4) throw trap_illegal_instruction; \
+              rm; })
 
 #define require_supervisor if(!(sr & SR_S)) throw trap_privileged_instruction
 #define xpr64 (xprlen == 64)