1 #ifndef _DECODE_HWACHA_UT_H
2 #define _DECODE_HWACHA_UT_H
5 #include "decode_hwacha.h"
7 #include "hwacha_xcpt.h"
13 static inline reg_t
read_rs1(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
15 if (INSN_RS1
>= h
->get_ct_state()->nxpr
)
16 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
20 static inline reg_t
read_rs2(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
22 if (INSN_RS2
>= h
->get_ct_state()->nxpr
)
23 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
27 static inline void write_rd(hwacha_t
* h
, insn_t insn
, uint32_t idx
, reg_t value
)
29 if (INSN_RD
>= h
->get_ct_state()->nxpr
)
30 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
31 UT_WRITE_RD(idx
, value
);
34 #define RS1 read_rs1(h, insn, UTIDX)
35 #define RS2 read_rs2(h, insn, UTIDX)
36 #define WRITE_RD(value) write_rd(h, insn, UTIDX, value)
43 static inline reg_t
read_frs1(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
45 if (INSN_RS1
>= h
->get_ct_state()->nfpr
)
46 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
50 static inline reg_t
read_frs2(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
52 if (INSN_RS2
>= h
->get_ct_state()->nfpr
)
53 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
57 static inline reg_t
read_frs3(hwacha_t
* h
, insn_t insn
, uint32_t idx
)
59 if (INSN_RS3
>= h
->get_ct_state()->nfpr
)
60 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
64 static inline void write_frd(hwacha_t
* h
, insn_t insn
, uint32_t idx
, reg_t value
)
66 if (INSN_RD
>= h
->get_ct_state()->nfpr
)
67 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_REGID
, VF_PC
);
68 UT_WRITE_FRD(idx
, value
);
71 #define FRS1 read_frs1(h, insn, UTIDX)
72 #define FRS2 read_frs2(h, insn, UTIDX)
73 #define FRS3 read_frs3(h, insn, UTIDX)
74 #define WRITE_FRD(value) write_frd(h, insn, UTIDX, value)
76 // we assume the vector unit has floating-point alus
82 #define HFRS1 cvt_hs(FRS1)
83 #define HFRS2 cvt_hs(FRS2)
84 #define HFRS3 cvt_hs(FRS3)
86 #define WRITE_HFRD(value) write_frd(h, insn, UTIDX, cvt_sh(value, RM))
88 #define sext16(x) ((sreg_t)(int16_t)(x))