File tree 1 file changed +20
-4
lines changed
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);
1983
1983
/* decode RISC-V instruction */
1984
1984
bool rv_decode (rv_insn_t * ir , uint32_t insn )
1985
1985
{
1986
+ bool ret ;
1986
1987
assert (ir );
1988
+ decode_t op ;
1987
1989
1988
1990
#define OP_UNIMP op_unimp
1989
1991
#define OP (insn ) op_##insn
@@ -2024,19 +2026,33 @@ bool rv_decode(rv_insn_t *ir, uint32_t insn)
2024
2026
const uint16_t c_index = (insn & FC_FUNC3 ) >> 11 | (insn & FC_OPCODE );
2025
2027
2026
2028
/* decode instruction (compressed instructions) */
2027
- const decode_t op = rvc_jump_table [c_index ];
2029
+ op = rvc_jump_table [c_index ];
2028
2030
assert (op );
2029
- return op (ir , insn );
2031
+ ret = op (ir , insn );
2032
+
2033
+ goto end ;
2030
2034
}
2031
2035
#endif
2032
2036
2033
2037
/* standard uncompressed instruction */
2034
2038
const uint32_t index = (insn & INSN_6_2 ) >> 2 ;
2035
2039
2036
2040
/* decode instruction */
2037
- const decode_t op = rv_jump_table [index ];
2041
+ op = rv_jump_table [index ];
2038
2042
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 ;
2040
2056
2041
2057
#undef OP_UNIMP
2042
2058
#undef OP
You can’t perform that action at this time.
0 commit comments