File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -1983,7 +1983,9 @@ typedef bool (*decode_t)(rv_insn_t *ir, uint32_t insn);
19831983/* decode RISC-V instruction */
19841984bool rv_decode (rv_insn_t * ir , uint32_t insn )
19851985{
1986+ bool ret ;
19861987 assert (ir );
1988+ decode_t op ;
19871989
19881990#define OP_UNIMP op_unimp
19891991#define OP (insn ) op_##insn
@@ -2024,19 +2026,33 @@ bool rv_decode(rv_insn_t *ir, uint32_t insn)
20242026 const uint16_t c_index = (insn & FC_FUNC3 ) >> 11 | (insn & FC_OPCODE );
20252027
20262028 /* decode instruction (compressed instructions) */
2027- const decode_t op = rvc_jump_table [c_index ];
2029+ op = rvc_jump_table [c_index ];
20282030 assert (op );
2029- return op (ir , insn );
2031+ ret = op (ir , insn );
2032+
2033+ goto end ;
20302034 }
20312035#endif
20322036
20332037 /* standard uncompressed instruction */
20342038 const uint32_t index = (insn & INSN_6_2 ) >> 2 ;
20352039
20362040 /* decode instruction */
2037- const decode_t op = rv_jump_table [index ];
2041+ op = rv_jump_table [index ];
20382042 assert (op );
2039- return op (ir , insn );
2043+ ret = op (ir , insn );
2044+
2045+ end :
2046+
2047+ #if RV32_HAS (RV32E )
2048+ /* RV32E forbids x16-x31 for integer registers, but with the F extension,
2049+ * floating-point registers are not limited to 16. */
2050+ if ((op != op_store_fp && op != op_load_fp && op != op_op_fp ) &&
2051+ unlikely (ir -> rd > 15 || ir -> rs1 > 15 || ir -> rs2 > 15 ))
2052+ ret = false;
2053+ #endif
2054+
2055+ return ret ;
20402056
20412057#undef OP_UNIMP
20422058#undef OP
You can’t perform that action at this time.
0 commit comments