diff options
Diffstat (limited to 'opcodes/riscv-dis.c')
-rw-r--r-- | opcodes/riscv-dis.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index c341a0f..9c3158a 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -37,6 +37,9 @@ disassemble_info::fprintf_func which is for unstyled output. */ #define fprintf_func please_use_fprintf_styled_func_instead +/* The earliest privilege spec supported by disassembler. */ +#define PRIV_SPEC_EARLIEST PRIV_SPEC_CLASS_1P10 + struct riscv_private_data { bfd_vma gp; @@ -66,7 +69,7 @@ struct riscv_private_data const char (*riscv_fpr_names)[NRC]; /* If set, disassemble as most general instruction. */ bool no_aliases; - /* If set, disassemble without checking architectire string, just like what + /* If set, disassemble without checking architecture string, just like what we did at the beginning. */ bool all_ext; }; @@ -80,6 +83,7 @@ set_default_riscv_dis_options (struct disassemble_info *info) pd->riscv_gpr_names = riscv_gpr_names_abi; pd->riscv_fpr_names = riscv_fpr_names_abi; pd->no_aliases = false; + pd->all_ext = false; } /* Parse RISC-V disassembler option (without arguments). */ @@ -139,7 +143,7 @@ parse_riscv_dis_option (const char *option, struct disassemble_info *info) const char *name = NULL; RISCV_GET_PRIV_SPEC_CLASS (value, priv_spec); - if (priv_spec == PRIV_SPEC_CLASS_NONE) + if (priv_spec < PRIV_SPEC_EARLIEST) opcodes_error_handler (_("unknown privileged spec set by %s=%s"), option, value); else if (pd->default_priv_spec == PRIV_SPEC_CLASS_NONE) @@ -509,6 +513,11 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info print (info->stream, dis_style_immediate, "0"); break; + case 'r': + print (info->stream, dis_style_register, "%s", + pd->riscv_gpr_names[EXTRACT_OPERAND (RS3, l)]); + break; + case 's': if ((l & MASK_JALR) == MATCH_JALR) maybe_print_address (pd, rs1, EXTRACT_ITYPE_IMM (l), 0); @@ -877,6 +886,37 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info break; } break; + case 'm': /* Vendor-specific (MIPS) operands. */ + switch (*++oparg) + { + case '@': + print (info->stream, dis_style_register, "0x%x", + (unsigned) EXTRACT_OPERAND (MIPS_HINT, l)); + break; + case '#': + print (info->stream, dis_style_register, "0x%x", + (unsigned) EXTRACT_OPERAND (MIPS_IMM9, l)); + break; + case '$': + print (info->stream, dis_style_immediate, "%d", + (unsigned)EXTRACT_MIPS_LDP_IMM (l)); + break; + case '%': + print (info->stream, dis_style_immediate, "%d", + (unsigned)EXTRACT_MIPS_LWP_IMM (l)); + break; + case '^': + print (info->stream, dis_style_immediate, "%d", + (unsigned)EXTRACT_MIPS_SDP_IMM (l)); + break; + case '&': + print (info->stream, dis_style_immediate, "%d", + (unsigned)EXTRACT_MIPS_SWP_IMM (l)); + break; + default: + goto undefined_modifier; + } + break; default: goto undefined_modifier; } @@ -1577,6 +1617,9 @@ static struct riscv_option_arg_t arg; } riscv_options[] = { + { "max", + N_("Disassemble without checking architecture string."), + RISCV_OPTION_ARG_NONE }, { "numeric", N_("Print numeric register names, rather than ABI names."), RISCV_OPTION_ARG_NONE }, @@ -1608,12 +1651,12 @@ disassembler_options_riscv (void) args = XNEWVEC (disasm_option_arg_t, num_args + 1); args[RISCV_OPTION_ARG_PRIV_SPEC].name = "SPEC"; - priv_spec_count = PRIV_SPEC_CLASS_DRAFT - PRIV_SPEC_CLASS_NONE - 1; + priv_spec_count = PRIV_SPEC_CLASS_DRAFT - PRIV_SPEC_EARLIEST; args[RISCV_OPTION_ARG_PRIV_SPEC].values = XNEWVEC (const char *, priv_spec_count + 1); for (i = 0; i < priv_spec_count; i++) args[RISCV_OPTION_ARG_PRIV_SPEC].values[i] - = riscv_priv_specs[i].name; + = riscv_priv_specs[PRIV_SPEC_EARLIEST - PRIV_SPEC_CLASS_NONE - 1 + i].name; /* The array we return must be NULL terminated. */ args[RISCV_OPTION_ARG_PRIV_SPEC].values[i] = NULL; |