#define do_writeback(rf,rd) rf[rd]
#endif
+#define throw_illegal_instruction \
+ ({ if (utmode) throw trap_vector_illegal_instruction; \
+ else throw trap_illegal_instruction; })
+
// helpful macros, etc
#define RS1 XPR[insn.rtype.rs1]
#define RS2 XPR[insn.rtype.rs2]
#define JUMP_TARGET (pc + (TARGET << JUMP_ALIGN_BITS))
#define RM ({ int rm = insn.ftype.rm; \
if(rm == 7) rm = (fsr & FSR_RD) >> FSR_RD_SHIFT; \
- if(rm > 4) throw trap_illegal_instruction; \
+ if(rm > 4) throw_illegal_instruction; \
rm; })
#define require_supervisor if(!(sr & SR_S)) throw trap_privileged_instruction
#define xpr64 (xprlen == 64)
-#define require_xpr64 if(!xpr64) throw trap_illegal_instruction
-#define require_xpr32 if(xpr64) throw trap_illegal_instruction
+#define require_xpr64 if(!xpr64) throw_illegal_instruction
+#define require_xpr32 if(xpr64) throw_illegal_instruction
#define require_fp if(!(sr & SR_EF)) throw trap_fp_disabled
-#define require_vector if(!(sr & SR_EV)) throw trap_vector_disabled
+#define require_vector \
+ ({ if(!(sr & SR_EV)) throw trap_vector_disabled; \
+ else if (!utmode && (vecbanks_count < 3)) throw trap_vector_bank; \
+ })
#define cmp_trunc(reg) (reg_t(reg) << (64-xprlen))
#define set_fp_exceptions ({ set_fsr(fsr | \
(softfloat_exceptionFlags << FSR_AEXC_SHIFT)); \
softfloat_exceptionFlags = 0; })
-#define require_rvc if(!(sr & SR_EC)) throw trap_illegal_instruction
+#define require_rvc if(!(sr & SR_EC)) throw_illegal_instruction
#define insn_length(x) (((x).bits & 0x3) < 0x3 ? 2 : 4)
#define sext32(x) ((sreg_t)(int32_t)(x))
#include "insns/c_j.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x3:
#include "insns/lhu.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x4:
#include "insns/fld.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x8:
#include "insns/vlseghu.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0xc:
#include "insns/vfssegd.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x10:
#include "insns/c_ld0.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x13:
#include "insns/slli.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x14:
#include "insns/c_slli32.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x1a:
#include "insns/c_add.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x1b:
#include "insns/sraiw.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x1c:
#include "insns/c_sub3.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x1d:
#include "insns/c_j.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x23:
#include "insns/sd.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x24:
#include "insns/fsw.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x28:
#include "insns/amoswap_w.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x2c:
#include "insns/fence_l_v.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x30:
#include "insns/c_ld0.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x33:
#include "insns/divu.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x34:
#include "insns/c_slli32.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x3a:
#include "insns/c_add.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x3b:
#include "insns/divw.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x3c:
#include "insns/c_sub3.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x3d:
#include "insns/c_j.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x43:
#include "insns/fmadd_d.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x44:
#include "insns/fmsub_d.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x48:
#include "insns/fnmsub_d.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x4c:
#include "insns/fnmadd_d.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x50:
#include "insns/c_ld0.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x53:
#include "insns/fadd_s.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x54:
#include "insns/c_slli32.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x5a:
#include "insns/c_add.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x5c:
#include "insns/c_sub3.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x5d:
#include "insns/c_j.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x63:
#include "insns/beq.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x64:
#include "insns/rdnpc.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x6c:
#include "insns/c_ld0.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x73:
#include "insns/vmst.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x74:
#include "insns/syscall.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x78:
#include "insns/c_slli32.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x7a:
#include "insns/c_add.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x7b:
#include "insns/eret.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x7c:
#include "insns/c_sub3.h"
break;
}
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
break;
}
case 0x7d:
}
default:
{
- throw trap_illegal_instruction;
+ throw_illegal_instruction;
}
}