diff options
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 7 | ||||
-rw-r--r-- | opcodes/riscv-dis.c | 21 | ||||
-rw-r--r-- | opcodes/riscv-opc.c | 87 |
3 files changed, 20 insertions, 95 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 03acd4d7..162aafcb 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2021-02-18 Nelson Chu <nelson.chu@sifive.com> + + * riscv-dis.c: Included cpu-riscv.h, and removed elfxx-riscv.h. + (default_priv_spec): Updated type to riscv_spec_class. + (parse_riscv_dis_option): Updated. + * riscv-opc.c: Moved stuff and make the file tidy. + 2021-02-17 Alan Modra <amodra@gmail.com> * wasm32-dis.c: Include limits.h. diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index b5883c3..667dbd8 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -27,12 +27,12 @@ #include "opintl.h" #include "elf-bfd.h" #include "elf/riscv.h" -#include "elfxx-riscv.h" +#include "cpu-riscv.h" #include "bfd_stdint.h" #include <ctype.h> -static enum riscv_priv_spec_class default_priv_spec = PRIV_SPEC_CLASS_NONE; +static enum riscv_spec_class default_priv_spec = PRIV_SPEC_CLASS_NONE; struct riscv_private_data { @@ -99,17 +99,22 @@ parse_riscv_dis_option (const char *option) value = equal + 1; if (strcmp (option, "priv-spec") == 0) { - enum riscv_priv_spec_class priv_spec = PRIV_SPEC_CLASS_NONE; - if (!riscv_get_priv_spec_class (value, &priv_spec)) + enum riscv_spec_class priv_spec = PRIV_SPEC_CLASS_NONE; + const char *name = NULL; + + RISCV_GET_PRIV_SPEC_CLASS (value, priv_spec); + if (priv_spec == PRIV_SPEC_CLASS_NONE) opcodes_error_handler (_("unknown privileged spec set by %s=%s"), option, value); else if (default_priv_spec == PRIV_SPEC_CLASS_NONE) default_priv_spec = priv_spec; else if (default_priv_spec != priv_spec) - opcodes_error_handler (_("mis-matched privilege spec set by %s=%s, " - "the elf privilege attribute is %s"), - option, value, - riscv_get_priv_spec_name (default_priv_spec)); + { + RISCV_GET_PRIV_SPEC_NAME (name, default_priv_spec); + opcodes_error_handler (_("mis-matched privilege spec set by %s=%s, " + "the elf privilege attribute is %s"), + option, value, name); + } } else { diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c index b072ee2..50a3f30 100644 --- a/opcodes/riscv-opc.c +++ b/opcodes/riscv-opc.c @@ -886,90 +886,3 @@ const struct riscv_opcode riscv_insn_types[] = /* Terminate the list. */ {0, 0, INSN_CLASS_NONE, 0, 0, 0, 0, 0} }; - -/* All standard extensions defined in all supported ISA spec. */ -const struct riscv_ext_version riscv_ext_version_table[] = -{ -/* name, ISA spec, major version, minor version. */ -{"e", ISA_SPEC_CLASS_20191213, 1, 9}, -{"e", ISA_SPEC_CLASS_20190608, 1, 9}, -{"e", ISA_SPEC_CLASS_2P2, 1, 9}, - -{"i", ISA_SPEC_CLASS_20191213, 2, 1}, -{"i", ISA_SPEC_CLASS_20190608, 2, 1}, -{"i", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"m", ISA_SPEC_CLASS_20191213, 2, 0}, -{"m", ISA_SPEC_CLASS_20190608, 2, 0}, -{"m", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"a", ISA_SPEC_CLASS_20191213, 2, 1}, -{"a", ISA_SPEC_CLASS_20190608, 2, 0}, -{"a", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"f", ISA_SPEC_CLASS_20191213, 2, 2}, -{"f", ISA_SPEC_CLASS_20190608, 2, 2}, -{"f", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"d", ISA_SPEC_CLASS_20191213, 2, 2}, -{"d", ISA_SPEC_CLASS_20190608, 2, 2}, -{"d", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"q", ISA_SPEC_CLASS_20191213, 2, 2}, -{"q", ISA_SPEC_CLASS_20190608, 2, 2}, -{"q", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"c", ISA_SPEC_CLASS_20191213, 2, 0}, -{"c", ISA_SPEC_CLASS_20190608, 2, 0}, -{"c", ISA_SPEC_CLASS_2P2, 2, 0}, - -{"zicsr", ISA_SPEC_CLASS_20191213, 2, 0}, -{"zicsr", ISA_SPEC_CLASS_20190608, 2, 0}, - -{"zifencei", ISA_SPEC_CLASS_20191213, 2, 0}, -{"zifencei", ISA_SPEC_CLASS_20190608, 2, 0}, - -{"zihintpause", ISA_SPEC_CLASS_DRAFT, 1, 0}, - -/* Terminate the list. */ -{NULL, 0, 0, 0} -}; - -struct isa_spec_t -{ - const char *name; - enum riscv_isa_spec_class class; -}; - -/* List for all supported ISA spec versions. */ -static const struct isa_spec_t isa_specs[] = -{ - {"2.2", ISA_SPEC_CLASS_2P2}, - {"20190608", ISA_SPEC_CLASS_20190608}, - {"20191213", ISA_SPEC_CLASS_20191213}, - - /* Terminate the list. */ - {NULL, 0} -}; - -/* Get the corresponding ISA spec class by giving a ISA spec string. */ - -int -riscv_get_isa_spec_class (const char *s, - enum riscv_isa_spec_class *class) -{ - const struct isa_spec_t *version; - - if (s == NULL) - return 0; - - for (version = &isa_specs[0]; version->name != NULL; ++version) - if (strcmp (version->name, s) == 0) - { - *class = version->class; - return 1; - } - - /* Can not find the supported ISA spec. */ - return 0; -} |