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.
This commit is contained in:
Martin Liska 2020-08-18 10:57:21 +02:00 committed by Alan Modra
parent 494b2fc807
commit 629310abec
56 changed files with 1114 additions and 1214 deletions

View file

@ -1,3 +1,300 @@
2020-08-20 Martin Liska <mliska@suse.cz>
* 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.
2020-08-20 Martin Liska <mliska@suse.cz> 2020-08-20 Martin Liska <mliska@suse.cz>
* dw2gencfi.c (dwcfi_hash_insert): Use htab_t and str_hash_* * dw2gencfi.c (dwcfi_hash_insert): Use htab_t and str_hash_*

View file

@ -31,7 +31,7 @@ struct seh_seg_list {
/* Local data. */ /* Local data. */
static seh_context *seh_ctx_cur = NULL; static seh_context *seh_ctx_cur = NULL;
static struct hash_control *seh_hash; static htab_t seh_hash;
static struct seh_seg_list *x_segcur = NULL; static struct seh_seg_list *x_segcur = NULL;
static struct seh_seg_list *p_segcur = NULL; static struct seh_seg_list *p_segcur = NULL;
@ -116,17 +116,13 @@ make_pxdata_seg (segT cseg, char *name)
static void static void
seh_hash_insert (const char *name, struct seh_seg_list *item) seh_hash_insert (const char *name, struct seh_seg_list *item)
{ {
const char *error_string; str_hash_insert (seh_hash, name, (char *) item);
if ((error_string = hash_jam (seh_hash, name, (char *) item)))
as_fatal (_("Inserting \"%s\" into structure table failed: %s"),
name, error_string);
} }
static struct seh_seg_list * static struct seh_seg_list *
seh_hash_find (char *name) seh_hash_find (char *name)
{ {
return (struct seh_seg_list *) hash_find (seh_hash, name); return (struct seh_seg_list *) str_hash_find (seh_hash, name);
} }
static struct seh_seg_list * static struct seh_seg_list *
@ -137,7 +133,7 @@ seh_hash_find_or_make (segT cseg, const char *base_name)
/* Initialize seh_hash once. */ /* Initialize seh_hash once. */
if (!seh_hash) if (!seh_hash)
seh_hash = hash_new (); seh_hash = str_htab_create ();
name = get_pxdata_name (cseg, base_name); name = get_pxdata_name (cseg, base_name);

View file

@ -117,28 +117,24 @@ stack_pop (stack *st)
/* Maintain a list of the tagnames of the structures. */ /* Maintain a list of the tagnames of the structures. */
static struct hash_control *tag_hash; static htab_t tag_hash;
static void static void
tag_init (void) tag_init (void)
{ {
tag_hash = hash_new (); tag_hash = str_htab_create ();
} }
static void static void
tag_insert (const char *name, symbolS *symbolP) tag_insert (const char *name, symbolS *symbolP)
{ {
const char *error_string; str_hash_insert (tag_hash, name, (char *) symbolP);
if ((error_string = hash_jam (tag_hash, name, (char *) symbolP)))
as_fatal (_("Inserting \"%s\" into structure table failed: %s"),
name, error_string);
} }
static symbolS * static symbolS *
tag_find (char *name) tag_find (char *name)
{ {
return (symbolS *) hash_find (tag_hash, name); return (symbolS *) str_hash_find (tag_hash, name);
} }
static symbolS * static symbolS *

View file

@ -2594,7 +2594,7 @@ struct group_list
{ {
asection **head; /* Section lists. */ asection **head; /* Section lists. */
unsigned int num_group; /* Number of lists. */ unsigned int num_group; /* Number of lists. */
struct hash_control *indexes; /* Maps group name to index in head array. */ htab_t indexes; /* Maps group name to index in head array. */
}; };
static struct group_list groups; static struct group_list groups;
@ -2632,7 +2632,7 @@ build_additional_section_info (bfd *abfd ATTRIBUTE_UNUSED,
/* If this group already has a list, add the section to the head of /* If this group already has a list, add the section to the head of
the list. */ the list. */
elem_idx = (unsigned int *) hash_find (list->indexes, group_name); elem_idx = (unsigned int *) str_hash_find (list->indexes, group_name);
if (elem_idx != NULL) if (elem_idx != NULL)
{ {
elf_next_in_group (sec) = list->head[*elem_idx]; elf_next_in_group (sec) = list->head[*elem_idx];
@ -2654,12 +2654,15 @@ build_additional_section_info (bfd *abfd ATTRIBUTE_UNUSED,
/* Add index to hash. */ /* Add index to hash. */
idx_ptr = XNEW (unsigned int); idx_ptr = XNEW (unsigned int);
*idx_ptr = i; *idx_ptr = i;
hash_insert (list->indexes, group_name, idx_ptr); str_hash_insert (list->indexes, group_name, (char *)idx_ptr);
} }
static void free_section_idx (const char *key ATTRIBUTE_UNUSED, void *val) static int
free_section_idx (void **slot, void *arg ATTRIBUTE_UNUSED)
{ {
free ((unsigned int *) val); string_tuple_t *tuple = *((string_tuple_t **) slot);
free ((char *)tuple->value);
return 1;
} }
/* Create symbols for group signature. */ /* Create symbols for group signature. */
@ -2672,7 +2675,7 @@ elf_adjust_symtab (void)
/* Go find section groups. */ /* Go find section groups. */
groups.num_group = 0; groups.num_group = 0;
groups.head = NULL; groups.head = NULL;
groups.indexes = hash_new (); groups.indexes = str_htab_create ();
bfd_map_over_sections (stdoutput, build_additional_section_info, bfd_map_over_sections (stdoutput, build_additional_section_info,
&groups); &groups);
@ -2844,8 +2847,8 @@ elf_frob_file_after_relocs (void)
} }
/* Cleanup hash. */ /* Cleanup hash. */
hash_traverse (groups.indexes, free_section_idx); htab_traverse (groups.indexes, free_section_idx, NULL);
hash_die (groups.indexes); htab_delete (groups.indexes);
#ifdef NEED_ECOFF_DEBUG #ifdef NEED_ECOFF_DEBUG
if (ECOFF_DEBUGGING) if (ECOFF_DEBUGGING)

View file

@ -451,21 +451,21 @@ get_reg_expected_msg (aarch64_reg_type reg_type)
/* Instructions take 4 bytes in the object file. */ /* Instructions take 4 bytes in the object file. */
#define INSN_SIZE 4 #define INSN_SIZE 4
static struct hash_control *aarch64_ops_hsh; static htab_t aarch64_ops_hsh;
static struct hash_control *aarch64_cond_hsh; static htab_t aarch64_cond_hsh;
static struct hash_control *aarch64_shift_hsh; static htab_t aarch64_shift_hsh;
static struct hash_control *aarch64_sys_regs_hsh; static htab_t aarch64_sys_regs_hsh;
static struct hash_control *aarch64_pstatefield_hsh; static htab_t aarch64_pstatefield_hsh;
static struct hash_control *aarch64_sys_regs_ic_hsh; static htab_t aarch64_sys_regs_ic_hsh;
static struct hash_control *aarch64_sys_regs_dc_hsh; static htab_t aarch64_sys_regs_dc_hsh;
static struct hash_control *aarch64_sys_regs_at_hsh; static htab_t aarch64_sys_regs_at_hsh;
static struct hash_control *aarch64_sys_regs_tlbi_hsh; static htab_t aarch64_sys_regs_tlbi_hsh;
static struct hash_control *aarch64_sys_regs_sr_hsh; static htab_t aarch64_sys_regs_sr_hsh;
static struct hash_control *aarch64_reg_hsh; static htab_t aarch64_reg_hsh;
static struct hash_control *aarch64_barrier_opt_hsh; static htab_t aarch64_barrier_opt_hsh;
static struct hash_control *aarch64_nzcv_hsh; static htab_t aarch64_nzcv_hsh;
static struct hash_control *aarch64_pldop_hsh; static htab_t aarch64_pldop_hsh;
static struct hash_control *aarch64_hint_opt_hsh; static htab_t aarch64_hint_opt_hsh;
/* Stuff needed to resolve the label ambiguity /* Stuff needed to resolve the label ambiguity
As: As:
@ -764,7 +764,7 @@ parse_reg (char **ccp)
p++; p++;
while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_'); while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_');
reg = (reg_entry *) hash_find_n (aarch64_reg_hsh, start, p - start); reg = (reg_entry *) str_hash_find_n (aarch64_reg_hsh, start, p - start);
if (!reg) if (!reg)
return NULL; return NULL;
@ -1315,7 +1315,7 @@ insert_reg_alias (char *str, int number, aarch64_reg_type type)
reg_entry *new; reg_entry *new;
const char *name; const char *name;
if ((new = hash_find (aarch64_reg_hsh, str)) != 0) if ((new = str_hash_find (aarch64_reg_hsh, str)) != 0)
{ {
if (new->builtin) if (new->builtin)
as_warn (_("ignoring attempt to redefine built-in register '%s'"), as_warn (_("ignoring attempt to redefine built-in register '%s'"),
@ -1337,8 +1337,7 @@ insert_reg_alias (char *str, int number, aarch64_reg_type type)
new->type = type; new->type = type;
new->builtin = FALSE; new->builtin = FALSE;
if (hash_insert (aarch64_reg_hsh, name, (void *) new)) str_hash_insert (aarch64_reg_hsh, name, (void *) new);
abort ();
return new; return new;
} }
@ -1367,7 +1366,7 @@ create_register_alias (char *newname, char *p)
if (*oldname == '\0') if (*oldname == '\0')
return FALSE; return FALSE;
old = hash_find (aarch64_reg_hsh, oldname); old = str_hash_find (aarch64_reg_hsh, oldname);
if (!old) if (!old)
{ {
as_warn (_("unknown register '%s' -- .req ignored"), oldname); as_warn (_("unknown register '%s' -- .req ignored"), oldname);
@ -1456,7 +1455,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
as_bad (_("invalid syntax for .unreq directive")); as_bad (_("invalid syntax for .unreq directive"));
else else
{ {
reg_entry *reg = hash_find (aarch64_reg_hsh, name); reg_entry *reg = str_hash_find (aarch64_reg_hsh, name);
if (!reg) if (!reg)
as_bad (_("unknown register alias '%s'"), name); as_bad (_("unknown register alias '%s'"), name);
@ -1468,7 +1467,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
char *p; char *p;
char *nbuf; char *nbuf;
hash_delete (aarch64_reg_hsh, name, FALSE); str_hash_delete (aarch64_reg_hsh, name);
free ((char *) reg->name); free ((char *) reg->name);
free (reg); free (reg);
@ -1479,20 +1478,20 @@ s_unreq (int a ATTRIBUTE_UNUSED)
nbuf = strdup (name); nbuf = strdup (name);
for (p = nbuf; *p; p++) for (p = nbuf; *p; p++)
*p = TOUPPER (*p); *p = TOUPPER (*p);
reg = hash_find (aarch64_reg_hsh, nbuf); reg = str_hash_find (aarch64_reg_hsh, nbuf);
if (reg) if (reg)
{ {
hash_delete (aarch64_reg_hsh, nbuf, FALSE); str_hash_delete (aarch64_reg_hsh, nbuf);
free ((char *) reg->name); free ((char *) reg->name);
free (reg); free (reg);
} }
for (p = nbuf; *p; p++) for (p = nbuf; *p; p++)
*p = TOLOWER (*p); *p = TOLOWER (*p);
reg = hash_find (aarch64_reg_hsh, nbuf); reg = str_hash_find (aarch64_reg_hsh, nbuf);
if (reg) if (reg)
{ {
hash_delete (aarch64_reg_hsh, nbuf, FALSE); str_hash_delete (aarch64_reg_hsh, nbuf);
free ((char *) reg->name); free ((char *) reg->name);
free (reg); free (reg);
} }
@ -3122,7 +3121,7 @@ parse_shift (char **str, aarch64_opnd_info *operand, enum parse_shift_mode mode)
return FALSE; return FALSE;
} }
shift_op = hash_find_n (aarch64_shift_hsh, *str, p - *str); shift_op = str_hash_find_n (aarch64_shift_hsh, *str, p - *str);
if (shift_op == NULL) if (shift_op == NULL)
{ {
@ -3979,7 +3978,7 @@ parse_pldop (char **str)
while (ISALNUM (*q)) while (ISALNUM (*q))
q++; q++;
o = hash_find_n (aarch64_pldop_hsh, p, q - p); o = str_hash_find_n (aarch64_pldop_hsh, p, q - p);
if (!o) if (!o)
return PARSE_FAIL; return PARSE_FAIL;
@ -4000,7 +3999,7 @@ parse_barrier (char **str)
while (ISALPHA (*q)) while (ISALPHA (*q))
q++; q++;
o = hash_find_n (aarch64_barrier_opt_hsh, p, q - p); o = str_hash_find_n (aarch64_barrier_opt_hsh, p, q - p);
if (!o) if (!o)
return PARSE_FAIL; return PARSE_FAIL;
@ -4022,7 +4021,7 @@ parse_barrier_psb (char **str,
while (ISALPHA (*q)) while (ISALPHA (*q))
q++; q++;
o = hash_find_n (aarch64_hint_opt_hsh, p, q - p); o = str_hash_find_n (aarch64_hint_opt_hsh, p, q - p);
if (!o) if (!o)
{ {
set_fatal_syntax_error set_fatal_syntax_error
@ -4057,7 +4056,7 @@ parse_bti_operand (char **str,
while (ISALPHA (*q)) while (ISALPHA (*q))
q++; q++;
o = hash_find_n (aarch64_hint_opt_hsh, p, q - p); o = str_hash_find_n (aarch64_hint_opt_hsh, p, q - p);
if (!o) if (!o)
{ {
set_fatal_syntax_error set_fatal_syntax_error
@ -4095,7 +4094,7 @@ parse_bti_operand (char **str,
*/ */
static int static int
parse_sys_reg (char **str, struct hash_control *sys_regs, parse_sys_reg (char **str, htab_t sys_regs,
int imple_defined_p, int pstatefield_p, int imple_defined_p, int pstatefield_p,
uint32_t* flags) uint32_t* flags)
{ {
@ -4116,7 +4115,7 @@ parse_sys_reg (char **str, struct hash_control *sys_regs,
if (p - buf != q - *str) if (p - buf != q - *str)
return PARSE_FAIL; return PARSE_FAIL;
o = hash_find (sys_regs, buf); o = str_hash_find (sys_regs, buf);
if (!o) if (!o)
{ {
if (!imple_defined_p) if (!imple_defined_p)
@ -4162,7 +4161,7 @@ parse_sys_reg (char **str, struct hash_control *sys_regs,
for the option, or NULL. */ for the option, or NULL. */
static const aarch64_sys_ins_reg * static const aarch64_sys_ins_reg *
parse_sys_ins_reg (char **str, struct hash_control *sys_ins_regs) parse_sys_ins_reg (char **str, htab_t sys_ins_regs)
{ {
char *p, *q; char *p, *q;
char buf[AARCH64_MAX_SYSREG_NAME_LEN]; char buf[AARCH64_MAX_SYSREG_NAME_LEN];
@ -4180,7 +4179,7 @@ parse_sys_ins_reg (char **str, struct hash_control *sys_ins_regs)
if (p - buf != q - *str) if (p - buf != q - *str)
return NULL; return NULL;
o = hash_find (sys_ins_regs, buf); o = str_hash_find (sys_ins_regs, buf);
if (!o) if (!o)
return NULL; return NULL;
@ -5096,7 +5095,7 @@ lookup_mnemonic (const char *start, int len)
{ {
templates *templ = NULL; templates *templ = NULL;
templ = hash_find_n (aarch64_ops_hsh, start, len); templ = str_hash_find_n (aarch64_ops_hsh, start, len);
return templ; return templ;
} }
@ -5127,7 +5126,7 @@ opcode_lookup (char **str)
/* Handle a possible condition. */ /* Handle a possible condition. */
if (dot) if (dot)
{ {
cond = hash_find_n (aarch64_cond_hsh, dot + 1, end - dot - 1); cond = str_hash_find_n (aarch64_cond_hsh, dot + 1, end - dot - 1);
if (cond) if (cond)
{ {
inst.cond = cond->value; inst.cond = cond->value;
@ -6178,7 +6177,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
case AARCH64_OPND_NZCV: case AARCH64_OPND_NZCV:
{ {
const asm_nzcv *nzcv = hash_find_n (aarch64_nzcv_hsh, str, 4); const asm_nzcv *nzcv = str_hash_find_n (aarch64_nzcv_hsh, str, 4);
if (nzcv != NULL) if (nzcv != NULL)
{ {
str += 4; str += 4;
@ -6197,7 +6196,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
do do
str++; str++;
while (ISALPHA (*str)); while (ISALPHA (*str));
info->cond = hash_find_n (aarch64_cond_hsh, start, str - start); info->cond = str_hash_find_n (aarch64_cond_hsh, start, str - start);
if (info->cond == NULL) if (info->cond == NULL)
{ {
set_syntax_error (_("invalid condition")); set_syntax_error (_("invalid condition"));
@ -8621,17 +8620,13 @@ aarch64_adjust_symtab (void)
} }
static void static void
checked_hash_insert (struct hash_control *table, const char *key, void *value) checked_hash_insert (htab_t table, const char *key, void *value)
{ {
const char *hash_err; str_hash_insert (table, key, value);
hash_err = hash_insert (table, key, value);
if (hash_err)
printf ("Internal Error: Can't hash %s\n", key);
} }
static void static void
sysreg_hash_insert (struct hash_control *table, const char *key, void *value) sysreg_hash_insert (htab_t table, const char *key, void *value)
{ {
gas_assert (strlen (key) < AARCH64_MAX_SYSREG_NAME_LEN); gas_assert (strlen (key) < AARCH64_MAX_SYSREG_NAME_LEN);
checked_hash_insert (table, key, value); checked_hash_insert (table, key, value);
@ -8645,7 +8640,7 @@ fill_instruction_hash_table (void)
while (opcode->name != NULL) while (opcode->name != NULL)
{ {
templates *templ, *new_templ; templates *templ, *new_templ;
templ = hash_find (aarch64_ops_hsh, opcode->name); templ = str_hash_find (aarch64_ops_hsh, opcode->name);
new_templ = XNEW (templates); new_templ = XNEW (templates);
new_templ->opcode = opcode; new_templ->opcode = opcode;
@ -8691,21 +8686,21 @@ md_begin (void)
unsigned mach; unsigned mach;
unsigned int i; unsigned int i;
if ((aarch64_ops_hsh = hash_new ()) == NULL if ((aarch64_ops_hsh = str_htab_create ()) == NULL
|| (aarch64_cond_hsh = hash_new ()) == NULL || (aarch64_cond_hsh = str_htab_create ()) == NULL
|| (aarch64_shift_hsh = hash_new ()) == NULL || (aarch64_shift_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_hsh = hash_new ()) == NULL || (aarch64_sys_regs_hsh = str_htab_create ()) == NULL
|| (aarch64_pstatefield_hsh = hash_new ()) == NULL || (aarch64_pstatefield_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_ic_hsh = hash_new ()) == NULL || (aarch64_sys_regs_ic_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_dc_hsh = hash_new ()) == NULL || (aarch64_sys_regs_dc_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_at_hsh = hash_new ()) == NULL || (aarch64_sys_regs_at_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_tlbi_hsh = hash_new ()) == NULL || (aarch64_sys_regs_tlbi_hsh = str_htab_create ()) == NULL
|| (aarch64_sys_regs_sr_hsh = hash_new ()) == NULL || (aarch64_sys_regs_sr_hsh = str_htab_create ()) == NULL
|| (aarch64_reg_hsh = hash_new ()) == NULL || (aarch64_reg_hsh = str_htab_create ()) == NULL
|| (aarch64_barrier_opt_hsh = hash_new ()) == NULL || (aarch64_barrier_opt_hsh = str_htab_create ()) == NULL
|| (aarch64_nzcv_hsh = hash_new ()) == NULL || (aarch64_nzcv_hsh = str_htab_create ()) == NULL
|| (aarch64_pldop_hsh = hash_new ()) == NULL || (aarch64_pldop_hsh = str_htab_create ()) == NULL
|| (aarch64_hint_opt_hsh = hash_new ()) == NULL) || (aarch64_hint_opt_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
fill_instruction_hash_table (); fill_instruction_hash_table ();

View file

@ -297,10 +297,10 @@ static unsigned alpha_target = AXP_OPCODE_BASE;
static const char *alpha_target_name = "<all>"; static const char *alpha_target_name = "<all>";
/* The hash table of instruction opcodes. */ /* The hash table of instruction opcodes. */
static struct hash_control *alpha_opcode_hash; static htab_t alpha_opcode_hash;
/* The hash table of macro opcodes. */ /* The hash table of macro opcodes. */
static struct hash_control *alpha_macro_hash; static htab_t alpha_macro_hash;
#ifdef OBJ_ECOFF #ifdef OBJ_ECOFF
/* The $gp relocation symbol. */ /* The $gp relocation symbol. */
@ -514,7 +514,7 @@ struct alpha_reloc_tag
}; };
/* Hash table to link up literals with the appropriate lituse. */ /* Hash table to link up literals with the appropriate lituse. */
static struct hash_control *alpha_literal_hash; static htab_t alpha_literal_hash;
/* Sequence numbers for internal use by macros. */ /* Sequence numbers for internal use by macros. */
static long next_sequence_num = -1; static long next_sequence_num = -1;
@ -589,11 +589,10 @@ get_alpha_reloc_tag (long sequence)
sprintf (buffer, "!%ld", sequence); sprintf (buffer, "!%ld", sequence);
info = (struct alpha_reloc_tag *) hash_find (alpha_literal_hash, buffer); info = (struct alpha_reloc_tag *) str_hash_find (alpha_literal_hash, buffer);
if (! info) if (! info)
{ {
size_t len = strlen (buffer); size_t len = strlen (buffer);
const char *errmsg;
info = (struct alpha_reloc_tag *) info = (struct alpha_reloc_tag *)
xcalloc (sizeof (struct alpha_reloc_tag) + len, 1); xcalloc (sizeof (struct alpha_reloc_tag) + len, 1);
@ -601,9 +600,7 @@ get_alpha_reloc_tag (long sequence)
info->segment = now_seg; info->segment = now_seg;
info->sequence = sequence; info->sequence = sequence;
strcpy (info->string, buffer); strcpy (info->string, buffer);
errmsg = hash_insert (alpha_literal_hash, info->string, (void *) info); str_hash_insert (alpha_literal_hash, info->string, (void *) info);
if (errmsg)
as_fatal ("%s", errmsg);
#ifdef OBJ_EVAX #ifdef OBJ_EVAX
info->sym = 0; info->sym = 0;
info->psym = 0; info->psym = 0;
@ -1171,7 +1168,7 @@ assemble_tokens_to_insn (const char *opname,
const struct alpha_opcode *opcode; const struct alpha_opcode *opcode;
/* Search opcodes. */ /* Search opcodes. */
opcode = (const struct alpha_opcode *) hash_find (alpha_opcode_hash, opname); opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash, opname);
if (opcode) if (opcode)
{ {
int cpumatch; int cpumatch;
@ -3319,7 +3316,7 @@ assemble_tokens (const char *opname,
if (local_macros_on) if (local_macros_on)
{ {
macro = ((const struct alpha_macro *) macro = ((const struct alpha_macro *)
hash_find (alpha_macro_hash, opname)); str_hash_find (alpha_macro_hash, opname));
if (macro) if (macro)
{ {
found_something = 1; found_something = 1;
@ -3333,7 +3330,7 @@ assemble_tokens (const char *opname,
} }
/* Search opcodes. */ /* Search opcodes. */
opcode = (const struct alpha_opcode *) hash_find (alpha_opcode_hash, opname); opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash, opname);
if (opcode) if (opcode)
{ {
found_something = 1; found_something = 1;
@ -5419,17 +5416,14 @@ md_begin (void)
} }
/* Create the opcode hash table. */ /* Create the opcode hash table. */
alpha_opcode_hash = hash_new (); alpha_opcode_hash = str_htab_create ();
for (i = 0; i < alpha_num_opcodes;) for (i = 0; i < alpha_num_opcodes;)
{ {
const char *name, *retval, *slash; const char *name, *slash;
name = alpha_opcodes[i].name; name = alpha_opcodes[i].name;
retval = hash_insert (alpha_opcode_hash, name, (void *) &alpha_opcodes[i]); str_hash_insert (alpha_opcode_hash, name, (void *) &alpha_opcodes[i]);
if (retval)
as_fatal (_("internal error: can't hash opcode `%s': %s"),
name, retval);
/* Some opcodes include modifiers of various sorts with a "/mod" /* Some opcodes include modifiers of various sorts with a "/mod"
syntax, like the architecture manual suggests. However, for syntax, like the architecture manual suggests. However, for
@ -5443,7 +5437,7 @@ md_begin (void)
memcpy (p, name, slash - name); memcpy (p, name, slash - name);
strcpy (p + (slash - name), slash + 1); strcpy (p + (slash - name), slash + 1);
(void) hash_insert (alpha_opcode_hash, p, (void *) &alpha_opcodes[i]); (void) str_hash_insert (alpha_opcode_hash, p, (void *) &alpha_opcodes[i]);
/* Ignore failures -- the opcode table does duplicate some /* Ignore failures -- the opcode table does duplicate some
variants in different forms, like "hw_stq" and "hw_st/q". */ variants in different forms, like "hw_stq" and "hw_st/q". */
} }
@ -5455,17 +5449,14 @@ md_begin (void)
} }
/* Create the macro hash table. */ /* Create the macro hash table. */
alpha_macro_hash = hash_new (); alpha_macro_hash = str_htab_create ();
for (i = 0; i < alpha_num_macros;) for (i = 0; i < alpha_num_macros;)
{ {
const char *name, *retval; const char *name;
name = alpha_macros[i].name; name = alpha_macros[i].name;
retval = hash_insert (alpha_macro_hash, name, (void *) &alpha_macros[i]); str_hash_insert (alpha_macro_hash, name, (void *) &alpha_macros[i]);
if (retval)
as_fatal (_("internal error: can't hash macro `%s': %s"),
name, retval);
while (++i < alpha_num_macros while (++i < alpha_num_macros
&& (alpha_macros[i].name == name && (alpha_macros[i].name == name
@ -5520,7 +5511,7 @@ md_begin (void)
#endif #endif
/* Create literal lookup hash table. */ /* Create literal lookup hash table. */
alpha_literal_hash = hash_new (); alpha_literal_hash = str_htab_create ();
subseg_set (text_section, 0); subseg_set (text_section, 0);
} }

View file

@ -428,16 +428,16 @@ enum mach_selection_type
static enum mach_selection_type mach_selection_mode = MACH_SELECTION_NONE; static enum mach_selection_type mach_selection_mode = MACH_SELECTION_NONE;
/* The hash table of instruction opcodes. */ /* The hash table of instruction opcodes. */
static struct hash_control *arc_opcode_hash; static htab_t arc_opcode_hash;
/* The hash table of register symbols. */ /* The hash table of register symbols. */
static struct hash_control *arc_reg_hash; static htab_t arc_reg_hash;
/* The hash table of aux register symbols. */ /* The hash table of aux register symbols. */
static struct hash_control *arc_aux_hash; static htab_t arc_aux_hash;
/* The hash table of address types. */ /* The hash table of address types. */
static struct hash_control *arc_addrtype_hash; static htab_t arc_addrtype_hash;
#define ARC_CPU_TYPE_A6xx(NAME,EXTRA) \ #define ARC_CPU_TYPE_A6xx(NAME,EXTRA) \
{ #NAME, ARC_OPCODE_ARC600, bfd_mach_arc_arc600, \ { #NAME, ARC_OPCODE_ARC600, bfd_mach_arc_arc600, \
@ -704,7 +704,7 @@ arc_find_opcode (const char *name)
{ {
const struct arc_opcode_hash_entry *entry; const struct arc_opcode_hash_entry *entry;
entry = hash_find (arc_opcode_hash, name); entry = str_hash_find (arc_opcode_hash, name);
return entry; return entry;
} }
@ -754,21 +754,18 @@ arc_opcode_hash_entry_iterator_next (const struct arc_opcode_hash_entry *entry,
static void static void
arc_insert_opcode (const struct arc_opcode *opcode) arc_insert_opcode (const struct arc_opcode *opcode)
{ {
const char *name, *retval; const char *name;
struct arc_opcode_hash_entry *entry; struct arc_opcode_hash_entry *entry;
name = opcode->name; name = opcode->name;
entry = hash_find (arc_opcode_hash, name); entry = str_hash_find (arc_opcode_hash, name);
if (entry == NULL) if (entry == NULL)
{ {
entry = XNEW (struct arc_opcode_hash_entry); entry = XNEW (struct arc_opcode_hash_entry);
entry->count = 0; entry->count = 0;
entry->opcode = NULL; entry->opcode = NULL;
retval = hash_insert (arc_opcode_hash, name, (void *) entry); str_hash_insert (arc_opcode_hash, name, (void *) entry);
if (retval)
as_fatal (_("internal error: can't hash opcode '%s': %s"),
name, retval);
} }
entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode, entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode,
@ -1921,7 +1918,7 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry,
tmpp = strdup (p); tmpp = strdup (p);
for (pp = tmpp; *pp; ++pp) *pp = TOLOWER (*pp); for (pp = tmpp; *pp; ++pp) *pp = TOLOWER (*pp);
auxr = hash_find (arc_aux_hash, tmpp); auxr = str_hash_find (arc_aux_hash, tmpp);
if (auxr) if (auxr)
{ {
/* We modify the token array here, safe in the /* We modify the token array here, safe in the
@ -2552,14 +2549,10 @@ md_assemble (char *str)
static void static void
declare_register (const char *name, int number) declare_register (const char *name, int number)
{ {
const char *err;
symbolS *regS = symbol_create (name, reg_section, symbolS *regS = symbol_create (name, reg_section,
number, &zero_address_frag); number, &zero_address_frag);
err = hash_insert (arc_reg_hash, S_GET_NAME (regS), (void *) regS); str_hash_insert (arc_reg_hash, S_GET_NAME (regS), (void *) regS);
if (err)
as_fatal (_("Inserting \"%s\" into register table failed: %s"),
name, err);
} }
/* Construct symbols for each of the general registers. */ /* Construct symbols for each of the general registers. */
@ -2587,15 +2580,11 @@ declare_register_set (void)
static void static void
declare_addrtype (const char *name, int number) declare_addrtype (const char *name, int number)
{ {
const char *err;
symbolS *addrtypeS = symbol_create (name, undefined_section, symbolS *addrtypeS = symbol_create (name, undefined_section,
number, &zero_address_frag); number, &zero_address_frag);
err = hash_insert (arc_addrtype_hash, S_GET_NAME (addrtypeS), str_hash_insert (arc_addrtype_hash, S_GET_NAME (addrtypeS),
(void *) addrtypeS); (void *) addrtypeS);
if (err)
as_fatal (_("Inserting \"%s\" into address type table failed: %s"),
name, err);
} }
/* Port-specific assembler initialization. This function is called /* Port-specific assembler initialization. This function is called
@ -2619,7 +2608,7 @@ md_begin (void)
bfd_set_private_flags (stdoutput, selected_cpu.eflags); bfd_set_private_flags (stdoutput, selected_cpu.eflags);
/* Set up a hash table for the instructions. */ /* Set up a hash table for the instructions. */
arc_opcode_hash = hash_new (); arc_opcode_hash = str_htab_create ();
if (arc_opcode_hash == NULL) if (arc_opcode_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -2637,7 +2626,7 @@ md_begin (void)
}while (opcode->name); }while (opcode->name);
/* Register declaration. */ /* Register declaration. */
arc_reg_hash = hash_new (); arc_reg_hash = str_htab_create ();
if (arc_reg_hash == NULL) if (arc_reg_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -2690,7 +2679,7 @@ md_begin (void)
memset (&arc_last_insns[0], 0, sizeof (arc_last_insns)); memset (&arc_last_insns[0], 0, sizeof (arc_last_insns));
/* Aux register declaration. */ /* Aux register declaration. */
arc_aux_hash = hash_new (); arc_aux_hash = str_htab_create ();
if (arc_aux_hash == NULL) if (arc_aux_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -2698,8 +2687,6 @@ md_begin (void)
unsigned int i; unsigned int i;
for (i = 0; i < arc_num_aux_regs; i++, auxr++) for (i = 0; i < arc_num_aux_regs; i++, auxr++)
{ {
const char *retval;
if (!(auxr->cpu & selected_cpu.flags)) if (!(auxr->cpu & selected_cpu.flags))
continue; continue;
@ -2707,14 +2694,11 @@ md_begin (void)
&& !check_cpu_feature (auxr->subclass)) && !check_cpu_feature (auxr->subclass))
continue; continue;
retval = hash_insert (arc_aux_hash, auxr->name, (void *) auxr); str_hash_insert (arc_aux_hash, auxr->name, (void *) auxr);
if (retval)
as_fatal (_("internal error: can't hash aux register '%s': %s"),
auxr->name, retval);
} }
/* Address type declaration. */ /* Address type declaration. */
arc_addrtype_hash = hash_new (); arc_addrtype_hash = str_htab_create ();
if (arc_addrtype_hash == NULL) if (arc_addrtype_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -3420,7 +3404,7 @@ arc_parse_name (const char *name,
&& e->X_md == O_absent) && e->X_md == O_absent)
return FALSE; return FALSE;
sym = hash_find (arc_reg_hash, name); sym = str_hash_find (arc_reg_hash, name);
if (sym) if (sym)
{ {
e->X_op = O_register; e->X_op = O_register;
@ -3428,7 +3412,7 @@ arc_parse_name (const char *name,
return TRUE; return TRUE;
} }
sym = hash_find (arc_addrtype_hash, name); sym = str_hash_find (arc_addrtype_hash, name);
if (sym) if (sym)
{ {
e->X_op = O_addrtype; e->X_op = O_addrtype;
@ -4393,7 +4377,7 @@ tc_arc_regname_to_dw2regnum (char *regname)
{ {
struct symbol *sym; struct symbol *sym;
sym = hash_find (arc_reg_hash, regname); sym = str_hash_find (arc_reg_hash, regname);
if (sym) if (sym)
return S_GET_VALUE (sym); return S_GET_VALUE (sym);
@ -4883,7 +4867,6 @@ arc_extcorereg (int opertype)
{ {
extRegister_t ereg; extRegister_t ereg;
struct arc_aux_reg *auxr; struct arc_aux_reg *auxr;
const char *retval;
struct arc_flag_operand *ccode; struct arc_flag_operand *ccode;
memset (&ereg, 0, sizeof (ereg)); memset (&ereg, 0, sizeof (ereg));
@ -4906,10 +4889,7 @@ arc_extcorereg (int opertype)
auxr->cpu = selected_cpu.flags; auxr->cpu = selected_cpu.flags;
auxr->subclass = NONE; auxr->subclass = NONE;
auxr->address = ereg.number; auxr->address = ereg.number;
retval = hash_insert (arc_aux_hash, auxr->name, (void *) auxr); str_hash_insert (arc_aux_hash, auxr->name, (void *) auxr);
if (retval)
as_fatal (_("internal error: can't hash aux register '%s': %s"),
auxr->name, retval);
break; break;
case EXT_COND_CODE: case EXT_COND_CODE:
/* Condition code. */ /* Condition code. */

View file

@ -945,15 +945,15 @@ struct asm_opcode
#define BAD_EL_TYPE _("bad element type for instruction") #define BAD_EL_TYPE _("bad element type for instruction")
#define MVE_BAD_QREG _("MVE vector register Q[0..7] expected") #define MVE_BAD_QREG _("MVE vector register Q[0..7] expected")
static struct hash_control * arm_ops_hsh; static htab_t arm_ops_hsh;
static struct hash_control * arm_cond_hsh; static htab_t arm_cond_hsh;
static struct hash_control * arm_vcond_hsh; static htab_t arm_vcond_hsh;
static struct hash_control * arm_shift_hsh; static htab_t arm_shift_hsh;
static struct hash_control * arm_psr_hsh; static htab_t arm_psr_hsh;
static struct hash_control * arm_v7m_psr_hsh; static htab_t arm_v7m_psr_hsh;
static struct hash_control * arm_reg_hsh; static htab_t arm_reg_hsh;
static struct hash_control * arm_reloc_hsh; static htab_t arm_reloc_hsh;
static struct hash_control * arm_barrier_opt_hsh; static htab_t arm_barrier_opt_hsh;
/* Stuff needed to resolve the label ambiguity /* Stuff needed to resolve the label ambiguity
As: As:
@ -1427,7 +1427,7 @@ arm_reg_parse_multi (char **ccp)
p++; p++;
while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_'); while (ISALPHA (*p) || ISDIGIT (*p) || *p == '_');
reg = (struct reg_entry *) hash_find_n (arm_reg_hsh, start, p - start); reg = (struct reg_entry *) str_hash_find_n (arm_reg_hsh, start, p - start);
if (!reg) if (!reg)
return NULL; return NULL;
@ -2546,7 +2546,7 @@ parse_reloc (char **str)
return -1; return -1;
if ((r = (struct reloc_entry *) if ((r = (struct reloc_entry *)
hash_find_n (arm_reloc_hsh, p, q - p)) == NULL) str_hash_find_n (arm_reloc_hsh, p, q - p)) == NULL)
return -1; return -1;
*str = q + 1; *str = q + 1;
@ -2561,7 +2561,7 @@ insert_reg_alias (char *str, unsigned number, int type)
struct reg_entry *new_reg; struct reg_entry *new_reg;
const char *name; const char *name;
if ((new_reg = (struct reg_entry *) hash_find (arm_reg_hsh, str)) != 0) if ((new_reg = (struct reg_entry *) str_hash_find (arm_reg_hsh, str)) != 0)
{ {
if (new_reg->builtin) if (new_reg->builtin)
as_warn (_("ignoring attempt to redefine built-in register '%s'"), str); as_warn (_("ignoring attempt to redefine built-in register '%s'"), str);
@ -2583,8 +2583,7 @@ insert_reg_alias (char *str, unsigned number, int type)
new_reg->builtin = FALSE; new_reg->builtin = FALSE;
new_reg->neon = NULL; new_reg->neon = NULL;
if (hash_insert (arm_reg_hsh, name, (void *) new_reg)) str_hash_insert (arm_reg_hsh, name, new_reg);
abort ();
return new_reg; return new_reg;
} }
@ -2632,7 +2631,7 @@ create_register_alias (char * newname, char *p)
if (*oldname == '\0') if (*oldname == '\0')
return FALSE; return FALSE;
old = (struct reg_entry *) hash_find (arm_reg_hsh, oldname); old = (struct reg_entry *) str_hash_find (arm_reg_hsh, oldname);
if (!old) if (!old)
{ {
as_warn (_("unknown register '%s' -- .req ignored"), oldname); as_warn (_("unknown register '%s' -- .req ignored"), oldname);
@ -2884,7 +2883,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
as_bad (_("invalid syntax for .unreq directive")); as_bad (_("invalid syntax for .unreq directive"));
else else
{ {
struct reg_entry *reg = (struct reg_entry *) hash_find (arm_reg_hsh, struct reg_entry *reg = (struct reg_entry *) str_hash_find (arm_reg_hsh,
name); name);
if (!reg) if (!reg)
@ -2897,7 +2896,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
char * p; char * p;
char * nbuf; char * nbuf;
hash_delete (arm_reg_hsh, name, FALSE); str_hash_delete (arm_reg_hsh, name);
free ((char *) reg->name); free ((char *) reg->name);
free (reg->neon); free (reg->neon);
free (reg); free (reg);
@ -2909,10 +2908,10 @@ s_unreq (int a ATTRIBUTE_UNUSED)
nbuf = strdup (name); nbuf = strdup (name);
for (p = nbuf; *p; p++) for (p = nbuf; *p; p++)
*p = TOUPPER (*p); *p = TOUPPER (*p);
reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf); reg = (struct reg_entry *) str_hash_find (arm_reg_hsh, nbuf);
if (reg) if (reg)
{ {
hash_delete (arm_reg_hsh, nbuf, FALSE); str_hash_delete (arm_reg_hsh, nbuf);
free ((char *) reg->name); free ((char *) reg->name);
free (reg->neon); free (reg->neon);
free (reg); free (reg);
@ -2920,10 +2919,10 @@ s_unreq (int a ATTRIBUTE_UNUSED)
for (p = nbuf; *p; p++) for (p = nbuf; *p; p++)
*p = TOLOWER (*p); *p = TOLOWER (*p);
reg = (struct reg_entry *) hash_find (arm_reg_hsh, nbuf); reg = (struct reg_entry *) str_hash_find (arm_reg_hsh, nbuf);
if (reg) if (reg)
{ {
hash_delete (arm_reg_hsh, nbuf, FALSE); str_hash_delete (arm_reg_hsh, nbuf);
free ((char *) reg->name); free ((char *) reg->name);
free (reg->neon); free (reg->neon);
free (reg); free (reg);
@ -5537,7 +5536,7 @@ parse_shift (char **str, int i, enum parse_shift_mode mode)
return FAIL; return FAIL;
} }
shift_name = (const struct asm_shift_name *) hash_find_n (arm_shift_hsh, *str, shift_name = (const struct asm_shift_name *) str_hash_find_n (arm_shift_hsh, *str,
p - *str); p - *str);
if (shift_name == NULL) if (shift_name == NULL)
@ -6338,7 +6337,7 @@ parse_psr (char **str, bfd_boolean lhs)
|| strncasecmp (start, "psr", 3) == 0) || strncasecmp (start, "psr", 3) == 0)
p = start + strcspn (start, "rR") + 1; p = start + strcspn (start, "rR") + 1;
psr = (const struct asm_psr *) hash_find_n (arm_v7m_psr_hsh, start, psr = (const struct asm_psr *) str_hash_find_n (arm_v7m_psr_hsh, start,
p - start); p - start);
if (!psr) if (!psr)
@ -6441,7 +6440,7 @@ parse_psr (char **str, bfd_boolean lhs)
} }
else else
{ {
psr = (const struct asm_psr *) hash_find_n (arm_psr_hsh, start, psr = (const struct asm_psr *) str_hash_find_n (arm_psr_hsh, start,
p - start); p - start);
if (!psr) if (!psr)
goto error; goto error;
@ -6633,7 +6632,7 @@ parse_cond (char **str)
n++; n++;
} }
c = (const struct asm_cond *) hash_find_n (arm_cond_hsh, cond, n); c = (const struct asm_cond *) str_hash_find_n (arm_cond_hsh, cond, n);
if (!c) if (!c)
{ {
inst.error = _("condition required"); inst.error = _("condition required");
@ -6656,7 +6655,7 @@ parse_barrier (char **str)
while (ISALPHA (*q)) while (ISALPHA (*q))
q++; q++;
o = (const struct asm_barrier_opt *) hash_find_n (arm_barrier_opt_hsh, p, o = (const struct asm_barrier_opt *) str_hash_find_n (arm_barrier_opt_hsh, p,
q - p); q - p);
if (!o) if (!o)
return FAIL; return FAIL;
@ -15606,7 +15605,7 @@ do_vfp_nsyn_opcode (const char *opname)
{ {
const struct asm_opcode *opcode; const struct asm_opcode *opcode;
opcode = (const struct asm_opcode *) hash_find (arm_ops_hsh, opname); opcode = (const struct asm_opcode *) str_hash_find (arm_ops_hsh, opname);
if (!opcode) if (!opcode)
abort (); abort ();
@ -22620,7 +22619,7 @@ opcode_lookup (char **str)
*str = end; *str = end;
/* Look for unaffixed or special-case affixed mnemonic. */ /* Look for unaffixed or special-case affixed mnemonic. */
opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base, opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
end - base); end - base);
if (opcode) if (opcode)
{ {
@ -22634,7 +22633,7 @@ opcode_lookup (char **str)
if (warn_on_deprecated && unified_syntax) if (warn_on_deprecated && unified_syntax)
as_tsktsk (_("conditional infixes are deprecated in unified syntax")); as_tsktsk (_("conditional infixes are deprecated in unified syntax"));
affix = base + (opcode->tag - OT_odd_infix_0); affix = base + (opcode->tag - OT_odd_infix_0);
cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2); cond = (const struct asm_cond *) str_hash_find_n (arm_cond_hsh, affix, 2);
gas_assert (cond); gas_assert (cond);
inst.cond = cond->value; inst.cond = cond->value;
@ -22647,8 +22646,8 @@ opcode_lookup (char **str)
if (end - base < 2) if (end - base < 2)
return NULL; return NULL;
affix = end - 1; affix = end - 1;
cond = (const struct asm_cond *) hash_find_n (arm_vcond_hsh, affix, 1); cond = (const struct asm_cond *) str_hash_find_n (arm_vcond_hsh, affix, 1);
opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base, opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
affix - base); affix - base);
/* If this opcode can not be vector predicated then don't accept it with a /* If this opcode can not be vector predicated then don't accept it with a
vector predication code. */ vector predication code. */
@ -22664,8 +22663,8 @@ opcode_lookup (char **str)
/* Look for suffixed mnemonic. */ /* Look for suffixed mnemonic. */
affix = end - 2; affix = end - 2;
cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2); cond = (const struct asm_cond *) str_hash_find_n (arm_cond_hsh, affix, 2);
opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base, opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
affix - base); affix - base);
} }
@ -22715,13 +22714,13 @@ opcode_lookup (char **str)
/* Look for infixed mnemonic in the usual position. */ /* Look for infixed mnemonic in the usual position. */
affix = base + 3; affix = base + 3;
cond = (const struct asm_cond *) hash_find_n (arm_cond_hsh, affix, 2); cond = (const struct asm_cond *) str_hash_find_n (arm_cond_hsh, affix, 2);
if (!cond) if (!cond)
return NULL; return NULL;
memcpy (save, affix, 2); memcpy (save, affix, 2);
memmove (affix, affix + 2, (end - affix) - 2); memmove (affix, affix + 2, (end - affix) - 2);
opcode = (const struct asm_opcode *) hash_find_n (arm_ops_hsh, base, opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
(end - base) - 2); (end - base) - 2);
memmove (affix + 2, affix, (end - affix) - 2); memmove (affix + 2, affix, (end - affix) - 2);
memcpy (affix, save, 2); memcpy (affix, save, 2);
@ -27989,16 +27988,19 @@ arm_tc_equal_in_insn (int c ATTRIBUTE_UNUSED, char * name)
for (p = nbuf; *p; p++) for (p = nbuf; *p; p++)
*p = TOLOWER (*p); *p = TOLOWER (*p);
if (hash_find (arm_ops_hsh, nbuf) != NULL) if (str_hash_find (arm_ops_hsh, nbuf) != NULL)
{ {
static struct hash_control * already_warned = NULL; static htab_t already_warned = NULL;
if (already_warned == NULL) if (already_warned == NULL)
already_warned = hash_new (); already_warned = str_htab_create ();
/* Only warn about the symbol once. To keep the code /* Only warn about the symbol once. To keep the code
simple we let hash_insert do the lookup for us. */ simple we let str_hash_insert do the lookup for us. */
if (hash_insert (already_warned, nbuf, NULL) == NULL) if (str_hash_find (already_warned, nbuf) == NULL)
{
as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name); as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name);
str_hash_insert (already_warned, nbuf, NULL);
}
} }
else else
free (nbuf); free (nbuf);
@ -30716,36 +30718,37 @@ md_begin (void)
unsigned mach; unsigned mach;
unsigned int i; unsigned int i;
if ( (arm_ops_hsh = hash_new ()) == NULL if ( (arm_ops_hsh = str_htab_create ()) == NULL
|| (arm_cond_hsh = hash_new ()) == NULL || (arm_cond_hsh = str_htab_create ()) == NULL
|| (arm_vcond_hsh = hash_new ()) == NULL || (arm_vcond_hsh = str_htab_create ()) == NULL
|| (arm_shift_hsh = hash_new ()) == NULL || (arm_shift_hsh = str_htab_create ()) == NULL
|| (arm_psr_hsh = hash_new ()) == NULL || (arm_psr_hsh = str_htab_create ()) == NULL
|| (arm_v7m_psr_hsh = hash_new ()) == NULL || (arm_v7m_psr_hsh = str_htab_create ()) == NULL
|| (arm_reg_hsh = hash_new ()) == NULL || (arm_reg_hsh = str_htab_create ()) == NULL
|| (arm_reloc_hsh = hash_new ()) == NULL || (arm_reloc_hsh = str_htab_create ()) == NULL
|| (arm_barrier_opt_hsh = hash_new ()) == NULL) || (arm_barrier_opt_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); i++) for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); i++)
hash_insert (arm_ops_hsh, insns[i].template_name, (void *) (insns + i)); if (str_hash_find (arm_ops_hsh, insns[i].template_name) == NULL)
str_hash_insert (arm_ops_hsh, insns[i].template_name, (void *) (insns + i));
for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++) for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++)
hash_insert (arm_cond_hsh, conds[i].template_name, (void *) (conds + i)); str_hash_insert (arm_cond_hsh, conds[i].template_name, (void *) (conds + i));
for (i = 0; i < sizeof (vconds) / sizeof (struct asm_cond); i++) for (i = 0; i < sizeof (vconds) / sizeof (struct asm_cond); i++)
hash_insert (arm_vcond_hsh, vconds[i].template_name, (void *) (vconds + i)); str_hash_insert (arm_vcond_hsh, vconds[i].template_name, (void *) (vconds + i));
for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++) for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++)
hash_insert (arm_shift_hsh, shift_names[i].name, (void *) (shift_names + i)); str_hash_insert (arm_shift_hsh, shift_names[i].name, (void *) (shift_names + i));
for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++) for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++)
hash_insert (arm_psr_hsh, psrs[i].template_name, (void *) (psrs + i)); str_hash_insert (arm_psr_hsh, psrs[i].template_name, (void *) (psrs + i));
for (i = 0; i < sizeof (v7m_psrs) / sizeof (struct asm_psr); i++) for (i = 0; i < sizeof (v7m_psrs) / sizeof (struct asm_psr); i++)
hash_insert (arm_v7m_psr_hsh, v7m_psrs[i].template_name, str_hash_insert (arm_v7m_psr_hsh, v7m_psrs[i].template_name,
(void *) (v7m_psrs + i)); (void *) (v7m_psrs + i));
for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++) for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++)
hash_insert (arm_reg_hsh, reg_names[i].name, (void *) (reg_names + i)); str_hash_insert (arm_reg_hsh, reg_names[i].name, (void *) (reg_names + i));
for (i = 0; for (i = 0;
i < sizeof (barrier_opt_names) / sizeof (struct asm_barrier_opt); i < sizeof (barrier_opt_names) / sizeof (struct asm_barrier_opt);
i++) i++)
hash_insert (arm_barrier_opt_hsh, barrier_opt_names[i].template_name, str_hash_insert (arm_barrier_opt_hsh, barrier_opt_names[i].template_name,
(void *) (barrier_opt_names + i)); (void *) (barrier_opt_names + i));
#ifdef OBJ_ELF #ifdef OBJ_ELF
for (i = 0; i < ARRAY_SIZE (reloc_names); i++) for (i = 0; i < ARRAY_SIZE (reloc_names); i++)
@ -30756,7 +30759,7 @@ md_begin (void)
/* This makes encode_branch() use the EABI versions of this relocation. */ /* This makes encode_branch() use the EABI versions of this relocation. */
entry->reloc = BFD_RELOC_UNUSED; entry->reloc = BFD_RELOC_UNUSED;
hash_insert (arm_reloc_hsh, entry->name, (void *) entry); str_hash_insert (arm_reloc_hsh, entry->name, (void *) entry);
} }
#endif #endif

View file

@ -524,13 +524,13 @@ typedef union
} mod_index; } mod_index;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *avr_hash; static htab_t avr_hash;
/* Reloc modifiers hash control (hh8,hi8,lo8,pm_xx). */ /* Reloc modifiers hash control (hh8,hi8,lo8,pm_xx). */
static struct hash_control *avr_mod_hash; static htab_t avr_mod_hash;
/* Whether some opcode does not change SREG. */ /* Whether some opcode does not change SREG. */
static struct hash_control *avr_no_sreg_hash; static htab_t avr_no_sreg_hash;
static const char* const avr_no_sreg[] = static const char* const avr_no_sreg[] =
{ {
@ -808,33 +808,35 @@ md_begin (void)
unsigned int i; unsigned int i;
struct avr_opcodes_s *opcode; struct avr_opcodes_s *opcode;
avr_hash = hash_new (); avr_hash = str_htab_create ();
/* Insert unique names into hash table. This hash table then provides a /* Insert unique names into hash table. This hash table then provides a
quick index to the first opcode with a particular name in the opcode quick index to the first opcode with a particular name in the opcode
table. */ table. */
for (opcode = avr_opcodes; opcode->name; opcode++) for (opcode = avr_opcodes; opcode->name; opcode++)
hash_insert (avr_hash, opcode->name, (char *) opcode); if (str_hash_find (avr_hash, opcode->name) == NULL)
str_hash_insert (avr_hash, opcode->name, (char *) opcode);
avr_mod_hash = hash_new (); avr_mod_hash = str_htab_create ();
for (i = 0; i < ARRAY_SIZE (exp_mod); ++i) for (i = 0; i < ARRAY_SIZE (exp_mod); ++i)
{ {
mod_index m; mod_index m;
m.index = i + 10; m.index = i + 10;
hash_insert (avr_mod_hash, EXP_MOD_NAME (i), m.ptr); str_hash_find (avr_mod_hash, EXP_MOD_NAME (i));
str_hash_insert (avr_mod_hash, EXP_MOD_NAME (i), m.ptr);
} }
avr_no_sreg_hash = hash_new (); avr_no_sreg_hash = str_htab_create ();
for (i = 0; i < ARRAY_SIZE (avr_no_sreg); ++i) for (i = 0; i < ARRAY_SIZE (avr_no_sreg); ++i)
{ {
gas_assert (hash_find (avr_hash, avr_no_sreg[i])); gas_assert (str_hash_find (avr_hash, avr_no_sreg[i]));
hash_insert (avr_no_sreg_hash, avr_no_sreg[i], (char*) 4 /* dummy */); str_hash_insert (avr_no_sreg_hash, avr_no_sreg[i], (char*) 4 /* dummy */);
} }
avr_gccisr_opcode = (struct avr_opcodes_s*) hash_find (avr_hash, "__gcc_isr"); avr_gccisr_opcode = (struct avr_opcodes_s*) str_hash_find (avr_hash, "__gcc_isr");
gas_assert (avr_gccisr_opcode); gas_assert (avr_gccisr_opcode);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach); bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach);
@ -923,7 +925,7 @@ avr_ldi_expression (expressionS *exp)
{ {
mod_index m; mod_index m;
m.ptr = hash_find (avr_mod_hash, op); m.ptr = str_hash_find (avr_mod_hash, op);
mod = m.index; mod = m.index;
if (mod) if (mod)
@ -1874,7 +1876,7 @@ md_assemble (char *str)
if (!op[0]) if (!op[0])
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
opcode = (struct avr_opcodes_s *) hash_find (avr_hash, op); opcode = (struct avr_opcodes_s *) str_hash_find (avr_hash, op);
if (opcode && !avr_opt.all_opcodes) if (opcode && !avr_opt.all_opcodes)
{ {
@ -2453,7 +2455,7 @@ avr_update_gccisr (struct avr_opcodes_s *opcode, int reg1, int reg2)
/* SREG: Look up instructions that don't clobber SREG. */ /* SREG: Look up instructions that don't clobber SREG. */
if (!avr_isr.need_sreg if (!avr_isr.need_sreg
&& !hash_find (avr_no_sreg_hash, opcode->name)) && !str_hash_find (avr_no_sreg_hash, opcode->name))
{ {
avr_isr.need_sreg = 1; avr_isr.need_sreg = 1;
} }
@ -2497,7 +2499,7 @@ avr_emit_insn (const char *insn, int reg, char **pwhere)
const int sreg = 0x3f; const int sreg = 0x3f;
unsigned bin = 0; unsigned bin = 0;
const struct avr_opcodes_s *op const struct avr_opcodes_s *op
= (struct avr_opcodes_s*) hash_find (avr_hash, insn); = (struct avr_opcodes_s*) str_hash_find (avr_hash, insn);
/* We only have to deal with: IN, OUT, PUSH, POP, CLR, LDI 0. All of /* We only have to deal with: IN, OUT, PUSH, POP, CLR, LDI 0. All of
these deal with at least one Reg and are 1-word instructions. */ these deal with at least one Reg and are 1-word instructions. */

View file

@ -53,15 +53,15 @@ typedef enum
op_err; op_err;
/* Opcode mnemonics hash table. */ /* Opcode mnemonics hash table. */
static struct hash_control *cr16_inst_hash; static htab_t cr16_inst_hash;
/* CR16 registers hash table. */ /* CR16 registers hash table. */
static struct hash_control *reg_hash; static htab_t reg_hash;
/* CR16 register pair hash table. */ /* CR16 register pair hash table. */
static struct hash_control *regp_hash; static htab_t regp_hash;
/* CR16 processor registers hash table. */ /* CR16 processor registers hash table. */
static struct hash_control *preg_hash; static htab_t preg_hash;
/* CR16 processor registers 32 bit hash table. */ /* CR16 processor registers 32 bit hash table. */
static struct hash_control *pregp_hash; static htab_t pregp_hash;
/* Current instruction we're assembling. */ /* Current instruction we're assembling. */
const inst *instruction; const inst *instruction;
@ -324,7 +324,7 @@ get_register (char *reg_name)
{ {
const reg_entry *rreg; const reg_entry *rreg;
rreg = (const reg_entry *) hash_find (reg_hash, reg_name); rreg = (const reg_entry *) str_hash_find (reg_hash, reg_name);
if (rreg != NULL) if (rreg != NULL)
return rreg->value.reg_val; return rreg->value.reg_val;
@ -345,10 +345,10 @@ get_register_pair (char *reg_name)
tmp_rp[0] = '('; tmp_rp[0] = '(';
strcat (tmp_rp, reg_name); strcat (tmp_rp, reg_name);
strcat (tmp_rp,")"); strcat (tmp_rp,")");
rreg = (const reg_entry *) hash_find (regp_hash, tmp_rp); rreg = (const reg_entry *) str_hash_find (regp_hash, tmp_rp);
} }
else else
rreg = (const reg_entry *) hash_find (regp_hash, reg_name); rreg = (const reg_entry *) str_hash_find (regp_hash, reg_name);
if (rreg != NULL) if (rreg != NULL)
return rreg->value.reg_val; return rreg->value.reg_val;
@ -363,7 +363,7 @@ get_index_register (char *reg_name)
{ {
const reg_entry *rreg; const reg_entry *rreg;
rreg = (const reg_entry *) hash_find (reg_hash, reg_name); rreg = (const reg_entry *) str_hash_find (reg_hash, reg_name);
if ((rreg != NULL) if ((rreg != NULL)
&& ((rreg->value.reg_val == 12) || (rreg->value.reg_val == 13))) && ((rreg->value.reg_val == 12) || (rreg->value.reg_val == 13)))
@ -378,7 +378,7 @@ get_index_register_pair (char *reg_name)
{ {
const reg_entry *rreg; const reg_entry *rreg;
rreg = (const reg_entry *) hash_find (regp_hash, reg_name); rreg = (const reg_entry *) str_hash_find (regp_hash, reg_name);
if (rreg != NULL) if (rreg != NULL)
{ {
@ -399,7 +399,7 @@ get_pregister (char *preg_name)
{ {
const reg_entry *prreg; const reg_entry *prreg;
prreg = (const reg_entry *) hash_find (preg_hash, preg_name); prreg = (const reg_entry *) str_hash_find (preg_hash, preg_name);
if (prreg != NULL) if (prreg != NULL)
return prreg->value.preg_val; return prreg->value.preg_val;
@ -414,7 +414,7 @@ get_pregisterp (char *preg_name)
{ {
const reg_entry *prreg; const reg_entry *prreg;
prreg = (const reg_entry *) hash_find (pregp_hash, preg_name); prreg = (const reg_entry *) str_hash_find (pregp_hash, preg_name);
if (prreg != NULL) if (prreg != NULL)
return prreg->value.preg_val; return prreg->value.preg_val;
@ -794,25 +794,18 @@ md_pcrel_from (fixS *fixp)
} }
static void static void
initialise_reg_hash_table (struct hash_control ** hash_table, initialise_reg_hash_table (htab_t * hash_table,
const reg_entry * register_table, const reg_entry * register_table,
const unsigned int num_entries) const unsigned int num_entries)
{ {
const reg_entry * rreg; const reg_entry * rreg;
const char *hashret; if ((* hash_table = str_htab_create ()) == NULL)
if ((* hash_table = hash_new ()) == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
for (rreg = register_table; for (rreg = register_table;
rreg < (register_table + num_entries); rreg < (register_table + num_entries);
rreg++) rreg++)
{ str_hash_insert (* hash_table, rreg->name, (char *) rreg);
hashret = hash_insert (* hash_table, rreg->name, (char *) rreg);
if (hashret)
as_fatal (_("Internal Error: Can't hash %s: %s"),
rreg->name, hashret);
}
} }
/* This function is called once, at assembler startup time. This should /* This function is called once, at assembler startup time. This should
@ -824,21 +817,15 @@ md_begin (void)
int i = 0; int i = 0;
/* Set up a hash table for the instructions. */ /* Set up a hash table for the instructions. */
if ((cr16_inst_hash = hash_new ()) == NULL) if ((cr16_inst_hash = str_htab_create ()) == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
while (cr16_instruction[i].mnemonic != NULL) while (cr16_instruction[i].mnemonic != NULL)
{ {
const char *hashret;
const char *mnemonic = cr16_instruction[i].mnemonic; const char *mnemonic = cr16_instruction[i].mnemonic;
hashret = hash_insert (cr16_inst_hash, mnemonic, str_hash_insert (cr16_inst_hash, mnemonic,
(char *)(cr16_instruction + i)); (char *)(cr16_instruction + i));
if (hashret != NULL && *hashret != '\0')
as_fatal (_("Can't hash `%s': %s\n"), cr16_instruction[i].mnemonic,
*hashret == 0 ? _("(unknown reason)") : hashret);
/* Insert unique names into hash table. The CR16 instruction set /* Insert unique names into hash table. The CR16 instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
on the operands. This hash table then provides a quick index to on the operands. This hash table then provides a quick index to
@ -2505,7 +2492,7 @@ cr16_assemble (const char *op, char *param)
ins cr16_ins; ins cr16_ins;
/* Find the instruction. */ /* Find the instruction. */
instruction = (const inst *) hash_find (cr16_inst_hash, op); instruction = (const inst *) str_hash_find (cr16_inst_hash, op);
if (instruction == NULL) if (instruction == NULL)
{ {
as_bad (_("Unknown opcode: `%s'"), op); as_bad (_("Unknown opcode: `%s'"), op);
@ -2575,7 +2562,7 @@ md_assemble (char *op)
{ {
strcpy (param1, param); strcpy (param1, param);
/* Find the instruction. */ /* Find the instruction. */
instruction = (const inst *) hash_find (cr16_inst_hash, op); instruction = (const inst *) str_hash_find (cr16_inst_hash, op);
parse_operands (&cr16_ins, param1); parse_operands (&cr16_ins, param1);
if (((&cr16_ins)->arg[0].type == arg_ic) if (((&cr16_ins)->arg[0].type == arg_ic)
&& ((&cr16_ins)->arg[0].constant >= 0)) && ((&cr16_ins)->arg[0].constant >= 0))

View file

@ -160,7 +160,7 @@ static void cris_sym_no_leading_underscore (void);
static char *cris_insn_first_word_frag (void); static char *cris_insn_first_word_frag (void);
/* Handle to the opcode hash table. */ /* Handle to the opcode hash table. */
static struct hash_control *op_hash = NULL; static htab_t op_hash = NULL;
/* If we target cris-axis-linux-gnu (as opposed to generic cris-axis-elf), /* If we target cris-axis-linux-gnu (as opposed to generic cris-axis-elf),
we default to no underscore and required register-prefixes. The we default to no underscore and required register-prefixes. The
@ -1186,11 +1186,10 @@ cris_insn_first_word_frag (void)
void void
md_begin (void) md_begin (void)
{ {
const char *hashret = NULL;
int i = 0; int i = 0;
/* Set up a hash table for the instructions. */ /* Set up a hash table for the instructions. */
op_hash = hash_new (); op_hash = str_htab_create ();
if (op_hash == NULL) if (op_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -1222,12 +1221,8 @@ md_begin (void)
continue; continue;
} }
/* Need to cast to get rid of "const". FIXME: Fix hash_insert instead. */ /* Need to cast to get rid of "const". FIXME: Fix str_hash_insert instead. */
hashret = hash_insert (op_hash, name, (void *) &cris_opcodes[i]); str_hash_insert (op_hash, name, (void *) &cris_opcodes[i]);
if (hashret != NULL && *hashret != '\0')
as_fatal (_("Can't hash `%s': %s\n"), cris_opcodes[i].name,
*hashret == 0 ? _("(unknown reason)") : hashret);
do do
{ {
if (cris_opcodes[i].match & cris_opcodes[i].lose) if (cris_opcodes[i].match & cris_opcodes[i].lose)
@ -1558,7 +1553,7 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp,
} }
/* Find the instruction. */ /* Find the instruction. */
instruction = (struct cris_opcode *) hash_find (op_hash, insn_text); instruction = (struct cris_opcode *) str_hash_find (op_hash, insn_text);
if (instruction == NULL) if (instruction == NULL)
{ {
as_bad (_("Unknown opcode: `%s'"), insn_text); as_bad (_("Unknown opcode: `%s'"), insn_text);

View file

@ -63,11 +63,11 @@ typedef enum
op_err; op_err;
/* Opcode mnemonics hash table. */ /* Opcode mnemonics hash table. */
static struct hash_control *crx_inst_hash; static htab_t crx_inst_hash;
/* CRX registers hash table. */ /* CRX registers hash table. */
static struct hash_control *reg_hash; static htab_t reg_hash;
/* CRX coprocessor registers hash table. */ /* CRX coprocessor registers hash table. */
static struct hash_control *copreg_hash; static htab_t copreg_hash;
/* Current instruction we're assembling. */ /* Current instruction we're assembling. */
static const inst *instruction; static const inst *instruction;
@ -208,7 +208,7 @@ get_register (char *reg_name)
{ {
const reg_entry *rreg; const reg_entry *rreg;
rreg = (const reg_entry *) hash_find (reg_hash, reg_name); rreg = (const reg_entry *) str_hash_find (reg_hash, reg_name);
if (rreg != NULL) if (rreg != NULL)
return rreg->value.reg_val; return rreg->value.reg_val;
@ -223,7 +223,7 @@ get_copregister (char *copreg_name)
{ {
const reg_entry *coreg; const reg_entry *coreg;
coreg = (const reg_entry *) hash_find (copreg_hash, copreg_name); coreg = (const reg_entry *) str_hash_find (copreg_hash, copreg_name);
if (coreg != NULL) if (coreg != NULL)
return coreg->value.copreg_val; return coreg->value.copreg_val;
@ -527,24 +527,19 @@ md_pcrel_from (fixS *fixp)
void void
md_begin (void) md_begin (void)
{ {
const char *hashret = NULL;
int i = 0; int i = 0;
/* Set up a hash table for the instructions. */ /* Set up a hash table for the instructions. */
if ((crx_inst_hash = hash_new ()) == NULL) if ((crx_inst_hash = str_htab_create ()) == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
while (crx_instruction[i].mnemonic != NULL) while (crx_instruction[i].mnemonic != NULL)
{ {
const char *mnemonic = crx_instruction[i].mnemonic; const char *mnemonic = crx_instruction[i].mnemonic;
hashret = hash_insert (crx_inst_hash, mnemonic, str_hash_insert (crx_inst_hash, mnemonic,
(void *) &crx_instruction[i]); (void *) &crx_instruction[i]);
if (hashret != NULL && *hashret != '\0')
as_fatal (_("Can't hash `%s': %s\n"), crx_instruction[i].mnemonic,
*hashret == 0 ? _("(unknown reason)") : hashret);
/* Insert unique names into hash table. The CRX instruction set /* Insert unique names into hash table. The CRX instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
on the operands. This hash table then provides a quick index to on the operands. This hash table then provides a quick index to
@ -558,7 +553,7 @@ md_begin (void)
} }
/* Initialize reg_hash hash table. */ /* Initialize reg_hash hash table. */
if ((reg_hash = hash_new ()) == NULL) if ((reg_hash = str_htab_create ()) == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
{ {
@ -566,17 +561,11 @@ md_begin (void)
for (regtab = crx_regtab; for (regtab = crx_regtab;
regtab < (crx_regtab + NUMREGS); regtab++) regtab < (crx_regtab + NUMREGS); regtab++)
{ str_hash_insert (reg_hash, regtab->name, (void *) regtab);
hashret = hash_insert (reg_hash, regtab->name, (void *) regtab);
if (hashret)
as_fatal (_("Internal error: Can't hash %s: %s"),
regtab->name,
hashret);
}
} }
/* Initialize copreg_hash hash table. */ /* Initialize copreg_hash hash table. */
if ((copreg_hash = hash_new ()) == NULL) if ((copreg_hash = str_htab_create ()) == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
{ {
@ -584,14 +573,8 @@ md_begin (void)
for (copregtab = crx_copregtab; copregtab < (crx_copregtab + NUMCOPREGS); for (copregtab = crx_copregtab; copregtab < (crx_copregtab + NUMCOPREGS);
copregtab++) copregtab++)
{ str_hash_insert (copreg_hash, copregtab->name,
hashret = hash_insert (copreg_hash, copregtab->name,
(void *) copregtab); (void *) copregtab);
if (hashret)
as_fatal (_("Internal error: Can't hash %s: %s"),
copregtab->name,
hashret);
}
} }
/* Set linkrelax here to avoid fixups in most sections. */ /* Set linkrelax here to avoid fixups in most sections. */
linkrelax = 1; linkrelax = 1;
@ -1989,7 +1972,7 @@ md_assemble (char *op)
*param++ = '\0'; *param++ = '\0';
/* Find the instruction. */ /* Find the instruction. */
instruction = (const inst *) hash_find (crx_inst_hash, op); instruction = (const inst *) str_hash_find (crx_inst_hash, op);
if (instruction == NULL) if (instruction == NULL)
{ {
as_bad (_("Unknown opcode: `%s'"), op); as_bad (_("Unknown opcode: `%s'"), op);

View file

@ -754,8 +754,8 @@ size_t md_longopts_size = sizeof (md_longopts);
static struct csky_insn_info csky_insn; static struct csky_insn_info csky_insn;
static struct hash_control *csky_opcodes_hash; static htab_t csky_opcodes_hash;
static struct hash_control *csky_macros_hash; static htab_t csky_macros_hash;
static struct csky_macro_info v1_macros_table[] = static struct csky_macro_info v1_macros_table[] =
{ {
@ -1356,16 +1356,16 @@ md_begin (void)
} }
/* Establish hash table for opcodes and macros. */ /* Establish hash table for opcodes and macros. */
csky_macros_hash = hash_new (); csky_macros_hash = str_htab_create ();
csky_opcodes_hash = hash_new (); csky_opcodes_hash = str_htab_create ();
for ( ; opcode->mnemonic != NULL; opcode++) for ( ; opcode->mnemonic != NULL; opcode++)
if ((isa_flag & (opcode->isa_flag16 | opcode->isa_flag32)) != 0) if ((isa_flag & (opcode->isa_flag16 | opcode->isa_flag32)) != 0)
hash_insert (csky_opcodes_hash, opcode->mnemonic, (char *)opcode); str_hash_insert (csky_opcodes_hash, opcode->mnemonic, (char *)opcode);
for ( ; macro->name != NULL; macro++) for ( ; macro->name != NULL; macro++)
if ((isa_flag & macro->isa_flag) != 0) if ((isa_flag & macro->isa_flag) != 0)
hash_insert (csky_macros_hash, macro->name, (char *)macro); str_hash_insert (csky_macros_hash, macro->name, (char *)macro);
if (do_nolrw && (isa_flag & CSKYV2_ISA_1E2) != 0) if (do_nolrw && (isa_flag & CSKYV2_ISA_1E2) != 0)
hash_insert (csky_macros_hash, str_hash_insert (csky_macros_hash,
v2_lrw_macro_opcode.name, v2_lrw_macro_opcode.name,
(char *)&v2_lrw_macro_opcode); (char *)&v2_lrw_macro_opcode);
/* Set e_flag to ELF Head. */ /* Set e_flag to ELF Head. */
@ -2933,9 +2933,9 @@ parse_opcode (char *str)
csky_insn.number = csky_count_operands (opcode_end); csky_insn.number = csky_count_operands (opcode_end);
/* Find hash by name in csky_macros_hash and csky_opcodes_hash. */ /* Find hash by name in csky_macros_hash and csky_opcodes_hash. */
csky_insn.macro = (struct csky_macro_info *) hash_find (csky_macros_hash, csky_insn.macro = (struct csky_macro_info *) str_hash_find (csky_macros_hash,
macro_name); macro_name);
csky_insn.opcode = (struct csky_opcode *) hash_find (csky_opcodes_hash, csky_insn.opcode = (struct csky_opcode *) str_hash_find (csky_opcodes_hash,
name); name);
if (csky_insn.macro == NULL && csky_insn.opcode == NULL) if (csky_insn.macro == NULL && csky_insn.opcode == NULL)
@ -3157,7 +3157,7 @@ get_operand_value (struct csky_opcode_info *op,
{ {
const char *name = "movi"; const char *name = "movi";
csky_insn.opcode = (struct csky_opcode *) csky_insn.opcode = (struct csky_opcode *)
hash_find (csky_opcodes_hash, name); str_hash_find (csky_opcodes_hash, name);
csky_insn.val[csky_insn.idx - 1] = 1 << val; csky_insn.val[csky_insn.idx - 1] = 1 << val;
} }
return TRUE; return TRUE;
@ -3191,7 +3191,7 @@ get_operand_value (struct csky_opcode_info *op,
{ {
const char *name = "movi"; const char *name = "movi";
csky_insn.opcode = (struct csky_opcode *) csky_insn.opcode = (struct csky_opcode *)
hash_find (csky_opcodes_hash, name); str_hash_find (csky_opcodes_hash, name);
as_warn (_("translating mgeni to movi")); as_warn (_("translating mgeni to movi"));
} }
else else
@ -3225,7 +3225,7 @@ get_operand_value (struct csky_opcode_info *op,
{ {
const char *op_movi = "movi"; const char *op_movi = "movi";
csky_insn.opcode = (struct csky_opcode *) csky_insn.opcode = (struct csky_opcode *)
hash_find (csky_opcodes_hash, op_movi); str_hash_find (csky_opcodes_hash, op_movi);
if (csky_insn.opcode == NULL) if (csky_insn.opcode == NULL)
return FALSE; return FALSE;
csky_insn.val[csky_insn.idx - 1] = (1 << mask_val) - 1; csky_insn.val[csky_insn.idx - 1] = (1 << mask_val) - 1;
@ -3275,7 +3275,7 @@ get_operand_value (struct csky_opcode_info *op,
{ {
const char *op_movi = "movi"; const char *op_movi = "movi";
csky_insn.opcode = (struct csky_opcode *) csky_insn.opcode = (struct csky_opcode *)
hash_find (csky_opcodes_hash, op_movi); str_hash_find (csky_opcodes_hash, op_movi);
if (csky_insn.opcode == NULL) if (csky_insn.opcode == NULL)
return FALSE; return FALSE;
csky_insn.val[csky_insn.idx - 1] = (1 << (mask_val + 1)) - 1; csky_insn.val[csky_insn.idx - 1] = (1 << (mask_val + 1)) - 1;
@ -5955,7 +5955,7 @@ v1_work_jbsr (void)
/* Using jsri instruction. */ /* Using jsri instruction. */
const char *name = "jsri"; const char *name = "jsri";
csky_insn.opcode = (struct csky_opcode *) csky_insn.opcode = (struct csky_opcode *)
hash_find (csky_opcodes_hash, name); str_hash_find (csky_opcodes_hash, name);
csky_insn.opcode_idx = 0; csky_insn.opcode_idx = 0;
csky_insn.isize = 2; csky_insn.isize = 2;
@ -6293,7 +6293,7 @@ v2_work_rotlc (void)
{ {
const char *name = "addc"; const char *name = "addc";
csky_insn.opcode csky_insn.opcode
= (struct csky_opcode *) hash_find (csky_opcodes_hash, name); = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
csky_insn.opcode_idx = 0; csky_insn.opcode_idx = 0;
if (csky_insn.isize == 2) if (csky_insn.isize == 2)
{ {
@ -6331,7 +6331,7 @@ v2_work_bgeni (void)
val >>= 16; val >>= 16;
} }
csky_insn.opcode csky_insn.opcode
= (struct csky_opcode *) hash_find (csky_opcodes_hash, name); = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
csky_insn.opcode_idx = 0; csky_insn.opcode_idx = 0;
csky_insn.val[1] = val; csky_insn.val[1] = val;
@ -6349,7 +6349,7 @@ v2_work_not (void)
{ {
const char *name = "nor"; const char *name = "nor";
csky_insn.opcode csky_insn.opcode
= (struct csky_opcode *) hash_find (csky_opcodes_hash, name); = (struct csky_opcode *) str_hash_find (csky_opcodes_hash, name);
csky_insn.opcode_idx = 0; csky_insn.opcode_idx = 0;
if (csky_insn.number == 1) if (csky_insn.number == 1)
{ {

View file

@ -101,7 +101,7 @@ struct option md_longopts[] =
size_t md_longopts_size = sizeof (md_longopts); size_t md_longopts_size = sizeof (md_longopts);
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *d10v_hash; static htab_t d10v_hash;
/* Do a binary search of the d10v_predefined_registers array to see if /* Do a binary search of the d10v_predefined_registers array to see if
NAME is a valid register name. Return the register number from the NAME is a valid register name. Return the register number from the
@ -277,7 +277,7 @@ md_begin (void)
{ {
const char *prev_name = ""; const char *prev_name = "";
struct d10v_opcode *opcode; struct d10v_opcode *opcode;
d10v_hash = hash_new (); d10v_hash = str_htab_create ();
/* Insert unique names into hash table. The D10v instruction set /* Insert unique names into hash table. The D10v instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
@ -289,7 +289,7 @@ md_begin (void)
if (strcmp (prev_name, opcode->name)) if (strcmp (prev_name, opcode->name))
{ {
prev_name = (char *) opcode->name; prev_name = (char *) opcode->name;
hash_insert (d10v_hash, opcode->name, (char *) opcode); str_hash_insert (d10v_hash, opcode->name, (char *) opcode);
} }
} }
@ -1430,7 +1430,7 @@ do_assemble (char *str, struct d10v_opcode **opcode)
return -1; return -1;
/* Find the first opcode with the proper name. */ /* Find the first opcode with the proper name. */
*opcode = (struct d10v_opcode *) hash_find (d10v_hash, name); *opcode = (struct d10v_opcode *) str_hash_find (d10v_hash, name);
if (*opcode == NULL) if (*opcode == NULL)
return -1; return -1;
@ -1558,8 +1558,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
{ {
struct d10v_opcode *rep, *repi; struct d10v_opcode *rep, *repi;
rep = (struct d10v_opcode *) hash_find (d10v_hash, "rep"); rep = (struct d10v_opcode *) str_hash_find (d10v_hash, "rep");
repi = (struct d10v_opcode *) hash_find (d10v_hash, "repi"); repi = (struct d10v_opcode *) str_hash_find (d10v_hash, "repi");
if ((insn & FM11) == FM11 if ((insn & FM11) == FM11
&& ((repi != NULL && ((repi != NULL
&& (insn & repi->mask) == (unsigned) repi->opcode) && (insn & repi->mask) == (unsigned) repi->opcode)

View file

@ -118,7 +118,7 @@ struct option md_longopts[] =
size_t md_longopts_size = sizeof (md_longopts); size_t md_longopts_size = sizeof (md_longopts);
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *d30v_hash; static htab_t d30v_hash;
/* Do a binary search of the pre_defined_registers array to see if /* Do a binary search of the pre_defined_registers array to see if
NAME is a valid register name. Return the register number from the NAME is a valid register name. Return the register number from the
@ -310,11 +310,11 @@ void
md_begin (void) md_begin (void)
{ {
struct d30v_opcode *opcode; struct d30v_opcode *opcode;
d30v_hash = hash_new (); d30v_hash = str_htab_create ();
/* Insert opcode names into a hash table. */ /* Insert opcode names into a hash table. */
for (opcode = (struct d30v_opcode *) d30v_opcode_table; opcode->name; opcode++) for (opcode = (struct d30v_opcode *) d30v_opcode_table; opcode->name; opcode++)
hash_insert (d30v_hash, opcode->name, (char *) opcode); str_hash_insert (d30v_hash, opcode->name, (char *) opcode);
fixups = &FixUps[0]; fixups = &FixUps[0];
FixUps[0].next = &FixUps[1]; FixUps[0].next = &FixUps[1];
@ -1390,7 +1390,7 @@ do_assemble (char *str,
} }
/* Find the first opcode with the proper name. */ /* Find the first opcode with the proper name. */
opcode->op = (struct d30v_opcode *) hash_find (d30v_hash, name); opcode->op = (struct d30v_opcode *) str_hash_find (d30v_hash, name);
if (opcode->op == NULL) if (opcode->op == NULL)
{ {
as_bad (_("unknown opcode: %s"), name); as_bad (_("unknown opcode: %s"), name);

View file

@ -43,7 +43,7 @@
#define RELOC_DLX_VTENTRY BFD_RELOC_VTABLE_ENTRY #define RELOC_DLX_VTENTRY BFD_RELOC_VTABLE_ENTRY
/* handle of the OPCODE hash table */ /* handle of the OPCODE hash table */
static struct hash_control *op_hash = NULL; static htab_t op_hash = NULL;
struct machine_it struct machine_it
{ {
@ -276,30 +276,17 @@ s_proc (int end_p)
void void
md_begin (void) md_begin (void)
{ {
const char *retval = NULL;
int lose = 0;
unsigned int i; unsigned int i;
/* Create a new hash table. */ /* Create a new hash table. */
op_hash = hash_new (); op_hash = str_htab_create ();
/* Hash up all the opcodes for fast use later. */ /* Hash up all the opcodes for fast use later. */
for (i = 0; i < num_dlx_opcodes; i++) for (i = 0; i < num_dlx_opcodes; i++)
{ {
const char *name = machine_opcodes[i].name; const char *name = machine_opcodes[i].name;
str_hash_insert (op_hash, name, (void *) &machine_opcodes[i]);
retval = hash_insert (op_hash, name, (void *) &machine_opcodes[i]);
if (retval != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
machine_opcodes[i].name, retval);
lose = 1;
} }
}
if (lose)
as_fatal (_("Broken assembler. No assembly attempted."));
define_some_regs (); define_some_regs ();
} }
@ -694,7 +681,7 @@ machine_ip (char *str)
} }
/* Hash the opcode, insn will have the string from opcode table. */ /* Hash the opcode, insn will have the string from opcode table. */
if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) if ((insn = (struct machine_opcode *) str_hash_find (op_hash, str)) == NULL)
{ {
/* Handle the ret and return macro here. */ /* Handle the ret and return macro here. */
if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0)) if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0))

View file

@ -34,7 +34,7 @@ const char line_separator_chars[] = ";";
const char line_comment_chars[] = "#"; const char line_comment_chars[] = "#";
static int pending_reloc; static int pending_reloc;
static struct hash_control *opcode_hash_control; static htab_t opcode_hash_control;
static valueT md_chars_to_number (char * buf, int n); static valueT md_chars_to_number (char * buf, int n);
@ -54,11 +54,11 @@ void
md_begin (void) md_begin (void)
{ {
const ft32_opc_info_t *opcode; const ft32_opc_info_t *opcode;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert names into hash table. */ /* Insert names into hash table. */
for (opcode = ft32_opc_info; opcode->name; opcode++) for (opcode = ft32_opc_info; opcode->name; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0); bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
if (!norelax) if (!norelax)
@ -231,7 +231,7 @@ md_assemble (char *str)
if (nlen == 0) if (nlen == 0)
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
opcode = (ft32_opc_info_t *) hash_find (opcode_hash_control, op_start); opcode = (ft32_opc_info_t *) str_hash_find (opcode_hash_control, op_start);
*op_end = pend; *op_end = pend;
if (opcode == NULL) if (opcode == NULL)

View file

@ -224,7 +224,7 @@ const char EXP_CHARS[] = "eE";
or 0d1.2345e12. */ or 0d1.2345e12. */
const char FLT_CHARS[] = "rRsSfFdDxXpP"; const char FLT_CHARS[] = "rRsSfFdDxXpP";
static struct hash_control *opcode_hash_control; /* Opcode mnemonics. */ static htab_t opcode_hash_control; /* Opcode mnemonics. */
/* This function is called once, at assembler startup time. This /* This function is called once, at assembler startup time. This
should set up all the tables, etc. that the MD part of the assembler should set up all the tables, etc. that the MD part of the assembler
@ -242,7 +242,7 @@ md_begin (void)
if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, default_mach)) if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, default_mach))
as_warn (_("could not set architecture and machine")); as_warn (_("could not set architecture and machine"));
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
prev_buffer[0] = 0; prev_buffer[0] = 0;
nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode); nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
@ -283,7 +283,7 @@ md_begin (void)
len = dst - buffer; len = dst - buffer;
if (cmplen == 0) if (cmplen == 0)
cmplen = len; cmplen = len;
hash_insert (opcode_hash_control, buffer, (char *) pi); str_hash_insert (opcode_hash_control, buffer, (char *) pi);
strcpy (prev_buffer, buffer); strcpy (prev_buffer, buffer);
idx++; idx++;
@ -1940,7 +1940,7 @@ md_assemble (char *str)
*slash = TOLOWER (*slash); *slash = TOLOWER (*slash);
instruction = (const struct h8_instruction *) instruction = (const struct h8_instruction *)
hash_find (opcode_hash_control, op_start); str_hash_find (opcode_hash_control, op_start);
if (instruction == NULL) if (instruction == NULL)
{ {

View file

@ -550,7 +550,7 @@ static struct call_info *last_call_info;
static struct call_desc last_call_desc; static struct call_desc last_call_desc;
/* handle of the OPCODE hash table */ /* handle of the OPCODE hash table */
static struct hash_control *op_hash = NULL; static htab_t op_hash = NULL;
/* These characters can be suffixes of opcode names and they may be /* These characters can be suffixes of opcode names and they may be
followed by meaningful whitespace. We don't include `,' and `!' followed by meaningful whitespace. We don't include `,' and `!'
@ -3214,7 +3214,7 @@ pa_ip (char *str)
} }
/* Look up the opcode in the hash table. */ /* Look up the opcode in the hash table. */
if ((insn = (struct pa_opcode *) hash_find (op_hash, str)) == NULL) if ((insn = (struct pa_opcode *) str_hash_find (op_hash, str)) == NULL)
{ {
as_bad (_("Unknown opcode: `%s'"), str); as_bad (_("Unknown opcode: `%s'"), str);
return; return;
@ -8215,7 +8215,6 @@ pa_lsym (int unused ATTRIBUTE_UNUSED)
void void
md_begin (void) md_begin (void)
{ {
const char *retval = NULL;
int lose = 0; int lose = 0;
unsigned int i = 0; unsigned int i = 0;
@ -8238,18 +8237,13 @@ md_begin (void)
pa_spaces_begin (); pa_spaces_begin ();
#endif #endif
op_hash = hash_new (); op_hash = str_htab_create ();
while (i < NUMOPCODES) while (i < NUMOPCODES)
{ {
const char *name = pa_opcodes[i].name; const char *name = pa_opcodes[i].name;
retval = hash_insert (op_hash, name, (struct pa_opcode *) &pa_opcodes[i]); str_hash_insert (op_hash, name, (void *)&pa_opcodes[i]);
if (retval != NULL && *retval != '\0')
{
as_fatal (_("Internal error: can't hash `%s': %s\n"), name, retval);
lose = 1;
}
do do
{ {

View file

@ -1376,10 +1376,10 @@ const pseudo_typeS md_pseudo_table[] =
extern char *input_line_pointer; extern char *input_line_pointer;
/* Hash table for instruction mnemonic lookup. */ /* Hash table for instruction mnemonic lookup. */
static struct hash_control *op_hash; static htab_t op_hash;
/* Hash table for register lookup. */ /* Hash table for register lookup. */
static struct hash_control *reg_hash; static htab_t reg_hash;
/* Various efficient no-op patterns for aligning code labels. /* Various efficient no-op patterns for aligning code labels.
Note: Don't try to assemble the instructions in the comments. Note: Don't try to assemble the instructions in the comments.
@ -3026,13 +3026,11 @@ i386_mach (void)
void void
md_begin (void) md_begin (void)
{ {
const char *hash_err;
/* Support pseudo prefixes like {disp32}. */ /* Support pseudo prefixes like {disp32}. */
lex_type ['{'] = LEX_BEGIN_NAME; lex_type ['{'] = LEX_BEGIN_NAME;
/* Initialize op_hash hash table. */ /* Initialize op_hash hash table. */
op_hash = hash_new (); op_hash = str_htab_create ();
{ {
const insn_template *optab; const insn_template *optab;
@ -3052,15 +3050,7 @@ md_begin (void)
/* different name --> ship out current template list; /* different name --> ship out current template list;
add to hash table; & begin anew. */ add to hash table; & begin anew. */
core_optab->end = optab; core_optab->end = optab;
hash_err = hash_insert (op_hash, str_hash_insert (op_hash, (optab - 1)->name, (void *) core_optab);
(optab - 1)->name,
(void *) core_optab);
if (hash_err)
{
as_fatal (_("can't hash %s: %s"),
(optab - 1)->name,
hash_err);
}
if (optab->name == NULL) if (optab->name == NULL)
break; break;
core_optab = XNEW (templates); core_optab = XNEW (templates);
@ -3070,19 +3060,13 @@ md_begin (void)
} }
/* Initialize reg_hash hash table. */ /* Initialize reg_hash hash table. */
reg_hash = hash_new (); reg_hash = str_htab_create ();
{ {
const reg_entry *regtab; const reg_entry *regtab;
unsigned int regtab_size = i386_regtab_size; unsigned int regtab_size = i386_regtab_size;
for (regtab = i386_regtab; regtab_size--; regtab++) for (regtab = i386_regtab; regtab_size--; regtab++)
{ str_hash_insert (reg_hash, regtab->reg_name, (void *) regtab);
hash_err = hash_insert (reg_hash, regtab->reg_name, (void *) regtab);
if (hash_err)
as_fatal (_("can't hash %s: %s"),
regtab->reg_name,
hash_err);
}
} }
/* Fill in lexical tables: mnemonic_chars, operand_chars. */ /* Fill in lexical tables: mnemonic_chars, operand_chars. */
@ -3173,8 +3157,8 @@ md_begin (void)
void void
i386_print_statistics (FILE *file) i386_print_statistics (FILE *file)
{ {
hash_print_statistics (file, "i386 opcode", op_hash); htab_print_statistics (file, "i386 opcode", op_hash);
hash_print_statistics (file, "i386 register", reg_hash); htab_print_statistics (file, "i386 register", reg_hash);
} }
#ifdef DEBUG386 #ifdef DEBUG386
@ -5088,7 +5072,7 @@ parse_insn (char *line, char *mnemonic)
} }
/* Look up instruction (or prefix) via hash table. */ /* Look up instruction (or prefix) via hash table. */
current_templates = (const templates *) hash_find (op_hash, mnemonic); current_templates = (const templates *) str_hash_find (op_hash, mnemonic);
if (*l != END_OF_INSN if (*l != END_OF_INSN
&& (!is_space_char (*l) || l[1] != END_OF_INSN) && (!is_space_char (*l) || l[1] != END_OF_INSN)
@ -5214,7 +5198,7 @@ parse_insn (char *line, char *mnemonic)
goto check_suffix; goto check_suffix;
mnem_p = dot_p; mnem_p = dot_p;
*dot_p = '\0'; *dot_p = '\0';
current_templates = (const templates *) hash_find (op_hash, mnemonic); current_templates = (const templates *) str_hash_find (op_hash, mnemonic);
} }
if (!current_templates) if (!current_templates)
@ -5234,7 +5218,7 @@ parse_insn (char *line, char *mnemonic)
case QWORD_MNEM_SUFFIX: case QWORD_MNEM_SUFFIX:
i.suffix = mnem_p[-1]; i.suffix = mnem_p[-1];
mnem_p[-1] = '\0'; mnem_p[-1] = '\0';
current_templates = (const templates *) hash_find (op_hash, current_templates = (const templates *) str_hash_find (op_hash,
mnemonic); mnemonic);
break; break;
case SHORT_MNEM_SUFFIX: case SHORT_MNEM_SUFFIX:
@ -5243,7 +5227,7 @@ parse_insn (char *line, char *mnemonic)
{ {
i.suffix = mnem_p[-1]; i.suffix = mnem_p[-1];
mnem_p[-1] = '\0'; mnem_p[-1] = '\0';
current_templates = (const templates *) hash_find (op_hash, current_templates = (const templates *) str_hash_find (op_hash,
mnemonic); mnemonic);
} }
break; break;
@ -5257,7 +5241,7 @@ parse_insn (char *line, char *mnemonic)
else else
i.suffix = LONG_MNEM_SUFFIX; i.suffix = LONG_MNEM_SUFFIX;
mnem_p[-1] = '\0'; mnem_p[-1] = '\0';
current_templates = (const templates *) hash_find (op_hash, current_templates = (const templates *) str_hash_find (op_hash,
mnemonic); mnemonic);
} }
break; break;
@ -7564,7 +7548,7 @@ process_operands (void)
i.flags[j] = i.flags[j - 1]; i.flags[j] = i.flags[j - 1];
} }
i.op[0].regs i.op[0].regs
= (const reg_entry *) hash_find (reg_hash, "xmm0"); = (const reg_entry *) str_hash_find (reg_hash, "xmm0");
i.types[0] = regxmm; i.types[0] = regxmm;
i.tm.operand_types[0] = regxmm; i.tm.operand_types[0] = regxmm;
@ -10984,10 +10968,10 @@ i386_index_check (const char *operand_string)
&& current_templates->end[-1].operand_types[1] && current_templates->end[-1].operand_types[1]
.bitfield.baseindex)) .bitfield.baseindex))
op = 1; op = 1;
expected_reg = hash_find (reg_hash, di_si[addr_mode][op == es_op]); expected_reg = (const reg_entry *)str_hash_find (reg_hash, di_si[addr_mode][op == es_op]);
} }
else else
expected_reg = hash_find (reg_hash, bx[addr_mode]); expected_reg = (const reg_entry *)str_hash_find (reg_hash, bx[addr_mode]);
if (i.base_reg != expected_reg if (i.base_reg != expected_reg
|| i.index_reg || i.index_reg
@ -12638,7 +12622,7 @@ parse_real_register (char *reg_string, char **end_op)
*end_op = s; *end_op = s;
r = (const reg_entry *) hash_find (reg_hash, reg_name_given); r = (const reg_entry *) str_hash_find (reg_hash, reg_name_given);
/* Handle floating point regs, allowing spaces in the (i) part. */ /* Handle floating point regs, allowing spaces in the (i) part. */
if (r == i386_regtab /* %st is first entry of table */) if (r == i386_regtab /* %st is first entry of table */)
@ -12665,7 +12649,7 @@ parse_real_register (char *reg_string, char **end_op)
if (*s == ')') if (*s == ')')
{ {
*end_op = s + 1; *end_op = s + 1;
r = (const reg_entry *) hash_find (reg_hash, "st(0)"); r = (const reg_entry *) str_hash_find (reg_hash, "st(0)");
know (r); know (r);
return r + fpr; return r + fpr;
} }

View file

@ -185,10 +185,10 @@ static void ia64_float_to_chars_littleendian (char *, LITTLENUM_TYPE *, int);
static void (*ia64_float_to_chars) (char *, LITTLENUM_TYPE *, int); static void (*ia64_float_to_chars) (char *, LITTLENUM_TYPE *, int);
static struct hash_control *alias_hash; static htab_t alias_hash;
static struct hash_control *alias_name_hash; static htab_t alias_name_hash;
static struct hash_control *secalias_hash; static htab_t secalias_hash;
static struct hash_control *secalias_name_hash; static htab_t secalias_name_hash;
/* List of chars besides those in app.c:symbol_chars that can start an /* List of chars besides those in app.c:symbol_chars that can start an
operand. Used to prevent the scrubber eating vital white-space. */ operand. Used to prevent the scrubber eating vital white-space. */
@ -228,11 +228,11 @@ size_t md_longopts_size = sizeof (md_longopts);
static struct static struct
{ {
struct hash_control *pseudo_hash; /* pseudo opcode hash table */ htab_t pseudo_hash; /* pseudo opcode hash table */
struct hash_control *reg_hash; /* register name hash table */ htab_t reg_hash; /* register name hash table */
struct hash_control *dynreg_hash; /* dynamic register hash table */ htab_t dynreg_hash; /* dynamic register hash table */
struct hash_control *const_hash; /* constant hash table */ htab_t const_hash; /* constant hash table */
struct hash_control *entry_hash; /* code entry hint hash table */ htab_t entry_hash; /* code entry hint hash table */
/* If X_op is != O_absent, the register name for the instruction's /* If X_op is != O_absent, the register name for the instruction's
qualifying predicate. If NULL, p0 is assumed for instructions qualifying predicate. If NULL, p0 is assumed for instructions
@ -4602,7 +4602,7 @@ dot_rot (int type)
/* First, remove existing names from hash table. */ /* First, remove existing names from hash table. */
for (dr = md.dynreg[type]; dr && dr->num_regs; dr = dr->next) for (dr = md.dynreg[type]; dr && dr->num_regs; dr = dr->next)
{ {
hash_delete (md.dynreg_hash, dr->name, FALSE); str_hash_delete (md.dynreg_hash, dr->name);
/* FIXME: Free dr->name. */ /* FIXME: Free dr->name. */
dr->num_regs = 0; dr->num_regs = 0;
} }
@ -4683,12 +4683,7 @@ dot_rot (int type)
drpp = &dr->next; drpp = &dr->next;
base_reg += num_regs; base_reg += num_regs;
if (hash_insert (md.dynreg_hash, name, dr)) str_hash_insert (md.dynreg_hash, name, dr);
{
as_bad (_("Attempt to redefine register set `%s'"), name);
obstack_free (&notes, name);
goto err;
}
if (*input_line_pointer != ',') if (*input_line_pointer != ',')
break; break;
@ -5166,7 +5161,6 @@ dot_pred_rel (int type)
static void static void
dot_entry (int dummy ATTRIBUTE_UNUSED) dot_entry (int dummy ATTRIBUTE_UNUSED)
{ {
const char *err;
char *name; char *name;
int c; int c;
symbolS *symbolP; symbolS *symbolP;
@ -5176,10 +5170,7 @@ dot_entry (int dummy ATTRIBUTE_UNUSED)
c = get_symbol_name (&name); c = get_symbol_name (&name);
symbolP = symbol_find_or_make (name); symbolP = symbol_find_or_make (name);
err = hash_insert (md.entry_hash, S_GET_NAME (symbolP), (void *) symbolP); str_hash_insert (md.entry_hash, S_GET_NAME (symbolP), (void *) symbolP);
if (err)
as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
name, err);
*input_line_pointer = c; *input_line_pointer = c;
SKIP_WHITESPACE_AFTER_NAME (); SKIP_WHITESPACE_AFTER_NAME ();
@ -5378,15 +5369,11 @@ pseudo_opcode[] =
static symbolS * static symbolS *
declare_register (const char *name, unsigned int regnum) declare_register (const char *name, unsigned int regnum)
{ {
const char *err;
symbolS *sym; symbolS *sym;
sym = symbol_create (name, reg_section, regnum, &zero_address_frag); sym = symbol_create (name, reg_section, regnum, &zero_address_frag);
err = hash_insert (md.reg_hash, S_GET_NAME (sym), (void *) sym); str_hash_insert (md.reg_hash, S_GET_NAME (sym), (void *) sym);
if (err)
as_fatal ("Inserting \"%s\" into register table failed: %s",
name, err);
return sym; return sym;
} }
@ -7241,8 +7228,6 @@ void
md_begin (void) md_begin (void)
{ {
int i, j, k, t, goodness, best, ok; int i, j, k, t, goodness, best, ok;
const char *err;
char name[8];
md.auto_align = 1; md.auto_align = 1;
md.explicit_mode = md.default_explicit_mode; md.explicit_mode = md.default_explicit_mode;
@ -7253,10 +7238,10 @@ md_begin (void)
target_big_endian = -1; target_big_endian = -1;
dot_byteorder (default_big_endian); dot_byteorder (default_big_endian);
alias_hash = hash_new (); alias_hash = str_htab_create ();
alias_name_hash = hash_new (); alias_name_hash = str_htab_create ();
secalias_hash = hash_new (); secalias_hash = str_htab_create ();
secalias_name_hash = hash_new (); secalias_name_hash = str_htab_create ();
pseudo_func[FUNC_DTP_MODULE].u.sym = pseudo_func[FUNC_DTP_MODULE].u.sym =
symbol_new (".<dtpmod>", undefined_section, FUNC_DTP_MODULE, symbol_new (".<dtpmod>", undefined_section, FUNC_DTP_MODULE,
@ -7405,20 +7390,15 @@ md_begin (void)
for (i = 0; i < NUM_SLOTS; ++i) for (i = 0; i < NUM_SLOTS; ++i)
md.slot[i].user_template = -1; md.slot[i].user_template = -1;
md.pseudo_hash = hash_new (); md.pseudo_hash = str_htab_create ();
for (i = 0; i < NELEMS (pseudo_opcode); ++i) for (i = 0; i < NELEMS (pseudo_opcode); ++i)
{ str_hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
err = hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
(void *) (pseudo_opcode + i)); (void *) (pseudo_opcode + i));
if (err)
as_fatal (_("ia64.md_begin: can't hash `%s': %s"),
pseudo_opcode[i].name, err);
}
md.reg_hash = hash_new (); md.reg_hash = str_htab_create ();
md.dynreg_hash = hash_new (); md.dynreg_hash = str_htab_create ();
md.const_hash = hash_new (); md.const_hash = str_htab_create ();
md.entry_hash = hash_new (); md.entry_hash = str_htab_create ();
/* general registers: */ /* general registers: */
declare_register_set ("r", 128, REG_GR); declare_register_set ("r", 128, REG_GR);
@ -7471,13 +7451,8 @@ md_begin (void)
declare_register ("psp", REG_PSP); declare_register ("psp", REG_PSP);
for (i = 0; i < NELEMS (const_bits); ++i) for (i = 0; i < NELEMS (const_bits); ++i)
{ str_hash_insert (md.const_hash, const_bits[i].name,
err = hash_insert (md.const_hash, const_bits[i].name,
(void *) (const_bits + i)); (void *) (const_bits + i));
if (err)
as_fatal (_("Inserting \"%s\" into constant hash table failed: %s"),
name, err);
}
/* Set the architecture and machine depending on defaults and command line /* Set the architecture and machine depending on defaults and command line
options. */ options. */
@ -7980,7 +7955,7 @@ ia64_parse_name (char *name, expressionS *e, char *nextcharP)
} }
/* first see if NAME is a known register name: */ /* first see if NAME is a known register name: */
sym = hash_find (md.reg_hash, name); sym = str_hash_find (md.reg_hash, name);
if (sym) if (sym)
{ {
e->X_op = O_register; e->X_op = O_register;
@ -7988,7 +7963,7 @@ ia64_parse_name (char *name, expressionS *e, char *nextcharP)
return 1; return 1;
} }
cdesc = hash_find (md.const_hash, name); cdesc = str_hash_find (md.const_hash, name);
if (cdesc) if (cdesc)
{ {
e->X_op = O_constant; e->X_op = O_constant;
@ -8054,7 +8029,7 @@ ia64_parse_name (char *name, expressionS *e, char *nextcharP)
end = xstrdup (name); end = xstrdup (name);
name = ia64_canonicalize_symbol_name (end); name = ia64_canonicalize_symbol_name (end);
if ((dr = hash_find (md.dynreg_hash, name))) if ((dr = str_hash_find (md.dynreg_hash, name)))
{ {
/* We've got ourselves the name of a rotating register set. /* We've got ourselves the name of a rotating register set.
Store the base register number in the low 16 bits of Store the base register number in the low 16 bits of
@ -10675,7 +10650,7 @@ md_assemble (char *str)
ch = get_symbol_name (&temp); ch = get_symbol_name (&temp);
mnemonic = temp; mnemonic = temp;
pdesc = (struct pseudo_opcode *) hash_find (md.pseudo_hash, mnemonic); pdesc = (struct pseudo_opcode *) str_hash_find (md.pseudo_hash, mnemonic);
if (pdesc) if (pdesc)
{ {
(void) restore_line_pointer (ch); (void) restore_line_pointer (ch);
@ -11750,10 +11725,9 @@ dot_alias (int section)
char delim; char delim;
char *end_name; char *end_name;
int len; int len;
const char *error_string;
struct alias *h; struct alias *h;
const char *a; const char *a;
struct hash_control *ahash, *nhash; htab_t ahash, nhash;
const char *kind; const char *kind;
delim = get_symbol_name (&name); delim = get_symbol_name (&name);
@ -11810,21 +11784,26 @@ dot_alias (int section)
} }
/* Check if alias has been used before. */ /* Check if alias has been used before. */
h = (struct alias *) hash_find (ahash, alias);
h = (struct alias *) str_hash_find (ahash, alias);
if (h) if (h)
{ {
if (strcmp (h->name, name)) if (strcmp (h->name, name))
as_bad (_("`%s' is already the alias of %s `%s'"), as_bad (_("`%s' is already the alias of %s `%s'"),
alias, kind, h->name); alias, kind, h->name);
obstack_free (&notes, name);
obstack_free (&notes, alias);
goto out; goto out;
} }
/* Check if name already has an alias. */ /* Check if name already has an alias. */
a = (const char *) hash_find (nhash, name); a = (const char *) str_hash_find (nhash, name);
if (a) if (a)
{ {
if (strcmp (a, alias)) if (strcmp (a, alias))
as_bad (_("%s `%s' already has an alias `%s'"), kind, name, a); as_bad (_("%s `%s' already has an alias `%s'"), kind, name, a);
obstack_free (&notes, name);
obstack_free (&notes, alias);
goto out; goto out;
} }
@ -11832,32 +11811,19 @@ dot_alias (int section)
h->file = as_where (&h->line); h->file = as_where (&h->line);
h->name = name; h->name = name;
error_string = hash_jam (ahash, alias, (void *) h); str_hash_insert (ahash, alias, (void *) h);
if (error_string) str_hash_insert (nhash, name, (void *) alias);
{
as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
alias, kind, error_string);
goto out;
}
error_string = hash_jam (nhash, name, (void *) alias);
if (error_string)
{
as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
alias, kind, error_string);
out:
obstack_free (&notes, name);
obstack_free (&notes, alias);
}
out:
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
/* It renames the original symbol name to its alias. */ /* It renames the original symbol name to its alias. */
static void static int
do_alias (const char *alias, void *value) do_alias (void **slot, void *arg ATTRIBUTE_UNUSED)
{ {
struct alias *h = (struct alias *) value; string_tuple_t *tuple = *((string_tuple_t **) slot);
struct alias *h = (struct alias *) tuple->value;
symbolS *sym = symbol_find (h->name); symbolS *sym = symbol_find (h->name);
if (sym == NULL) if (sym == NULL)
@ -11866,43 +11832,48 @@ do_alias (const char *alias, void *value)
/* Uses .alias extensively to alias CRTL functions to same with /* Uses .alias extensively to alias CRTL functions to same with
decc$ prefix. Sometimes function gets optimized away and a decc$ prefix. Sometimes function gets optimized away and a
warning results, which should be suppressed. */ warning results, which should be suppressed. */
if (strncmp (alias, "decc$", 5) != 0) if (strncmp (tuple->key, "decc$", 5) != 0)
#endif #endif
as_warn_where (h->file, h->line, as_warn_where (h->file, h->line,
_("symbol `%s' aliased to `%s' is not used"), _("symbol `%s' aliased to `%s' is not used"),
h->name, alias); h->name, tuple->key);
} }
else else
S_SET_NAME (sym, (char *) alias); S_SET_NAME (sym, (char *) tuple->key);
return 1;
} }
/* Called from write_object_file. */ /* Called from write_object_file. */
void void
ia64_adjust_symtab (void) ia64_adjust_symtab (void)
{ {
hash_traverse (alias_hash, do_alias); htab_traverse (alias_hash, do_alias, NULL);
} }
/* It renames the original section name to its alias. */ /* It renames the original section name to its alias. */
static void static int
do_secalias (const char *alias, void *value) do_secalias (void **slot, void *arg ATTRIBUTE_UNUSED)
{ {
struct alias *h = (struct alias *) value; string_tuple_t *tuple = *((string_tuple_t **) slot);
struct alias *h = (struct alias *) tuple->value;
segT sec = bfd_get_section_by_name (stdoutput, h->name); segT sec = bfd_get_section_by_name (stdoutput, h->name);
if (sec == NULL) if (sec == NULL)
as_warn_where (h->file, h->line, as_warn_where (h->file, h->line,
_("section `%s' aliased to `%s' is not used"), _("section `%s' aliased to `%s' is not used"),
h->name, alias); h->name, tuple->key);
else else
sec->name = alias; sec->name = tuple->key;
return 1;
} }
/* Called from write_object_file. */ /* Called from write_object_file. */
void void
ia64_frob_file (void) ia64_frob_file (void)
{ {
hash_traverse (secalias_hash, do_secalias); htab_traverse (secalias_hash, do_secalias, NULL);
} }
#ifdef TE_VMS #ifdef TE_VMS

View file

@ -263,7 +263,7 @@ static short flag_print_insn_syntax = 0;
static short flag_print_opcodes = 0; static short flag_print_opcodes = 0;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *m68hc11_hash; static htab_t m68hc11_hash;
/* Current cpu (either cpu6811 or cpu6812). This is determined automagically /* Current cpu (either cpu6811 or cpu6812). This is determined automagically
by 'get_default_target' by looking at default BFD vector. This is overridden by 'get_default_target' by looking at default BFD vector. This is overridden
@ -472,7 +472,7 @@ m68hc11_print_statistics (FILE *file)
int i; int i;
struct m68hc11_opcode_def *opc; struct m68hc11_opcode_def *opc;
hash_print_statistics (file, "opcode table", m68hc11_hash); htab_print_statistics (file, "opcode table", m68hc11_hash);
opc = m68hc11_opcode_defs; opc = m68hc11_opcode_defs;
if (opc == 0 || m68hc11_nb_opcode_defs == 0) if (opc == 0 || m68hc11_nb_opcode_defs == 0)
@ -610,7 +610,7 @@ md_begin (void)
get_default_target (); get_default_target ();
m68hc11_hash = hash_new (); m68hc11_hash = str_htab_create ();
/* Get a writable copy of the opcode table and sort it on the names. */ /* Get a writable copy of the opcode table and sort it on the names. */
opcodes = XNEWVEC (struct m68hc11_opcode, m68hc11_num_opcodes); opcodes = XNEWVEC (struct m68hc11_opcode, m68hc11_num_opcodes);
@ -664,7 +664,7 @@ md_begin (void)
opc->nb_modes = 0; opc->nb_modes = 0;
opc->opcode = opcodes; opc->opcode = opcodes;
opc->used = 0; opc->used = 0;
hash_insert (m68hc11_hash, opcodes->name, opc); str_hash_insert (m68hc11_hash, opcodes->name, opc);
} }
opc->nb_modes++; opc->nb_modes++;
opc->format |= opcodes->format; opc->format |= opcodes->format;
@ -1010,7 +1010,7 @@ print_insn_format (char *name)
struct m68hc11_opcode *opcode; struct m68hc11_opcode *opcode;
char buf[128]; char buf[128];
opc = (struct m68hc11_opcode_def *) hash_find (m68hc11_hash, name); opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name);
if (opc == NULL) if (opc == NULL)
{ {
as_bad (_("Instruction `%s' is not recognized."), name); as_bad (_("Instruction `%s' is not recognized."), name);
@ -2848,7 +2848,7 @@ md_assemble (char *str)
if (current_architecture == cpuxgate) if (current_architecture == cpuxgate)
{ {
/* Find the opcode definition given its name. */ /* Find the opcode definition given its name. */
opc = (struct m68hc11_opcode_def *) hash_find (m68hc11_hash, name); opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name);
if (opc == NULL) if (opc == NULL)
{ {
as_bad (_("Opcode `%s' is not recognized."), name); as_bad (_("Opcode `%s' is not recognized."), name);
@ -3469,7 +3469,7 @@ md_assemble (char *str)
} }
/* Find the opcode definition given its name. */ /* Find the opcode definition given its name. */
opc = (struct m68hc11_opcode_def *) hash_find (m68hc11_hash, name); opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, name);
/* If it's not recognized, look for 'jbsr' and 'jbxx'. These are /* If it's not recognized, look for 'jbsr' and 'jbxx'. These are
pseudo insns for relative branch. For these branches, we always pseudo insns for relative branch. For these branches, we always
@ -3477,7 +3477,7 @@ md_assemble (char *str)
is given. */ is given. */
if (opc == NULL && name[0] == 'j' && name[1] == 'b') if (opc == NULL && name[0] == 'j' && name[1] == 'b')
{ {
opc = (struct m68hc11_opcode_def *) hash_find (m68hc11_hash, &name[1]); opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, &name[1]);
if (opc if (opc
&& (!(opc->format & M6811_OP_JUMP_REL) && (!(opc->format & M6811_OP_JUMP_REL)
|| (opc->format & M6811_OP_BITMASK))) || (opc->format & M6811_OP_BITMASK)))
@ -3508,7 +3508,7 @@ md_assemble (char *str)
{ {
name[nlen++] = TOLOWER (*op_end++); name[nlen++] = TOLOWER (*op_end++);
name[nlen] = 0; name[nlen] = 0;
opc = (struct m68hc11_opcode_def *) hash_find (m68hc11_hash, opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash,
name); name);
} }
} }

View file

@ -1320,7 +1320,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
/* Handle of the OPCODE hash table. NULL means any use before /* Handle of the OPCODE hash table. NULL means any use before
m68k_ip_begin() will crash. */ m68k_ip_begin() will crash. */
static struct hash_control *op_hash; static htab_t op_hash;
/* Assemble an m68k instruction. */ /* Assemble an m68k instruction. */
@ -1375,7 +1375,7 @@ m68k_ip (char *instring)
c = *p; c = *p;
*p = '\0'; *p = '\0';
opcode = (const struct m68k_incant *) hash_find (op_hash, instring); opcode = (const struct m68k_incant *) str_hash_find (op_hash, instring);
*p = c; *p = c;
if (pdot != NULL) if (pdot != NULL)
@ -4496,7 +4496,6 @@ md_begin (void)
{ {
const struct m68k_opcode *ins; const struct m68k_opcode *ins;
struct m68k_incant *hack, *slak; struct m68k_incant *hack, *slak;
const char *retval = 0; /* Empty string, or error msg text. */
int i; int i;
/* Set up hash tables with 68000 instructions. /* Set up hash tables with 68000 instructions.
@ -4527,7 +4526,7 @@ md_begin (void)
qsort (m68k_sorted_opcodes, m68k_numopcodes, qsort (m68k_sorted_opcodes, m68k_numopcodes,
sizeof (m68k_sorted_opcodes[0]), m68k_compare_opcode); sizeof (m68k_sorted_opcodes[0]), m68k_compare_opcode);
op_hash = hash_new (); op_hash = str_htab_create ();
obstack_begin (&robyn, 4000); obstack_begin (&robyn, 4000);
for (i = 0; i < m68k_numopcodes; i++) for (i = 0; i < m68k_numopcodes; i++)
@ -4571,22 +4570,18 @@ md_begin (void)
} }
while (slak); while (slak);
retval = hash_insert (op_hash, ins->name, (char *) hack); str_hash_insert (op_hash, ins->name, (char *) hack);
if (retval)
as_fatal (_("Internal Error: Can't hash %s: %s"), ins->name, retval);
} }
for (i = 0; i < m68k_numaliases; i++) for (i = 0; i < m68k_numaliases; i++)
{ {
const char *name = m68k_opcode_aliases[i].primary; const char *name = m68k_opcode_aliases[i].primary;
const char *alias = m68k_opcode_aliases[i].alias; const char *alias = m68k_opcode_aliases[i].alias;
void *val = hash_find (op_hash, name); void *val = (void *)str_hash_find (op_hash, name);
if (!val) if (!val)
as_fatal (_("Internal Error: Can't find %s in hash table"), name); as_fatal (_("Internal Error: Can't find %s in hash table"), name);
retval = hash_insert (op_hash, alias, val); str_hash_insert (op_hash, alias, val);
if (retval)
as_fatal (_("Internal Error: Can't hash %s: %s"), alias, retval);
} }
/* In MRI mode, all unsized branches are variable sized. Normally, /* In MRI mode, all unsized branches are variable sized. Normally,
@ -4619,13 +4614,11 @@ md_begin (void)
{ {
const char *name = mri_aliases[i].primary; const char *name = mri_aliases[i].primary;
const char *alias = mri_aliases[i].alias; const char *alias = mri_aliases[i].alias;
void *val = hash_find (op_hash, name); void *val = (void *)str_hash_find (op_hash, name);
if (!val) if (!val)
as_fatal (_("Internal Error: Can't find %s in hash table"), name); as_fatal (_("Internal Error: Can't find %s in hash table"), name);
retval = hash_jam (op_hash, alias, val); str_hash_insert (op_hash, alias, val);
if (retval)
as_fatal (_("Internal Error: Can't hash %s: %s"), alias, retval);
} }
} }
@ -4680,7 +4673,7 @@ md_begin (void)
while (mote_pseudo_table[n].poc_name) while (mote_pseudo_table[n].poc_name)
{ {
hack = XOBNEW (&robyn, struct m68k_incant); hack = XOBNEW (&robyn, struct m68k_incant);
hash_insert (op_hash, str_hash_insert (op_hash,
mote_pseudo_table[n].poc_name, (char *) hack); mote_pseudo_table[n].poc_name, (char *) hack);
hack->m_operands = 0; hack->m_operands = 0;
hack->m_opnum = n; hack->m_opnum = n;

View file

@ -135,7 +135,7 @@ static unsigned long poolspan;
#define SPANEXIT (600) #define SPANEXIT (600)
static symbolS * poolsym; /* Label for current pool. */ static symbolS * poolsym; /* Label for current pool. */
static char poolname[8]; static char poolname[8];
static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */ static htab_t opcode_hash_control; /* Opcode mnemonics. */
#define POOL_END_LABEL ".LE" #define POOL_END_LABEL ".LE"
#define POOL_START_LABEL ".LS" #define POOL_START_LABEL ".LS"
@ -457,7 +457,7 @@ md_begin (void)
const char * prev_name = ""; const char * prev_name = "";
unsigned int i; unsigned int i;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert unique names into hash table. */ /* Insert unique names into hash table. */
for (i = 0; i < ARRAY_SIZE (mcore_table); i++) for (i = 0; i < ARRAY_SIZE (mcore_table); i++)
@ -465,7 +465,7 @@ md_begin (void)
if (! streq (prev_name, mcore_table[i].name)) if (! streq (prev_name, mcore_table[i].name))
{ {
prev_name = mcore_table[i].name; prev_name = mcore_table[i].name;
hash_insert (opcode_hash_control, mcore_table[i].name, (char *) &mcore_table[i]); str_hash_insert (opcode_hash_control, mcore_table[i].name, (char *) &mcore_table[i]);
} }
} }
} }
@ -881,7 +881,7 @@ md_assemble (char * str)
return; return;
} }
opcode = (mcore_opcode_info *) hash_find (opcode_hash_control, name); opcode = (mcore_opcode_info *) str_hash_find (opcode_hash_control, name);
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), name); as_bad (_("unknown opcode \"%s\""), name);

View file

@ -114,7 +114,7 @@ const relax_typeS md_relax_table[] =
{ 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
}; };
static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */ static htab_t opcode_hash_control; /* Opcode mnemonics. */
static segT sbss_segment = 0; /* Small bss section. */ static segT sbss_segment = 0; /* Small bss section. */
static segT sbss2_segment = 0; /* Section not used. */ static segT sbss2_segment = 0; /* Section not used. */
@ -413,11 +413,11 @@ md_begin (void)
{ {
struct op_code_struct * opcode; struct op_code_struct * opcode;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert unique names into hash table. */ /* Insert unique names into hash table. */
for (opcode = opcodes; opcode->name; opcode ++) for (opcode = opcodes; opcode->name; opcode ++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
} }
/* Try to parse a reg name. */ /* Try to parse a reg name. */
@ -942,7 +942,7 @@ md_assemble (char * str)
return; return;
} }
opcode = (struct op_code_struct *) hash_find (opcode_hash_control, name); opcode = (struct op_code_struct *) str_hash_find (opcode_hash_control, name);
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), name); as_bad (_("unknown opcode \"%s\""), name);
@ -1072,9 +1072,9 @@ md_assemble (char * str)
count = 32 - reg1; count = 32 - reg1;
if (streq (name, "lmi")) if (streq (name, "lmi"))
opcode = (struct op_code_struct *) hash_find (opcode_hash_control, "lwi"); opcode = (struct op_code_struct *) str_hash_find (opcode_hash_control, "lwi");
else else
opcode = (struct op_code_struct *) hash_find (opcode_hash_control, "swi"); opcode = (struct op_code_struct *) str_hash_find (opcode_hash_control, "swi");
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "lwi"); as_bad (_("unknown opcode \"%s\""), "lwi");
@ -1106,7 +1106,7 @@ md_assemble (char * str)
if ((temp != 0) && (temp != 0xFFFF8000)) if ((temp != 0) && (temp != 0xFFFF8000))
{ {
/* Needs an immediate inst. */ /* Needs an immediate inst. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");
@ -1559,7 +1559,7 @@ md_assemble (char * str)
if ((temp != 0) && (temp != 0xFFFF8000)) if ((temp != 0) && (temp != 0xFFFF8000))
{ {
/* Needs an immediate inst. */ /* Needs an immediate inst. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");
@ -1625,7 +1625,7 @@ md_assemble (char * str)
if ((temp != 0) && (temp != 0xFFFF8000)) if ((temp != 0) && (temp != 0xFFFF8000))
{ {
/* Needs an immediate inst. */ /* Needs an immediate inst. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");
@ -1698,7 +1698,7 @@ md_assemble (char * str)
if ((temp != 0) && (temp != 0xFFFF8000)) if ((temp != 0) && (temp != 0xFFFF8000))
{ {
/* Needs an immediate inst. */ /* Needs an immediate inst. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");
@ -2119,7 +2119,7 @@ md_apply_fix (fixS * fixP,
buf[i + INST_WORD_SIZE] = buf[i]; buf[i + INST_WORD_SIZE] = buf[i];
/* Generate the imm instruction. */ /* Generate the imm instruction. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");
@ -2167,7 +2167,7 @@ md_apply_fix (fixS * fixP,
buf[i + INST_WORD_SIZE] = buf[i]; buf[i + INST_WORD_SIZE] = buf[i];
/* Generate the imm instruction. */ /* Generate the imm instruction. */
opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm"); opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL) if (opcode1 == NULL)
{ {
as_bad (_("unknown opcode \"%s\""), "imm"); as_bad (_("unknown opcode \"%s\""), "imm");

View file

@ -675,13 +675,13 @@ static int g_switch_seen = 0;
static int nopic_need_relax (symbolS *, int); static int nopic_need_relax (symbolS *, int);
/* Handle of the OPCODE hash table. */ /* Handle of the OPCODE hash table. */
static struct hash_control *op_hash = NULL; static htab_t op_hash = NULL;
/* The opcode hash table we use for the mips16. */ /* The opcode hash table we use for the mips16. */
static struct hash_control *mips16_op_hash = NULL; static htab_t mips16_op_hash = NULL;
/* The opcode hash table we use for the microMIPS ASE. */ /* The opcode hash table we use for the microMIPS ASE. */
static struct hash_control *micromips_op_hash = NULL; static htab_t micromips_op_hash = NULL;
/* This array holds the chars that always start a comment. If the /* This array holds the chars that always start a comment. If the
pre-processor is disabled, these aren't very useful. */ pre-processor is disabled, these aren't very useful. */
@ -3668,7 +3668,6 @@ validate_micromips_insn (const struct mips_opcode *opc,
void void
md_begin (void) md_begin (void)
{ {
const char *retval = NULL;
int i = 0; int i = 0;
int broken = 0; int broken = 0;
@ -3688,21 +3687,14 @@ md_begin (void)
if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, file_mips_opts.arch)) if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, file_mips_opts.arch))
as_warn (_("could not set architecture and machine")); as_warn (_("could not set architecture and machine"));
op_hash = hash_new (); op_hash = str_htab_create ();
mips_operands = XCNEWVEC (struct mips_operand_array, NUMOPCODES); mips_operands = XCNEWVEC (struct mips_operand_array, NUMOPCODES);
for (i = 0; i < NUMOPCODES;) for (i = 0; i < NUMOPCODES;)
{ {
const char *name = mips_opcodes[i].name; const char *name = mips_opcodes[i].name;
retval = hash_insert (op_hash, name, (void *) &mips_opcodes[i]); str_hash_insert (op_hash, name, (void *) &mips_opcodes[i]);
if (retval != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
mips_opcodes[i].name, retval);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("broken assembler, no assembly attempted"));
}
do do
{ {
if (!validate_mips_insn (&mips_opcodes[i], 0xffffffff, if (!validate_mips_insn (&mips_opcodes[i], 0xffffffff,
@ -3725,7 +3717,7 @@ md_begin (void)
while ((i < NUMOPCODES) && !strcmp (mips_opcodes[i].name, name)); while ((i < NUMOPCODES) && !strcmp (mips_opcodes[i].name, name));
} }
mips16_op_hash = hash_new (); mips16_op_hash = str_htab_create ();
mips16_operands = XCNEWVEC (struct mips_operand_array, mips16_operands = XCNEWVEC (struct mips_operand_array,
bfd_mips16_num_opcodes); bfd_mips16_num_opcodes);
@ -3734,10 +3726,7 @@ md_begin (void)
{ {
const char *name = mips16_opcodes[i].name; const char *name = mips16_opcodes[i].name;
retval = hash_insert (mips16_op_hash, name, (void *) &mips16_opcodes[i]); str_hash_insert (mips16_op_hash, name, (void *) &mips16_opcodes[i]);
if (retval != NULL)
as_fatal (_("internal: can't hash `%s': %s"),
mips16_opcodes[i].name, retval);
do do
{ {
if (!validate_mips16_insn (&mips16_opcodes[i], &mips16_operands[i])) if (!validate_mips16_insn (&mips16_opcodes[i], &mips16_operands[i]))
@ -3753,7 +3742,7 @@ md_begin (void)
&& strcmp (mips16_opcodes[i].name, name) == 0); && strcmp (mips16_opcodes[i].name, name) == 0);
} }
micromips_op_hash = hash_new (); micromips_op_hash = str_htab_create ();
micromips_operands = XCNEWVEC (struct mips_operand_array, micromips_operands = XCNEWVEC (struct mips_operand_array,
bfd_micromips_num_opcodes); bfd_micromips_num_opcodes);
@ -3762,11 +3751,8 @@ md_begin (void)
{ {
const char *name = micromips_opcodes[i].name; const char *name = micromips_opcodes[i].name;
retval = hash_insert (micromips_op_hash, name, str_hash_insert (micromips_op_hash, name,
(void *) &micromips_opcodes[i]); (void *) &micromips_opcodes[i]);
if (retval != NULL)
as_fatal (_("internal: can't hash `%s': %s"),
micromips_opcodes[i].name, retval);
do do
{ {
struct mips_cl_insn *micromips_nop_insn; struct mips_cl_insn *micromips_nop_insn;
@ -9022,7 +9008,7 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...)
bfd_reloc_code_real_type r[3]; bfd_reloc_code_real_type r[3];
const struct mips_opcode *amo; const struct mips_opcode *amo;
const struct mips_operand *operand; const struct mips_operand *operand;
struct hash_control *hash; htab_t hash;
struct mips_cl_insn insn; struct mips_cl_insn insn;
va_list args; va_list args;
unsigned int uval; unsigned int uval;
@ -9040,7 +9026,7 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...)
r[1] = BFD_RELOC_UNUSED; r[1] = BFD_RELOC_UNUSED;
r[2] = BFD_RELOC_UNUSED; r[2] = BFD_RELOC_UNUSED;
hash = mips_opts.micromips ? micromips_op_hash : op_hash; hash = mips_opts.micromips ? micromips_op_hash : op_hash;
amo = (struct mips_opcode *) hash_find (hash, name); amo = (struct mips_opcode *) str_hash_find (hash, name);
gas_assert (amo); gas_assert (amo);
gas_assert (strcmp (name, amo->name) == 0); gas_assert (strcmp (name, amo->name) == 0);
@ -9198,7 +9184,7 @@ mips16_macro_build (expressionS *ep, const char *name, const char *fmt,
bfd_reloc_code_real_type r[3] bfd_reloc_code_real_type r[3]
= {BFD_RELOC_UNUSED, BFD_RELOC_UNUSED, BFD_RELOC_UNUSED}; = {BFD_RELOC_UNUSED, BFD_RELOC_UNUSED, BFD_RELOC_UNUSED};
mo = (struct mips_opcode *) hash_find (mips16_op_hash, name); mo = (struct mips_opcode *) str_hash_find (mips16_op_hash, name);
gas_assert (mo); gas_assert (mo);
gas_assert (strcmp (name, mo->name) == 0); gas_assert (strcmp (name, mo->name) == 0);
@ -14258,7 +14244,7 @@ mips16_macro (struct mips_cl_insn *ip)
opcode bits in *OPCODE_EXTRA. */ opcode bits in *OPCODE_EXTRA. */
static struct mips_opcode * static struct mips_opcode *
mips_lookup_insn (struct hash_control *hash, const char *start, mips_lookup_insn (htab_t hash, const char *start,
ssize_t length, unsigned int *opcode_extra) ssize_t length, unsigned int *opcode_extra)
{ {
char *name, *dot, *p; char *name, *dot, *p;
@ -14270,7 +14256,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start,
name = xstrndup (start, length); name = xstrndup (start, length);
/* Look up the instruction as-is. */ /* Look up the instruction as-is. */
insn = (struct mips_opcode *) hash_find (hash, name); insn = (struct mips_opcode *) str_hash_find (hash, name);
if (insn) if (insn)
goto end; goto end;
@ -14282,7 +14268,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start,
if (*p == 0 && mask != 0) if (*p == 0 && mask != 0)
{ {
*dot = 0; *dot = 0;
insn = (struct mips_opcode *) hash_find (hash, name); insn = (struct mips_opcode *) str_hash_find (hash, name);
*dot = '.'; *dot = '.';
if (insn && (insn->pinfo2 & INSN2_VU0_CHANNEL_SUFFIX) != 0) if (insn && (insn->pinfo2 & INSN2_VU0_CHANNEL_SUFFIX) != 0)
{ {
@ -14308,7 +14294,7 @@ mips_lookup_insn (struct hash_control *hash, const char *start,
if (suffix) if (suffix)
{ {
memmove (name + opend - 2, name + opend, length - opend + 1); memmove (name + opend - 2, name + opend, length - opend + 1);
insn = (struct mips_opcode *) hash_find (hash, name); insn = (struct mips_opcode *) str_hash_find (hash, name);
if (insn) if (insn)
{ {
forced_insn_length = suffix; forced_insn_length = suffix;
@ -14333,7 +14319,7 @@ static void
mips_ip (char *str, struct mips_cl_insn *insn) mips_ip (char *str, struct mips_cl_insn *insn)
{ {
const struct mips_opcode *first, *past; const struct mips_opcode *first, *past;
struct hash_control *hash; htab_t hash;
char format; char format;
size_t end; size_t end;
struct mips_operand_token *tokens; struct mips_operand_token *tokens;
@ -14429,7 +14415,7 @@ mips16_ip (char *str, struct mips_cl_insn *insn)
forced_insn_length = l; forced_insn_length = l;
*end = 0; *end = 0;
first = (struct mips_opcode *) hash_find (mips16_op_hash, str); first = (struct mips_opcode *) str_hash_find (mips16_op_hash, str);
*end = c; *end = c;
if (!first) if (!first)

View file

@ -217,7 +217,7 @@ struct option md_longopts[] =
size_t md_longopts_size = sizeof (md_longopts); size_t md_longopts_size = sizeof (md_longopts);
static struct hash_control *mmix_opcode_hash; static htab_t mmix_opcode_hash;
/* We use these when implementing the PREFIX pseudo. */ /* We use these when implementing the PREFIX pseudo. */
char *mmix_current_prefix; char *mmix_current_prefix;
@ -769,13 +769,13 @@ mmix_md_begin (void)
only way to make ':' part of a name, and a name beginner. */ only way to make ':' part of a name, and a name beginner. */
lex_type[':'] = (LEX_NAME | LEX_BEGIN_NAME); lex_type[':'] = (LEX_NAME | LEX_BEGIN_NAME);
mmix_opcode_hash = hash_new (); mmix_opcode_hash = str_htab_create ();
real_reg_section real_reg_section
= bfd_make_section_old_way (stdoutput, MMIX_REG_SECTION_NAME); = bfd_make_section_old_way (stdoutput, MMIX_REG_SECTION_NAME);
for (opcode = mmix_opcodes; opcode->name; opcode++) for (opcode = mmix_opcodes; opcode->name; opcode++)
hash_insert (mmix_opcode_hash, opcode->name, (char *) opcode); str_hash_insert (mmix_opcode_hash, opcode->name, (char *) opcode);
/* We always insert the ordinary registers 0..255 as registers. */ /* We always insert the ordinary registers 0..255 as registers. */
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
@ -843,7 +843,7 @@ md_assemble (char *str)
*operands++ = '\0'; *operands++ = '\0';
} }
instruction = (struct mmix_opcode *) hash_find (mmix_opcode_hash, str); instruction = (struct mmix_opcode *) str_hash_find (mmix_opcode_hash, str);
if (instruction == NULL) if (instruction == NULL)
{ {
as_bad (_("unknown opcode: `%s'"), str); as_bad (_("unknown opcode: `%s'"), str);

View file

@ -101,7 +101,7 @@ const pseudo_typeS md_pseudo_table[] =
}; };
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *mn10200_hash; static htab_t mn10200_hash;
/* This table is sorted. Suitable for searching by a binary search. */ /* This table is sorted. Suitable for searching by a binary search. */
static const struct reg_name data_registers[] = static const struct reg_name data_registers[] =
@ -685,7 +685,7 @@ md_begin (void)
const char *prev_name = ""; const char *prev_name = "";
const struct mn10200_opcode *op; const struct mn10200_opcode *op;
mn10200_hash = hash_new (); mn10200_hash = str_htab_create ();
/* Insert unique names into hash table. The MN10200 instruction set /* Insert unique names into hash table. The MN10200 instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
@ -698,7 +698,7 @@ md_begin (void)
if (strcmp (prev_name, op->name)) if (strcmp (prev_name, op->name))
{ {
prev_name = (char *) op->name; prev_name = (char *) op->name;
hash_insert (mn10200_hash, op->name, (char *) op); str_hash_insert (mn10200_hash, op->name, (char *) op);
} }
op++; op++;
} }
@ -890,7 +890,7 @@ md_assemble (char *str)
*s++ = '\0'; *s++ = '\0';
/* Find the first opcode with the proper name. */ /* Find the first opcode with the proper name. */
opcode = (struct mn10200_opcode *) hash_find (mn10200_hash, str); opcode = (struct mn10200_opcode *) str_hash_find (mn10200_hash, str);
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("Unrecognized opcode: `%s'"), str); as_bad (_("Unrecognized opcode: `%s'"), str);

View file

@ -121,7 +121,7 @@ size_t md_longopts_size = sizeof (md_longopts);
#define HAVE_AM30 (current_machine == AM30) #define HAVE_AM30 (current_machine == AM30)
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *mn10300_hash; static htab_t mn10300_hash;
/* This table is sorted. Suitable for searching by a binary search. */ /* This table is sorted. Suitable for searching by a binary search. */
static const struct reg_name data_registers[] = static const struct reg_name data_registers[] =
@ -911,7 +911,7 @@ md_begin (void)
const char *prev_name = ""; const char *prev_name = "";
const struct mn10300_opcode *op; const struct mn10300_opcode *op;
mn10300_hash = hash_new (); mn10300_hash = str_htab_create ();
/* Insert unique names into hash table. The MN10300 instruction set /* Insert unique names into hash table. The MN10300 instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
@ -924,7 +924,7 @@ md_begin (void)
if (strcmp (prev_name, op->name)) if (strcmp (prev_name, op->name))
{ {
prev_name = (char *) op->name; prev_name = (char *) op->name;
hash_insert (mn10300_hash, op->name, (char *) op); str_hash_insert (mn10300_hash, op->name, (char *) op);
} }
op++; op++;
} }
@ -1247,7 +1247,7 @@ md_assemble (char *str)
*s++ = '\0'; *s++ = '\0';
/* Find the first opcode with the proper name. */ /* Find the first opcode with the proper name. */
opcode = (struct mn10300_opcode *) hash_find (mn10300_hash, str); opcode = (struct mn10300_opcode *) str_hash_find (mn10300_hash, str);
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("Unrecognized opcode: `%s'"), str); as_bad (_("Unrecognized opcode: `%s'"), str);

View file

@ -32,7 +32,7 @@ const char line_separator_chars[] = ";";
const char line_comment_chars[] = "#"; const char line_comment_chars[] = "#";
static int pending_reloc; static int pending_reloc;
static struct hash_control *opcode_hash_control; static htab_t opcode_hash_control;
const pseudo_typeS md_pseudo_table[] = const pseudo_typeS md_pseudo_table[] =
{ {
@ -62,17 +62,17 @@ md_begin (void)
{ {
int count; int count;
const moxie_opc_info_t *opcode; const moxie_opc_info_t *opcode;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert names into hash table. */ /* Insert names into hash table. */
for (count = 0, opcode = moxie_form1_opc_info; count++ < 64; opcode++) for (count = 0, opcode = moxie_form1_opc_info; count++ < 64; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++) for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++) for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0); bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
} }
@ -178,7 +178,7 @@ md_assemble (char *str)
if (nlen == 0) if (nlen == 0)
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
opcode = (moxie_opc_info_t *) hash_find (opcode_hash_control, op_start); opcode = (moxie_opc_info_t *) str_hash_find (opcode_hash_control, op_start);
*op_end = pend; *op_end = pend;
if (opcode == NULL) if (opcode == NULL)

View file

@ -194,7 +194,7 @@ const char FLT_CHARS[] = "dD";
/* Handle long expressions. */ /* Handle long expressions. */
extern LITTLENUM_TYPE generic_bignum[]; extern LITTLENUM_TYPE generic_bignum[];
static struct hash_control *msp430_hash; static htab_t msp430_hash;
/* Relaxations. */ /* Relaxations. */
#define STATE_UNCOND_BRANCH 1 /* jump */ #define STATE_UNCOND_BRANCH 1 /* jump */
@ -1825,10 +1825,11 @@ void
md_begin (void) md_begin (void)
{ {
struct msp430_opcode_s * opcode; struct msp430_opcode_s * opcode;
msp430_hash = hash_new (); msp430_hash = str_htab_create ();
for (opcode = msp430_opcodes; opcode->name; opcode++) for (opcode = msp430_opcodes; opcode->name; opcode++)
hash_insert (msp430_hash, opcode->name, (char *) opcode); if (str_hash_find (msp430_hash, opcode->name) == NULL)
str_hash_insert (msp430_hash, opcode->name, (char *) opcode);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, bfd_set_arch_mach (stdoutput, TARGET_ARCH,
target_is_430x () ? bfd_mach_msp430x : bfd_mach_msp11); target_is_430x () ? bfd_mach_msp430x : bfd_mach_msp11);
@ -2862,7 +2863,7 @@ msp430_operands (struct msp430_opcode_s * opcode, char * line)
char real_name[32]; char real_name[32];
sprintf (real_name, "%sa", old_name); sprintf (real_name, "%sa", old_name);
opcode = hash_find (msp430_hash, real_name); opcode = str_hash_find (msp430_hash, real_name);
if (opcode == NULL) if (opcode == NULL)
{ {
as_bad (_("instruction %s.a does not exist"), old_name); as_bad (_("instruction %s.a does not exist"), old_name);
@ -4346,7 +4347,7 @@ md_assemble (char * str)
return; return;
} }
opcode = (struct msp430_opcode_s *) hash_find (msp430_hash, cmd); opcode = (struct msp430_opcode_s *) str_hash_find (msp430_hash, cmd);
if (opcode == NULL) if (opcode == NULL)
{ {

View file

@ -82,8 +82,8 @@ static int vec_size = 0;
".flag verbatim" at beginning of the content. We have ".flag verbatim" at beginning of the content. We have
'nds32_flag' to parse it and set this field to be non-zero. */ 'nds32_flag' to parse it and set this field to be non-zero. */
static int verbatim = 0; static int verbatim = 0;
static struct hash_control *nds32_gprs_hash; static htab_t nds32_gprs_hash;
static struct hash_control *nds32_hint_hash; static htab_t nds32_hint_hash;
#define TLS_REG "$r27" #define TLS_REG "$r27"
#define GOT_NAME "_GLOBAL_OFFSET_TABLE_" #define GOT_NAME "_GLOBAL_OFFSET_TABLE_"
@ -109,7 +109,7 @@ enum ict_option {
static enum ict_option ict_flag = ICT_NONE; static enum ict_option ict_flag = ICT_NONE;
static struct hash_control *nds32_relax_info_hash; static htab_t nds32_relax_info_hash;
/* Branch patterns. */ /* Branch patterns. */
static relax_info_t relax_table[] = static relax_info_t relax_table[] =
@ -2569,12 +2569,12 @@ struct nds32_pseudo_opcode
}; };
#define PV_DONT_CARE 0 #define PV_DONT_CARE 0
static struct hash_control *nds32_pseudo_opcode_hash = NULL; static htab_t nds32_pseudo_opcode_hash = NULL;
static int static int
builtin_isreg (const char *s, const char *x ATTRIBUTE_UNUSED) builtin_isreg (const char *s, const char *x ATTRIBUTE_UNUSED)
{ {
if (s [0] == '$' && hash_find (nds32_gprs_hash, (s + 1))) if (s [0] == '$' && str_hash_find (nds32_gprs_hash, (s + 1)))
return 1; return 1;
return 0; return 0;
} }
@ -2586,7 +2586,7 @@ builtin_regnum (const char *s, const char *x ATTRIBUTE_UNUSED)
if (*s != '$') if (*s != '$')
return -1; return -1;
s++; s++;
k = hash_find (nds32_gprs_hash, s); k = str_hash_find (nds32_gprs_hash, s);
if (k == NULL) if (k == NULL)
return -1; return -1;
@ -3434,18 +3434,18 @@ nds32_init_nds32_pseudo_opcodes (void)
{ {
struct nds32_pseudo_opcode *opcode = nds32_pseudo_opcode_table; struct nds32_pseudo_opcode *opcode = nds32_pseudo_opcode_table;
nds32_pseudo_opcode_hash = hash_new (); nds32_pseudo_opcode_hash = str_htab_create ();
for ( ; opcode->opcode; opcode++) for ( ; opcode->opcode; opcode++)
{ {
void *op; void *op;
op = hash_find (nds32_pseudo_opcode_hash, opcode->opcode); op = str_hash_find (nds32_pseudo_opcode_hash, opcode->opcode);
if (op != NULL) if (op != NULL)
{ {
as_warn (_("Duplicated pseudo-opcode %s."), opcode->opcode); as_warn (_("Duplicated pseudo-opcode %s."), opcode->opcode);
continue; continue;
} }
hash_insert (nds32_pseudo_opcode_hash, opcode->opcode, opcode); str_hash_insert (nds32_pseudo_opcode_hash, opcode->opcode, opcode);
} }
} }
@ -3466,7 +3466,7 @@ nds32_lookup_pseudo_opcode (const char *str)
} }
op[i] = '\0'; op[i] = '\0';
result = hash_find (nds32_pseudo_opcode_hash, op); result = str_hash_find (nds32_pseudo_opcode_hash, op);
free (op); free (op);
return result; return result;
} }
@ -4291,12 +4291,12 @@ nds32_relax_hint (int mode ATTRIBUTE_UNUSED)
/* Find relax hint entry for next instruction, and all member will be /* Find relax hint entry for next instruction, and all member will be
initialized at that time. */ initialized at that time. */
relocs = hash_find (nds32_hint_hash, name); relocs = str_hash_find (nds32_hint_hash, name);
if (relocs == NULL) if (relocs == NULL)
{ {
relocs = XNEW (struct nds32_relocs_pattern); relocs = XNEW (struct nds32_relocs_pattern);
memset (relocs, 0, sizeof (struct nds32_relocs_pattern)); memset (relocs, 0, sizeof (struct nds32_relocs_pattern));
hash_insert (nds32_hint_hash, name, relocs); str_hash_insert (nds32_hint_hash, name, relocs);
} }
else else
{ {
@ -4623,17 +4623,17 @@ md_begin (void)
nds32_asm_init (&asm_desc, flags); nds32_asm_init (&asm_desc, flags);
/* Initial general purpose registers hash table. */ /* Initial general purpose registers hash table. */
nds32_gprs_hash = hash_new (); nds32_gprs_hash = str_htab_create ();
for (k = keyword_gpr; k->name; k++) for (k = keyword_gpr; k->name; k++)
hash_insert (nds32_gprs_hash, k->name, k); str_hash_insert (nds32_gprs_hash, k->name, k);
/* Initial branch hash table. */ /* Initial branch hash table. */
nds32_relax_info_hash = hash_new (); nds32_relax_info_hash = str_htab_create ();
for (relax_info = relax_table; relax_info->opcode; relax_info++) for (relax_info = relax_table; relax_info->opcode; relax_info++)
hash_insert (nds32_relax_info_hash, relax_info->opcode, relax_info); str_hash_insert (nds32_relax_info_hash, relax_info->opcode, relax_info);
/* Initial relax hint hash table. */ /* Initial relax hint hash table. */
nds32_hint_hash = hash_new (); nds32_hint_hash = str_htab_create ();
enable_16bit = nds32_16bit_ext; enable_16bit = nds32_16bit_ext;
} }
@ -5813,7 +5813,7 @@ nds32_find_reloc_table (struct nds32_relocs_pattern *relocs_pattern,
if (opc) if (opc)
{ {
/* Branch relax pattern. */ /* Branch relax pattern. */
relax_info = hash_find (nds32_relax_info_hash, opc); relax_info = str_hash_find (nds32_relax_info_hash, opc);
if (!relax_info) if (!relax_info)
return FALSE; return FALSE;
fixup_info = relax_info->relax_fixup[range]; fixup_info = relax_info->relax_fixup[range];
@ -6272,6 +6272,15 @@ nds32_elf_append_relax_relocs (const char *key, void *value)
frchain_now = frchain_bak; frchain_now = frchain_bak;
} }
static int
nds32_elf_append_relax_relocs_traverse (void **slot, void *arg ATTRIBUTE_UNUSED)
{
string_tuple_t *tuple = *((string_tuple_t **) slot);
nds32_elf_append_relax_relocs (tuple->key, tuple->value);
return 1;
}
static void static void
nds32_str_tolower (const char *src, char *dest) nds32_str_tolower (const char *src, char *dest)
{ {
@ -6757,7 +6766,7 @@ nds32_relax_branch_instructions (segT segment, fragS *fragP,
return 0; return 0;
} }
relax_info = hash_find (nds32_relax_info_hash, opcode->opcode); relax_info = str_hash_find (nds32_relax_info_hash, opcode->opcode);
if (relax_info == NULL) if (relax_info == NULL)
return adjust; return adjust;
@ -7046,7 +7055,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec, fragS *fragP)
if (fragP->tc_frag_data.flag & NDS32_FRAG_RELAXABLE_BRANCH) if (fragP->tc_frag_data.flag & NDS32_FRAG_RELAXABLE_BRANCH)
{ {
relax_info = hash_find (nds32_relax_info_hash, opcode->opcode); relax_info = str_hash_find (nds32_relax_info_hash, opcode->opcode);
if (relax_info == NULL) if (relax_info == NULL)
return; return;
@ -7106,7 +7115,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec, fragS *fragP)
else if (fragP->tc_frag_data.flag & NDS32_FRAG_BRANCH) else if (fragP->tc_frag_data.flag & NDS32_FRAG_BRANCH)
{ {
/* Branch instruction adjust and append relocations. */ /* Branch instruction adjust and append relocations. */
relax_info = hash_find (nds32_relax_info_hash, opcode->opcode); relax_info = str_hash_find (nds32_relax_info_hash, opcode->opcode);
if (relax_info == NULL) if (relax_info == NULL)
return; return;
@ -7481,7 +7490,7 @@ nds32_insert_relax_entry (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
static void static void
nds32_elf_analysis_relax_hint (void) nds32_elf_analysis_relax_hint (void)
{ {
hash_traverse (nds32_hint_hash, nds32_elf_append_relax_relocs); htab_traverse (nds32_hint_hash, nds32_elf_append_relax_relocs_traverse, NULL);
} }
static void static void
@ -7966,7 +7975,7 @@ nds32_parse_name (char const *name, expressionS *exprP,
int int
tc_nds32_regname_to_dw2regnum (char *regname) tc_nds32_regname_to_dw2regnum (char *regname)
{ {
struct nds32_keyword *sym = hash_find (nds32_gprs_hash, regname); struct nds32_keyword *sym = str_hash_find (nds32_gprs_hash, regname);
if (!sym) if (!sym)
return -1; return -1;

View file

@ -184,20 +184,20 @@ typedef struct nios2_ps_insn_info
} nios2_ps_insn_infoS; } nios2_ps_insn_infoS;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *nios2_opcode_hash = NULL; static htab_t nios2_opcode_hash = NULL;
#define nios2_opcode_lookup(NAME) \ #define nios2_opcode_lookup(NAME) \
((struct nios2_opcode *) hash_find (nios2_opcode_hash, (NAME))) ((struct nios2_opcode *) str_hash_find (nios2_opcode_hash, (NAME)))
/* Register hash table. */ /* Register hash table. */
static struct hash_control *nios2_reg_hash = NULL; static htab_t nios2_reg_hash = NULL;
#define nios2_reg_lookup(NAME) \ #define nios2_reg_lookup(NAME) \
((struct nios2_reg *) hash_find (nios2_reg_hash, (NAME))) ((struct nios2_reg *) str_hash_find (nios2_reg_hash, (NAME)))
/* Pseudo-op hash table. */ /* Pseudo-op hash table. */
static struct hash_control *nios2_ps_hash = NULL; static htab_t nios2_ps_hash = NULL;
#define nios2_ps_lookup(NAME) \ #define nios2_ps_lookup(NAME) \
((nios2_ps_insn_infoS *) hash_find (nios2_ps_hash, (NAME))) ((nios2_ps_insn_infoS *) str_hash_find (nios2_ps_hash, (NAME)))
/* The known current alignment of the current section. */ /* The known current alignment of the current section. */
static int nios2_current_align; static int nios2_current_align;
@ -3603,7 +3603,6 @@ void
md_begin (void) md_begin (void)
{ {
int i; int i;
const char *inserted;
switch (nios2_architecture) switch (nios2_architecture)
{ {
@ -3620,52 +3619,21 @@ md_begin (void)
/* Create and fill a hashtable for the Nios II opcodes, registers and /* Create and fill a hashtable for the Nios II opcodes, registers and
arguments. */ arguments. */
nios2_opcode_hash = hash_new (); nios2_opcode_hash = str_htab_create ();
nios2_reg_hash = hash_new (); nios2_reg_hash = str_htab_create ();
nios2_ps_hash = hash_new (); nios2_ps_hash = str_htab_create ();
for (i = 0; i < nios2_num_opcodes; ++i) for (i = 0; i < nios2_num_opcodes; ++i)
{ str_hash_insert (nios2_opcode_hash, nios2_opcodes[i].name,
inserted
= hash_insert (nios2_opcode_hash, nios2_opcodes[i].name,
(PTR) & nios2_opcodes[i]); (PTR) & nios2_opcodes[i]);
if (inserted != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
nios2_opcodes[i].name, inserted);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("Broken assembler. No assembly attempted."));
}
}
for (i = 0; i < nios2_num_regs; ++i) for (i = 0; i < nios2_num_regs; ++i)
{ str_hash_insert (nios2_reg_hash, nios2_regs[i].name,
inserted
= hash_insert (nios2_reg_hash, nios2_regs[i].name,
(PTR) & nios2_regs[i]); (PTR) & nios2_regs[i]);
if (inserted != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
nios2_regs[i].name, inserted);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("Broken assembler. No assembly attempted."));
}
}
for (i = 0; i < nios2_num_ps_insn_info_structs; ++i) for (i = 0; i < nios2_num_ps_insn_info_structs; ++i)
{ str_hash_insert (nios2_ps_hash, nios2_ps_insn_info_structs[i].pseudo_insn,
inserted
= hash_insert (nios2_ps_hash, nios2_ps_insn_info_structs[i].pseudo_insn,
(PTR) & nios2_ps_insn_info_structs[i]); (PTR) & nios2_ps_insn_info_structs[i]);
if (inserted != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
nios2_ps_insn_info_structs[i].pseudo_insn, inserted);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("Broken assembler. No assembly attempted."));
}
}
/* Assembler option defaults. */ /* Assembler option defaults. */
nios2_as_options.noat = FALSE; nios2_as_options.noat = FALSE;

View file

@ -84,7 +84,7 @@ struct addr_mode
typedef struct addr_mode addr_modeS; typedef struct addr_mode addr_modeS;
char *freeptr, *freeptr_static; /* Points at some number of free bytes. */ char *freeptr, *freeptr_static; /* Points at some number of free bytes. */
struct hash_control *inst_hash_handle; htab_t inst_hash_handle;
struct ns32k_opcode *desc; /* Pointer at description of instruction. */ struct ns32k_opcode *desc; /* Pointer at description of instruction. */
addr_modeS addr_modeP; addr_modeS addr_modeP;
@ -1103,7 +1103,7 @@ parse (const char *line, int recursive_level)
c = *lineptr; c = *lineptr;
*(char *) lineptr = '\0'; *(char *) lineptr = '\0';
if (!(desc = (struct ns32k_opcode *) hash_find (inst_hash_handle, line))) if (!(desc = (struct ns32k_opcode *) str_hash_find (inst_hash_handle, line)))
as_fatal (_("No such opcode")); as_fatal (_("No such opcode"));
*(char *) lineptr = c; *(char *) lineptr = c;
@ -1895,18 +1895,13 @@ md_begin (void)
{ {
/* Build a hashtable of the instructions. */ /* Build a hashtable of the instructions. */
const struct ns32k_opcode *ptr; const struct ns32k_opcode *ptr;
const char *status;
const struct ns32k_opcode *endop; const struct ns32k_opcode *endop;
inst_hash_handle = hash_new (); inst_hash_handle = str_htab_create ();
endop = ns32k_opcodes + sizeof (ns32k_opcodes) / sizeof (ns32k_opcodes[0]); endop = ns32k_opcodes + sizeof (ns32k_opcodes) / sizeof (ns32k_opcodes[0]);
for (ptr = ns32k_opcodes; ptr < endop; ptr++) for (ptr = ns32k_opcodes; ptr < endop; ptr++)
{ str_hash_insert (inst_hash_handle, ptr->name, (char *) ptr);
if ((status = hash_insert (inst_hash_handle, ptr->name, (char *) ptr)))
/* Fatal. */
as_fatal (_("Can't hash %s: %s"), ptr->name, status);
}
/* Some private space please! */ /* Some private space please! */
freeptr_static = XNEWVEC (char, PRIVATE_SIZE); freeptr_static = XNEWVEC (char, PRIVATE_SIZE);

View file

@ -82,7 +82,7 @@ const pseudo_typeS md_pseudo_table[] =
{ 0, 0, 0 }, { 0, 0, 0 },
}; };
static struct hash_control *insn_hash = NULL; static htab_t insn_hash = NULL;
static int static int
set_option (const char *arg) set_option (const char *arg)
@ -188,14 +188,14 @@ md_begin (void)
init_defaults (); init_defaults ();
insn_hash = hash_new (); insn_hash = str_htab_create ();
if (insn_hash == NULL) if (insn_hash == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
for (i = 0; i < pdp11_num_opcodes; i++) for (i = 0; i < pdp11_num_opcodes; i++)
hash_insert (insn_hash, pdp11_opcodes[i].name, (void *) (pdp11_opcodes + i)); str_hash_insert (insn_hash, pdp11_opcodes[i].name, (void *) (pdp11_opcodes + i));
for (i = 0; i < pdp11_num_aliases; i++) for (i = 0; i < pdp11_num_aliases; i++)
hash_insert (insn_hash, pdp11_aliases[i].name, (void *) (pdp11_aliases + i)); str_hash_insert (insn_hash, pdp11_aliases[i].name, (void *) (pdp11_aliases + i));
} }
void void
@ -713,7 +713,7 @@ md_assemble (char *instruction_string)
c = *p; c = *p;
*p = '\0'; *p = '\0';
op = (struct pdp11_opcode *)hash_find (insn_hash, str); op = (struct pdp11_opcode *)str_hash_find (insn_hash, str);
*p = c; *p = c;
if (op == 0) if (op == 0)
{ {

View file

@ -31,7 +31,7 @@ const char line_separator_chars[] = ";";
const char line_comment_chars[] = "/!#"; const char line_comment_chars[] = "/!#";
static int pending_reloc; static int pending_reloc;
static struct hash_control *opcode_hash_control; static htab_t opcode_hash_control;
static void static void
little (int ignore ATTRIBUTE_UNUSED) little (int ignore ATTRIBUTE_UNUSED)
@ -176,7 +176,7 @@ fake_opcode (const char *name,
fake->opcode = -1; fake->opcode = -1;
fake->opcode_next = -1; fake->opcode_next = -1;
fake->u.func = func; fake->u.func = func;
hash_insert (opcode_hash_control, name, (char *) fake); str_hash_insert (opcode_hash_control, name, (char *) fake);
} }
/* Enter another entry into the opcode hash table so the same opcode /* Enter another entry into the opcode hash table so the same opcode
@ -185,8 +185,8 @@ fake_opcode (const char *name,
static void static void
alias (const char *new_name, const char *old) alias (const char *new_name, const char *old)
{ {
hash_insert (opcode_hash_control, new_name, str_hash_insert (opcode_hash_control, new_name,
(char *) hash_find (opcode_hash_control, old)); (char *) str_hash_find (opcode_hash_control, old));
} }
/* This function is called once, at assembler startup time. It sets /* This function is called once, at assembler startup time. It sets
@ -197,11 +197,11 @@ void
md_begin (void) md_begin (void)
{ {
const pj_opc_info_t *opcode; const pj_opc_info_t *opcode;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert names into hash table. */ /* Insert names into hash table. */
for (opcode = pj_opc_info; opcode->u.name; opcode++) for (opcode = pj_opc_info; opcode->u.name; opcode++)
hash_insert (opcode_hash_control, opcode->u.name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->u.name, (char *) opcode);
/* Insert the only fake opcode. */ /* Insert the only fake opcode. */
fake_opcode ("ipush", ipush_code); fake_opcode ("ipush", ipush_code);
@ -252,7 +252,7 @@ md_assemble (char *str)
if (nlen == 0) if (nlen == 0)
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
opcode = (pj_opc_info_t *) hash_find (opcode_hash_control, op_start); opcode = (pj_opc_info_t *) str_hash_find (opcode_hash_control, op_start);
*op_end = pend; *op_end = pend;
if (opcode == NULL) if (opcode == NULL)

View file

@ -966,10 +966,10 @@ ppc_optimize_expr (expressionS *left, operatorT op, expressionS *right)
static unsigned int ppc_obj64 = BFD_DEFAULT_TARGET_SIZE == 64; static unsigned int ppc_obj64 = BFD_DEFAULT_TARGET_SIZE == 64;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *ppc_hash; static htab_t ppc_hash;
/* Macro hash table. */ /* Macro hash table. */
static struct hash_control *ppc_macro_hash; static htab_t ppc_macro_hash;
#ifdef OBJ_ELF #ifdef OBJ_ELF
/* What type of shared library support to use. */ /* What type of shared library support to use. */
@ -1601,12 +1601,12 @@ ppc_setup_opcodes (void)
bfd_boolean bad_insn = FALSE; bfd_boolean bad_insn = FALSE;
if (ppc_hash != NULL) if (ppc_hash != NULL)
hash_die (ppc_hash); htab_delete (ppc_hash);
if (ppc_macro_hash != NULL) if (ppc_macro_hash != NULL)
hash_die (ppc_macro_hash); htab_delete (ppc_macro_hash);
/* Insert the opcodes into a hash table. */ /* Insert the opcodes into a hash table. */
ppc_hash = hash_new (); ppc_hash = str_htab_create ();
if (ENABLE_CHECKING) if (ENABLE_CHECKING)
{ {
@ -1683,22 +1683,12 @@ ppc_setup_opcodes (void)
if ((ppc_cpu & op->flags) != 0 if ((ppc_cpu & op->flags) != 0
&& !(ppc_cpu & op->deprecated)) && !(ppc_cpu & op->deprecated))
{ str_hash_insert (ppc_hash, op->name, (void *) op);
const char *retval;
retval = hash_insert (ppc_hash, op->name, (void *) op);
if (retval != NULL)
{
as_bad (_("duplicate instruction %s"),
op->name);
bad_insn = TRUE;
}
}
} }
if ((ppc_cpu & PPC_OPCODE_ANY) != 0) if ((ppc_cpu & PPC_OPCODE_ANY) != 0)
for (op = powerpc_opcodes; op < op_end; op++) for (op = powerpc_opcodes; op < op_end; op++)
hash_insert (ppc_hash, op->name, (void *) op); str_hash_insert (ppc_hash, op->name, (void *) op);
op_end = prefix_opcodes + prefix_num_opcodes; op_end = prefix_opcodes + prefix_num_opcodes;
for (op = prefix_opcodes; op < op_end; op++) for (op = prefix_opcodes; op < op_end; op++)
@ -1727,22 +1717,12 @@ ppc_setup_opcodes (void)
if ((ppc_cpu & op->flags) != 0 if ((ppc_cpu & op->flags) != 0
&& !(ppc_cpu & op->deprecated)) && !(ppc_cpu & op->deprecated))
{ str_hash_insert (ppc_hash, op->name, (void *) op);
const char *retval;
retval = hash_insert (ppc_hash, op->name, (void *) op);
if (retval != NULL)
{
as_bad (_("duplicate instruction %s"),
op->name);
bad_insn = TRUE;
}
}
} }
if ((ppc_cpu & PPC_OPCODE_ANY) != 0) if ((ppc_cpu & PPC_OPCODE_ANY) != 0)
for (op = prefix_opcodes; op < op_end; op++) for (op = prefix_opcodes; op < op_end; op++)
hash_insert (ppc_hash, op->name, (void *) op); str_hash_insert (ppc_hash, op->name, (void *) op);
op_end = vle_opcodes + vle_num_opcodes; op_end = vle_opcodes + vle_num_opcodes;
for (op = vle_opcodes; op < op_end; op++) for (op = vle_opcodes; op < op_end; op++)
@ -1772,17 +1752,7 @@ ppc_setup_opcodes (void)
if ((ppc_cpu & op->flags) != 0 if ((ppc_cpu & op->flags) != 0
&& !(ppc_cpu & op->deprecated)) && !(ppc_cpu & op->deprecated))
{ str_hash_insert (ppc_hash, op->name, (void *) op);
const char *retval;
retval = hash_insert (ppc_hash, op->name, (void *) op);
if (retval != NULL)
{
as_bad (_("duplicate instruction %s"),
op->name);
bad_insn = TRUE;
}
}
} }
/* SPE2 instructions */ /* SPE2 instructions */
@ -1816,40 +1786,21 @@ ppc_setup_opcodes (void)
} }
if ((ppc_cpu & op->flags) != 0 && !(ppc_cpu & op->deprecated)) if ((ppc_cpu & op->flags) != 0 && !(ppc_cpu & op->deprecated))
{ str_hash_insert (ppc_hash, op->name, (void *) op);
const char *retval;
retval = hash_insert (ppc_hash, op->name, (void *) op);
if (retval != NULL)
{
as_bad (_("duplicate instruction %s"),
op->name);
bad_insn = TRUE;
}
}
} }
for (op = spe2_opcodes; op < op_end; op++) for (op = spe2_opcodes; op < op_end; op++)
hash_insert (ppc_hash, op->name, (void *) op); str_hash_insert (ppc_hash, op->name, (void *) op);
} }
/* Insert the macros into a hash table. */ /* Insert the macros into a hash table. */
ppc_macro_hash = hash_new (); ppc_macro_hash = str_htab_create ();
macro_end = powerpc_macros + powerpc_num_macros; macro_end = powerpc_macros + powerpc_num_macros;
for (macro = powerpc_macros; macro < macro_end; macro++) for (macro = powerpc_macros; macro < macro_end; macro++)
{ {
if ((macro->flags & ppc_cpu) != 0 || (ppc_cpu & PPC_OPCODE_ANY) != 0) if ((macro->flags & ppc_cpu) != 0 || (ppc_cpu & PPC_OPCODE_ANY) != 0)
{ str_hash_insert (ppc_macro_hash, macro->name, (void *) macro);
const char *retval;
retval = hash_insert (ppc_macro_hash, macro->name, (void *) macro);
if (retval != (const char *) NULL)
{
as_bad (_("duplicate macro %s"), macro->name);
bad_insn = TRUE;
}
}
} }
if (bad_insn) if (bad_insn)
@ -3160,12 +3111,12 @@ md_assemble (char *str)
*s++ = '\0'; *s++ = '\0';
/* Look up the opcode in the hash table. */ /* Look up the opcode in the hash table. */
opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, str); opcode = (const struct powerpc_opcode *) str_hash_find (ppc_hash, str);
if (opcode == (const struct powerpc_opcode *) NULL) if (opcode == (const struct powerpc_opcode *) NULL)
{ {
const struct powerpc_macro *macro; const struct powerpc_macro *macro;
macro = (const struct powerpc_macro *) hash_find (ppc_macro_hash, str); macro = (const struct powerpc_macro *) str_hash_find (ppc_macro_hash, str);
if (macro == (const struct powerpc_macro *) NULL) if (macro == (const struct powerpc_macro *) NULL)
as_bad (_("unrecognized opcode: `%s'"), str); as_bad (_("unrecognized opcode: `%s'"), str);
else else

View file

@ -132,14 +132,14 @@ typedef struct pru_insn_info
} pru_insn_infoS; } pru_insn_infoS;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *pru_opcode_hash = NULL; static htab_t pru_opcode_hash = NULL;
#define pru_opcode_lookup(NAME) \ #define pru_opcode_lookup(NAME) \
((struct pru_opcode *) hash_find (pru_opcode_hash, (NAME))) ((struct pru_opcode *) str_hash_find (pru_opcode_hash, (NAME)))
/* Register hash table. */ /* Register hash table. */
static struct hash_control *pru_reg_hash = NULL; static htab_t pru_reg_hash = NULL;
#define pru_reg_lookup(NAME) \ #define pru_reg_lookup(NAME) \
((struct pru_reg *) hash_find (pru_reg_hash, (NAME))) ((struct pru_reg *) str_hash_find (pru_reg_hash, (NAME)))
/* The known current alignment of the current section. */ /* The known current alignment of the current section. */
static int pru_current_align; static int pru_current_align;
@ -1557,41 +1557,19 @@ void
md_begin (void) md_begin (void)
{ {
int i; int i;
const char *inserted;
/* Create and fill a hashtable for the PRU opcodes, registers and /* Create and fill a hashtable for the PRU opcodes, registers and
arguments. */ arguments. */
pru_opcode_hash = hash_new (); pru_opcode_hash = str_htab_create ();
pru_reg_hash = hash_new (); pru_reg_hash = str_htab_create ();
for (i = 0; i < NUMOPCODES; ++i) for (i = 0; i < NUMOPCODES; ++i)
{ str_hash_insert (pru_opcode_hash, pru_opcodes[i].name,
inserted
= hash_insert (pru_opcode_hash, pru_opcodes[i].name,
(PTR) & pru_opcodes[i]); (PTR) & pru_opcodes[i]);
if (inserted != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
pru_opcodes[i].name, inserted);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("Broken assembler. No assembly attempted."));
}
}
for (i = 0; i < pru_num_regs; ++i) for (i = 0; i < pru_num_regs; ++i)
{ str_hash_insert (pru_reg_hash, pru_regs[i].name,
inserted
= hash_insert (pru_reg_hash, pru_regs[i].name,
(PTR) & pru_regs[i]); (PTR) & pru_regs[i]);
if (inserted != NULL)
{
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
pru_regs[i].name, inserted);
/* Probably a memory allocation problem? Give up now. */
as_fatal (_("Broken assembler. No assembly attempted."));
}
}
linkrelax = pru_opt.link_relax; linkrelax = pru_opt.link_relax;
/* Initialize the alignment data. */ /* Initialize the alignment data. */
@ -1811,8 +1789,8 @@ md_pcrel_from (fixS *fixP ATTRIBUTE_UNUSED)
void void
md_end (void) md_end (void)
{ {
hash_die (pru_opcode_hash); htab_delete (pru_opcode_hash);
hash_die (pru_reg_hash); htab_delete (pru_reg_hash);
} }
symbolS * symbolS *

View file

@ -242,28 +242,18 @@ riscv_multi_subset_supports (enum riscv_insn_class insn_class)
} }
/* Handle of the extension with version hash table. */ /* 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) init_ext_version_hash (const struct riscv_ext_version *table)
{ {
int i = 0; int i = 0;
struct hash_control *hash = hash_new (); htab_t hash = str_htab_create ();
while (table[i].name) while (table[i].name)
{ {
const char *name = table[i].name; const char *name = table[i].name;
const char *hash_error = str_hash_insert (hash, name, (void *) &table[i]);
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;
}
i++; i++;
while (table[i].name 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) if (name == NULL || default_isa_spec == ISA_SPEC_CLASS_NONE)
return; 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 while (ext
&& ext->name && ext->name
&& strcmp (ext->name, name) == 0) && strcmp (ext->name, name) == 0)
@ -321,10 +311,10 @@ riscv_set_arch (const char *s)
} }
/* Handle of the OPCODE hash table. */ /* 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. */ /* 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 /* This array holds the chars that always start a comment. If the
pre-processor is disabled, these aren't very useful */ 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. */ /* 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. */ /* Initialization for hash table of opcode name. */
static void static void
init_opcode_names_hash (void) init_opcode_names_hash (void)
{ {
const char *retval;
const struct opcode_name_t *opcode; const struct opcode_name_t *opcode;
for (opcode = &opcode_name_list[0]; opcode->name != NULL; ++opcode) for (opcode = &opcode_name_list[0]; opcode->name != NULL; ++opcode)
{ str_hash_insert (opcode_names_hash, opcode->name, (void *)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);
}
} }
/* Find `s` is a valid opcode name or not, /* Find `s` is a valid opcode name or not,
@ -598,7 +581,7 @@ opcode_name_lookup (char **s)
save_c = *e; save_c = *e;
*e = '\0'; *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. */ /* Advance to next token if one was recognized. */
if (o) if (o)
@ -619,8 +602,8 @@ enum reg_class
RCLASS_CSR RCLASS_CSR
}; };
static struct hash_control *reg_names_hash = NULL; static htab_t reg_names_hash = NULL;
static struct hash_control *csr_extra_hash = NULL; static htab_t csr_extra_hash = NULL;
#define ENCODE_REG_HASH(cls, n) \ #define ENCODE_REG_HASH(cls, n) \
((void *)(uintptr_t)((n) * RCLASS_MAX + (cls) + 1)) ((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) hash_reg_name (enum reg_class class, const char *name, unsigned n)
{ {
void *hash = ENCODE_REG_HASH (class, n); void *hash = ENCODE_REG_HASH (class, n);
const char *retval = hash_insert (reg_names_hash, name, hash); str_hash_insert (reg_names_hash, name, hash);
if (retval != NULL)
as_fatal (_("internal error: can't hash `%s': %s"), name, retval);
} }
static void static void
@ -655,11 +635,10 @@ riscv_init_csr_hash (const char *name,
enum riscv_priv_spec_class abort_version) enum riscv_priv_spec_class abort_version)
{ {
struct riscv_csr_extra *entry, *pre_entry; struct riscv_csr_extra *entry, *pre_entry;
const char *hash_error = NULL;
bfd_boolean need_enrty = TRUE; bfd_boolean need_enrty = TRUE;
pre_entry = NULL; 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) while (need_enrty && entry != NULL)
{ {
if (entry->csr_class == class 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 Otherwise, attach the extra information to the entry which is already
in the hash table. */ in the hash table. */
if (pre_entry == NULL) if (pre_entry == NULL)
{ str_hash_insert (csr_extra_hash, name, (void *) entry);
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."));
}
}
else else
pre_entry->next = entry; pre_entry->next = entry;
} }
@ -772,7 +742,7 @@ static unsigned int
reg_csr_lookup_internal (const char *s) reg_csr_lookup_internal (const char *s)
{ {
struct riscv_csr_extra *r = 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) if (r == NULL)
return -1U; return -1U;
@ -794,7 +764,7 @@ reg_lookup_internal (const char *s, enum reg_class class)
if (class == RCLASS_CSR) if (class == RCLASS_CSR)
return reg_csr_lookup_internal (s); 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) if (r == NULL || DECODE_REG_CLASS (r) != class)
return -1; return -1;
@ -1018,26 +988,17 @@ struct percent_op_match
/* Common hash table initialization function for /* Common hash table initialization function for
instruction and .insn directive. */ instruction and .insn directive. */
static struct hash_control * static htab_t
init_opcode_hash (const struct riscv_opcode *opcodes, init_opcode_hash (const struct riscv_opcode *opcodes,
bfd_boolean insn_directive_p) bfd_boolean insn_directive_p)
{ {
int i = 0; int i = 0;
int length; int length;
struct hash_control *hash = hash_new (); htab_t hash = str_htab_create ();
while (opcodes[i].name) while (opcodes[i].name)
{ {
const char *name = opcodes[i].name; const char *name = opcodes[i].name;
const char *hash_error = str_hash_insert (hash, name, (void *) &opcodes[i]);
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."));
}
do do
{ {
@ -1074,7 +1035,7 @@ md_begin (void)
op_hash = init_opcode_hash (riscv_opcodes, FALSE); op_hash = init_opcode_hash (riscv_opcodes, FALSE);
insn_type_hash = init_opcode_hash (riscv_insn_types, TRUE); 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_numeric, NGPR);
hash_reg_names (RCLASS_GPR, riscv_gpr_names_abi, NGPR); hash_reg_names (RCLASS_GPR, riscv_gpr_names_abi, NGPR);
hash_reg_names (RCLASS_FPR, riscv_fpr_names_numeric, NFPR); hash_reg_names (RCLASS_FPR, riscv_fpr_names_numeric, NFPR);
@ -1083,7 +1044,7 @@ md_begin (void)
hash_reg_name (RCLASS_GPR, "fp", 8); hash_reg_name (RCLASS_GPR, "fp", 8);
/* Create and insert CSR hash tables. */ /* 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) \ #define DECLARE_CSR(name, num, class, define_version, abort_version) \
riscv_init_csr_hash (#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) \ #define DECLARE_CSR_ALIAS(name, num, class, define_version, abort_version) \
@ -1091,7 +1052,7 @@ md_begin (void)
#include "opcode/riscv-opc.h" #include "opcode/riscv-opc.h"
#undef DECLARE_CSR #undef DECLARE_CSR
opcode_names_hash = hash_new (); opcode_names_hash = str_htab_create ();
init_opcode_names_hash (); init_opcode_names_hash ();
/* Set the default alignment for the text section. */ /* 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); va_start (args, fmt);
r = BFD_RELOC_UNUSED; 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); gas_assert (mo);
/* Find a non-RVC variant of the instruction. append_insn will compress /* 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 * static const char *
riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, 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; char *s;
const char *args; 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; bfd_boolean insn_with_csr = FALSE;
/* Parse the name of the instruction. Terminate the string if whitespace /* 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) for (s = str; *s != '\0'; ++s)
if (ISSPACE (*s)) if (ISSPACE (*s))
{ {
@ -1821,7 +1782,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
break; break;
} }
insn = (struct riscv_opcode *) hash_find (hash, str); insn = (struct riscv_opcode *) str_hash_find (hash, str);
argsStart = s; argsStart = s;
for ( ; insn && insn->name && strcmp (insn->name, str) == 0; insn++) for ( ; insn && insn->name && strcmp (insn->name, str) == 0; insn++)

View file

@ -197,10 +197,10 @@ register_name (expressionS *expressionP)
/* Local variables. */ /* Local variables. */
/* Opformat hash table. */ /* Opformat hash table. */
static struct hash_control *s390_opformat_hash; static htab_t s390_opformat_hash;
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *s390_opcode_hash = NULL; static htab_t s390_opcode_hash = NULL;
/* Flags to set in the elf header */ /* Flags to set in the elf header */
static flagword s390_flags = 0; static flagword s390_flags = 0;
@ -494,13 +494,12 @@ s390_setup_opcodes (void)
const struct s390_opcode *op; const struct s390_opcode *op;
const struct s390_opcode *op_end; const struct s390_opcode *op_end;
bfd_boolean dup_insn = FALSE; bfd_boolean dup_insn = FALSE;
const char *retval;
if (s390_opcode_hash != NULL) if (s390_opcode_hash != NULL)
hash_die (s390_opcode_hash); htab_delete (s390_opcode_hash);
/* Insert the opcodes into a hash table. */ /* Insert the opcodes into a hash table. */
s390_opcode_hash = hash_new (); s390_opcode_hash = str_htab_create ();
op_end = s390_opcodes + s390_num_opcodes; op_end = s390_opcodes + s390_num_opcodes;
for (op = s390_opcodes; op < op_end; op++) for (op = s390_opcodes; op < op_end; op++)
@ -532,15 +531,7 @@ s390_setup_opcodes (void)
use_opcode = ((f & current_flags) == f); use_opcode = ((f & current_flags) == f);
} }
if (use_opcode) if (use_opcode)
{ str_hash_insert (s390_opcode_hash, op->name, (void *) op);
retval = hash_insert (s390_opcode_hash, op->name, (void *) op);
if (retval != (const char *) NULL)
{
as_bad (_("Internal assembler error for instruction %s"),
op->name);
dup_insn = TRUE;
}
}
while (op < op_end - 1 && strcmp (op->name, op[1].name) == 0) while (op < op_end - 1 && strcmp (op->name, op[1].name) == 0)
op++; op++;
@ -559,7 +550,6 @@ md_begin (void)
{ {
const struct s390_opcode *op; const struct s390_opcode *op;
const struct s390_opcode *op_end; const struct s390_opcode *op_end;
const char *retval;
/* Give a warning if the combination -m64-bit and -Aesa is used. */ /* Give a warning if the combination -m64-bit and -Aesa is used. */
if (s390_arch_size == 64 && current_cpu < S390_OPCODE_Z900) if (s390_arch_size == 64 && current_cpu < S390_OPCODE_Z900)
@ -572,16 +562,11 @@ md_begin (void)
bfd_set_private_flags (stdoutput, s390_flags); bfd_set_private_flags (stdoutput, s390_flags);
/* Insert the opcode formats into a hash table. */ /* Insert the opcode formats into a hash table. */
s390_opformat_hash = hash_new (); s390_opformat_hash = str_htab_create ();
op_end = s390_opformats + s390_num_opformats; op_end = s390_opformats + s390_num_opformats;
for (op = s390_opformats; op < op_end; op++) for (op = s390_opformats; op < op_end; op++)
{ str_hash_insert (s390_opformat_hash, op->name, (void *) op);
retval = hash_insert (s390_opformat_hash, op->name, (void *) op);
if (retval != (const char *) NULL)
as_bad (_("Internal assembler error for instruction format %s"),
op->name);
}
s390_setup_opcodes (); s390_setup_opcodes ();
@ -1693,7 +1678,7 @@ md_assemble (char *str)
*s++ = '\0'; *s++ = '\0';
/* Look up the opcode in the hash table. */ /* Look up the opcode in the hash table. */
opcode = (struct s390_opcode *) hash_find (s390_opcode_hash, str); opcode = (struct s390_opcode *) str_hash_find (s390_opcode_hash, str);
if (opcode == (const struct s390_opcode *) NULL) if (opcode == (const struct s390_opcode *) NULL)
{ {
as_bad (_("Unrecognized opcode: `%s'"), str); as_bad (_("Unrecognized opcode: `%s'"), str);
@ -1761,7 +1746,7 @@ s390_insn (int ignore ATTRIBUTE_UNUSED)
/* Look up the opcode in the hash table. */ /* Look up the opcode in the hash table. */
opformat = (struct s390_opcode *) opformat = (struct s390_opcode *)
hash_find (s390_opformat_hash, input_line_pointer); str_hash_find (s390_opformat_hash, input_line_pointer);
if (opformat == (const struct s390_opcode *) NULL) if (opformat == (const struct s390_opcode *) NULL)
{ {
as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer); as_bad (_("Unrecognized opcode format: `%s'"), input_line_pointer);

View file

@ -459,7 +459,7 @@ struct s3_reg_map
{ {
const struct s3_reg_entry *names; const struct s3_reg_entry *names;
int max_regno; int max_regno;
struct hash_control *htab; htab_t htab;
const char *expected; const char *expected;
}; };
@ -470,8 +470,8 @@ static struct s3_reg_map s3_all_reg_maps[] =
{s3_score_crn_table, 31, NULL, N_("S+core co-processor register expected")}, {s3_score_crn_table, 31, NULL, N_("S+core co-processor register expected")},
}; };
static struct hash_control *s3_score_ops_hsh = NULL; static htab_t s3_score_ops_hsh = NULL;
static struct hash_control *s3_dependency_insn_hsh = NULL; static htab_t s3_dependency_insn_hsh = NULL;
struct s3_datafield_range struct s3_datafield_range
@ -1027,7 +1027,7 @@ s3_end_of_line (char *str)
} }
static int static int
s3_score_reg_parse (char **ccp, struct hash_control *htab) s3_score_reg_parse (char **ccp, htab_t htab)
{ {
char *start = *ccp; char *start = *ccp;
char c; char c;
@ -1044,7 +1044,7 @@ s3_score_reg_parse (char **ccp, struct hash_control *htab)
c = *p++; c = *p++;
*--p = 0; *--p = 0;
reg = (struct s3_reg_entry *) hash_find (htab, start); reg = (struct s3_reg_entry *) str_hash_find (htab, start);
*p = c; *p = c;
if (reg) if (reg)
@ -2203,7 +2203,7 @@ s3_dependency_type_from_insn (char *insn_name)
const struct s3_insn_to_dependency *tmp; const struct s3_insn_to_dependency *tmp;
strcpy (name, insn_name); strcpy (name, insn_name);
tmp = (const struct s3_insn_to_dependency *) hash_find (s3_dependency_insn_hsh, name); tmp = (const struct s3_insn_to_dependency *) str_hash_find (s3_dependency_insn_hsh, name);
if (tmp) if (tmp)
return tmp->type; return tmp->type;
@ -2662,7 +2662,7 @@ s3_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p)
c = *p; c = *p;
*p = '\0'; *p = '\0';
opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator); opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh, operator);
*p = c; *p = c;
memset (&s3_inst, '\0', sizeof (s3_inst)); memset (&s3_inst, '\0', sizeof (s3_inst));
@ -2708,7 +2708,7 @@ s3_parse_48_inst (char *insnstr, bfd_boolean gen_frag_p)
c = *p; c = *p;
*p = '\0'; *p = '\0';
opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator); opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh, operator);
*p = c; *p = c;
memset (&s3_inst, '\0', sizeof (s3_inst)); memset (&s3_inst, '\0', sizeof (s3_inst));
@ -6251,7 +6251,7 @@ s3_s_score_lcomm (int bytes_p)
} }
static void static void
s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab) s3_insert_reg (const struct s3_reg_entry *r, htab_t htab)
{ {
int i = 0; int i = 0;
int len = strlen (r->name) + 2; int len = strlen (r->name) + 2;
@ -6265,8 +6265,8 @@ s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
} }
buf2[i] = '\0'; buf2[i] = '\0';
hash_insert (htab, buf, (void *) r); str_hash_insert (htab, buf, (void *) r);
hash_insert (htab, buf2, (void *) r); str_hash_insert (htab, buf2, (void *) r);
} }
static void static void
@ -6274,7 +6274,7 @@ s3_build_reg_hsh (struct s3_reg_map *map)
{ {
const struct s3_reg_entry *r; const struct s3_reg_entry *r;
if ((map->htab = hash_new ()) == NULL) if ((map->htab = str_htab_create ()) == NULL)
{ {
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
} }
@ -6309,7 +6309,7 @@ s3_build_score_ops_hsh (void)
new_opcode->relax_value = insn->relax_value; new_opcode->relax_value = insn->relax_value;
new_opcode->type = insn->type; new_opcode->type = insn->type;
new_opcode->bitmask = insn->bitmask; new_opcode->bitmask = insn->bitmask;
hash_insert (s3_score_ops_hsh, new_opcode->template_name, str_hash_insert (s3_score_ops_hsh, new_opcode->template_name,
(void *) new_opcode); (void *) new_opcode);
} }
} }
@ -6336,7 +6336,7 @@ s3_build_dependency_insn_hsh (void)
strcpy (buf, tmp->insn_name); strcpy (buf, tmp->insn_name);
new_i2n->insn_name = buf; new_i2n->insn_name = buf;
new_i2n->type = tmp->type; new_i2n->type = tmp->type;
hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name, str_hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name,
(void *) new_i2n); (void *) new_i2n);
} }
} }
@ -6505,12 +6505,12 @@ s3_begin (void)
segT seg; segT seg;
subsegT subseg; subsegT subseg;
if ((s3_score_ops_hsh = hash_new ()) == NULL) if ((s3_score_ops_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
s3_build_score_ops_hsh (); s3_build_score_ops_hsh ();
if ((s3_dependency_insn_hsh = hash_new ()) == NULL) if ((s3_dependency_insn_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
s3_build_dependency_insn_hsh (); s3_build_dependency_insn_hsh ();

View file

@ -520,7 +520,7 @@ struct s7_reg_map
{ {
const struct s7_reg_entry *names; const struct s7_reg_entry *names;
int max_regno; int max_regno;
struct hash_control *htab; htab_t htab;
const char *expected; const char *expected;
}; };
@ -531,8 +531,8 @@ static struct s7_reg_map s7_all_reg_maps[] =
{s7_score_crn_table, 31, NULL, N_("S+core co-processor register expected")}, {s7_score_crn_table, 31, NULL, N_("S+core co-processor register expected")},
}; };
static struct hash_control *s7_score_ops_hsh = NULL; static htab_t s7_score_ops_hsh = NULL;
static struct hash_control *s7_dependency_insn_hsh = NULL; static htab_t s7_dependency_insn_hsh = NULL;
struct s7_datafield_range struct s7_datafield_range
@ -1112,7 +1112,7 @@ s7_end_of_line (char *str)
} }
static int static int
s7_score_reg_parse (char **ccp, struct hash_control *htab) s7_score_reg_parse (char **ccp, htab_t htab)
{ {
char *start = *ccp; char *start = *ccp;
char c; char c;
@ -1129,7 +1129,7 @@ s7_score_reg_parse (char **ccp, struct hash_control *htab)
c = *p++; c = *p++;
*--p = 0; *--p = 0;
reg = (struct s7_reg_entry *) hash_find (htab, start); reg = (struct s7_reg_entry *) str_hash_find (htab, start);
*p = c; *p = c;
if (reg) if (reg)
@ -2321,7 +2321,7 @@ s7_dependency_type_from_insn (char *insn_name)
const struct s7_insn_to_dependency *tmp; const struct s7_insn_to_dependency *tmp;
strcpy (name, insn_name); strcpy (name, insn_name);
tmp = (const struct s7_insn_to_dependency *) hash_find (s7_dependency_insn_hsh, name); tmp = (const struct s7_insn_to_dependency *) str_hash_find (s7_dependency_insn_hsh, name);
if (tmp) if (tmp)
return tmp->type; return tmp->type;
@ -2789,7 +2789,7 @@ s7_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p)
c = *p; c = *p;
*p = '\0'; *p = '\0';
opcode = (const struct s7_asm_opcode *) hash_find (s7_score_ops_hsh, operator); opcode = (const struct s7_asm_opcode *) str_hash_find (s7_score_ops_hsh, operator);
*p = c; *p = c;
memset (&s7_inst, '\0', sizeof (s7_inst)); memset (&s7_inst, '\0', sizeof (s7_inst));
@ -5103,7 +5103,7 @@ s7_build_score_ops_hsh (void)
new_opcode->relax_value = insn->relax_value; new_opcode->relax_value = insn->relax_value;
new_opcode->type = insn->type; new_opcode->type = insn->type;
new_opcode->bitmask = insn->bitmask; new_opcode->bitmask = insn->bitmask;
hash_insert (s7_score_ops_hsh, new_opcode->template_name, str_hash_insert (s7_score_ops_hsh, new_opcode->template_name,
(void *) new_opcode); (void *) new_opcode);
} }
} }
@ -5130,7 +5130,7 @@ s7_build_dependency_insn_hsh (void)
strcpy (insn_name, tmp->insn_name); strcpy (insn_name, tmp->insn_name);
new_i2d->insn_name = insn_name; new_i2d->insn_name = insn_name;
new_i2d->type = tmp->type; new_i2d->type = tmp->type;
hash_insert (s7_dependency_insn_hsh, new_i2d->insn_name, str_hash_insert (s7_dependency_insn_hsh, new_i2d->insn_name,
(void *) new_i2d); (void *) new_i2d);
} }
} }
@ -5345,7 +5345,7 @@ s7_parse_pce_inst (char *insnstr)
static void static void
s7_insert_reg (const struct s7_reg_entry *r, struct hash_control *htab) s7_insert_reg (const struct s7_reg_entry *r, htab_t htab)
{ {
int i = 0; int i = 0;
int len = strlen (r->name) + 2; int len = strlen (r->name) + 2;
@ -5359,8 +5359,8 @@ s7_insert_reg (const struct s7_reg_entry *r, struct hash_control *htab)
} }
buf2[i] = '\0'; buf2[i] = '\0';
hash_insert (htab, buf, (void *) r); str_hash_insert (htab, buf, (void *) r);
hash_insert (htab, buf2, (void *) r); str_hash_insert (htab, buf2, (void *) r);
} }
static void static void
@ -5368,7 +5368,7 @@ s7_build_reg_hsh (struct s7_reg_map *map)
{ {
const struct s7_reg_entry *r; const struct s7_reg_entry *r;
if ((map->htab = hash_new ()) == NULL) if ((map->htab = str_htab_create ()) == NULL)
{ {
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
} }
@ -6115,12 +6115,12 @@ s7_begin (void)
segT seg; segT seg;
subsegT subseg; subsegT subseg;
if ((s7_score_ops_hsh = hash_new ()) == NULL) if ((s7_score_ops_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
s7_build_score_ops_hsh (); s7_build_score_ops_hsh ();
if ((s7_dependency_insn_hsh = hash_new ()) == NULL) if ((s7_dependency_insn_hsh = str_htab_create ()) == NULL)
as_fatal (_("virtual memory exhausted")); as_fatal (_("virtual memory exhausted"));
s7_build_dependency_insn_hsh (); s7_build_dependency_insn_hsh ();

View file

@ -240,7 +240,7 @@ const relax_typeS md_relax_table[C (END, 0)] = {
#undef EMPTY #undef EMPTY
static struct hash_control *opcode_hash_control; /* Opcode mnemonics */ static htab_t opcode_hash_control; /* Opcode mnemonics */
#ifdef OBJ_ELF #ifdef OBJ_ELF
@ -564,7 +564,7 @@ md_begin (void)
= preset_target_arch ? preset_target_arch : arch_sh_up & ~arch_sh_has_dsp; = preset_target_arch ? preset_target_arch : arch_sh_up & ~arch_sh_has_dsp;
valid_arch = target_arch; valid_arch = target_arch;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
/* Insert unique names into hash table. */ /* Insert unique names into hash table. */
for (opcode = sh_table; opcode->name; opcode++) for (opcode = sh_table; opcode->name; opcode++)
@ -574,7 +574,7 @@ md_begin (void)
if (!SH_MERGE_ARCH_SET_VALID (opcode->arch, target_arch)) if (!SH_MERGE_ARCH_SET_VALID (opcode->arch, target_arch))
continue; continue;
prev_name = opcode->name; prev_name = opcode->name;
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
} }
} }
} }
@ -2196,7 +2196,7 @@ find_cooked_opcode (char **str_p)
if (nlen == 0) if (nlen == 0)
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
return (sh_opcode_info *) hash_find (opcode_hash_control, name); return (sh_opcode_info *) str_hash_find (opcode_hash_control, name);
} }
/* Assemble a parallel processing insn. */ /* Assemble a parallel processing insn. */

View file

@ -126,7 +126,7 @@ int sparc_cie_data_alignment;
#endif #endif
/* Handle of the OPCODE hash table. */ /* Handle of the OPCODE hash table. */
static struct hash_control *op_hash; static htab_t op_hash;
static void s_data1 (void); static void s_data1 (void);
static void s_seg (int); static void s_seg (int);
@ -941,7 +941,6 @@ cmp_perc_entry (const void *parg, const void *qarg)
void void
md_begin (void) md_begin (void)
{ {
const char *retval = NULL;
int lose = 0; int lose = 0;
unsigned int i = 0; unsigned int i = 0;
@ -952,18 +951,12 @@ md_begin (void)
init_default_arch (); init_default_arch ();
sparc_cie_data_alignment = sparc_arch_size == 64 ? -8 : -4; sparc_cie_data_alignment = sparc_arch_size == 64 ? -8 : -4;
op_hash = hash_new (); op_hash = str_htab_create ();
while (i < (unsigned int) sparc_num_opcodes) while (i < (unsigned int) sparc_num_opcodes)
{ {
const char *name = sparc_opcodes[i].name; const char *name = sparc_opcodes[i].name;
retval = hash_insert (op_hash, name, (void *) &sparc_opcodes[i]); str_hash_insert (op_hash, name, (void *) &sparc_opcodes[i]);
if (retval != NULL)
{
as_bad (_("Internal error: can't hash `%s': %s\n"),
sparc_opcodes[i].name, retval);
lose = 1;
}
do do
{ {
if (sparc_opcodes[i].match & sparc_opcodes[i].lose) if (sparc_opcodes[i].match & sparc_opcodes[i].lose)
@ -984,7 +977,7 @@ md_begin (void)
const char *name = ((sparc_arch_size == 32) const char *name = ((sparc_arch_size == 32)
? native_op_table[i].name32 ? native_op_table[i].name32
: native_op_table[i].name64); : native_op_table[i].name64);
insn = (struct sparc_opcode *) hash_find (op_hash, name); insn = (struct sparc_opcode *) str_hash_find (op_hash, name);
if (insn == NULL) if (insn == NULL)
{ {
as_bad (_("Internal error: can't find opcode `%s' for `%s'\n"), as_bad (_("Internal error: can't find opcode `%s' for `%s'\n"),
@ -992,16 +985,8 @@ md_begin (void)
lose = 1; lose = 1;
} }
else else
{ str_hash_insert (op_hash, native_op_table[i].name,
retval = hash_insert (op_hash, native_op_table[i].name,
(void *) insn); (void *) insn);
if (retval != NULL)
{
as_bad (_("Internal error: can't hash `%s': %s\n"),
sparc_opcodes[i].name, retval);
lose = 1;
}
}
} }
if (lose) if (lose)
@ -1759,7 +1744,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
*pinsn = NULL; *pinsn = NULL;
return special_case; return special_case;
} }
insn = (struct sparc_opcode *) hash_find (op_hash, str); insn = (struct sparc_opcode *) str_hash_find (op_hash, str);
*pinsn = insn; *pinsn = insn;
if (insn == NULL) if (insn == NULL)
{ {

View file

@ -57,7 +57,7 @@ static void spu_brinfo (int);
static void spu_cons (int); static void spu_cons (int);
extern char *myname; extern char *myname;
static struct hash_control *op_hash = NULL; static htab_t op_hash = NULL;
/* These bits should be turned off in the first address of every segment */ /* These bits should be turned off in the first address of every segment */
int md_seg_align = 7; int md_seg_align = 7;
@ -110,26 +110,19 @@ unsigned int brinfo;
void void
md_begin (void) md_begin (void)
{ {
const char *retval = NULL;
int i; int i;
/* initialize hash table */ /* initialize hash table */
op_hash = hash_new (); op_hash = str_htab_create ();
/* loop until you see the end of the list */ /* loop until you see the end of the list */
for (i = 0; i < spu_num_opcodes; i++) for (i = 0; i < spu_num_opcodes; i++)
{
/* hash each mnemonic and record its position */ /* hash each mnemonic and record its position */
if (str_hash_find (op_hash, spu_opcodes[i].mnemonic) == NULL)
retval = hash_insert (op_hash, spu_opcodes[i].mnemonic, str_hash_insert (op_hash, spu_opcodes[i].mnemonic,
(void *) &spu_opcodes[i]); (void *) &spu_opcodes[i]);
if (retval != NULL && strcmp (retval, "exists") != 0)
as_fatal (_("Can't hash instruction '%s':%s"),
spu_opcodes[i].mnemonic, retval);
}
} }
const char *md_shortopts = ""; const char *md_shortopts = "";
@ -285,7 +278,7 @@ md_assemble (char *op)
/* try to find the instruction in the hash table */ /* try to find the instruction in the hash table */
if ((format = (struct spu_opcode *) hash_find (op_hash, op)) == NULL) if ((format = (struct spu_opcode *) str_hash_find (op_hash, op)) == NULL)
{ {
as_bad (_("Invalid mnemonic '%s'"), op); as_bad (_("Invalid mnemonic '%s'"), op);
return; return;

View file

@ -99,78 +99,56 @@ debug (const char *string, ...)
} }
/* Hash table for opcode lookup. */ /* Hash table for opcode lookup. */
static struct hash_control *op_hash; static htab_t op_hash;
/* Hash table for parallel opcode lookup. */ /* Hash table for parallel opcode lookup. */
static struct hash_control *parop_hash; static htab_t parop_hash;
/* Hash table for register lookup. */ /* Hash table for register lookup. */
static struct hash_control *reg_hash; static htab_t reg_hash;
/* Hash table for indirect addressing lookup. */ /* Hash table for indirect addressing lookup. */
static struct hash_control *ind_hash; static htab_t ind_hash;
void void
md_begin (void) md_begin (void)
{ {
const char *hash_err;
debug ("In md_begin()\n"); debug ("In md_begin()\n");
op_hash = hash_new (); op_hash = str_htab_create ();
{ {
const insn_template *current_optab = tic30_optab; const insn_template *current_optab = tic30_optab;
for (; current_optab < tic30_optab_end; current_optab++) for (; current_optab < tic30_optab_end; current_optab++)
{ str_hash_insert (op_hash, current_optab->name,
hash_err = hash_insert (op_hash, current_optab->name,
(char *) current_optab); (char *) current_optab);
if (hash_err)
as_fatal ("Internal Error: Can't Hash %s: %s",
current_optab->name, hash_err);
}
} }
parop_hash = hash_new (); parop_hash = str_htab_create ();
{ {
const partemplate *current_parop = tic30_paroptab; const partemplate *current_parop = tic30_paroptab;
for (; current_parop < tic30_paroptab_end; current_parop++) for (; current_parop < tic30_paroptab_end; current_parop++)
{ str_hash_insert (parop_hash, current_parop->name,
hash_err = hash_insert (parop_hash, current_parop->name,
(char *) current_parop); (char *) current_parop);
if (hash_err)
as_fatal ("Internal Error: Can't Hash %s: %s",
current_parop->name, hash_err);
}
} }
reg_hash = hash_new (); reg_hash = str_htab_create ();
{ {
const reg *current_reg = tic30_regtab; const reg *current_reg = tic30_regtab;
for (; current_reg < tic30_regtab_end; current_reg++) for (; current_reg < tic30_regtab_end; current_reg++)
{ str_hash_insert (reg_hash, current_reg->name,
hash_err = hash_insert (reg_hash, current_reg->name,
(char *) current_reg); (char *) current_reg);
if (hash_err)
as_fatal ("Internal Error: Can't Hash %s: %s",
current_reg->name, hash_err);
}
} }
ind_hash = hash_new (); ind_hash = str_htab_create ();
{ {
const ind_addr_type *current_ind = tic30_indaddr_tab; const ind_addr_type *current_ind = tic30_indaddr_tab;
for (; current_ind < tic30_indaddrtab_end; current_ind++) for (; current_ind < tic30_indaddrtab_end; current_ind++)
{ str_hash_insert (ind_hash, current_ind->syntax,
hash_err = hash_insert (ind_hash, current_ind->syntax,
(char *) current_ind); (char *) current_ind);
if (hash_err)
as_fatal ("Internal Error: Can't Hash %s: %s",
current_ind->syntax, hash_err);
}
} }
/* Fill in lexical tables: opcode_chars, operand_chars, space_chars. */ /* Fill in lexical tables: opcode_chars, operand_chars, space_chars. */
@ -476,7 +454,7 @@ tic30_operand (char *token)
&& (*(token + count) == 'r' || *(token + count) == 'R')) && (*(token + count) == 'r' || *(token + count) == 'R'))
{ {
/* AR reference is found, so get its number and remove /* AR reference is found, so get its number and remove
it from the buffer so it can pass through hash_find(). */ it from the buffer so it can pass through str_hash_find(). */
if (found_ar) if (found_ar)
{ {
as_bad (_("More than one AR register found in indirect reference")); as_bad (_("More than one AR register found in indirect reference"));
@ -538,7 +516,7 @@ tic30_operand (char *token)
return NULL; return NULL;
} }
ind_addr_op = (ind_addr_type *) hash_find (ind_hash, ind_buffer); ind_addr_op = (ind_addr_type *) str_hash_find (ind_hash, ind_buffer);
if (ind_addr_op) if (ind_addr_op)
{ {
debug ("Found indirect reference: %s\n", ind_addr_op->syntax); debug ("Found indirect reference: %s\n", ind_addr_op->syntax);
@ -577,7 +555,7 @@ tic30_operand (char *token)
} }
else else
{ {
reg *regop = (reg *) hash_find (reg_hash, token); reg *regop = (reg *) str_hash_find (reg_hash, token);
if (regop) if (regop)
{ {
@ -674,7 +652,7 @@ tic30_parallel_insn (char *token)
/* Find instruction. */ /* Find instruction. */
save_char = *current_posn; save_char = *current_posn;
*current_posn = '\0'; *current_posn = '\0';
p_opcode = (partemplate *) hash_find (parop_hash, token); p_opcode = (partemplate *) str_hash_find (parop_hash, token);
if (p_opcode) if (p_opcode)
{ {
debug ("Found instruction %s\n", p_opcode->name); debug ("Found instruction %s\n", p_opcode->name);
@ -719,7 +697,7 @@ tic30_parallel_insn (char *token)
debug ("first_opcode = %s\n", first_opcode); debug ("first_opcode = %s\n", first_opcode);
debug ("second_opcode = %s\n", second_opcode); debug ("second_opcode = %s\n", second_opcode);
sprintf (token, "q_%s_%s", second_opcode, first_opcode); sprintf (token, "q_%s_%s", second_opcode, first_opcode);
p_opcode = (partemplate *) hash_find (parop_hash, token); p_opcode = (partemplate *) str_hash_find (parop_hash, token);
if (p_opcode) if (p_opcode)
{ {
@ -1466,7 +1444,7 @@ md_assemble (char *line)
/* Find instruction. */ /* Find instruction. */
save_char = *current_posn; save_char = *current_posn;
*current_posn = '\0'; *current_posn = '\0';
op = (insn_template *) hash_find (op_hash, token_start); op = (insn_template *) str_hash_find (op_hash, token_start);
if (op) if (op)
{ {
debug ("Found instruction %s\n", op->name); debug ("Found instruction %s\n", op->name);

View file

@ -53,10 +53,10 @@
#define TIC4X_ALT_SYNTAX #define TIC4X_ALT_SYNTAX
/* Handle of the inst mnemonic hash table. */ /* Handle of the inst mnemonic hash table. */
static struct hash_control *tic4x_op_hash = NULL; static htab_t tic4x_op_hash = NULL;
/* Handle asg pseudo. */ /* Handle asg pseudo. */
static struct hash_control *tic4x_asg_hash = NULL; static htab_t tic4x_asg_hash = NULL;
static unsigned int tic4x_cpu = 0; /* Default to TMS320C40. */ static unsigned int tic4x_cpu = 0; /* Default to TMS320C40. */
static unsigned int tic4x_revision = 0; /* CPU revision */ static unsigned int tic4x_revision = 0; /* CPU revision */
@ -727,10 +727,7 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
c = get_symbol_name (&name); /* Get terminator. */ c = get_symbol_name (&name); /* Get terminator. */
str = xstrdup (str); str = xstrdup (str);
name = xstrdup (name); name = xstrdup (name);
if (hash_find (tic4x_asg_hash, name)) str_hash_insert (tic4x_asg_hash, name, str);
hash_replace (tic4x_asg_hash, name, (void *) str);
else
hash_insert (tic4x_asg_hash, name, (void *) str);
(void) restore_line_pointer (c); (void) restore_line_pointer (c);
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
@ -1209,23 +1206,17 @@ tic4x_init_symbols (void)
} }
/* Insert a new instruction template into hash table. */ /* Insert a new instruction template into hash table. */
static int static void
tic4x_inst_insert (const tic4x_inst_t *inst) tic4x_inst_insert (const tic4x_inst_t *inst)
{ {
static char prev_name[16]; static char prev_name[16];
const char *retval = NULL;
/* Only insert the first name if have several similar entries. */ /* Only insert the first name if have several similar entries. */
if (!strcmp (inst->name, prev_name) || inst->name[0] == '\0') if (!strcmp (inst->name, prev_name) || inst->name[0] == '\0')
return 1; return;
retval = hash_insert (tic4x_op_hash, inst->name, (void *) inst); str_hash_insert (tic4x_op_hash, inst->name, (void *) inst);
if (retval != NULL)
fprintf (stderr, "internal error: can't hash `%s': %s\n",
inst->name, retval);
else
strcpy (prev_name, inst->name); strcpy (prev_name, inst->name);
return retval == NULL;
} }
/* Make a new instruction template. */ /* Make a new instruction template. */
@ -1258,13 +1249,12 @@ tic4x_inst_make (const char *name, unsigned long opcode, const char *args)
} }
/* Add instruction template, creating dynamic templates as required. */ /* Add instruction template, creating dynamic templates as required. */
static int static void
tic4x_inst_add (const tic4x_inst_t *insts) tic4x_inst_add (const tic4x_inst_t *insts)
{ {
const char *s = insts->name; const char *s = insts->name;
char *d; char *d;
unsigned int i; unsigned int i;
int ok = 1;
char name[16]; char name[16];
d = name; d = name;
@ -1272,7 +1262,7 @@ tic4x_inst_add (const tic4x_inst_t *insts)
/* We do not care about INSNs that is not a part of our /* We do not care about INSNs that is not a part of our
oplevel setting. */ oplevel setting. */
if ((insts->oplevel & tic4x_oplevel) == 0) if ((insts->oplevel & tic4x_oplevel) == 0)
return ok; return;
while (1) while (1)
{ {
@ -1296,8 +1286,8 @@ tic4x_inst_add (const tic4x_inst_t *insts)
*e = '\0'; *e = '\0';
/* If instruction found then have already processed it. */ /* If instruction found then have already processed it. */
if (hash_find (tic4x_op_hash, name)) if (str_hash_find (tic4x_op_hash, name))
return 1; return;
do do
{ {
@ -1306,18 +1296,17 @@ tic4x_inst_add (const tic4x_inst_t *insts)
(*s == 'B' ? 16 : 23)), (*s == 'B' ? 16 : 23)),
insts[k].args); insts[k].args);
if (k == 0) /* Save strcmp() with following func. */ if (k == 0) /* Save strcmp() with following func. */
ok &= tic4x_inst_insert (inst); tic4x_inst_insert (inst);
k++; k++;
} }
while (!strcmp (insts->name, while (!strcmp (insts->name,
insts[k].name)); insts[k].name));
} }
return ok; return;
break;
case '\0': case '\0':
return tic4x_inst_insert (insts); tic4x_inst_insert (insts);
break; return;
default: default:
*d++ = *s++; *d++ = *s++;
@ -1332,7 +1321,6 @@ tic4x_inst_add (const tic4x_inst_t *insts)
void void
md_begin (void) md_begin (void)
{ {
int ok = 1;
unsigned int i; unsigned int i;
/* Setup the proper opcode level according to the /* Setup the proper opcode level according to the
@ -1364,21 +1352,18 @@ md_begin (void)
tic4x_oplevel |= OP_IDLE2; tic4x_oplevel |= OP_IDLE2;
/* Create hash table for mnemonics. */ /* Create hash table for mnemonics. */
tic4x_op_hash = hash_new (); tic4x_op_hash = str_htab_create ();
/* Create hash table for asg pseudo. */ /* Create hash table for asg pseudo. */
tic4x_asg_hash = hash_new (); tic4x_asg_hash = str_htab_create ();
/* Add mnemonics to hash table, expanding conditional mnemonics on fly. */ /* Add mnemonics to hash table, expanding conditional mnemonics on fly. */
for (i = 0; i < tic4x_num_insts; i++) for (i = 0; i < tic4x_num_insts; i++)
ok &= tic4x_inst_add (tic4x_insts + i); tic4x_inst_add (tic4x_insts + i);
/* Create dummy inst to avoid errors accessing end of table. */ /* Create dummy inst to avoid errors accessing end of table. */
tic4x_inst_make ("", 0, ""); tic4x_inst_make ("", 0, "");
if (!ok)
as_fatal ("Broken assembler. No assembly attempted.");
/* Add registers to symbol table. */ /* Add registers to symbol table. */
tic4x_init_regtable (); tic4x_init_regtable ();
@ -1509,7 +1494,7 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
c = get_symbol_name (&str); /* Get terminator. */ c = get_symbol_name (&str); /* Get terminator. */
new_pointer = input_line_pointer; new_pointer = input_line_pointer;
if (strlen (str) && (entry = hash_find (tic4x_asg_hash, str)) != NULL) if (strlen (str) && (entry = str_hash_find (tic4x_asg_hash, str)) != NULL)
{ {
(void) restore_line_pointer (c); (void) restore_line_pointer (c);
input_line_pointer = (char *) entry; input_line_pointer = (char *) entry;
@ -2444,7 +2429,7 @@ md_assemble (char *str)
/* Skip past instruction mnemonic. */ /* Skip past instruction mnemonic. */
while (*s && *s != ' ') while (*s && *s != ' ')
s++; s++;
if (*s) /* Null terminate for hash_find. */ if (*s) /* Null terminate for str_hash_find. */
*s++ = '\0'; /* and skip past null. */ *s++ = '\0'; /* and skip past null. */
len = strlen (insn->name); len = strlen (insn->name);
snprintf (insn->name + len, TIC4X_NAME_MAX - len, "_%s", str); snprintf (insn->name + len, TIC4X_NAME_MAX - len, "_%s", str);
@ -2465,7 +2450,7 @@ md_assemble (char *str)
if (insn->in_use) if (insn->in_use)
{ {
if ((insn->inst = (struct tic4x_inst *) if ((insn->inst = (struct tic4x_inst *)
hash_find (tic4x_op_hash, insn->name)) == NULL) str_hash_find (tic4x_op_hash, insn->name)) == NULL)
{ {
as_bad (_("Unknown opcode `%s'."), insn->name); as_bad (_("Unknown opcode `%s'."), insn->name);
insn->parallel = 0; insn->parallel = 0;
@ -2508,7 +2493,7 @@ md_assemble (char *str)
s = str; s = str;
while (*s && *s != ' ') /* Skip past instruction mnemonic. */ while (*s && *s != ' ') /* Skip past instruction mnemonic. */
s++; s++;
if (*s) /* Null terminate for hash_find. */ if (*s) /* Null terminate for str_hash_find. */
*s++ = '\0'; /* and skip past null. */ *s++ = '\0'; /* and skip past null. */
strncpy (insn->name, str, TIC4X_NAME_MAX - 1); strncpy (insn->name, str, TIC4X_NAME_MAX - 1);
insn->name[TIC4X_NAME_MAX - 1] = '\0'; insn->name[TIC4X_NAME_MAX - 1] = '\0';

View file

@ -181,12 +181,12 @@ static symbolS *last_label_seen = NULL;
/* This ensures that all new labels are unique. */ /* This ensures that all new labels are unique. */
static int local_label_id; static int local_label_id;
static struct hash_control *subsym_recurse_hash; /* Prevent infinite recurse. */ static htab_t subsym_recurse_hash; /* Prevent infinite recurse. */
static struct hash_control *math_hash; /* Built-in math functions. */ static htab_t math_hash; /* Built-in math functions. */
/* Allow maximum levels of macro nesting; level 0 is the main substitution /* Allow maximum levels of macro nesting; level 0 is the main substitution
symbol table. The other assembler only does 32 levels, so there! */ symbol table. The other assembler only does 32 levels, so there! */
#define MAX_SUBSYM_HASH 100 #define MAX_SUBSYM_HASH 100
static struct hash_control *subsym_hash[MAX_SUBSYM_HASH]; static htab_t subsym_hash[MAX_SUBSYM_HASH];
/* Keep track of local labels so we can substitute them before GAS sees them /* Keep track of local labels so we can substitute them before GAS sees them
since macros use their own 'namespace' for local labels, use a separate hash since macros use their own 'namespace' for local labels, use a separate hash
@ -197,18 +197,18 @@ static struct hash_control *subsym_hash[MAX_SUBSYM_HASH];
We use our own macro nesting counter, since GAS overloads it when expanding We use our own macro nesting counter, since GAS overloads it when expanding
other things (like conditionals and repeat loops). */ other things (like conditionals and repeat loops). */
static int macro_level = 0; static int macro_level = 0;
static struct hash_control *local_label_hash[100]; static htab_t local_label_hash[100];
/* Keep track of struct/union tags. */ /* Keep track of struct/union tags. */
static struct hash_control *stag_hash; static htab_t stag_hash;
static struct hash_control *op_hash; static htab_t op_hash;
static struct hash_control *parop_hash; static htab_t parop_hash;
static struct hash_control *reg_hash; static htab_t reg_hash;
static struct hash_control *mmreg_hash; static htab_t mmreg_hash;
static struct hash_control *cc_hash; static htab_t cc_hash;
static struct hash_control *cc2_hash; static htab_t cc2_hash;
static struct hash_control *cc3_hash; static htab_t cc3_hash;
static struct hash_control *sbit_hash; static htab_t sbit_hash;
static struct hash_control *misc_symbol_hash; static htab_t misc_symbol_hash;
/* Only word (et al.), align, or conditionals are allowed within /* Only word (et al.), align, or conditionals are allowed within
.struct/.union. */ .struct/.union. */
@ -569,7 +569,7 @@ stag_add_field_symbols (struct stag *stag,
replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name, replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name,
name + strlen (S_GET_NAME (rootsym)), NULL); name + strlen (S_GET_NAME (rootsym)), NULL);
hash_insert (subsym_hash[0], name, replacement); str_hash_insert (subsym_hash[0], name, replacement);
} }
/* Recurse if the field is a structure. /* Recurse if the field is a structure.
@ -740,7 +740,7 @@ tic54x_endstruct (int is_union)
/* Nested .structs don't get put in the stag table. */ /* Nested .structs don't get put in the stag table. */
if (current_stag->outer == NULL) if (current_stag->outer == NULL)
{ {
hash_insert (stag_hash, current_stag->name, current_stag); str_hash_insert (stag_hash, current_stag->name, current_stag);
stag_add_field_symbols (current_stag, path, stag_add_field_symbols (current_stag, path,
S_GET_VALUE (current_stag->sym), S_GET_VALUE (current_stag->sym),
NULL, NULL); NULL, NULL);
@ -770,7 +770,7 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED)
{ {
char *name; char *name;
int c = get_symbol_name (&name); int c = get_symbol_name (&name);
struct stag *stag = (struct stag *) hash_find (stag_hash, name); struct stag *stag = (struct stag *) str_hash_find (stag_hash, name);
if (!stag) if (!stag)
{ {
@ -1117,11 +1117,14 @@ tic54x_global (int type)
/* Remove the symbol from the local label hash lookup. */ /* Remove the symbol from the local label hash lookup. */
static void static int
tic54x_remove_local_label (const char *key, void *value ATTRIBUTE_UNUSED) tic54x_remove_local_label (void **slot, void *arg ATTRIBUTE_UNUSED)
{ {
void *elem = hash_delete (local_label_hash[macro_level], key, FALSE); string_tuple_t *tuple = *((string_tuple_t **) slot);
void *elem = str_hash_find (local_label_hash[macro_level], tuple->key);
str_hash_delete (local_label_hash[macro_level], tuple->key);
free (elem); free (elem);
return 0;
} }
/* Reset all local labels. */ /* Reset all local labels. */
@ -1129,7 +1132,7 @@ tic54x_remove_local_label (const char *key, void *value ATTRIBUTE_UNUSED)
static void static void
tic54x_clear_local_labels (int ignored ATTRIBUTE_UNUSED) tic54x_clear_local_labels (int ignored ATTRIBUTE_UNUSED)
{ {
hash_traverse (local_label_hash[macro_level], tic54x_remove_local_label); htab_traverse (local_label_hash[macro_level], tic54x_remove_local_label, NULL);
} }
/* .text /* .text
@ -2235,7 +2238,7 @@ tic54x_var (int ignore ATTRIBUTE_UNUSED)
c = get_symbol_name (&name); c = get_symbol_name (&name);
/* .var symbols start out with a null string. */ /* .var symbols start out with a null string. */
name = xstrdup (name); name = xstrdup (name);
hash_insert (subsym_hash[macro_level], name, empty); str_hash_insert (subsym_hash[macro_level], name, empty);
c = restore_line_pointer (c); c = restore_line_pointer (c);
if (c == ',') if (c == ',')
{ {
@ -2503,8 +2506,8 @@ tic54x_macro_start (void)
as_fatal (_("Macro nesting is too deep")); as_fatal (_("Macro nesting is too deep"));
return; return;
} }
subsym_hash[macro_level] = hash_new (); subsym_hash[macro_level] = str_htab_create ();
local_label_hash[macro_level] = hash_new (); local_label_hash[macro_level] = str_htab_create ();
} }
void void
@ -2520,7 +2523,7 @@ tic54x_macro_info (const macro_entry *macro)
name[entry->name.len] = '\0'; name[entry->name.len] = '\0';
value[entry->actual.len] = '\0'; value[entry->actual.len] = '\0';
hash_insert (subsym_hash[macro_level], name, value); str_hash_insert (subsym_hash[macro_level], name, value);
} }
} }
@ -2529,9 +2532,9 @@ tic54x_macro_info (const macro_entry *macro)
void void
tic54x_macro_end (void) tic54x_macro_end (void)
{ {
hash_die (subsym_hash[macro_level]); htab_delete (subsym_hash[macro_level]);
subsym_hash[macro_level] = NULL; subsym_hash[macro_level] = NULL;
hash_die (local_label_hash[macro_level]); htab_delete (local_label_hash[macro_level]);
local_label_hash[macro_level] = NULL; local_label_hash[macro_level] = NULL;
--macro_level; --macro_level;
} }
@ -2685,9 +2688,9 @@ subsym_isname (char *a, char *ignore ATTRIBUTE_UNUSED)
static int static int
subsym_isreg (char *a, char *ignore ATTRIBUTE_UNUSED) subsym_isreg (char *a, char *ignore ATTRIBUTE_UNUSED)
{ {
if (hash_find (reg_hash, a)) if (str_hash_find (reg_hash, a))
return 1; return 1;
if (hash_find (mmreg_hash, a)) if (str_hash_find (mmreg_hash, a))
return 1; return 1;
return 0; return 0;
} }
@ -2697,7 +2700,7 @@ subsym_isreg (char *a, char *ignore ATTRIBUTE_UNUSED)
static int static int
subsym_structsz (char *name, char *ignore ATTRIBUTE_UNUSED) subsym_structsz (char *name, char *ignore ATTRIBUTE_UNUSED)
{ {
struct stag *stag = (struct stag *) hash_find (stag_hash, name); struct stag *stag = (struct stag *) str_hash_find (stag_hash, name);
if (stag) if (stag)
return stag->size; return stag->size;
@ -2965,7 +2968,6 @@ md_begin (void)
tic54x_symbol *sym; tic54x_symbol *sym;
const subsym_proc_entry *subsym_proc; const subsym_proc_entry *subsym_proc;
const math_proc_entry *math_proc; const math_proc_entry *math_proc;
const char *hash_err;
char **symname; char **symname;
char *TIC54X_DIR = getenv ("TIC54X_DIR"); char *TIC54X_DIR = getenv ("TIC54X_DIR");
char *A_DIR = TIC54X_DIR ? TIC54X_DIR : getenv ("A_DIR"); char *A_DIR = TIC54X_DIR ? TIC54X_DIR : getenv ("A_DIR");
@ -2989,27 +2991,21 @@ md_begin (void)
while (tmp != NULL); while (tmp != NULL);
} }
op_hash = hash_new (); op_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_optab; tm->name; tm++) for (tm = (insn_template *) tic54x_optab; tm->name; tm++)
{ {
if (hash_find (op_hash, tm->name)) if (str_hash_find (op_hash, tm->name))
continue; continue;
hash_err = hash_insert (op_hash, tm->name, (char *) tm); str_hash_insert (op_hash, tm->name, (char *) tm);
if (hash_err)
as_fatal ("Internal Error: Can't hash %s: %s",
tm->name, hash_err);
} }
parop_hash = hash_new (); parop_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++) for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++)
{ {
if (hash_find (parop_hash, tm->name)) if (str_hash_find (parop_hash, tm->name))
continue; continue;
hash_err = hash_insert (parop_hash, tm->name, (char *) tm); str_hash_insert (parop_hash, tm->name, (char *) tm);
if (hash_err)
as_fatal ("Internal Error: Can't hash %s: %s",
tm->name, hash_err);
} }
reg_hash = hash_new (); reg_hash = str_htab_create ();
for (sym = (tic54x_symbol *) regs; sym->name; sym++) for (sym = (tic54x_symbol *) regs; sym->name; sym++)
{ {
/* Add basic registers to the symbol table. */ /* Add basic registers to the symbol table. */
@ -3017,54 +3013,54 @@ md_begin (void)
(valueT) sym->value, &zero_address_frag); (valueT) sym->value, &zero_address_frag);
SF_SET_LOCAL (symbolP); SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP); symbol_table_insert (symbolP);
hash_err = hash_insert (reg_hash, sym->name, (char *) sym); str_hash_insert (reg_hash, sym->name, (char *) sym);
} }
for (sym = (tic54x_symbol *) mmregs; sym->name; sym++) for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
hash_err = hash_insert (reg_hash, sym->name, (char *) sym); str_hash_insert (reg_hash, sym->name, (char *) sym);
mmreg_hash = hash_new (); mmreg_hash = str_htab_create ();
for (sym = (tic54x_symbol *) mmregs; sym->name; sym++) for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
hash_err = hash_insert (mmreg_hash, sym->name, (char *) sym); str_hash_insert (mmreg_hash, sym->name, (char *) sym);
cc_hash = hash_new (); cc_hash = str_htab_create ();
for (sym = (tic54x_symbol *) condition_codes; sym->name; sym++) for (sym = (tic54x_symbol *) condition_codes; sym->name; sym++)
hash_err = hash_insert (cc_hash, sym->name, (char *) sym); str_hash_insert (cc_hash, sym->name, (char *) sym);
cc2_hash = hash_new (); cc2_hash = str_htab_create ();
for (sym = (tic54x_symbol *) cc2_codes; sym->name; sym++) for (sym = (tic54x_symbol *) cc2_codes; sym->name; sym++)
hash_err = hash_insert (cc2_hash, sym->name, (char *) sym); str_hash_insert (cc2_hash, sym->name, (char *) sym);
cc3_hash = hash_new (); cc3_hash = str_htab_create ();
for (sym = (tic54x_symbol *) cc3_codes; sym->name; sym++) for (sym = (tic54x_symbol *) cc3_codes; sym->name; sym++)
hash_err = hash_insert (cc3_hash, sym->name, (char *) sym); str_hash_insert (cc3_hash, sym->name, (char *) sym);
sbit_hash = hash_new (); sbit_hash = str_htab_create ();
for (sym = (tic54x_symbol *) status_bits; sym->name; sym++) for (sym = (tic54x_symbol *) status_bits; sym->name; sym++)
hash_err = hash_insert (sbit_hash, sym->name, (char *) sym); str_hash_insert (sbit_hash, sym->name, (char *) sym);
misc_symbol_hash = hash_new (); misc_symbol_hash = str_htab_create ();
for (symname = (char **) misc_symbols; *symname; symname++) for (symname = (char **) misc_symbols; *symname; symname++)
hash_err = hash_insert (misc_symbol_hash, *symname, *symname); str_hash_insert (misc_symbol_hash, *symname, *symname);
/* Only the base substitution table and local label table are initialized; /* Only the base substitution table and local label table are initialized;
the others (for local macro substitution) get instantiated as needed. */ the others (for local macro substitution) get instantiated as needed. */
local_label_hash[0] = hash_new (); local_label_hash[0] = str_htab_create ();
subsym_hash[0] = hash_new (); subsym_hash[0] = str_htab_create ();
for (subsym_proc = subsym_procs; subsym_proc->name; subsym_proc++) for (subsym_proc = subsym_procs; subsym_proc->name; subsym_proc++)
hash_err = hash_insert (subsym_hash[0], subsym_proc->name, str_hash_insert (subsym_hash[0], subsym_proc->name,
(char *) subsym_proc); (char *) subsym_proc);
math_hash = hash_new (); math_hash = str_htab_create ();
for (math_proc = math_procs; math_proc->name; math_proc++) for (math_proc = math_procs; math_proc->name; math_proc++)
{ {
/* Insert into the main subsym hash for recognition; insert into /* Insert into the main subsym hash for recognition; insert into
the math hash to actually store information. */ the math hash to actually store information. */
hash_err = hash_insert (subsym_hash[0], math_proc->name, str_hash_insert (subsym_hash[0], math_proc->name,
(char *) math_proc); (char *) math_proc);
hash_err = hash_insert (math_hash, math_proc->name, str_hash_insert (math_hash, math_proc->name,
(char *) math_proc); (char *) math_proc);
} }
subsym_recurse_hash = hash_new (); subsym_recurse_hash = str_htab_create ();
stag_hash = hash_new (); stag_hash = str_htab_create ();
} }
static int static int
@ -3257,7 +3253,7 @@ is_mmreg (struct opstruct *operand)
{ {
return (is_absolute (operand) return (is_absolute (operand)
|| is_immediate (operand) || is_immediate (operand)
|| hash_find (mmreg_hash, operand->buf) != 0); || str_hash_find (mmreg_hash, operand->buf) != 0);
} }
static int static int
@ -3301,13 +3297,13 @@ is_type (struct opstruct *operand, enum optype type)
return strncasecmp ("ar", operand->buf, 2) == 0 return strncasecmp ("ar", operand->buf, 2) == 0
&& ISDIGIT (operand->buf[2]); && ISDIGIT (operand->buf[2]);
case OP_SBIT: case OP_SBIT:
return hash_find (sbit_hash, operand->buf) != 0 || is_absolute (operand); return str_hash_find (sbit_hash, operand->buf) != 0 || is_absolute (operand);
case OP_CC: case OP_CC:
return hash_find (cc_hash, operand->buf) != 0; return str_hash_find (cc_hash, operand->buf) != 0;
case OP_CC2: case OP_CC2:
return hash_find (cc2_hash, operand->buf) != 0; return str_hash_find (cc2_hash, operand->buf) != 0;
case OP_CC3: case OP_CC3:
return hash_find (cc3_hash, operand->buf) != 0 return str_hash_find (cc3_hash, operand->buf) != 0
|| is_immediate (operand) || is_absolute (operand); || is_immediate (operand) || is_absolute (operand);
case OP_16: case OP_16:
return (is_immediate (operand) || is_absolute (operand)) return (is_immediate (operand) || is_absolute (operand))
@ -3649,7 +3645,7 @@ encode_integer (tic54x_insn *insn,
static int static int
encode_condition (tic54x_insn *insn, struct opstruct *operand) encode_condition (tic54x_insn *insn, struct opstruct *operand)
{ {
tic54x_symbol *cc = (tic54x_symbol *) hash_find (cc_hash, operand->buf); tic54x_symbol *cc = (tic54x_symbol *) str_hash_find (cc_hash, operand->buf);
if (!cc) if (!cc)
{ {
as_bad (_("Unrecognized condition code \"%s\""), operand->buf); as_bad (_("Unrecognized condition code \"%s\""), operand->buf);
@ -3709,7 +3705,7 @@ encode_condition (tic54x_insn *insn, struct opstruct *operand)
static int static int
encode_cc3 (tic54x_insn *insn, struct opstruct *operand) encode_cc3 (tic54x_insn *insn, struct opstruct *operand)
{ {
tic54x_symbol *cc3 = (tic54x_symbol *) hash_find (cc3_hash, operand->buf); tic54x_symbol *cc3 = (tic54x_symbol *) str_hash_find (cc3_hash, operand->buf);
int value = cc3 ? cc3->value : operand->exp.X_add_number << 8; int value = cc3 ? cc3->value : operand->exp.X_add_number << 8;
if ((value & 0x0300) != value) if ((value & 0x0300) != value)
@ -3738,7 +3734,7 @@ encode_arx (tic54x_insn *insn, struct opstruct *operand)
static int static int
encode_cc2 (tic54x_insn *insn, struct opstruct *operand) encode_cc2 (tic54x_insn *insn, struct opstruct *operand)
{ {
tic54x_symbol *cc2 = (tic54x_symbol *) hash_find (cc2_hash, operand->buf); tic54x_symbol *cc2 = (tic54x_symbol *) str_hash_find (cc2_hash, operand->buf);
if (!cc2) if (!cc2)
{ {
@ -3898,7 +3894,7 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand)
case OP_SBIT: case OP_SBIT:
{ {
tic54x_symbol *sbit = (tic54x_symbol *) tic54x_symbol *sbit = (tic54x_symbol *)
hash_find (sbit_hash, operand->buf); str_hash_find (sbit_hash, operand->buf);
int value = is_absolute (operand) ? int value = is_absolute (operand) ?
operand->exp.X_add_number : (sbit ? sbit->value : -1); operand->exp.X_add_number : (sbit ? sbit->value : -1);
int reg = 0; int reg = 0;
@ -3912,7 +3908,7 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand)
} }
/* Guess the register based on the status bit; "ovb" is the last /* Guess the register based on the status bit; "ovb" is the last
status bit defined for st0. */ status bit defined for st0. */
if (sbit > (tic54x_symbol *) hash_find (sbit_hash, "ovb")) if (sbit > (tic54x_symbol *) str_hash_find (sbit_hash, "ovb"))
reg = 1; reg = 1;
} }
if (value == -1) if (value == -1)
@ -4152,7 +4148,7 @@ optimize_insn (tic54x_insn *insn)
static int static int
tic54x_parse_insn (tic54x_insn *insn, char *line) tic54x_parse_insn (tic54x_insn *insn, char *line)
{ {
insn->tm = (insn_template *) hash_find (op_hash, insn->mnemonic); insn->tm = (insn_template *) str_hash_find (op_hash, insn->mnemonic);
if (!insn->tm) if (!insn->tm)
{ {
as_bad (_("Unrecognized instruction \"%s\""), insn->mnemonic); as_bad (_("Unrecognized instruction \"%s\""), insn->mnemonic);
@ -4175,7 +4171,7 @@ tic54x_parse_insn (tic54x_insn *insn, char *line)
/* SUCCESS! now try some optimizations. */ /* SUCCESS! now try some optimizations. */
if (optimize_insn (insn)) if (optimize_insn (insn))
{ {
insn->tm = (insn_template *) hash_find (op_hash, insn->tm = (insn_template *) str_hash_find (op_hash,
insn->mnemonic); insn->mnemonic);
continue; continue;
} }
@ -4210,7 +4206,7 @@ next_line_shows_parallel (char *next_line)
static int static int
tic54x_parse_parallel_insn_firstline (tic54x_insn *insn, char *line) tic54x_parse_parallel_insn_firstline (tic54x_insn *insn, char *line)
{ {
insn->tm = (insn_template *) hash_find (parop_hash, insn->mnemonic); insn->tm = (insn_template *) str_hash_find (parop_hash, insn->mnemonic);
if (!insn->tm) if (!insn->tm)
{ {
as_bad (_("Unrecognized parallel instruction \"%s\""), as_bad (_("Unrecognized parallel instruction \"%s\""),
@ -4341,17 +4337,8 @@ subsym_create_or_replace (char *name, char *value)
int i; int i;
for (i = macro_level; i > 0; i--) for (i = macro_level; i > 0; i--)
{ str_hash_insert (subsym_hash[i], name, value);
if (hash_find (subsym_hash[i], name)) str_hash_insert (subsym_hash[0], name, value);
{
hash_replace (subsym_hash[i], name, value);
return;
}
}
if (hash_find (subsym_hash[0], name))
hash_replace (subsym_hash[0], name, value);
else
hash_insert (subsym_hash[0], name, value);
} }
/* Look up the substitution string replacement for the given symbol. /* Look up the substitution string replacement for the given symbol.
@ -4361,7 +4348,7 @@ subsym_create_or_replace (char *name, char *value)
static char * static char *
subsym_lookup (char *name, int nest_level) subsym_lookup (char *name, int nest_level)
{ {
char *value = hash_find (subsym_hash[nest_level], name); char *value = str_hash_find (subsym_hash[nest_level], name);
if (value || nest_level == 0) if (value || nest_level == 0)
return value; return value;
@ -4482,7 +4469,7 @@ subsym_substitute (char *line, int forced)
} }
/* Avoid infinite recursion; if a symbol shows up a second time for /* Avoid infinite recursion; if a symbol shows up a second time for
substitution, leave it as is. */ substitution, leave it as is. */
if (hash_find (subsym_recurse_hash, name) == NULL) if (str_hash_find (subsym_recurse_hash, name) == NULL)
value = subsym_lookup (name, macro_level); value = subsym_lookup (name, macro_level);
else else
as_warn (_("%s symbol recursion stopped at " as_warn (_("%s symbol recursion stopped at "
@ -4498,7 +4485,7 @@ subsym_substitute (char *line, int forced)
{ {
/* Use an existing identifier for that label if, available, or /* Use an existing identifier for that label if, available, or
create a new, unique identifier. */ create a new, unique identifier. */
value = hash_find (local_label_hash[macro_level], name); value = str_hash_find (local_label_hash[macro_level], name);
if (value == NULL) if (value == NULL)
{ {
char digit[11]; char digit[11];
@ -4510,7 +4497,7 @@ subsym_substitute (char *line, int forced)
value[strlen (value) - 1] = '\0'; value[strlen (value) - 1] = '\0';
sprintf (digit, ".%d", local_label_id++); sprintf (digit, ".%d", local_label_id++);
strcat (value, digit); strcat (value, digit);
hash_insert (local_label_hash[macro_level], namecopy, value); str_hash_insert (local_label_hash[macro_level], namecopy, value);
} }
/* Indicate where to continue looking for substitutions. */ /* Indicate where to continue looking for substitutions. */
ptr = tail; ptr = tail;
@ -4519,7 +4506,7 @@ subsym_substitute (char *line, int forced)
else if (value != NULL && *name == '$') else if (value != NULL && *name == '$')
{ {
subsym_proc_entry *entry = (subsym_proc_entry *) value; subsym_proc_entry *entry = (subsym_proc_entry *) value;
math_proc_entry *math_entry = hash_find (math_hash, name); math_proc_entry *math_entry = str_hash_find (math_hash, name);
char *arg1, *arg2 = NULL; char *arg1, *arg2 = NULL;
*ptr = c; *ptr = c;
@ -4631,9 +4618,9 @@ subsym_substitute (char *line, int forced)
try to replace a symbol once. */ try to replace a symbol once. */
if (recurse) if (recurse)
{ {
hash_insert (subsym_recurse_hash, name, name); str_hash_insert (subsym_recurse_hash, name, name);
value = subsym_substitute (value, macro_level > 0); value = subsym_substitute (value, macro_level > 0);
hash_delete (subsym_recurse_hash, name, FALSE); str_hash_delete (subsym_recurse_hash, name);
} }
/* Temporarily zero-terminate where the symbol started. */ /* Temporarily zero-terminate where the symbol started. */
@ -5022,19 +5009,19 @@ tic54x_undefined_symbol (char *name)
tic54x_symbol *sym; tic54x_symbol *sym;
/* Not sure how to handle predefined symbols. */ /* Not sure how to handle predefined symbols. */
if ((sym = (tic54x_symbol *) hash_find (cc_hash, name)) != NULL || if ((sym = (tic54x_symbol *) str_hash_find (cc_hash, name)) != NULL ||
(sym = (tic54x_symbol *) hash_find (cc2_hash, name)) != NULL || (sym = (tic54x_symbol *) str_hash_find (cc2_hash, name)) != NULL ||
(sym = (tic54x_symbol *) hash_find (cc3_hash, name)) != NULL || (sym = (tic54x_symbol *) str_hash_find (cc3_hash, name)) != NULL ||
(sym = (tic54x_symbol *) hash_find (misc_symbol_hash, name)) != NULL || (sym = (tic54x_symbol *) str_hash_find (misc_symbol_hash, name)) != NULL ||
(sym = (tic54x_symbol *) hash_find (sbit_hash, name)) != NULL) (sym = (tic54x_symbol *) str_hash_find (sbit_hash, name)) != NULL)
{ {
return symbol_new (name, reg_section, return symbol_new (name, reg_section,
(valueT) sym->value, (valueT) sym->value,
&zero_address_frag); &zero_address_frag);
} }
if ((sym = (tic54x_symbol *) hash_find (reg_hash, name)) != NULL || if ((sym = (tic54x_symbol *) str_hash_find (reg_hash, name)) != NULL ||
(sym = (tic54x_symbol *) hash_find (mmreg_hash, name)) != NULL || (sym = (tic54x_symbol *) str_hash_find (mmreg_hash, name)) != NULL ||
!strcasecmp (name, "a") || !strcasecmp (name, "b")) !strcasecmp (name, "a") || !strcasecmp (name, "b"))
{ {
return symbol_new (name, reg_section, return symbol_new (name, reg_section,

View file

@ -742,7 +742,7 @@ const pseudo_typeS md_pseudo_table[] =
/* Hash table of opcodes. For each opcode name, this stores a pointer /* Hash table of opcodes. For each opcode name, this stores a pointer
to a tic6x_opcode_list listing (in an arbitrary order) all opcode to a tic6x_opcode_list listing (in an arbitrary order) all opcode
table entries with that name. */ table entries with that name. */
static struct hash_control *opcode_hash; static htab_t opcode_hash;
/* Initialize the assembler (called once at assembler startup). */ /* Initialize the assembler (called once at assembler startup). */
@ -757,17 +757,14 @@ md_begin (void)
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0); bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
/* Insert opcodes into the hash table. */ /* Insert opcodes into the hash table. */
opcode_hash = hash_new (); opcode_hash = str_htab_create ();
for (id = 0; id < tic6x_opcode_max; id++) for (id = 0; id < tic6x_opcode_max; id++)
{ {
const char *errmsg;
tic6x_opcode_list *opc = XNEW (tic6x_opcode_list); tic6x_opcode_list *opc = XNEW (tic6x_opcode_list);
opc->id = id; opc->id = id;
opc->next = hash_find (opcode_hash, tic6x_opcode_table[id].name); opc->next = str_hash_find (opcode_hash, tic6x_opcode_table[id].name);
if ((errmsg = hash_jam (opcode_hash, tic6x_opcode_table[id].name, opc)) str_hash_insert (opcode_hash, tic6x_opcode_table[id].name, opc);
!= NULL)
as_fatal ("%s", _(errmsg));
} }
/* Save the current subseg so we can restore it [it's the default one and /* Save the current subseg so we can restore it [it's the default one and
@ -3187,7 +3184,7 @@ md_assemble (char *str)
this_insn_label_list = seginfo->tc_segment_info_data.label_list; this_insn_label_list = seginfo->tc_segment_info_data.label_list;
seginfo->tc_segment_info_data.label_list = NULL; seginfo->tc_segment_info_data.label_list = NULL;
opc_list = hash_find_n (opcode_hash, str, p - str); opc_list = str_hash_find_n (opcode_hash, str, p - str);
if (opc_list == NULL) if (opc_list == NULL)
{ {
char c = *p; char c = *p;

View file

@ -177,13 +177,13 @@ md_show_usage (FILE *stream)
#define O_hw1_last_plt O_md27 #define O_hw1_last_plt O_md27
#define O_hw2_last_plt O_md28 #define O_hw2_last_plt O_md28
static struct hash_control *special_operator_hash; static htab_t special_operator_hash;
/* Hash tables for instruction mnemonic lookup. */ /* Hash tables for instruction mnemonic lookup. */
static struct hash_control *op_hash; static htab_t op_hash;
/* Hash table for spr lookup. */ /* Hash table for spr lookup. */
static struct hash_control *spr_hash; static htab_t spr_hash;
/* True temporarily while parsing an SPR expression. This changes the /* True temporarily while parsing an SPR expression. This changes the
* namespace to include SPR names. */ * namespace to include SPR names. */
@ -231,7 +231,7 @@ static int allow_suspicious_bundles;
for that register (e.g. r63 instead of zero), so we should generate for that register (e.g. r63 instead of zero), so we should generate
a warning. The attempted register number can be found by clearing a warning. The attempted register number can be found by clearing
NONCANONICAL_REG_NAME_FLAG. */ NONCANONICAL_REG_NAME_FLAG. */
static struct hash_control *main_reg_hash; static htab_t main_reg_hash;
/* We cannot unambiguously store a 0 in a hash table and look it up, /* We cannot unambiguously store a 0 in a hash table and look it up,
@ -273,9 +273,9 @@ md_begin (void)
tilegx_cie_data_alignment = (tilegx_arch_size == 64 ? -8 : -4); tilegx_cie_data_alignment = (tilegx_arch_size == 64 ? -8 : -4);
/* Initialize special operator hash table. */ /* Initialize special operator hash table. */
special_operator_hash = hash_new (); special_operator_hash = str_htab_create ();
#define INSERT_SPECIAL_OP(name) \ #define INSERT_SPECIAL_OP(name) \
hash_insert (special_operator_hash, #name, (void *)O_##name) str_hash_insert (special_operator_hash, #name, (void *)O_##name)
INSERT_SPECIAL_OP (hw0); INSERT_SPECIAL_OP (hw0);
INSERT_SPECIAL_OP (hw1); INSERT_SPECIAL_OP (hw1);
@ -285,7 +285,7 @@ md_begin (void)
INSERT_SPECIAL_OP (hw1_last); INSERT_SPECIAL_OP (hw1_last);
INSERT_SPECIAL_OP (hw2_last); INSERT_SPECIAL_OP (hw2_last);
/* hw3_last is a convenience alias for the equivalent hw3. */ /* hw3_last is a convenience alias for the equivalent hw3. */
hash_insert (special_operator_hash, "hw3_last", (void*)O_hw3); str_hash_insert (special_operator_hash, "hw3_last", (void*)O_hw3);
INSERT_SPECIAL_OP (hw0_got); INSERT_SPECIAL_OP (hw0_got);
INSERT_SPECIAL_OP (hw0_last_got); INSERT_SPECIAL_OP (hw0_last_got);
INSERT_SPECIAL_OP (hw1_last_got); INSERT_SPECIAL_OP (hw1_last_got);
@ -310,36 +310,32 @@ md_begin (void)
#undef INSERT_SPECIAL_OP #undef INSERT_SPECIAL_OP
/* Initialize op_hash hash table. */ /* Initialize op_hash hash table. */
op_hash = hash_new (); op_hash = str_htab_create ();
for (op = &tilegx_opcodes[0]; op->name != NULL; op++) for (op = &tilegx_opcodes[0]; op->name != NULL; op++)
{ str_hash_insert (op_hash, op->name, (void *)op);
const char *hash_err = hash_insert (op_hash, op->name, (void *)op);
if (hash_err != NULL)
as_fatal (_("Internal Error: Can't hash %s: %s"), op->name, hash_err);
}
/* Initialize the spr hash table. */ /* Initialize the spr hash table. */
parsing_spr = 0; parsing_spr = 0;
spr_hash = hash_new (); spr_hash = str_htab_create ();
for (i = 0; i < tilegx_num_sprs; i++) for (i = 0; i < tilegx_num_sprs; i++)
hash_insert (spr_hash, tilegx_sprs[i].name, str_hash_insert (spr_hash, tilegx_sprs[i].name,
(void *) &tilegx_sprs[i]); (void *) &tilegx_sprs[i]);
/* Set up the main_reg_hash table. We use this instead of /* Set up the main_reg_hash table. We use this instead of
creating a symbol in the register section to avoid ambiguities creating a symbol in the register section to avoid ambiguities
with labels that have the same names as registers. */ with labels that have the same names as registers. */
main_reg_hash = hash_new (); main_reg_hash = str_htab_create ();
for (i = 0; i < TILEGX_NUM_REGISTERS; i++) for (i = 0; i < TILEGX_NUM_REGISTERS; i++)
{ {
char buf[64]; char buf[64];
hash_insert (main_reg_hash, tilegx_register_names[i], str_hash_insert (main_reg_hash, tilegx_register_names[i],
(void *) (long) (i | CANONICAL_REG_NAME_FLAG)); (void *) (long) (i | CANONICAL_REG_NAME_FLAG));
/* See if we should insert a noncanonical alias, like r63. */ /* See if we should insert a noncanonical alias, like r63. */
sprintf (buf, "r%d", i); sprintf (buf, "r%d", i);
if (strcmp (buf, tilegx_register_names[i]) != 0) if (strcmp (buf, tilegx_register_names[i]) != 0)
hash_insert (main_reg_hash, xstrdup (buf), str_hash_insert (main_reg_hash, xstrdup (buf),
(void *) (long) (i | NONCANONICAL_REG_NAME_FLAG)); (void *) (long) (i | NONCANONICAL_REG_NAME_FLAG));
} }
} }
@ -1013,7 +1009,7 @@ tilegx_parse_name (char *name, expressionS *e, char *nextcharP)
if (parsing_spr) if (parsing_spr)
{ {
void* val = hash_find (spr_hash, name); void* val = str_hash_find (spr_hash, name);
if (val == NULL) if (val == NULL)
return 0; return 0;
@ -1031,7 +1027,7 @@ tilegx_parse_name (char *name, expressionS *e, char *nextcharP)
else else
{ {
/* Look up the operator in our table. */ /* Look up the operator in our table. */
void* val = hash_find (special_operator_hash, name); void* val = str_hash_find (special_operator_hash, name);
if (val == 0) if (val == 0)
return 0; return 0;
op = (operatorT)(long)val; op = (operatorT)(long)val;
@ -1098,7 +1094,7 @@ parse_reg_expression (expressionS* expression)
terminating_char = get_symbol_name (&regname); terminating_char = get_symbol_name (&regname);
pval = hash_find (main_reg_hash, regname); pval = str_hash_find (main_reg_hash, regname);
if (pval == NULL) if (pval == NULL)
as_bad (_("Expected register, got '%s'."), regname); as_bad (_("Expected register, got '%s'."), regname);
@ -1243,7 +1239,7 @@ md_assemble (char *str)
old_char = str[opname_len]; old_char = str[opname_len];
str[opname_len] = '\0'; str[opname_len] = '\0';
op = hash_find(op_hash, str); op = str_hash_find(op_hash, str);
str[opname_len] = old_char; str[opname_len] = old_char;
if (op == NULL) if (op == NULL)
{ {

View file

@ -126,13 +126,13 @@ md_show_usage (FILE *stream)
#define O_tls_gd_add O_md22 #define O_tls_gd_add O_md22
#define O_tls_ie_load O_md23 #define O_tls_ie_load O_md23
static struct hash_control *special_operator_hash; static htab_t special_operator_hash;
/* Hash tables for instruction mnemonic lookup. */ /* Hash tables for instruction mnemonic lookup. */
static struct hash_control *op_hash; static htab_t op_hash;
/* Hash table for spr lookup. */ /* Hash table for spr lookup. */
static struct hash_control *spr_hash; static htab_t spr_hash;
/* True temporarily while parsing an SPR expression. This changes the /* True temporarily while parsing an SPR expression. This changes the
* namespace to include SPR names. */ * namespace to include SPR names. */
@ -181,7 +181,7 @@ static int allow_suspicious_bundles;
for that register (e.g. r63 instead of zero), so we should generate for that register (e.g. r63 instead of zero), so we should generate
a warning. The attempted register number can be found by clearing a warning. The attempted register number can be found by clearing
NONCANONICAL_REG_NAME_FLAG. */ NONCANONICAL_REG_NAME_FLAG. */
static struct hash_control *main_reg_hash; static htab_t main_reg_hash;
/* We cannot unambiguously store a 0 in a hash table and look it up, /* We cannot unambiguously store a 0 in a hash table and look it up,
@ -216,9 +216,9 @@ md_begin (void)
inside_bundle = 0; inside_bundle = 0;
/* Initialize special operator hash table. */ /* Initialize special operator hash table. */
special_operator_hash = hash_new (); special_operator_hash = str_htab_create ();
#define INSERT_SPECIAL_OP(name) \ #define INSERT_SPECIAL_OP(name) \
hash_insert (special_operator_hash, #name, (void *)O_##name) str_hash_insert (special_operator_hash, #name, (void *)O_##name)
INSERT_SPECIAL_OP(lo16); INSERT_SPECIAL_OP(lo16);
INSERT_SPECIAL_OP(hi16); INSERT_SPECIAL_OP(hi16);
@ -246,54 +246,47 @@ md_begin (void)
#undef INSERT_SPECIAL_OP #undef INSERT_SPECIAL_OP
/* Initialize op_hash hash table. */ /* Initialize op_hash hash table. */
op_hash = hash_new (); op_hash = str_htab_create ();
for (op = &tilepro_opcodes[0]; op->name != NULL; op++) for (op = &tilepro_opcodes[0]; op->name != NULL; op++)
{ str_hash_insert (op_hash, op->name, (void *)op);
const char *hash_err = hash_insert (op_hash, op->name, (void *)op);
if (hash_err != NULL)
{
as_fatal (_("Internal Error: Can't hash %s: %s"),
op->name, hash_err);
}
}
/* Initialize the spr hash table. */ /* Initialize the spr hash table. */
parsing_spr = 0; parsing_spr = 0;
spr_hash = hash_new (); spr_hash = str_htab_create ();
for (i = 0; i < tilepro_num_sprs; i++) for (i = 0; i < tilepro_num_sprs; i++)
hash_insert (spr_hash, tilepro_sprs[i].name, str_hash_insert (spr_hash, tilepro_sprs[i].name,
(void *) &tilepro_sprs[i]); (void *) &tilepro_sprs[i]);
/* Set up the main_reg_hash table. We use this instead of /* Set up the main_reg_hash table. We use this instead of
* creating a symbol in the register section to avoid ambiguities * creating a symbol in the register section to avoid ambiguities
* with labels that have the same names as registers. */ * with labels that have the same names as registers. */
main_reg_hash = hash_new (); main_reg_hash = str_htab_create ();
for (i = 0; i < TILEPRO_NUM_REGISTERS; i++) for (i = 0; i < TILEPRO_NUM_REGISTERS; i++)
{ {
char buf[64]; char buf[64];
hash_insert (main_reg_hash, tilepro_register_names[i], str_hash_insert (main_reg_hash, tilepro_register_names[i],
(void *) (long)(i | CANONICAL_REG_NAME_FLAG)); (void *) (long)(i | CANONICAL_REG_NAME_FLAG));
/* See if we should insert a noncanonical alias, like r63. */ /* See if we should insert a noncanonical alias, like r63. */
sprintf (buf, "r%d", i); sprintf (buf, "r%d", i);
if (strcmp (buf, tilepro_register_names[i]) != 0) if (strcmp (buf, tilepro_register_names[i]) != 0)
hash_insert (main_reg_hash, xstrdup (buf), str_hash_insert (main_reg_hash, xstrdup (buf),
(void *) (long)(i | NONCANONICAL_REG_NAME_FLAG)); (void *) (long)(i | NONCANONICAL_REG_NAME_FLAG));
} }
/* Insert obsolete backwards-compatibility register names. */ /* Insert obsolete backwards-compatibility register names. */
hash_insert (main_reg_hash, "io0", str_hash_insert (main_reg_hash, "io0",
(void *) (long) (TREG_IDN0 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_IDN0 | CANONICAL_REG_NAME_FLAG));
hash_insert (main_reg_hash, "io1", str_hash_insert (main_reg_hash, "io1",
(void *) (long) (TREG_IDN1 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_IDN1 | CANONICAL_REG_NAME_FLAG));
hash_insert (main_reg_hash, "us0", str_hash_insert (main_reg_hash, "us0",
(void *) (long) (TREG_UDN0 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_UDN0 | CANONICAL_REG_NAME_FLAG));
hash_insert (main_reg_hash, "us1", str_hash_insert (main_reg_hash, "us1",
(void *) (long) (TREG_UDN1 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_UDN1 | CANONICAL_REG_NAME_FLAG));
hash_insert (main_reg_hash, "us2", str_hash_insert (main_reg_hash, "us2",
(void *) (long) (TREG_UDN2 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_UDN2 | CANONICAL_REG_NAME_FLAG));
hash_insert (main_reg_hash, "us3", str_hash_insert (main_reg_hash, "us3",
(void *) (long) (TREG_UDN3 | CANONICAL_REG_NAME_FLAG)); (void *) (long) (TREG_UDN3 | CANONICAL_REG_NAME_FLAG));
} }
@ -903,7 +896,7 @@ tilepro_parse_name (char *name, expressionS *e, char *nextcharP)
if (parsing_spr) if (parsing_spr)
{ {
void *val = hash_find (spr_hash, name); void *val = str_hash_find (spr_hash, name);
if (val == NULL) if (val == NULL)
return 0; return 0;
@ -922,7 +915,7 @@ tilepro_parse_name (char *name, expressionS *e, char *nextcharP)
else else
{ {
/* Look up the operator in our table. */ /* Look up the operator in our table. */
void *val = hash_find (special_operator_hash, name); void *val = str_hash_find (special_operator_hash, name);
if (val == 0) if (val == 0)
return 0; return 0;
op = (operatorT)(long)val; op = (operatorT)(long)val;
@ -984,7 +977,7 @@ parse_reg_expression (expressionS* expression)
char *regname; char *regname;
char terminating_char = get_symbol_name (&regname); char terminating_char = get_symbol_name (&regname);
void* pval = hash_find (main_reg_hash, regname); void* pval = str_hash_find (main_reg_hash, regname);
if (pval == NULL) if (pval == NULL)
as_bad (_("Expected register, got '%s'."), regname); as_bad (_("Expected register, got '%s'."), regname);
@ -1128,7 +1121,7 @@ md_assemble (char *str)
old_char = str[opname_len]; old_char = str[opname_len];
str[opname_len] = '\0'; str[opname_len] = '\0';
op = hash_find(op_hash, str); op = str_hash_find(op_hash, str);
str[opname_len] = old_char; str[opname_len] = old_char;
if (op == NULL) if (op == NULL)
{ {

View file

@ -599,7 +599,7 @@ const pseudo_typeS md_pseudo_table[] =
}; };
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *v850_hash; static htab_t v850_hash;
/* This table is sorted. Suitable for searching by a binary search. */ /* This table is sorted. Suitable for searching by a binary search. */
static const struct reg_name pre_defined_registers[] = static const struct reg_name pre_defined_registers[] =
@ -1952,7 +1952,7 @@ md_begin (void)
if (soft_float == -1) if (soft_float == -1)
soft_float = machine < bfd_mach_v850e2v3; soft_float = machine < bfd_mach_v850e2v3;
v850_hash = hash_new (); v850_hash = str_htab_create ();
/* Insert unique names into hash table. The V850 instruction set /* Insert unique names into hash table. The V850 instruction set
has many identical opcode names that have different opcodes based has many identical opcode names that have different opcodes based
@ -1964,7 +1964,8 @@ md_begin (void)
if (strcmp (prev_name, op->name)) if (strcmp (prev_name, op->name))
{ {
prev_name = (char *) op->name; prev_name = (char *) op->name;
hash_insert (v850_hash, op->name, (char *) op); if (str_hash_find (v850_hash, op->name) == NULL)
str_hash_insert (v850_hash, op->name, (char *) op);
} }
op++; op++;
} }
@ -2321,7 +2322,7 @@ md_assemble (char *str)
*s++ = '\0'; *s++ = '\0';
/* Find the first opcode with the proper name. */ /* Find the first opcode with the proper name. */
opcode = (struct v850_opcode *) hash_find (v850_hash, str); opcode = (struct v850_opcode *) str_hash_find (v850_hash, str);
if (opcode == NULL) if (opcode == NULL)
{ {
/* xgettext:c-format */ /* xgettext:c-format */

View file

@ -736,7 +736,7 @@ md_ri_to_chars (char *the_bytes, struct reloc_info_generic ri)
source file, and changed the makefile. */ source file, and changed the makefile. */
/* Handle of the OPCODE hash table. */ /* Handle of the OPCODE hash table. */
static struct hash_control *op_hash; static htab_t op_hash;
/* In: 1 character, from "bdfghloqpw" being the data-type of an operand /* In: 1 character, from "bdfghloqpw" being the data-type of an operand
of a vax instruction. of a vax instruction.
@ -950,29 +950,26 @@ vip_op_defaults (const char *immediate, const char *indirect, const char *disple
instruction table. instruction table.
You must nominate metacharacters for eg DEC's "#", "@", "^". */ You must nominate metacharacters for eg DEC's "#", "@", "^". */
static const char * static void
vip_begin (int synthetic_too, /* 1 means include jXXX op-codes. */ vip_begin (int synthetic_too, /* 1 means include jXXX op-codes. */
const char *immediate, const char *immediate,
const char *indirect, const char *indirect,
const char *displen) const char *displen)
{ {
const struct vot *vP; /* scan votstrs */ const struct vot *vP; /* scan votstrs */
const char *retval = 0; /* error text */
op_hash = hash_new (); op_hash = str_htab_create ();
for (vP = votstrs; *vP->vot_name && !retval; vP++) for (vP = votstrs; *vP->vot_name; vP++)
retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail); str_hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
if (synthetic_too) if (synthetic_too)
for (vP = synthetic_votstrs; *vP->vot_name && !retval; vP++) for (vP = synthetic_votstrs; *vP->vot_name; vP++)
retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail); str_hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
#ifndef CONST_TABLE #ifndef CONST_TABLE
vip_op_defaults (immediate, indirect, displen); vip_op_defaults (immediate, indirect, displen);
#endif #endif
return retval;
} }
/* Take 3 char.s, the last of which may be `\0` (non-existent) /* Take 3 char.s, the last of which may be `\0` (non-existent)
@ -1887,7 +1884,7 @@ vip (struct vit *vitP, /* We build an exploded instruction here. */
/* Here with instring pointing to what better be an op-name, and p /* Here with instring pointing to what better be an op-name, and p
pointing to character just past that. pointing to character just past that.
We trust instring points to an op-name, with no whitespace. */ We trust instring points to an op-name, with no whitespace. */
vwP = (struct vot_wot *) hash_find (op_hash, instring); vwP = (struct vot_wot *) str_hash_find (op_hash, instring);
/* Restore char after op-code. */ /* Restore char after op-code. */
*p = c; *p = c;
if (vwP == 0) if (vwP == 0)
@ -1986,8 +1983,7 @@ main (void)
printf ("enter displen symbols eg enter ^ "); printf ("enter displen symbols eg enter ^ ");
gets (my_displen); gets (my_displen);
if (p = vip_begin (mysynth, my_immediate, my_indirect, my_displen)) vip_begin (mysynth, my_immediate, my_indirect, my_displen)
error ("vip_begin=%s", p);
printf ("An empty input line will quit you from the vax instruction parser\n"); printf ("An empty input line will quit you from the vax instruction parser\n");
for (;;) for (;;)
@ -3256,12 +3252,10 @@ md_assemble (char *instruction_string)
void void
md_begin (void) md_begin (void)
{ {
const char *errtxt;
FLONUM_TYPE *fP; FLONUM_TYPE *fP;
int i; int i;
if ((errtxt = vip_begin (1, "$", "*", "`")) != 0) vip_begin (1, "$", "*", "`");
as_fatal (_("VIP_BEGIN error:%s"), errtxt);
for (i = 0, fP = float_operand; for (i = 0, fP = float_operand;
fP < float_operand + VIT_MAX_OPERANDS; fP < float_operand + VIT_MAX_OPERANDS;

View file

@ -92,7 +92,7 @@ const pseudo_typeS md_pseudo_table[] =
/* Opcode hash table. */ /* Opcode hash table. */
static struct hash_control *wasm32_hash; static htab_t wasm32_hash;
struct option md_longopts[] = struct option md_longopts[] =
{ {
@ -158,13 +158,13 @@ md_begin (void)
{ {
struct wasm32_opcode_s *opcode; struct wasm32_opcode_s *opcode;
wasm32_hash = hash_new (); wasm32_hash = str_htab_create ();
/* Insert unique names into hash table. This hash table then /* Insert unique names into hash table. This hash table then
provides a quick index to the first opcode with a particular name provides a quick index to the first opcode with a particular name
in the opcode table. */ in the opcode table. */
for (opcode = wasm32_opcodes; opcode->name; opcode++) for (opcode = wasm32_opcodes; opcode->name; opcode++)
hash_insert (wasm32_hash, opcode->name, (char *) opcode); str_hash_insert (wasm32_hash, opcode->name, (char *) opcode);
linkrelax = 0; linkrelax = 0;
flag_sectname_subst = 1; flag_sectname_subst = 1;
@ -746,7 +746,7 @@ md_assemble (char *str)
if (!op[0]) if (!op[0])
as_bad (_("can't find opcode ")); as_bad (_("can't find opcode "));
opcode = (struct wasm32_opcode_s *) hash_find (wasm32_hash, op); opcode = (struct wasm32_opcode_s *) str_hash_find (wasm32_hash, op);
if (opcode == NULL) if (opcode == NULL)
{ {

View file

@ -113,7 +113,7 @@ static void xgate_scan_operands (struct xgate_opcode *opcode, s_operand []);
static unsigned int xgate_parse_operand (struct xgate_opcode *, int *, int, static unsigned int xgate_parse_operand (struct xgate_opcode *, int *, int,
char **, s_operand); char **, s_operand);
static struct hash_control *xgate_hash; static htab_t xgate_hash;
/* Previous opcode. */ /* Previous opcode. */
static unsigned int prev = 0; static unsigned int prev = 0;
@ -324,7 +324,7 @@ md_begin (void)
op_handles = XNEWVEC (struct xgate_opcode_handle, number_of_op_handles); op_handles = XNEWVEC (struct xgate_opcode_handle, number_of_op_handles);
/* Insert unique opcode names into hash table, aliasing duplicates. */ /* Insert unique opcode names into hash table, aliasing duplicates. */
xgate_hash = hash_new (); xgate_hash = str_htab_create ();
prev_op_name = ""; prev_op_name = "";
for (xgate_opcode_ptr = xgate_op_table, i = 0, j = 0; i < xgate_num_opcodes; for (xgate_opcode_ptr = xgate_op_table, i = 0, j = 0; i < xgate_num_opcodes;
@ -342,7 +342,7 @@ md_begin (void)
j++; j++;
op_handles[j].name = xgate_opcode_ptr->name; op_handles[j].name = xgate_opcode_ptr->name;
op_handles[j].opc0[0] = xgate_opcode_ptr; op_handles[j].opc0[0] = xgate_opcode_ptr;
hash_insert (xgate_hash, (char *) op_handles[j].name, str_hash_insert (xgate_hash, (char *) op_handles[j].name,
(char *) &(op_handles[j])); (char *) &(op_handles[j]));
} }
op_handles[j].number_of_modes = handle_enum; op_handles[j].number_of_modes = handle_enum;
@ -492,7 +492,7 @@ md_assemble (char *input_line)
if (!op_name[0]) if (!op_name[0])
as_bad (_("opcode missing or not found on input line")); as_bad (_("opcode missing or not found on input line"));
if (!(opcode_handle = (struct xgate_opcode_handle *) hash_find (xgate_hash, if (!(opcode_handle = (struct xgate_opcode_handle *) str_hash_find (xgate_hash,
op_name))) op_name)))
{ {
as_bad (_("opcode %s not found in opcode hash table"), op_name); as_bad (_("opcode %s not found in opcode hash table"), op_name);
@ -544,7 +544,7 @@ md_assemble (char *input_line)
p = extract_word (p, op_name, 10); p = extract_word (p, op_name, 10);
if (!(opcode_handle = (struct xgate_opcode_handle *) if (!(opcode_handle = (struct xgate_opcode_handle *)
hash_find (xgate_hash, op_name))) str_hash_find (xgate_hash, op_name)))
{ {
as_bad (_(": processing macro, real opcode handle" as_bad (_(": processing macro, real opcode handle"
" not found in hash")); " not found in hash"));

View file

@ -137,7 +137,7 @@ const char EXP_CHARS[] = "eE";
const char FLT_CHARS[] = "rRsSfFdDxXpP"; const char FLT_CHARS[] = "rRsSfFdDxXpP";
/* Opcode mnemonics. */ /* Opcode mnemonics. */
static struct hash_control *opcode_hash_control; static htab_t opcode_hash_control;
void void
md_begin (void) md_begin (void)
@ -145,13 +145,13 @@ md_begin (void)
const opcode_entry_type *opcode; const opcode_entry_type *opcode;
unsigned int idx = -1u; unsigned int idx = -1u;
opcode_hash_control = hash_new (); opcode_hash_control = str_htab_create ();
for (opcode = z8k_table; opcode->name; opcode++) for (opcode = z8k_table; opcode->name; opcode++)
{ {
/* Only enter unique codes into the table. */ /* Only enter unique codes into the table. */
if (idx != opcode->idx) if (idx != opcode->idx)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode); str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
idx = opcode->idx; idx = opcode->idx;
} }
@ -166,7 +166,7 @@ md_begin (void)
fake_opcode->name = md_pseudo_table[idx].poc_name; fake_opcode->name = md_pseudo_table[idx].poc_name;
fake_opcode->func = (void *) (md_pseudo_table + idx); fake_opcode->func = (void *) (md_pseudo_table + idx);
fake_opcode->opcode = 250; fake_opcode->opcode = 250;
hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode); str_hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
} }
} }
@ -1224,9 +1224,9 @@ md_assemble (char *str)
} }
c = *op_end; c = *op_end;
*op_end = 0; /* Zero-terminate op code string for hash_find() call. */ *op_end = 0; /* Zero-terminate op code string for str_hash_find() call. */
opcode = (opcode_entry_type *) hash_find (opcode_hash_control, op_start); opcode = (opcode_entry_type *) str_hash_find (opcode_hash_control, op_start);
if (opcode == NULL) if (opcode == NULL)
{ {