opcodes/riscv: add disassembler options support to libopcodes
authorAndrew Burgess <aburgess@redhat.com>
Tue, 28 Sep 2021 21:11:42 +0000 (22:11 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 26 Nov 2021 10:18:35 +0000 (10:18 +0000)
commit3a337a86d9d273b5da57b1cd8ecec4baa7e95e33
treeb7b3022634d0a3bc5e1c6b12bbeed1c8ac337555
parent4780e5e4933a2497a5aecc4ceabbbb8e82aaf822
opcodes/riscv: add disassembler options support to libopcodes

In preparation for the next commit, which will add GDB support for
RISC-V disassembler options, this commit restructures how the
disassembler options are managed within libopcodes.

The implementation provided here is based on this mailing list patch
which was never committed:

  https://sourceware.org/pipermail/binutils/2021-January/114944.html

which in turn took inspiration from the MIPS implementation of the
same feature.

The biggest changes from the original mailing list post are:

  1. The GDB changes have been split into a separate patch, and

  2. The `riscv_option_args_privspec` variable, which held the valid
  priv-spec values is now gone, instead we use the `riscv_priv_specs`
  array from bfd/cpu-riscv.c instead.

Co-authored-by: Simon Cook <simon.cook@embecosm.com>
include/ChangeLog:

* dis-asm.h (disassembler_options_riscv): Declare.

opcodes/ChangeLog:

* riscv-dis.c (enum riscv_option_arg_t): New enum typedef.
(riscv_options): New static global.
(disassembler_options_riscv): New function.
(print_riscv_disassembler_options): Rewrite to use
disassembler_options_riscv.
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/riscv-dis.c