Skip to content

Commit

Permalink
Merge pull request #348 from visitorckw/fix-illegal-instruciton-handling
Browse files Browse the repository at this point in the history
Fix illegal instruction handling for SLLI, SRLI, and SRAI
  • Loading branch information
jserv authored Feb 7, 2024
2 parents 50b8a07 + 52fe009 commit 1c9da01
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ static inline bool op_op_imm(rv_insn_t *ir, const uint32_t insn)
break;
case 1: /* SLLI: Shift Left Logical */
ir->opcode = rv_insn_slli;
if (unlikely(ir->imm & (1 << 5)))
return false;
break;
case 2: /* SLTI: Set on Less Than Immediate */
ir->opcode = rv_insn_slti;
Expand All @@ -482,6 +484,8 @@ static inline bool op_op_imm(rv_insn_t *ir, const uint32_t insn)
ir->opcode = (ir->imm & ~0x1f)
? rv_insn_srai /* SRAI: Shift Right Arithmetic */
: rv_insn_srli; /* SRLI: Shift Right Logical */
if (unlikely(ir->imm & (1 << 5)))
return false;
break;
case 6: /* ORI: OR Immediate */
ir->opcode = rv_insn_ori;
Expand Down

0 comments on commit 1c9da01

Please sign in to comment.