foss-for-synopsys-dwc-arc-processors / binutils-gdb

A mirror of the upstream binutils-gdb repository for ARC specific work
GNU General Public License v2.0
13 stars 10 forks source link

arc: Construct disassembler options dynamically #60

Closed shahab-vahedi closed 3 years ago

shahab-vahedi commented 3 years ago
The idea of this change is simple: Populate a data structure, namely
"disasm_option_and_arg_t" from "include/dis-asm.h", to encompass the
disassembly options and their possible arguments.

This will make it easier to manage or extend those options by adapting
entries in a data structure, "arc_options".  There is a lesser need to
hard-code the options in the code itself.  Moreover, ARC GDB will use
this population function, "disassembler_options_arc ()", to enable the
"disassembler-option" for ARC targets.  The gdb change will be in a
separate patch though.

The changes in this patch can be divided into:

1) Introduction of "disassembler_options_arc ()" that will return a
"disasm_option_and_arg_t" structure representing the disassembly
options and their likely arguments.

2) New data type "arc_options_arg_t" and new data "arc_options".
These are the internals for keeping track of options and arguments
entries that can easily be extended.

3) To print the options, the "print_arc_disassembler_options ()" has
been adjusted to use this dynamically built structure instead of having
them hard-coded inside.

To see this in effect, one can look into the output of:
$ ./binutils/objdump --help
  ...
  The following ARC specific disassembler options are...

include/ChangeLog:

    * dis-asm.h (disassembler_options_arc): New prototype.

opcodes/ChangeLog:

    * arc-dis.c (arc_option_arg_t): New enumeration.
    (arc_options): New variable.
    (disassembler_options_arc): New function.
    (print_arc_disassembler_options): Reimplement in terms of
    "disassembler_options_arc".
shahab-vahedi commented 3 years ago

As we talked, the GNU style format has been applied. Moreover, we checked that there is no regression in make check-{binutils,gas,ld}.