1 #ifndef _DECODE_HWACHA_UT_H
2 #define _DECODE_HWACHA_UT_H
5 #include "decode_hwacha.h"
7 #include "hwacha_xcpt.h"
15 static inline reg_t
read_rs1(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
17 if (INSN_RS1
>= h
->get_ct_state()->nxpr
)
18 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
22 static inline reg_t
read_rs2(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
24 if (INSN_RS2
>= h
->get_ct_state()->nxpr
)
25 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
29 static inline void write_rd(hwacha_t
* h
, insn_t insn
, uint32_t idx
, reg_t value
)
31 if (INSN_RD
>= h
->get_ct_state()->nxpr
)
32 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
33 UT_WRITE_RD(idx
, value
);
36 #define RS1 read_rs1(h, insn, UTIDX)
37 #define RS2 read_rs2(h, insn, UTIDX)
38 #define WRITE_RD(value) write_rd(h, insn, UTIDX, value)
45 static inline reg_t
read_frs1(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
47 if (INSN_RS1
>= h
->get_ct_state()->nfpr
)
48 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
52 static inline reg_t
read_frs2(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
54 if (INSN_RS2
>= h
->get_ct_state()->nfpr
)
55 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
59 static inline reg_t
read_frs3(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
61 if (INSN_RS3
>= h
->get_ct_state()->nfpr
)
62 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
66 static inline void write_frd(hwacha_t
* h
, insn_t insn
, uint32_t idx
, reg_t value
)
68 if (INSN_RD
>= h
->get_ct_state()->nfpr
)
69 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
70 UT_WRITE_FRD(idx
, value
);
73 #define FRS1 read_frs1(h, insn, UTIDX)
74 #define FRS2 read_frs2(h, insn, UTIDX)
75 #define FRS3 read_frs3(h, insn, UTIDX)
76 #define WRITE_FRD(value) write_frd(h, insn, UTIDX, value)
78 // we assume the vector unit has floating-point alus
83 #undef set_fp_exceptions
84 #define set_fp_exceptions