From 3d73d29e4eff8701ae6251347d03dd6057911178 Mon Sep 17 00:00:00 2001 From: Nelson Chu Date: Thu, 28 Jan 2021 10:45:56 +0800 Subject: RISC-V: Add bfd/cpu-riscv.h to support all spec versions controlling. Make the opcode/riscv-opc.c and include/opcode/riscv.h tidy, move the spec versions stuff to bfd/cpu-riscv.h. Also move the csr stuff and ext_version_table to gas/config/tc-riscv.c for internal use. To avoid too many repeated code, define general RISCV_GET_SPEC_NAME/SPEC_CLASS macros. Therefore, assembler/dis-assembler/linker/gdb can get all spec versions related stuff from cpu-riscv.h and cpu-riscv.c, since the stuff are defined there uniformly. bfd/ * Makefile.am: Added cpu-riscv.h. * Makefile.in: Regenerated. * po/SRC-POTFILES.in: Regenerated. * cpu-riscv.h: Added to support spec versions controlling. Also added extern arrays and functions for cpu-riscv.c. (enum riscv_spec_class): Define all spec classes here uniformly. (struct riscv_spec): Added for all specs. (RISCV_GET_SPEC_CLASS): Added to reduce repeated code. (RISCV_GET_SPEC_NAME): Likewise. (RISCV_GET_ISA_SPEC_CLASS): Added to get ISA spec class. (RISCV_GET_PRIV_SPEC_CLASS): Added to get privileged spec class. (RISCV_GET_PRIV_SPEC_NAME): Added to get privileged spec name. * cpu-riscv.c (struct priv_spec_t): Replaced with struct riscv_spec. (riscv_get_priv_spec_class): Replaced with RISCV_GET_PRIV_SPEC_CLASS. (riscv_get_priv_spec_name): Replaced with RISCV_GET_PRIV_SPEC_NAME. (riscv_priv_specs): Moved below. (riscv_get_priv_spec_class_from_numbers): Likewise, updated. (riscv_isa_specs): Moved from include/opcode/riscv.h. * elfnn-riscv.c: Included cpu-riscv.h. (riscv_merge_attributes): Initialize in_priv_spec and out_priv_spec. * elfxx-riscv.c: Included cpu-riscv.h and opcode/riscv.h. (RISCV_UNKNOWN_VERSION): Moved from include/opcode/riscv.h. * elfxx-riscv.h: Removed extern functions to cpu-riscv.h. gas/ * config/tc-riscv.c: Included cpu-riscv.h. (enum riscv_csr_clas): Moved from include/opcode/riscv.h. (struct riscv_csr_extra): Likewise. (struct riscv_ext_version): Likewise. (ext_version_table): Moved from opcodes/riscv-opc.c. (default_isa_spec): Updated type to riscv_spec_class. (default_priv_spec): Likewise. (riscv_set_default_isa_spec): Updated. (init_ext_version_hash): Likewise. (riscv_init_csr_hash): Likewise, also fixed indent. include/ * opcode/riscv.h: Moved stuff and make the file tidy. opcodes/ * 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. --- opcodes/riscv-opc.c | 87 ----------------------------------------------------- 1 file changed, 87 deletions(-) (limited to 'opcodes/riscv-opc.c') diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c index b072ee292c9..50a3f30391e 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; -} -- cgit v1.2.1