Skip to content

Commit 1c9da01

Browse files
authored
Merge pull request #348 from visitorckw/fix-illegal-instruciton-handling
Fix illegal instruction handling for SLLI, SRLI, and SRAI
2 parents 50b8a07 + 52fe009 commit 1c9da01

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/decode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ static inline bool op_op_imm(rv_insn_t *ir, const uint32_t insn)
465465
break;
466466
case 1: /* SLLI: Shift Left Logical */
467467
ir->opcode = rv_insn_slli;
468+
if (unlikely(ir->imm & (1 << 5)))
469+
return false;
468470
break;
469471
case 2: /* SLTI: Set on Less Than Immediate */
470472
ir->opcode = rv_insn_slti;
@@ -482,6 +484,8 @@ static inline bool op_op_imm(rv_insn_t *ir, const uint32_t insn)
482484
ir->opcode = (ir->imm & ~0x1f)
483485
? rv_insn_srai /* SRAI: Shift Right Arithmetic */
484486
: rv_insn_srli; /* SRLI: Shift Right Logical */
487+
if (unlikely(ir->imm & (1 << 5)))
488+
return false;
485489
break;
486490
case 6: /* ORI: OR Immediate */
487491
ir->opcode = rv_insn_ori;

0 commit comments

Comments
 (0)