diff options
author | Martin Liska <mliska@suse.cz> | 2020-08-18 10:57:21 +0200 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-08-20 10:56:07 +0930 |
commit | 629310abec8811510177101f3c7992dfd4be24dd (patch) | |
tree | d8de5773b66f877c3f8a7ddb9a4bd27d1a4705fa /gas/config/tc-riscv.c | |
parent | 494b2fc8078502f84a2ff2a3402a5989b221526d (diff) | |
download | gdb-629310abec8811510177101f3c7992dfd4be24dd.zip gdb-629310abec8811510177101f3c7992dfd4be24dd.tar.gz gdb-629310abec8811510177101f3c7992dfd4be24dd.tar.bz2 |
Port gas/config/* to str_htab.
* config/obj-coff-seh.c (seh_hash_insert): Port to use new
str_htab type.
(seh_hash_find): Likewise.
(seh_hash_find_or_make): Likewise.
* config/obj-coff.c (tag_init): Likewise.
(tag_insert): Likewise.
(tag_find): Likewise.
* config/obj-elf.c (struct group_list): Likewise.
(build_additional_section_info): Likewise.
(free_section_idx): Likewise.
(elf_adjust_symtab): Likewise.
(elf_frob_file_after_relocs): Likewise.
* config/tc-aarch64.c (INSN_SIZE): Likewise.
(parse_reg): Likewise.
(insert_reg_alias): Likewise.
(create_register_alias): Likewise.
(s_unreq): Likewise.
(parse_shift): Likewise.
(parse_pldop): Likewise.
(parse_barrier): Likewise.
(parse_barrier_psb): Likewise.
(parse_bti_operand): Likewise.
(parse_sys_reg): Likewise.
(parse_sys_ins_reg): Likewise.
(lookup_mnemonic): Likewise.
(opcode_lookup): Likewise.
(parse_operands): Likewise.
(checked_hash_insert): Likewise.
(sysreg_hash_insert): Likewise.
(fill_instruction_hash_table): Likewise.
(md_begin): Likewise.
* config/tc-alpha.c (struct alpha_reloc_tag): Likewise.
(get_alpha_reloc_tag): Likewise.
(assemble_tokens_to_insn): Likewise.
(assemble_tokens): Likewise.
(md_begin): Likewise.
* config/tc-arc.c (arc_find_opcode): Likewise.
(arc_insert_opcode): Likewise.
(find_opcode_match): Likewise.
(declare_register): Likewise.
(declare_addrtype): Likewise.
(md_begin): Likewise.
(arc_parse_name): Likewise.
(tc_arc_regname_to_dw2regnum): Likewise.
(arc_extcorereg): Likewise.
* config/tc-arm.c (MVE_BAD_QREG): Likewise.
(arm_reg_parse_multi): Likewise.
(parse_reloc): Likewise.
(insert_reg_alias): Likewise.
(create_register_alias): Likewise.
(s_unreq): Likewise.
(parse_shift): Likewise.
(parse_psr): Likewise.
(parse_cond): Likewise.
(parse_barrier): Likewise.
(do_vfp_nsyn_opcode): Likewise.
(opcode_lookup): Likewise.
(arm_tc_equal_in_insn): Likewise.
(md_begin): Likewise.
* config/tc-avr.c (md_begin): Likewise.
(avr_ldi_expression): Likewise.
(md_assemble): Likewise.
(avr_update_gccisr): Likewise.
(avr_emit_insn): Likewise.
* config/tc-cr16.c (get_register): Likewise.
(get_register_pair): Likewise.
(get_index_register): Likewise.
(get_index_register_pair): Likewise.
(get_pregister): Likewise.
(get_pregisterp): Likewise.
(initialise_reg_hash_table): Likewise.
(md_begin): Likewise.
(cr16_assemble): Likewise.
(md_assemble): Likewise.
* config/tc-cris.c (cris_insn_first_word_frag): Likewise.
(md_begin): Likewise.
(cris_process_instruction): Likewise.
* config/tc-crx.c (get_register): Likewise.
(get_copregister): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-csky.c (md_begin): Likewise.
(parse_opcode): Likewise.
(get_operand_value): Likewise.
(v1_work_jbsr): Likewise.
(v2_work_rotlc): Likewise.
(v2_work_bgeni): Likewise.
(v2_work_not): Likewise.
* config/tc-d10v.c (sizeof): Likewise.
(md_begin): Likewise.
(do_assemble): Likewise.
(md_apply_fix): Likewise.
* config/tc-d30v.c (sizeof): Likewise.
(md_begin): Likewise.
(do_assemble): Likewise.
* config/tc-dlx.c (RELOC_DLX_VTENTRY): Likewise.
(md_begin): Likewise.
(machine_ip): Likewise.
* config/tc-ft32.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-h8300.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-hppa.c (pa_ip): Likewise.
(md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
(i386_print_statistics): Likewise.
(parse_insn): Likewise.
(process_operands): Likewise.
(i386_index_check): Likewise.
(parse_real_register): Likewise.
* config/tc-ia64.c (dot_rot): Likewise.
(dot_entry): Likewise.
(declare_register): Likewise.
(md_begin): Likewise.
(ia64_parse_name): Likewise.
(md_assemble): Likewise.
(dot_alias): Likewise.
(do_alias): Likewise.
(ia64_adjust_symtab): Likewise.
(do_secalias): Likewise.
(ia64_frob_file): Likewise.
* config/tc-m68hc11.c (m68hc11_print_statistics): Likewise.
(md_begin): Likewise.
(print_insn_format): Likewise.
(md_assemble): Likewise.
* config/tc-m68k.c (tc_gen_reloc): Likewise.
(m68k_ip): Likewise.
(md_begin): Likewise.
* config/tc-mcore.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-microblaze.c (md_begin): Likewise.
(md_assemble): Likewise.
(md_apply_fix): Likewise.
* config/tc-mips.c (nopic_need_relax): Likewise.
(md_begin): Likewise.
(macro_build): Likewise.
(mips16_macro_build): Likewise.
(mips_lookup_insn): Likewise.
(mips_ip): Likewise.
(mips16_ip): Likewise.
* config/tc-mmix.c (sizeof): Likewise.
(mmix_md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-mn10200.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-mn10300.c (HAVE_AM30): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-moxie.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-msp430.c (md_begin): Likewise.
(msp430_operands): Likewise.
(md_assemble): Likewise.
* config/tc-nds32.c (PV_DONT_CARE): Likewise.
(builtin_isreg): Likewise.
(builtin_regnum): Likewise.
(nds32_init_nds32_pseudo_opcodes): Likewise.
(nds32_lookup_pseudo_opcode): Likewise.
(nds32_relax_hint): Likewise.
(md_begin): Likewise.
(nds32_find_reloc_table): Likewise.
(nds32_elf_append_relax_relocs_traverse): Likewise.
(nds32_relax_branch_instructions): Likewise.
(md_convert_frag): Likewise.
(nds32_elf_analysis_relax_hint): Likewise.
(tc_nds32_regname_to_dw2regnum): Likewise.
* config/tc-nios2.c (nios2_opcode_lookup): Likewise.
(nios2_reg_lookup): Likewise.
(nios2_ps_lookup): Likewise.
(md_begin): Likewise.
* config/tc-ns32k.c (struct hash_control): Likewise.
(parse): Likewise.
(md_begin): Likewise.
* config/tc-pdp11.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-pj.c (fake_opcode): Likewise.
(alias): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
(md_assemble): Likewise.
* config/tc-pru.c (pru_opcode_lookup): Likewise.
(pru_reg_lookup): Likewise.
(md_begin): Likewise.
(md_end): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(riscv_get_default_ext_version): Likewise.
(riscv_set_arch): Likewise.
(init_opcode_names_hash): Likewise.
(opcode_name_lookup): Likewise.
(enum reg_class): Likewise.
(hash_reg_name): Likewise.
(riscv_init_csr_hash): Likewise.
(reg_csr_lookup_internal): Likewise.
(reg_lookup_internal): Likewise.
(init_opcode_hash): Likewise.
(md_begin): Likewise.
(DECLARE_CSR): Likewise.
(macro_build): Likewise.
(riscv_ip): Likewise.
* config/tc-s390.c (register_name): Likewise.
(s390_setup_opcodes): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
(s390_insn): Likewise.
* config/tc-score.c (struct s3_reg_map): Likewise.
(s3_score_reg_parse): Likewise.
(s3_dependency_type_from_insn): Likewise.
(s3_parse_16_32_inst): Likewise.
(s3_parse_48_inst): Likewise.
(s3_insert_reg): Likewise.
(s3_build_reg_hsh): Likewise.
(s3_build_score_ops_hsh): Likewise.
(s3_build_dependency_insn_hsh): Likewise.
(s3_begin): Likewise.
* config/tc-score7.c (struct s7_reg_map): Likewise.
(s7_score_reg_parse): Likewise.
(s7_dependency_type_from_insn): Likewise.
(s7_parse_16_32_inst): Likewise.
(s7_build_score_ops_hsh): Likewise.
(s7_build_dependency_insn_hsh): Likewise.
(s7_insert_reg): Likewise.
(s7_build_reg_hsh): Likewise.
(s7_begin): Likewise.
* config/tc-sh.c (EMPTY): Likewise.
(md_begin): Likewise.
(find_cooked_opcode): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
(sparc_ip): Likewise.
* config/tc-spu.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
(tic30_operand): Likewise.
(tic30_parallel_insn): Likewise.
(md_assemble): Likewise.
* config/tc-tic4x.c (TIC4X_ALT_SYNTAX): Likewise.
(tic4x_asg): Likewise.
(tic4x_inst_insert): Likewise.
(tic4x_inst_add): Likewise.
(md_begin): Likewise.
(tic4x_operand_parse): Likewise.
(md_assemble): Likewise.
* config/tc-tic54x.c (MAX_SUBSYM_HASH): Likewise.
(stag_add_field_symbols): Likewise.
(tic54x_endstruct): Likewise.
(tic54x_tag): Likewise.
(tic54x_remove_local_label): Likewise.
(tic54x_clear_local_labels): Likewise.
(tic54x_var): Likewise.
(tic54x_macro_start): Likewise.
(tic54x_macro_info): Likewise.
(tic54x_macro_end): Likewise.
(subsym_isreg): Likewise.
(subsym_structsz): Likewise.
(md_begin): Likewise.
(is_mmreg): Likewise.
(is_type): Likewise.
(encode_condition): Likewise.
(encode_cc3): Likewise.
(encode_cc2): Likewise.
(encode_operand): Likewise.
(tic54x_parse_insn): Likewise.
(tic54x_parse_parallel_insn_firstline): Likewise.
(subsym_create_or_replace): Likewise.
(subsym_lookup): Likewise.
(subsym_substitute): Likewise.
(tic54x_undefined_symbol): Likewise.
* config/tc-tic6x.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-tilegx.c (O_hw2_last_plt): Likewise.
(INSERT_SPECIAL_OP): Likewise.
(md_begin): Likewise.
(tilegx_parse_name): Likewise.
(parse_reg_expression): Likewise.
(md_assemble): Likewise.
* config/tc-tilepro.c (O_tls_ie_load): Likewise.
(INSERT_SPECIAL_OP): Likewise.
(tilepro_parse_name): Likewise.
(parse_reg_expression): Likewise.
(md_assemble): Likewise.
* config/tc-v850.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-vax.c (md_ri_to_chars): Likewise.
(vip_begin): Likewise.
(vip): Likewise.
(main): Likewise.
(md_begin): Likewise.
* config/tc-wasm32.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-xgate.c (xgate_parse_operand): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-z8k.c (md_begin): Likewise.
(md_assemble): Likewise.
Diffstat (limited to 'gas/config/tc-riscv.c')
-rw-r--r-- | gas/config/tc-riscv.c | 93 |
1 files changed, 27 insertions, 66 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 1d33aea..c575c07 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -242,28 +242,18 @@ riscv_multi_subset_supports (enum riscv_insn_class insn_class) } /* Handle of the extension with version hash table. */ -static struct hash_control *ext_version_hash = NULL; +static htab_t ext_version_hash = NULL; -static struct hash_control * +static htab_t init_ext_version_hash (const struct riscv_ext_version *table) { int i = 0; - struct hash_control *hash = hash_new (); + htab_t hash = str_htab_create (); while (table[i].name) { const char *name = table[i].name; - const char *hash_error = - hash_insert (hash, name, (void *) &table[i]); - - if (hash_error != NULL) - { - fprintf (stderr, _("internal error: can't hash `%s': %s\n"), - table[i].name, hash_error); - /* Probably a memory allocation problem? Give up now. */ - as_fatal (_("Broken assembler. No assembly attempted.")); - return NULL; - } + str_hash_insert (hash, name, (void *) &table[i]); i++; while (table[i].name @@ -287,7 +277,7 @@ riscv_get_default_ext_version (const char *name, if (name == NULL || default_isa_spec == ISA_SPEC_CLASS_NONE) return; - ext = (struct riscv_ext_version *) hash_find (ext_version_hash, name); + ext = (struct riscv_ext_version *) str_hash_find (ext_version_hash, name); while (ext && ext->name && strcmp (ext->name, name) == 0) @@ -321,10 +311,10 @@ riscv_set_arch (const char *s) } /* Handle of the OPCODE hash table. */ -static struct hash_control *op_hash = NULL; +static htab_t op_hash = NULL; /* Handle of the type of .insn hash table. */ -static struct hash_control *insn_type_hash = NULL; +static htab_t insn_type_hash = NULL; /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful */ @@ -559,23 +549,16 @@ static const struct opcode_name_t opcode_name_list[] = }; /* Hash table for lookup opcode name. */ -static struct hash_control *opcode_names_hash = NULL; +static htab_t opcode_names_hash = NULL; /* Initialization for hash table of opcode name. */ static void init_opcode_names_hash (void) { - const char *retval; const struct opcode_name_t *opcode; for (opcode = &opcode_name_list[0]; opcode->name != NULL; ++opcode) - { - retval = hash_insert (opcode_names_hash, opcode->name, (void *)opcode); - - if (retval != NULL) - as_fatal (_("internal error: can't hash `%s': %s"), - opcode->name, retval); - } + str_hash_insert (opcode_names_hash, opcode->name, (void *)opcode); } /* Find `s` is a valid opcode name or not, @@ -598,7 +581,7 @@ opcode_name_lookup (char **s) save_c = *e; *e = '\0'; - o = (struct opcode_name_t *) hash_find (opcode_names_hash, *s); + o = (struct opcode_name_t *) str_hash_find (opcode_names_hash, *s); /* Advance to next token if one was recognized. */ if (o) @@ -619,8 +602,8 @@ enum reg_class RCLASS_CSR }; -static struct hash_control *reg_names_hash = NULL; -static struct hash_control *csr_extra_hash = NULL; +static htab_t reg_names_hash = NULL; +static htab_t csr_extra_hash = NULL; #define ENCODE_REG_HASH(cls, n) \ ((void *)(uintptr_t)((n) * RCLASS_MAX + (cls) + 1)) @@ -631,10 +614,7 @@ static void hash_reg_name (enum reg_class class, const char *name, unsigned n) { void *hash = ENCODE_REG_HASH (class, n); - const char *retval = hash_insert (reg_names_hash, name, hash); - - if (retval != NULL) - as_fatal (_("internal error: can't hash `%s': %s"), name, retval); + str_hash_insert (reg_names_hash, name, hash); } static void @@ -655,11 +635,10 @@ riscv_init_csr_hash (const char *name, enum riscv_priv_spec_class abort_version) { struct riscv_csr_extra *entry, *pre_entry; - const char *hash_error = NULL; bfd_boolean need_enrty = TRUE; pre_entry = NULL; - entry = (struct riscv_csr_extra *) hash_find (csr_extra_hash, name); + entry = (struct riscv_csr_extra *) str_hash_find (csr_extra_hash, name); while (need_enrty && entry != NULL) { if (entry->csr_class == class @@ -686,16 +665,7 @@ riscv_init_csr_hash (const char *name, Otherwise, attach the extra information to the entry which is already in the hash table. */ if (pre_entry == NULL) - { - hash_error = hash_insert (csr_extra_hash, name, (void *) entry); - if (hash_error != NULL) - { - fprintf (stderr, _("internal error: can't hash `%s': %s\n"), - name, hash_error); - /* Probably a memory allocation problem? Give up now. */ - as_fatal (_("Broken assembler. No assembly attempted.")); - } - } + str_hash_insert (csr_extra_hash, name, (void *) entry); else pre_entry->next = entry; } @@ -772,7 +742,7 @@ static unsigned int reg_csr_lookup_internal (const char *s) { struct riscv_csr_extra *r = - (struct riscv_csr_extra *) hash_find (csr_extra_hash, s); + (struct riscv_csr_extra *) str_hash_find (csr_extra_hash, s); if (r == NULL) return -1U; @@ -794,7 +764,7 @@ reg_lookup_internal (const char *s, enum reg_class class) if (class == RCLASS_CSR) return reg_csr_lookup_internal (s); - r = hash_find (reg_names_hash, s); + r = str_hash_find (reg_names_hash, s); if (r == NULL || DECODE_REG_CLASS (r) != class) return -1; @@ -1018,26 +988,17 @@ struct percent_op_match /* Common hash table initialization function for instruction and .insn directive. */ -static struct hash_control * +static htab_t init_opcode_hash (const struct riscv_opcode *opcodes, bfd_boolean insn_directive_p) { int i = 0; int length; - struct hash_control *hash = hash_new (); + htab_t hash = str_htab_create (); while (opcodes[i].name) { const char *name = opcodes[i].name; - const char *hash_error = - hash_insert (hash, name, (void *) &opcodes[i]); - - if (hash_error != NULL) - { - fprintf (stderr, _("internal error: can't hash `%s': %s\n"), - opcodes[i].name, hash_error); - /* Probably a memory allocation problem? Give up now. */ - as_fatal (_("Broken assembler. No assembly attempted.")); - } + str_hash_insert (hash, name, (void *) &opcodes[i]); do { @@ -1074,7 +1035,7 @@ md_begin (void) op_hash = init_opcode_hash (riscv_opcodes, FALSE); insn_type_hash = init_opcode_hash (riscv_insn_types, TRUE); - reg_names_hash = hash_new (); + reg_names_hash = str_htab_create (); hash_reg_names (RCLASS_GPR, riscv_gpr_names_numeric, NGPR); hash_reg_names (RCLASS_GPR, riscv_gpr_names_abi, NGPR); hash_reg_names (RCLASS_FPR, riscv_fpr_names_numeric, NFPR); @@ -1083,7 +1044,7 @@ md_begin (void) hash_reg_name (RCLASS_GPR, "fp", 8); /* Create and insert CSR hash tables. */ - csr_extra_hash = hash_new (); + csr_extra_hash = str_htab_create (); #define DECLARE_CSR(name, num, class, define_version, abort_version) \ riscv_init_csr_hash (#name, num, class, define_version, abort_version); #define DECLARE_CSR_ALIAS(name, num, class, define_version, abort_version) \ @@ -1091,7 +1052,7 @@ md_begin (void) #include "opcode/riscv-opc.h" #undef DECLARE_CSR - opcode_names_hash = hash_new (); + opcode_names_hash = str_htab_create (); init_opcode_names_hash (); /* Set the default alignment for the text section. */ @@ -1196,7 +1157,7 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...) va_start (args, fmt); r = BFD_RELOC_UNUSED; - mo = (struct riscv_opcode *) hash_find (op_hash, name); + mo = (struct riscv_opcode *) str_hash_find (op_hash, name); gas_assert (mo); /* Find a non-RVC variant of the instruction. append_insn will compress @@ -1796,7 +1757,7 @@ riscv_is_priv_insn (insn_t insn) static const char * riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, - bfd_reloc_code_real_type *imm_reloc, struct hash_control *hash) + bfd_reloc_code_real_type *imm_reloc, htab_t hash) { char *s; const char *args; @@ -1812,7 +1773,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, bfd_boolean insn_with_csr = FALSE; /* Parse the name of the instruction. Terminate the string if whitespace - is found so that hash_find only sees the name part of the string. */ + is found so that str_hash_find only sees the name part of the string. */ for (s = str; *s != '\0'; ++s) if (ISSPACE (*s)) { @@ -1821,7 +1782,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, break; } - insn = (struct riscv_opcode *) hash_find (hash, str); + insn = (struct riscv_opcode *) str_hash_find (hash, str); argsStart = s; for ( ; insn && insn->name && strcmp (insn->name, str) == 0; insn++) |