From 0d25ef9702fbce7073a22b16edbe256c79d336e6 Mon Sep 17 00:00:00 2001 From: Yen-Fu Chen Date: Wed, 11 Oct 2023 22:42:16 +0800 Subject: [PATCH] Remove insn_len field in IR structure --- src/decode.c | 2 -- src/decode.h | 3 --- src/emulate.c | 4 ++-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/decode.c b/src/decode.c index 88de60224..6cdd6de1f 100644 --- a/src/decode.c +++ b/src/decode.c @@ -1729,7 +1729,6 @@ bool rv_decode(rv_insn_t *ir, uint32_t insn) if ((insn & FC_OPCODE) != 3) { insn &= 0x0000FFFF; const uint16_t c_index = (insn & FC_FUNC3) >> 11 | (insn & FC_OPCODE); - ir->insn_len = INSN_16; /* decode instruction (compressed instructions) */ const decode_t op = rvc_jump_table[c_index]; @@ -1740,7 +1739,6 @@ bool rv_decode(rv_insn_t *ir, uint32_t insn) /* standard uncompressed instruction */ const uint32_t index = (insn & INSN_6_2) >> 2; - ir->insn_len = INSN_32; /* decode instruction */ const decode_t op = rv_jump_table[index]; diff --git a/src/decode.h b/src/decode.h index eb5dfb9bf..c4c826d99 100644 --- a/src/decode.h +++ b/src/decode.h @@ -275,9 +275,6 @@ typedef struct rv_insn { uint32_t pc; - /* instruction length */ - uint8_t insn_len; - /* Tail-call optimization (TCO) allows a C function to replace a function * call to another function or itself, followed by a simple return of the * function's result, with a direct jump to the target function. This diff --git a/src/emulate.c b/src/emulate.c index e4cba3c5a..30f9d6f80 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -628,14 +628,14 @@ static void block_translate(riscv_t *rv, block_map_t *map, block_t *block) /* decode the instruction */ if (!rv_decode(ir, insn)) { - rv->compressed = (ir->insn_len == INSN_16); + rv->compressed = ((insn & FC_OPCODE) != 3); rv_except_illegal_insn(rv, insn); break; } ir->impl = dispatch_table[ir->opcode]; ir->pc = block->pc_end; /* compute the end of pc */ - block->pc_end += ir->insn_len; + block->pc_end += ((insn & FC_OPCODE) != 3) ? 2 : 4; block->n_insn++; prev_ir = ir; /* stop on branch */