Add used_opcode_data field in rv_decode. After this patch, we will not use opcode_data directly.
This will give the custom opcode data a choice to be selected in the future. Signed-off-by: LIU Zhiwei <zhiwei_...@linux.alibaba.com> --- disas/riscv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/disas/riscv.c b/disas/riscv.c index 5c36ae08dc..aaf85b2aba 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -601,6 +601,7 @@ typedef struct { uint8_t rl; uint8_t bs; uint8_t rnum; + const rv_opcode_data *used_opcode_data; } rv_decode; /* register names */ @@ -2532,7 +2533,7 @@ static uint32_t operand_rnum(rv_inst inst) static void decode_inst_operands(rv_decode *dec) { rv_inst inst = dec->inst; - dec->codec = opcode_data[dec->op].codec; + dec->codec = dec->used_opcode_data[dec->op].codec; switch (dec->codec) { case rv_codec_none: dec->rd = dec->rs1 = dec->rs2 = rv_ireg_zero; @@ -2959,6 +2960,7 @@ static void format_inst(char *buf, size_t buflen, size_t tab, rv_decode *dec) { char tmp[64]; const char *fmt; + const rv_opcode_data *opcode_data = dec->used_opcode_data; fmt = opcode_data[dec->op].format; while (*fmt) { @@ -3111,6 +3113,7 @@ static void format_inst(char *buf, size_t buflen, size_t tab, rv_decode *dec) static void decode_inst_lift_pseudo(rv_decode *dec) { + const rv_opcode_data *opcode_data = dec->used_opcode_data; const rv_comp_data *comp_data = opcode_data[dec->op].pseudo; if (!comp_data) { return; @@ -3129,6 +3132,7 @@ static void decode_inst_lift_pseudo(rv_decode *dec) static void decode_inst_decompress_rv32(rv_decode *dec) { + const rv_opcode_data *opcode_data = dec->used_opcode_data; int decomp_op = opcode_data[dec->op].decomp_rv32; if (decomp_op != rv_op_illegal) { if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz) @@ -3143,6 +3147,7 @@ static void decode_inst_decompress_rv32(rv_decode *dec) static void decode_inst_decompress_rv64(rv_decode *dec) { + const rv_opcode_data *opcode_data = dec->used_opcode_data; int decomp_op = opcode_data[dec->op].decomp_rv64; if (decomp_op != rv_op_illegal) { if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz) @@ -3157,6 +3162,7 @@ static void decode_inst_decompress_rv64(rv_decode *dec) static void decode_inst_decompress_rv128(rv_decode *dec) { + const rv_opcode_data *opcode_data = dec->used_opcode_data; int decomp_op = opcode_data[dec->op].decomp_rv128; if (decomp_op != rv_op_illegal) { if ((opcode_data[dec->op].decomp_data & rvcd_imm_nz) @@ -3192,6 +3198,7 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst) rv_decode dec = { 0 }; dec.pc = pc; dec.inst = inst; + dec.used_opcode_data = opcode_data; decode_inst_opcode(&dec, isa); decode_inst_operands(&dec); decode_inst_decompress(&dec, isa); -- 2.25.1