aboutsummaryrefslogtreecommitdiff
path: root/hwacha/decode_hwacha_ut.h
diff options
context:
space:
mode:
Diffstat (limited to 'hwacha/decode_hwacha_ut.h')
-rw-r--r--hwacha/decode_hwacha_ut.h66
1 files changed, 59 insertions, 7 deletions
diff --git a/hwacha/decode_hwacha_ut.h b/hwacha/decode_hwacha_ut.h
index 675f77c..daad217 100644
--- a/hwacha/decode_hwacha_ut.h
+++ b/hwacha/decode_hwacha_ut.h
@@ -1,7 +1,10 @@
#ifndef _DECODE_HWACHA_UT_H
#define _DECODE_HWACHA_UT_H
+#include "decode.h"
#include "decode_hwacha.h"
+#include "hwacha.h"
+#include "hwacha_xcpt.h"
#define UTIDX (i)
@@ -9,19 +12,68 @@
#undef RS2
#undef WRITE_RD
-#define RS1 UT_RS1(UTIDX)
-#define RS2 UT_RS2(UTIDX)
-#define WRITE_RD(value) UT_WRITE_RD(UTIDX, value)
+static inline reg_t read_rs1(hwacha_t* h, insn_t insn, uint32_t idx)
+{
+ if (INSN_RS1 >= h->get_ct_state()->nxpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ return UT_RS1(idx);
+}
+
+static inline reg_t read_rs2(hwacha_t* h, insn_t insn, uint32_t idx)
+{
+ if (INSN_RS2 >= h->get_ct_state()->nxpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ return UT_RS2(idx);
+}
+
+static inline void write_rd(hwacha_t* h, insn_t insn, uint32_t idx, reg_t value)
+{
+ if (INSN_RD >= h->get_ct_state()->nxpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ UT_WRITE_RD(idx, value);
+}
+
+#define RS1 read_rs1(h, insn, UTIDX)
+#define RS2 read_rs2(h, insn, UTIDX)
+#define WRITE_RD(value) write_rd(h, insn, UTIDX, value)
#undef FRS1
#undef FRS2
#undef FRS3
#undef WRITE_FRD
-#define FRS1 UT_FRS1(UTIDX)
-#define FRS2 UT_FRS2(UTIDX)
-#define FRS3 UT_FRS3(UTIDX)
-#define WRITE_FRD(value) UT_WRITE_FRD(UTIDX, value)
+static inline reg_t read_frs1(hwacha_t* h, insn_t insn, uint32_t idx)
+{
+ if (INSN_RS1 >= h->get_ct_state()->nfpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ return UT_FRS1(idx);
+}
+
+static inline reg_t read_frs2(hwacha_t* h, insn_t insn, uint32_t idx)
+{
+ if (INSN_RS2 >= h->get_ct_state()->nfpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ return UT_FRS2(idx);
+}
+
+static inline reg_t read_frs3(hwacha_t* h, insn_t insn, uint32_t idx)
+{
+ if (INSN_RS3 >= h->get_ct_state()->nfpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ return UT_FRS3(idx);
+}
+
+static inline void write_frd(hwacha_t* h, insn_t insn, uint32_t idx, reg_t value)
+{
+ if (INSN_RD >= h->get_ct_state()->nfpr)
+ h->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID, VF_PC);
+ UT_WRITE_FRD(idx, value);
+}
+
+#define FRS1 read_frs1(h, insn, UTIDX)
+#define FRS2 read_frs2(h, insn, UTIDX)
+#define FRS3 read_frs3(h, insn, UTIDX)
+#define WRITE_FRD(value) write_frd(h, insn, UTIDX, value)
// we assume the vector unit has floating-point alus
#undef require_fp