Inserting with replacement is wrong for some gas hash table uses.
This patch implements an htab_insert that conditionally replaces, and
similarly for str_hash_insert. str_hash_insert with replace=0 is
roughly equivalent to the older hash_insert, and str_hash_insert with
replace=1 to the older hash_jam, but return values are different. I
found it useful to know whether the slot was occupied prior to
inserting/replacing. I've also reinstated the fatal errors on messing
up opcode tables with duplicates.
PR 26513
* hash.h (htab_insert): Update prototype and comment.
(struct string_tuple): Make "value" a const void*.
(string_tuple_alloc): Likewise.
(str_hash_find, str_hash_find_n): Cast returned value.
(str_hash_insert): Add "replace" parameter, and return slot pointer.
Free alloc'd element when not inserted.
* hash.c (htab_insert): Likewise. Return slot when element exists,
otherwise return NULL.
* read.c (pop_insert): Insert into hash table without first searching.
* config/tc-avr.c (md_begin): Likewise.
* config/tc-msp430.c (md_begin): Likewise.
* config/tc-nds32.c (nds32_init_nds32_pseudo_opcodes): Likewise.
* config/tc-v850.c (md_begin): Likewise.
* macro.c (do_formals, define_macro, macro_expand_body): Likewise.
(delete_macro): Delete from hash table.
* config/tc-tic54x.c (subsym_create_or_replace): Correct logic.
* symbols.c (local_symbol_make, symbol_table_insert): Allow
replacement of hash table entries.
* config/obj-coff-seh.c (seh_hash_insert): Likewise.
* config/obj-coff.c (tag_insert): Likewise.
* config/tc-iq2000.c (iq2000_add_macro): Likewise.
* config/tc-m68k.c (md_begin): Likewise for aliases.
* config/tc-tic4x.c (tic4x_asg): Likewise.
* config/tc-tic6x.c (md_begin): Likewise.
* dw2gencfi.c (dwcfi_hash_find_or_make): Disallow replacement of
hash table entries.
* ecoff.c (add_string, get_tag): Likewise.
* macro.c (expand_irp): Likewise.
* config/obj-elf.c (build_additional_section_info): Likewise.
* config/tc-aarch64.c (insert_reg_alias): Likewise.
(checked_hash_insert): Likewise.
* config/tc-alpha.c (get_alpha_reloc_tag, md_begin): Likewise.
* config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
(declare_addrtype, md_begin, arc_extcorereg): Likewise.
* config/tc-arm.c (insert_reg_alias): Likewise.
(arm_tc_equal_in_insn, md_begin): Likewise.
* config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
* config/tc-cris.c (md_begin): Likewise.
* config/tc-crx.c (md_begin): Likewise.
* config/tc-csky.c (md_begin): Likewise.
* config/tc-d10v.c (md_begin): Likewise.
* config/tc-dlx.c (md_begin): Likewise.
* config/tc-ft32.c (md_begin): Likewise.
* config/tc-h8300.c (md_begin): Likewise.
* config/tc-hppa.c (md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
* config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
(md_begin, dot_alias): Likewise.
* config/tc-m68hc11.c (md_begin): Likewise.
* config/tc-m68k.c (md_begin): Likewise.
* config/tc-mcore.c (md_begin): Likewise.
* config/tc-microblaze.c (md_begin): Likewise.
* config/tc-mips.c (md_begin): Likewise.
* config/tc-mmix.c (md_begin): Likewise.
* config/tc-mn10200.c (md_begin): Likewise.
* config/tc-mn10300.c (md_begin): Likewise.
* config/tc-moxie.c (md_begin): Likewise.
* config/tc-nds32.c (nds32_relax_hint, md_begin): Likewise.
* config/tc-nios2.c (md_begin): Likewise.
* config/tc-ns32k.c (md_begin): Likewise.
* config/tc-pdp11.c (md_begin): Likewise.
* config/tc-pj.c (fake_opcode, md_begin): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
* config/tc-pru.c (md_begin): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
(riscv_init_csr_hash): Likewise.
* config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
* config/tc-score.c (s3_insert_reg): Likewise.
(s3_build_score_ops_hsh, s3_build_dependency_insn_hsh): Likewise.
* config/tc-score7.c (s7_build_score_ops_hsh): Likewise.
(s7_build_dependency_insn_hsh, s7_insert_reg): Likewise.
* config/tc-sh.c (md_begin): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
* config/tc-spu.c (md_begin): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
* config/tc-tic4x.c (tic4x_inst_insert): Likewise.
* config/tc-tic54x.c (stag_add_field_symbols, md_begin): Likewise.
(tic54x_endstruct, tic54x_var, tic54x_macro_info): Likewise.
(subsym_substitute): Likewise.
* config/tc-tilegx.c (md_begin): Likewise.
* config/tc-tilepro.c (md_begin): Likewise.
* config/tc-vax.c (vip_begin): Likewise.
* config/tc-wasm32.c (md_begin): Likewise.
* config/tc-xgate.c (md_begin): Likewise.
* config/tc-z8k.c (md_begin): Likewise.
* testsuite/gas/ppc/dcbt.d,
* testsuite/gas/ppc/dcbt.s: New test.
* testsuite/gas/ppc/ppc.exp: Run it.
* ecoff.c (add_string): Report fatal error on duplicates.
* config/tc-alpha.c (md_begin): Likewise.
* config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
(declare_addrtype, md_begin, arc_extcorereg): Likewise.
* config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
* config/tc-cris.c (md_begin): Likewise.
* config/tc-crx.c (md_begin): Likewise.
* config/tc-dlx.c (md_begin): Likewise.
* config/tc-hppa.c (md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
* config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
(md_begin): Likewise.
* config/tc-m68k.c (md_begin): Likewise.
* config/tc-mips.c (md_begin): Likewise.
* config/tc-nios2.c (md_begin): Likewise.
* config/tc-ns32k.c (md_begin): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
* config/tc-pru.c (md_begin): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
* config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
* config/tc-tic4x.c (tic4x_inst_insert): Likewise.
* config/tc-tilegx.c (md_begin): Likewise.
* config/tc-tilepro.c (md_begin): Likewise.
* config/tc-vax.c (vip_begin): Likewise.
* config/tc-alpha.c,
* config/tc-arm.c,
* config/tc-avr.c,
* config/tc-cr16.c,
* config/tc-csky.c,
* config/tc-i386.c,
* config/tc-m68hc11.c,
* config/tc-m68k.c,
* config/tc-microblaze.c,
* config/tc-ns32k.c,
* config/tc-pj.c,
* config/tc-ppc.c,
* config/tc-score.c,
* config/tc-score7.c,
* config/tc-tic4x.c,
* config/tc-tic54x.c,
* config/tc-tilegx.c,
* config/tc-tilepro.c,
* config/tc-xgate.c: Formatting.
+2020-08-23 Alan Modra <amodra@gmail.com>
+
+ PR 26513
+ * hash.h (htab_insert): Update prototype and comment.
+ (struct string_tuple): Make "value" a const void*.
+ (string_tuple_alloc): Likewise.
+ (str_hash_find, str_hash_find_n): Cast returned value.
+ (str_hash_insert): Add "replace" parameter, and return slot pointer.
+ Free alloc'd element when not inserted.
+ * hash.c (htab_insert): Likewise. Return slot when element exists,
+ otherwise return NULL.
+ * read.c (pop_insert): Insert into hash table without first searching.
+ * config/tc-avr.c (md_begin): Likewise.
+ * config/tc-msp430.c (md_begin): Likewise.
+ * config/tc-nds32.c (nds32_init_nds32_pseudo_opcodes): Likewise.
+ * config/tc-v850.c (md_begin): Likewise.
+ * macro.c (do_formals, define_macro, macro_expand_body): Likewise.
+ (delete_macro): Delete from hash table.
+ * config/tc-tic54x.c (subsym_create_or_replace): Correct logic.
+
+ * symbols.c (local_symbol_make, symbol_table_insert): Allow
+ replacement of hash table entries.
+ * config/obj-coff-seh.c (seh_hash_insert): Likewise.
+ * config/obj-coff.c (tag_insert): Likewise.
+ * config/tc-iq2000.c (iq2000_add_macro): Likewise.
+ * config/tc-m68k.c (md_begin): Likewise for aliases.
+ * config/tc-tic4x.c (tic4x_asg): Likewise.
+ * config/tc-tic6x.c (md_begin): Likewise.
+
+ * dw2gencfi.c (dwcfi_hash_find_or_make): Disallow replacement of
+ hash table entries.
+ * ecoff.c (add_string, get_tag): Likewise.
+ * macro.c (expand_irp): Likewise.
+ * config/obj-elf.c (build_additional_section_info): Likewise.
+ * config/tc-aarch64.c (insert_reg_alias): Likewise.
+ (checked_hash_insert): Likewise.
+ * config/tc-alpha.c (get_alpha_reloc_tag, md_begin): Likewise.
+ * config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
+ (declare_addrtype, md_begin, arc_extcorereg): Likewise.
+ * config/tc-arm.c (insert_reg_alias): Likewise.
+ (arm_tc_equal_in_insn, md_begin): Likewise.
+ * config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
+ * config/tc-cris.c (md_begin): Likewise.
+ * config/tc-crx.c (md_begin): Likewise.
+ * config/tc-csky.c (md_begin): Likewise.
+ * config/tc-d10v.c (md_begin): Likewise.
+ * config/tc-dlx.c (md_begin): Likewise.
+ * config/tc-ft32.c (md_begin): Likewise.
+ * config/tc-h8300.c (md_begin): Likewise.
+ * config/tc-hppa.c (md_begin): Likewise.
+ * config/tc-i386.c (md_begin): Likewise.
+ * config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
+ (md_begin, dot_alias): Likewise.
+ * config/tc-m68hc11.c (md_begin): Likewise.
+ * config/tc-m68k.c (md_begin): Likewise.
+ * config/tc-mcore.c (md_begin): Likewise.
+ * config/tc-microblaze.c (md_begin): Likewise.
+ * config/tc-mips.c (md_begin): Likewise.
+ * config/tc-mmix.c (md_begin): Likewise.
+ * config/tc-mn10200.c (md_begin): Likewise.
+ * config/tc-mn10300.c (md_begin): Likewise.
+ * config/tc-moxie.c (md_begin): Likewise.
+ * config/tc-nds32.c (nds32_relax_hint, md_begin): Likewise.
+ * config/tc-nios2.c (md_begin): Likewise.
+ * config/tc-ns32k.c (md_begin): Likewise.
+ * config/tc-pdp11.c (md_begin): Likewise.
+ * config/tc-pj.c (fake_opcode, md_begin): Likewise.
+ * config/tc-ppc.c (ppc_setup_opcodes): Likewise.
+ * config/tc-pru.c (md_begin): Likewise.
+ * config/tc-riscv.c (init_ext_version_hash): Likewise.
+ (init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
+ (riscv_init_csr_hash): Likewise.
+ * config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
+ * config/tc-score.c (s3_insert_reg): Likewise.
+ (s3_build_score_ops_hsh, s3_build_dependency_insn_hsh): Likewise.
+ * config/tc-score7.c (s7_build_score_ops_hsh): Likewise.
+ (s7_build_dependency_insn_hsh, s7_insert_reg): Likewise.
+ * config/tc-sh.c (md_begin): Likewise.
+ * config/tc-sparc.c (md_begin): Likewise.
+ * config/tc-spu.c (md_begin): Likewise.
+ * config/tc-tic30.c (md_begin): Likewise.
+ * config/tc-tic4x.c (tic4x_inst_insert): Likewise.
+ * config/tc-tic54x.c (stag_add_field_symbols, md_begin): Likewise.
+ (tic54x_endstruct, tic54x_var, tic54x_macro_info): Likewise.
+ (subsym_substitute): Likewise.
+ * config/tc-tilegx.c (md_begin): Likewise.
+ * config/tc-tilepro.c (md_begin): Likewise.
+ * config/tc-vax.c (vip_begin): Likewise.
+ * config/tc-wasm32.c (md_begin): Likewise.
+ * config/tc-xgate.c (md_begin): Likewise.
+ * config/tc-z8k.c (md_begin): Likewise.
+ * testsuite/gas/ppc/dcbt.d,
+ * testsuite/gas/ppc/dcbt.s: New test.
+ * testsuite/gas/ppc/ppc.exp: Run it.
+
+ * ecoff.c (add_string): Report fatal error on duplicates.
+ * config/tc-alpha.c (md_begin): Likewise.
+ * config/tc-arc.c (arc_insert_opcode, declare_register): Likewise.
+ (declare_addrtype, md_begin, arc_extcorereg): Likewise.
+ * config/tc-cr16.c (initialise_reg_hash_table, md_begin): Likewise.
+ * config/tc-cris.c (md_begin): Likewise.
+ * config/tc-crx.c (md_begin): Likewise.
+ * config/tc-dlx.c (md_begin): Likewise.
+ * config/tc-hppa.c (md_begin): Likewise.
+ * config/tc-i386.c (md_begin): Likewise.
+ * config/tc-ia64.c (dot_rot, dot_entry, declare_register): Likewise.
+ (md_begin): Likewise.
+ * config/tc-m68k.c (md_begin): Likewise.
+ * config/tc-mips.c (md_begin): Likewise.
+ * config/tc-nios2.c (md_begin): Likewise.
+ * config/tc-ns32k.c (md_begin): Likewise.
+ * config/tc-ppc.c (ppc_setup_opcodes): Likewise.
+ * config/tc-pru.c (md_begin): Likewise.
+ * config/tc-riscv.c (init_ext_version_hash): Likewise.
+ (init_opcode_names_hash, hash_reg_name, init_opcode_hash): Likewise.
+ * config/tc-s390.c (s390_setup_opcodes, md_begin): Likewise.
+ * config/tc-sparc.c (md_begin): Likewise.
+ * config/tc-tic30.c (md_begin): Likewise.
+ * config/tc-tic4x.c (tic4x_inst_insert): Likewise.
+ * config/tc-tilegx.c (md_begin): Likewise.
+ * config/tc-tilepro.c (md_begin): Likewise.
+ * config/tc-vax.c (vip_begin): Likewise.
+
+ * config/tc-alpha.c,
+ * config/tc-arm.c,
+ * config/tc-avr.c,
+ * config/tc-cr16.c,
+ * config/tc-csky.c,
+ * config/tc-i386.c,
+ * config/tc-m68hc11.c,
+ * config/tc-m68k.c,
+ * config/tc-microblaze.c,
+ * config/tc-ns32k.c,
+ * config/tc-pj.c,
+ * config/tc-ppc.c,
+ * config/tc-score.c,
+ * config/tc-score7.c,
+ * config/tc-tic4x.c,
+ * config/tc-tic54x.c,
+ * config/tc-tilegx.c,
+ * config/tc-tilepro.c,
+ * config/tc-xgate.c: Formatting.
+
2020-08-21 Alan Modra <amodra@gmail.com>
* symbols.c (struct local_symbol): Add "hash" entry. Reorder fields.
static void
seh_hash_insert (const char *name, struct seh_seg_list *item)
{
- str_hash_insert (seh_hash, name, (char *) item);
+ str_hash_insert (seh_hash, name, item, 1);
}
static struct seh_seg_list *
static void
tag_insert (const char *name, symbolS *symbolP)
{
- str_hash_insert (tag_hash, name, (char *) symbolP);
+ str_hash_insert (tag_hash, name, symbolP, 1);
}
static symbolS *
/* Add index to hash. */
idx_ptr = XNEW (unsigned int);
*idx_ptr = i;
- str_hash_insert (list->indexes, group_name, (char *)idx_ptr);
+ str_hash_insert (list->indexes, group_name, idx_ptr, 0);
}
static int
new->type = type;
new->builtin = FALSE;
- str_hash_insert (aarch64_reg_hsh, name, (void *) new);
+ str_hash_insert (aarch64_reg_hsh, name, new, 0);
return new;
}
static void
checked_hash_insert (htab_t table, const char *key, void *value)
{
- str_hash_insert (table, key, value);
+ str_hash_insert (table, key, value, 0);
}
static void
info->segment = now_seg;
info->sequence = sequence;
strcpy (info->string, buffer);
- str_hash_insert (alpha_literal_hash, info->string, (void *) info);
+ str_hash_insert (alpha_literal_hash, info->string, info, 0);
#ifdef OBJ_EVAX
info->sym = 0;
info->psym = 0;
const struct alpha_opcode *opcode;
/* Search opcodes. */
- opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash, opname);
+ opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash,
+ opname);
if (opcode)
{
int cpumatch;
#endif
if (local_macros_on)
{
- macro = ((const struct alpha_macro *)
- str_hash_find (alpha_macro_hash, opname));
+ macro = (const struct alpha_macro *) str_hash_find (alpha_macro_hash,
+ opname);
if (macro)
{
found_something = 1;
}
/* Search opcodes. */
- opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash, opname);
+ opcode = (const struct alpha_opcode *) str_hash_find (alpha_opcode_hash,
+ opname);
if (opcode)
{
found_something = 1;
const char *name, *slash;
name = alpha_opcodes[i].name;
- str_hash_insert (alpha_opcode_hash, name, (void *) &alpha_opcodes[i]);
+ if (str_hash_insert (alpha_opcode_hash, name, &alpha_opcodes[i], 0))
+ as_fatal (_("duplicate %s"), name);
/* Some opcodes include modifiers of various sorts with a "/mod"
syntax, like the architecture manual suggests. However, for
memcpy (p, name, slash - name);
strcpy (p + (slash - name), slash + 1);
- (void) str_hash_insert (alpha_opcode_hash, p, (void *) &alpha_opcodes[i]);
+ (void) str_hash_insert (alpha_opcode_hash, p, &alpha_opcodes[i], 0);
/* Ignore failures -- the opcode table does duplicate some
variants in different forms, like "hw_stq" and "hw_st/q". */
}
const char *name;
name = alpha_macros[i].name;
- str_hash_insert (alpha_macro_hash, name, (void *) &alpha_macros[i]);
+ if (str_hash_insert (alpha_macro_hash, name, &alpha_macros[i], 0))
+ as_fatal (_("duplicate %s"), name);
while (++i < alpha_num_macros
&& (alpha_macros[i].name == name
entry->count = 0;
entry->opcode = NULL;
- str_hash_insert (arc_opcode_hash, name, (void *) entry);
+ if (str_hash_insert (arc_opcode_hash, name, entry, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
}
entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode,
symbolS *regS = symbol_create (name, reg_section,
&zero_address_frag, number);
- str_hash_insert (arc_reg_hash, S_GET_NAME (regS), (void *) regS);
+ if (str_hash_insert (arc_reg_hash, S_GET_NAME (regS), regS, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
}
/* Construct symbols for each of the general registers. */
symbolS *addrtypeS = symbol_create (name, undefined_section,
&zero_address_frag, number);
- str_hash_insert (arc_addrtype_hash, S_GET_NAME (addrtypeS),
- (void *) addrtypeS);
+ if (str_hash_insert (arc_addrtype_hash, S_GET_NAME (addrtypeS), addrtypeS, 0))
+ as_fatal (_("duplicate %s"), name);
}
/* Port-specific assembler initialization. This function is called
&& !check_cpu_feature (auxr->subclass))
continue;
- str_hash_insert (arc_aux_hash, auxr->name, (void *) auxr);
+ if (str_hash_insert (arc_aux_hash, auxr->name, auxr, 0) != 0)
+ as_fatal (_("duplicate %s"), auxr->name);
}
/* Address type declaration. */
auxr->cpu = selected_cpu.flags;
auxr->subclass = NONE;
auxr->address = ereg.number;
- str_hash_insert (arc_aux_hash, auxr->name, (void *) auxr);
+ if (str_hash_insert (arc_aux_hash, auxr->name, auxr, 0) != NULL)
+ as_bad (_("duplicate aux register %s"), auxr->name);
break;
case EXT_COND_CODE:
/* Condition code. */
new_reg->builtin = FALSE;
new_reg->neon = NULL;
- str_hash_insert (arm_reg_hsh, name, new_reg);
+ str_hash_insert (arm_reg_hsh, name, new_reg, 0);
return new_reg;
}
as_bad (_("invalid syntax for .unreq directive"));
else
{
- struct reg_entry *reg = (struct reg_entry *) str_hash_find (arm_reg_hsh,
- name);
+ struct reg_entry *reg
+ = (struct reg_entry *) str_hash_find (arm_reg_hsh, name);
if (!reg)
as_bad (_("unknown register alias '%s'"), name);
return FAIL;
}
- shift_name = (const struct asm_shift_name *) str_hash_find_n (arm_shift_hsh, *str,
- p - *str);
+ shift_name
+ = (const struct asm_shift_name *) str_hash_find_n (arm_shift_hsh, *str,
+ p - *str);
if (shift_name == NULL)
{
p = start + strcspn (start, "rR") + 1;
psr = (const struct asm_psr *) str_hash_find_n (arm_v7m_psr_hsh, start,
- p - start);
+ p - start);
if (!psr)
return FAIL;
else
{
psr = (const struct asm_psr *) str_hash_find_n (arm_psr_hsh, start,
- p - start);
+ p - start);
if (!psr)
goto error;
q++;
o = (const struct asm_barrier_opt *) str_hash_find_n (arm_barrier_opt_hsh, p,
- q - p);
+ q - p);
if (!o)
return FAIL;
/* Look for unaffixed or special-case affixed mnemonic. */
opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
- end - base);
+ end - base);
if (opcode)
{
/* step U */
affix = end - 1;
cond = (const struct asm_cond *) str_hash_find_n (arm_vcond_hsh, affix, 1);
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
vector predication code. */
if (opcode && !opcode->mayBeVecPred)
affix = end - 2;
cond = (const struct asm_cond *) str_hash_find_n (arm_cond_hsh, affix, 2);
opcode = (const struct asm_opcode *) str_hash_find_n (arm_ops_hsh, base,
- affix - base);
+ affix - base);
}
if (opcode && cond)
memcpy (save, affix, 2);
memmove (affix, affix + 2, (end - affix) - 2);
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);
memcpy (affix, save, 2);
if (str_hash_find (already_warned, nbuf) == NULL)
{
as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name);
- str_hash_insert (already_warned, nbuf, NULL);
+ str_hash_insert (already_warned, nbuf, NULL, 0);
}
}
else
for (i = 0; i < sizeof (insns) / sizeof (struct asm_opcode); 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));
+ str_hash_insert (arm_ops_hsh, insns[i].template_name, insns + i, 0);
for (i = 0; i < sizeof (conds) / sizeof (struct asm_cond); i++)
- str_hash_insert (arm_cond_hsh, conds[i].template_name, (void *) (conds + i));
+ str_hash_insert (arm_cond_hsh, conds[i].template_name, conds + i, 0);
for (i = 0; i < sizeof (vconds) / sizeof (struct asm_cond); i++)
- str_hash_insert (arm_vcond_hsh, vconds[i].template_name, (void *) (vconds + i));
+ str_hash_insert (arm_vcond_hsh, vconds[i].template_name, vconds + i, 0);
for (i = 0; i < sizeof (shift_names) / sizeof (struct asm_shift_name); i++)
- str_hash_insert (arm_shift_hsh, shift_names[i].name, (void *) (shift_names + i));
+ str_hash_insert (arm_shift_hsh, shift_names[i].name, shift_names + i, 0);
for (i = 0; i < sizeof (psrs) / sizeof (struct asm_psr); i++)
- str_hash_insert (arm_psr_hsh, psrs[i].template_name, (void *) (psrs + i));
+ str_hash_insert (arm_psr_hsh, psrs[i].template_name, psrs + i, 0);
for (i = 0; i < sizeof (v7m_psrs) / sizeof (struct asm_psr); i++)
str_hash_insert (arm_v7m_psr_hsh, v7m_psrs[i].template_name,
- (void *) (v7m_psrs + i));
+ v7m_psrs + i, 0);
for (i = 0; i < sizeof (reg_names) / sizeof (struct reg_entry); i++)
- str_hash_insert (arm_reg_hsh, reg_names[i].name, (void *) (reg_names + i));
+ str_hash_insert (arm_reg_hsh, reg_names[i].name, reg_names + i, 0);
for (i = 0;
i < sizeof (barrier_opt_names) / sizeof (struct asm_barrier_opt);
i++)
str_hash_insert (arm_barrier_opt_hsh, barrier_opt_names[i].template_name,
- (void *) (barrier_opt_names + i));
+ barrier_opt_names + i, 0);
#ifdef OBJ_ELF
for (i = 0; i < ARRAY_SIZE (reloc_names); i++)
{
/* This makes encode_branch() use the EABI versions of this relocation. */
entry->reloc = BFD_RELOC_UNUSED;
- str_hash_insert (arm_reloc_hsh, entry->name, (void *) entry);
+ str_hash_insert (arm_reloc_hsh, entry->name, entry, 0);
}
#endif
quick index to the first opcode with a particular name in the opcode
table. */
for (opcode = avr_opcodes; opcode->name; opcode++)
- if (str_hash_find (avr_hash, opcode->name) == NULL)
- str_hash_insert (avr_hash, opcode->name, (char *) opcode);
+ str_hash_insert (avr_hash, opcode->name, opcode, 0);
avr_mod_hash = str_htab_create ();
mod_index m;
m.index = i + 10;
- str_hash_find (avr_mod_hash, EXP_MOD_NAME (i));
- str_hash_insert (avr_mod_hash, EXP_MOD_NAME (i), m.ptr);
+ str_hash_insert (avr_mod_hash, EXP_MOD_NAME (i), m.ptr, 0);
}
avr_no_sreg_hash = str_htab_create ();
for (i = 0; i < ARRAY_SIZE (avr_no_sreg); ++i)
{
gas_assert (str_hash_find (avr_hash, avr_no_sreg[i]));
- str_hash_insert (avr_no_sreg_hash, avr_no_sreg[i], (char*) 4 /* dummy */);
+ str_hash_insert (avr_no_sreg_hash, avr_no_sreg[i],
+ (void *) 4 /* dummy */, 0);
}
- avr_gccisr_opcode = (struct avr_opcodes_s*) str_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);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach);
}
static void
-initialise_reg_hash_table (htab_t * hash_table,
- const reg_entry * register_table,
- const unsigned int num_entries)
+initialise_reg_hash_table (htab_t *hash_table,
+ const reg_entry *register_table,
+ const unsigned int num_entries)
{
- const reg_entry * rreg;
- if ((* hash_table = str_htab_create ()) == NULL)
+ const reg_entry *rreg;
+
+ *hash_table = str_htab_create ();
+ if (*hash_table == NULL)
as_fatal (_("Virtual memory exhausted"));
for (rreg = register_table;
rreg < (register_table + num_entries);
rreg++)
- str_hash_insert (* hash_table, rreg->name, (char *) rreg);
+ if (str_hash_insert (*hash_table, rreg->name, rreg, 0) != NULL)
+ as_fatal (_("duplicate %s"), rreg->name);
}
/* This function is called once, at assembler startup time. This should
{
const char *mnemonic = cr16_instruction[i].mnemonic;
- str_hash_insert (cr16_inst_hash, mnemonic,
- (char *)(cr16_instruction + i));
+ if (str_hash_insert (cr16_inst_hash, mnemonic, cr16_instruction + i, 0))
+ as_fatal (_("duplicate %s"), mnemonic);
+
/* Insert unique names into hash table. The CR16 instruction set
has many identical opcode names that have different opcodes based
on the operands. This hash table then provides a quick index to
continue;
}
- /* Need to cast to get rid of "const". FIXME: Fix str_hash_insert instead. */
- str_hash_insert (op_hash, name, (void *) &cris_opcodes[i]);
+ if (str_hash_insert (op_hash, name, &cris_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
+
do
{
if (cris_opcodes[i].match & cris_opcodes[i].lose)
{
const char *mnemonic = crx_instruction[i].mnemonic;
- str_hash_insert (crx_inst_hash, mnemonic,
- (void *) &crx_instruction[i]);
+ if (str_hash_insert (crx_inst_hash, mnemonic, &crx_instruction[i], 0))
+ as_fatal (_("duplicate %s"), mnemonic);
/* Insert unique names into hash table. The CRX instruction set
has many identical opcode names that have different opcodes based
for (regtab = crx_regtab;
regtab < (crx_regtab + NUMREGS); regtab++)
- str_hash_insert (reg_hash, regtab->name, (void *) regtab);
+ if (str_hash_insert (reg_hash, regtab->name, regtab, 0) != NULL)
+ as_fatal (_("duplicate %s"), regtab->name);
}
/* Initialize copreg_hash hash table. */
for (copregtab = crx_copregtab; copregtab < (crx_copregtab + NUMCOPREGS);
copregtab++)
- str_hash_insert (copreg_hash, copregtab->name,
- (void *) copregtab);
+ if (str_hash_insert (copreg_hash, copregtab->name, copregtab, 0) != NULL)
+ as_fatal (_("duplicate %s"), copregtab->name);
}
/* Set linkrelax here to avoid fixups in most sections. */
linkrelax = 1;
csky_opcodes_hash = str_htab_create ();
for ( ; opcode->mnemonic != NULL; opcode++)
if ((isa_flag & (opcode->isa_flag16 | opcode->isa_flag32)) != 0)
- str_hash_insert (csky_opcodes_hash, opcode->mnemonic, (char *)opcode);
+ str_hash_insert (csky_opcodes_hash, opcode->mnemonic, opcode, 0);
for ( ; macro->name != NULL; macro++)
if ((isa_flag & macro->isa_flag) != 0)
- str_hash_insert (csky_macros_hash, macro->name, (char *)macro);
+ str_hash_insert (csky_macros_hash, macro->name, macro, 0);
if (do_nolrw && (isa_flag & CSKYV2_ISA_1E2) != 0)
str_hash_insert (csky_macros_hash,
- v2_lrw_macro_opcode.name,
- (char *)&v2_lrw_macro_opcode);
+ v2_lrw_macro_opcode.name, &v2_lrw_macro_opcode, 0);
/* Set e_flag to ELF Head. */
bfd_set_private_flags (stdoutput, mach_flag);
/* Set bfd_mach to bfd backend data. */
/* Find hash by name in csky_macros_hash and csky_opcodes_hash. */
csky_insn.macro = (struct csky_macro_info *) str_hash_find (csky_macros_hash,
- macro_name);
+ macro_name);
csky_insn.opcode = (struct csky_opcode *) str_hash_find (csky_opcodes_hash,
- name);
+ name);
if (csky_insn.macro == NULL && csky_insn.opcode == NULL)
return FALSE;
if (strcmp (prev_name, opcode->name))
{
prev_name = (char *) opcode->name;
- str_hash_insert (d10v_hash, opcode->name, (char *) opcode);
+ str_hash_insert (d10v_hash, opcode->name, opcode, 0);
}
}
/* Insert opcode names into a hash table. */
for (opcode = (struct d30v_opcode *) d30v_opcode_table; opcode->name; opcode++)
- str_hash_insert (d30v_hash, opcode->name, (char *) opcode);
+ str_hash_insert (d30v_hash, opcode->name, opcode, 0);
fixups = &FixUps[0];
FixUps[0].next = &FixUps[1];
for (i = 0; i < num_dlx_opcodes; i++)
{
const char *name = machine_opcodes[i].name;
- str_hash_insert (op_hash, name, (void *) &machine_opcodes[i]);
+ if (str_hash_insert (op_hash, name, &machine_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
}
define_some_regs ();
/* Insert names into hash table. */
for (opcode = ft32_opc_info; opcode->name; opcode++)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
if (!norelax)
len = dst - buffer;
if (cmplen == 0)
cmplen = len;
- str_hash_insert (opcode_hash_control, buffer, (char *) pi);
+ str_hash_insert (opcode_hash_control, buffer, pi, 0);
strcpy (prev_buffer, buffer);
idx++;
{
const char *name = pa_opcodes[i].name;
- str_hash_insert (op_hash, name, (void *)&pa_opcodes[i]);
+ if (str_hash_insert (op_hash, name, &pa_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
do
{
/* different name --> ship out current template list;
add to hash table; & begin anew. */
core_optab->end = optab;
- str_hash_insert (op_hash, (optab - 1)->name, (void *) core_optab);
+ if (str_hash_insert (op_hash, (optab - 1)->name, core_optab, 0))
+ as_fatal (_("duplicate %s"), (optab - 1)->name);
+
if (optab->name == NULL)
break;
core_optab = XNEW (templates);
unsigned int regtab_size = i386_regtab_size;
for (regtab = i386_regtab; regtab_size--; regtab++)
- str_hash_insert (reg_hash, regtab->reg_name, (void *) regtab);
+ if (str_hash_insert (reg_hash, regtab->reg_name, regtab, 0) != NULL)
+ as_fatal (_("duplicate %s"), regtab->reg_name);
}
/* Fill in lexical tables: mnemonic_chars, operand_chars. */
case QWORD_MNEM_SUFFIX:
i.suffix = mnem_p[-1];
mnem_p[-1] = '\0';
- current_templates = (const templates *) str_hash_find (op_hash,
- mnemonic);
+ current_templates
+ = (const templates *) str_hash_find (op_hash, mnemonic);
break;
case SHORT_MNEM_SUFFIX:
case LONG_MNEM_SUFFIX:
{
i.suffix = mnem_p[-1];
mnem_p[-1] = '\0';
- current_templates = (const templates *) str_hash_find (op_hash,
- mnemonic);
+ current_templates
+ = (const templates *) str_hash_find (op_hash, mnemonic);
}
break;
else
i.suffix = LONG_MNEM_SUFFIX;
mnem_p[-1] = '\0';
- current_templates = (const templates *) str_hash_find (op_hash,
- mnemonic);
+ current_templates
+ = (const templates *) str_hash_find (op_hash, mnemonic);
}
break;
}
&& current_templates->end[-1].operand_types[1]
.bitfield.baseindex))
op = 1;
- expected_reg = (const reg_entry *)str_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
- expected_reg = (const reg_entry *)str_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
|| i.index_reg
drpp = &dr->next;
base_reg += num_regs;
- str_hash_insert (md.dynreg_hash, name, dr);
+ if (str_hash_insert (md.dynreg_hash, name, dr, 0) != NULL)
+ {
+ as_bad (_("Attempt to redefine register set `%s'"), name);
+ obstack_free (¬es, name);
+ goto err;
+ }
if (*input_line_pointer != ',')
break;
c = get_symbol_name (&name);
symbolP = symbol_find_or_make (name);
- str_hash_insert (md.entry_hash, S_GET_NAME (symbolP), (void *) symbolP);
+ if (str_hash_insert (md.entry_hash, S_GET_NAME (symbolP), symbolP, 0))
+ as_bad (_("duplicate entry hint %s"), name);
*input_line_pointer = c;
SKIP_WHITESPACE_AFTER_NAME ();
sym = symbol_create (name, reg_section, &zero_address_frag, regnum);
- str_hash_insert (md.reg_hash, S_GET_NAME (sym), (void *) sym);
+ if (str_hash_insert (md.reg_hash, S_GET_NAME (sym), sym, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
return sym;
}
md.pseudo_hash = str_htab_create ();
for (i = 0; i < NELEMS (pseudo_opcode); ++i)
- str_hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
- (void *) (pseudo_opcode + i));
+ if (str_hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
+ pseudo_opcode + i, 0) != NULL)
+ as_fatal (_("duplicate %s"), pseudo_opcode[i].name);
md.reg_hash = str_htab_create ();
md.dynreg_hash = str_htab_create ();
declare_register ("psp", REG_PSP);
for (i = 0; i < NELEMS (const_bits); ++i)
- str_hash_insert (md.const_hash, const_bits[i].name,
- (void *) (const_bits + i));
+ if (str_hash_insert (md.const_hash, const_bits[i].name, const_bits + i, 0))
+ as_fatal (_("duplicate %s"), const_bits[i].name);
/* Set the architecture and machine depending on defaults and command line
options. */
h->file = as_where (&h->line);
h->name = name;
- str_hash_insert (ahash, alias, (void *) h);
- str_hash_insert (nhash, name, (void *) alias);
+ str_hash_insert (ahash, alias, h, 0);
+ str_hash_insert (nhash, name, alias, 0);
out:
demand_empty_rest_of_line ();
/* Add to macro's hash table. */
htab_insert (macro->formal_hash,
formal_entry_alloc (sb_terminate (& formal->name),
- formal));
+ formal),
+ 1);
formal->index = macro->formal_count;
macro->formal_count++;
*p = formal;
sb_add_string (¯o_name, name);
namestr = sb_terminate (¯o_name);
- htab_insert (macro_hash, macro_entry_alloc (namestr, macro));
+ htab_insert (macro_hash, macro_entry_alloc (namestr, macro), 1);
macro_defined = 1;
}
opc->nb_modes = 0;
opc->opcode = opcodes;
opc->used = 0;
- str_hash_insert (m68hc11_hash, opcodes->name, opc);
+ str_hash_insert (m68hc11_hash, opcodes->name, opc, 0);
}
opc->nb_modes++;
opc->format |= opcodes->format;
is given. */
if (opc == NULL && name[0] == 'j' && name[1] == 'b')
{
- opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash, &name[1]);
+ opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash,
+ &name[1]);
if (opc
&& (!(opc->format & M6811_OP_JUMP_REL)
|| (opc->format & M6811_OP_BITMASK)))
name[nlen++] = TOLOWER (*op_end++);
name[nlen] = 0;
opc = (struct m68hc11_opcode_def *) str_hash_find (m68hc11_hash,
- name);
+ name);
}
}
}
}
while (slak);
- str_hash_insert (op_hash, ins->name, (char *) hack);
+ if (str_hash_insert (op_hash, ins->name, hack, 0) != NULL)
+ as_fatal (_("duplicate %s"), ins->name);
}
for (i = 0; i < m68k_numaliases; i++)
{
const char *name = m68k_opcode_aliases[i].primary;
const char *alias = m68k_opcode_aliases[i].alias;
- void *val = (void *)str_hash_find (op_hash, name);
+ void *val = (void *) str_hash_find (op_hash, name);
if (!val)
as_fatal (_("Internal Error: Can't find %s in hash table"), name);
- str_hash_insert (op_hash, alias, val);
+ if (str_hash_insert (op_hash, alias, val, 0) != NULL)
+ as_fatal (_("duplicate %s"), alias);
}
/* In MRI mode, all unsized branches are variable sized. Normally,
{
const char *name = mri_aliases[i].primary;
const char *alias = mri_aliases[i].alias;
- void *val = (void *)str_hash_find (op_hash, name);
+ void *val = (void *) str_hash_find (op_hash, name);
if (!val)
as_fatal (_("Internal Error: Can't find %s in hash table"), name);
- str_hash_insert (op_hash, alias, val);
+ str_hash_insert (op_hash, alias, val, 1);
}
}
{
hack = XOBNEW (&robyn, struct m68k_incant);
str_hash_insert (op_hash,
- mote_pseudo_table[n].poc_name, (char *) hack);
+ mote_pseudo_table[n].poc_name, hack, 0);
hack->m_operands = 0;
hack->m_opnum = n;
n++;
if (! streq (prev_name, mcore_table[i].name))
{
prev_name = mcore_table[i].name;
- str_hash_insert (opcode_hash_control, mcore_table[i].name, (char *) &mcore_table[i]);
+ str_hash_insert (opcode_hash_control, mcore_table[i].name,
+ &mcore_table[i], 0);
}
}
}
/* Insert unique names into hash table. */
for (opcode = opcodes; opcode->name; opcode ++)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
}
/* Try to parse a reg name. */
count = 32 - reg1;
if (streq (name, "lmi"))
- opcode = (struct op_code_struct *) str_hash_find (opcode_hash_control, "lwi");
+ opcode
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "lwi");
else
- opcode = (struct op_code_struct *) str_hash_find (opcode_hash_control, "swi");
+ opcode
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "swi");
if (opcode == NULL)
{
as_bad (_("unknown opcode \"%s\""), "lwi");
if ((temp != 0) && (temp != 0xFFFF8000))
{
/* Needs an immediate inst. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
if ((temp != 0) && (temp != 0xFFFF8000))
{
/* Needs an immediate inst. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
if ((temp != 0) && (temp != 0xFFFF8000))
{
/* Needs an immediate inst. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
if ((temp != 0) && (temp != 0xFFFF8000))
{
/* Needs an immediate inst. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control,
+ "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
buf[i + INST_WORD_SIZE] = buf[i];
/* Generate the imm instruction. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
buf[i + INST_WORD_SIZE] = buf[i];
/* Generate the imm instruction. */
- opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
+ opcode1
+ = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm");
if (opcode1 == NULL)
{
as_bad (_("unknown opcode \"%s\""), "imm");
{
const char *name = mips_opcodes[i].name;
- str_hash_insert (op_hash, name, (void *) &mips_opcodes[i]);
+ if (str_hash_insert (op_hash, name, &mips_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
do
{
if (!validate_mips_insn (&mips_opcodes[i], 0xffffffff,
{
const char *name = mips16_opcodes[i].name;
- str_hash_insert (mips16_op_hash, name, (void *) &mips16_opcodes[i]);
+ if (str_hash_insert (mips16_op_hash, name, &mips16_opcodes[i], 0))
+ as_fatal (_("duplicate %s"), name);
do
{
if (!validate_mips16_insn (&mips16_opcodes[i], &mips16_operands[i]))
{
const char *name = micromips_opcodes[i].name;
- str_hash_insert (micromips_op_hash, name,
- (void *) µmips_opcodes[i]);
+ if (str_hash_insert (micromips_op_hash, name, µmips_opcodes[i], 0))
+ as_fatal (_("duplicate %s"), name);
do
{
struct mips_cl_insn *micromips_nop_insn;
= bfd_make_section_old_way (stdoutput, MMIX_REG_SECTION_NAME);
for (opcode = mmix_opcodes; opcode->name; opcode++)
- str_hash_insert (mmix_opcode_hash, opcode->name, (char *) opcode);
+ str_hash_insert (mmix_opcode_hash, opcode->name, opcode, 0);
/* We always insert the ordinary registers 0..255 as registers. */
for (i = 0; i < 256; i++)
if (strcmp (prev_name, op->name))
{
prev_name = (char *) op->name;
- str_hash_insert (mn10200_hash, op->name, (char *) op);
+ str_hash_insert (mn10200_hash, op->name, op, 0);
}
op++;
}
if (strcmp (prev_name, op->name))
{
prev_name = (char *) op->name;
- str_hash_insert (mn10300_hash, op->name, (char *) op);
+ str_hash_insert (mn10300_hash, op->name, op, 0);
}
op++;
}
/* Insert names into hash table. */
for (count = 0, opcode = moxie_form1_opc_info; count++ < 64; opcode++)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
}
msp430_hash = str_htab_create ();
for (opcode = msp430_opcodes; opcode->name; opcode++)
- if (str_hash_find (msp430_hash, opcode->name) == NULL)
- str_hash_insert (msp430_hash, opcode->name, (char *) opcode);
+ str_hash_insert (msp430_hash, opcode->name, opcode, 0);
bfd_set_arch_mach (stdoutput, TARGET_ARCH,
target_is_430x () ? bfd_mach_msp430x : bfd_mach_msp11);
static void
nds32_init_nds32_pseudo_opcodes (void)
{
- struct nds32_pseudo_opcode *opcode = nds32_pseudo_opcode_table;
+ struct nds32_pseudo_opcode *opcode;
nds32_pseudo_opcode_hash = str_htab_create ();
- for ( ; opcode->opcode; opcode++)
- {
- void *op;
-
- op = str_hash_find (nds32_pseudo_opcode_hash, opcode->opcode);
- if (op != NULL)
- {
- as_warn (_("Duplicated pseudo-opcode %s."), opcode->opcode);
- continue;
- }
- str_hash_insert (nds32_pseudo_opcode_hash, opcode->opcode, opcode);
- }
+ for (opcode = nds32_pseudo_opcode_table; opcode->opcode; opcode++)
+ if (str_hash_insert (nds32_pseudo_opcode_hash, opcode->opcode, opcode, 0))
+ as_fatal (_("duplicate %s"), opcode->opcode);
}
static struct nds32_pseudo_opcode *
{
relocs = XNEW (struct nds32_relocs_pattern);
memset (relocs, 0, sizeof (struct nds32_relocs_pattern));
- str_hash_insert (nds32_hint_hash, name, relocs);
+ str_hash_insert (nds32_hint_hash, name, relocs, 0);
}
else
{
/* Initial general purpose registers hash table. */
nds32_gprs_hash = str_htab_create ();
for (k = keyword_gpr; k->name; k++)
- str_hash_insert (nds32_gprs_hash, k->name, k);
+ str_hash_insert (nds32_gprs_hash, k->name, k, 0);
/* Initial branch hash table. */
nds32_relax_info_hash = str_htab_create ();
for (relax_info = relax_table; relax_info->opcode; relax_info++)
- str_hash_insert (nds32_relax_info_hash, relax_info->opcode, relax_info);
+ str_hash_insert (nds32_relax_info_hash, relax_info->opcode, relax_info, 0);
/* Initial relax hint hash table. */
nds32_hint_hash = str_htab_create ();
/* Append relax relocation for link time relaxing. */
static void
-nds32_elf_append_relax_relocs (const char *key, void *value)
+nds32_elf_append_relax_relocs (const char *key, const void *value)
{
struct nds32_relocs_pattern *relocs_pattern =
(struct nds32_relocs_pattern *) value;
nios2_ps_hash = str_htab_create ();
for (i = 0; i < nios2_num_opcodes; ++i)
- str_hash_insert (nios2_opcode_hash, nios2_opcodes[i].name,
- (PTR) & nios2_opcodes[i]);
+ if (str_hash_insert (nios2_opcode_hash, nios2_opcodes[i].name,
+ &nios2_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), nios2_opcodes[i].name);
for (i = 0; i < nios2_num_regs; ++i)
- str_hash_insert (nios2_reg_hash, nios2_regs[i].name,
- (PTR) & nios2_regs[i]);
+ if (str_hash_insert (nios2_reg_hash, nios2_regs[i].name,
+ &nios2_regs[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), nios2_regs[i].name);
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,
- (PTR) & nios2_ps_insn_info_structs[i]);
+ if (str_hash_insert (nios2_ps_hash,
+ nios2_ps_insn_info_structs[i].pseudo_insn,
+ &nios2_ps_insn_info_structs[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), nios2_ps_insn_info_structs[i].pseudo_insn);
/* Assembler option defaults. */
nios2_as_options.noat = FALSE;
c = *lineptr;
*(char *) lineptr = '\0';
- if (!(desc = (struct ns32k_opcode *) str_hash_find (inst_hash_handle, line)))
+ desc = (struct ns32k_opcode *) str_hash_find (inst_hash_handle, line);
+ if (!desc)
as_fatal (_("No such opcode"));
*(char *) lineptr = c;
endop = ns32k_opcodes + sizeof (ns32k_opcodes) / sizeof (ns32k_opcodes[0]);
for (ptr = ns32k_opcodes; ptr < endop; ptr++)
- str_hash_insert (inst_hash_handle, ptr->name, (char *) ptr);
+ if (str_hash_insert (inst_hash_handle, ptr->name, ptr, 0) != NULL)
+ as_fatal (_("duplicate %s"), ptr->name);
/* Some private space please! */
freeptr_static = XNEWVEC (char, PRIVATE_SIZE);
as_fatal (_("Virtual memory exhausted"));
for (i = 0; i < pdp11_num_opcodes; i++)
- str_hash_insert (insn_hash, pdp11_opcodes[i].name, (void *) (pdp11_opcodes + i));
+ str_hash_insert (insn_hash, pdp11_opcodes[i].name, pdp11_opcodes + i, 0);
for (i = 0; i < pdp11_num_aliases; i++)
- str_hash_insert (insn_hash, pdp11_aliases[i].name, (void *) (pdp11_aliases + i));
+ str_hash_insert (insn_hash, pdp11_aliases[i].name, pdp11_aliases + i, 0);
}
void
fake->opcode = -1;
fake->opcode_next = -1;
fake->u.func = func;
- str_hash_insert (opcode_hash_control, name, (char *) fake);
+ str_hash_insert (opcode_hash_control, name, fake, 0);
}
/* Enter another entry into the opcode hash table so the same opcode
alias (const char *new_name, const char *old)
{
str_hash_insert (opcode_hash_control, new_name,
- (char *) str_hash_find (opcode_hash_control, old));
+ str_hash_find (opcode_hash_control, old), 0);
}
/* This function is called once, at assembler startup time. It sets
/* Insert names into hash table. */
for (opcode = pj_opc_info; opcode->u.name; opcode++)
- str_hash_insert (opcode_hash_control, opcode->u.name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->u.name, opcode, 0);
/* Insert the only fake opcode. */
fake_opcode ("ipush", ipush_code);
}
if ((ppc_cpu & op->flags) != 0
- && !(ppc_cpu & op->deprecated))
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ && !(ppc_cpu & op->deprecated)
+ && str_hash_insert (ppc_hash, op->name, op, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), op->name);
+ bad_insn = TRUE;
+ }
}
if ((ppc_cpu & PPC_OPCODE_ANY) != 0)
for (op = powerpc_opcodes; op < op_end; op++)
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ str_hash_insert (ppc_hash, op->name, op, 0);
op_end = prefix_opcodes + prefix_num_opcodes;
for (op = prefix_opcodes; op < op_end; op++)
}
if ((ppc_cpu & op->flags) != 0
- && !(ppc_cpu & op->deprecated))
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ && !(ppc_cpu & op->deprecated)
+ && str_hash_insert (ppc_hash, op->name, op, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), op->name);
+ bad_insn = TRUE;
+ }
}
if ((ppc_cpu & PPC_OPCODE_ANY) != 0)
for (op = prefix_opcodes; op < op_end; op++)
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ str_hash_insert (ppc_hash, op->name, op, 0);
op_end = vle_opcodes + vle_num_opcodes;
for (op = vle_opcodes; op < op_end; op++)
}
if ((ppc_cpu & op->flags) != 0
- && !(ppc_cpu & op->deprecated))
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ && !(ppc_cpu & op->deprecated)
+ && str_hash_insert (ppc_hash, op->name, op, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), op->name);
+ bad_insn = TRUE;
+ }
}
/* SPE2 instructions */
bad_insn |= insn_validate (op);
}
- if ((ppc_cpu & op->flags) != 0 && !(ppc_cpu & op->deprecated))
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ if ((ppc_cpu & op->flags) != 0
+ && !(ppc_cpu & op->deprecated)
+ && str_hash_insert (ppc_hash, op->name, op, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), op->name);
+ bad_insn = TRUE;
+ }
}
for (op = spe2_opcodes; op < op_end; op++)
- str_hash_insert (ppc_hash, op->name, (void *) op);
+ str_hash_insert (ppc_hash, op->name, op, 0);
}
/* Insert the macros into a hash table. */
macro_end = powerpc_macros + powerpc_num_macros;
for (macro = powerpc_macros; macro < macro_end; macro++)
- {
- if ((macro->flags & ppc_cpu) != 0 || (ppc_cpu & PPC_OPCODE_ANY) != 0)
- str_hash_insert (ppc_macro_hash, macro->name, (void *) macro);
- }
+ if (((macro->flags & ppc_cpu) != 0
+ || (ppc_cpu & PPC_OPCODE_ANY) != 0)
+ && str_hash_insert (ppc_macro_hash, macro->name, macro, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), macro->name);
+ bad_insn = TRUE;
+ }
if (bad_insn)
abort ();
{
const struct powerpc_macro *macro;
- macro = (const struct powerpc_macro *) str_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)
as_bad (_("unrecognized opcode: `%s'"), str);
else
pru_reg_hash = str_htab_create ();
for (i = 0; i < NUMOPCODES; ++i)
- str_hash_insert (pru_opcode_hash, pru_opcodes[i].name,
- (PTR) & pru_opcodes[i]);
+ if (str_hash_insert (pru_opcode_hash, pru_opcodes[i].name,
+ &pru_opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), pru_opcodes[i].name);
for (i = 0; i < pru_num_regs; ++i)
- str_hash_insert (pru_reg_hash, pru_regs[i].name,
- (PTR) & pru_regs[i]);
+ if (str_hash_insert (pru_reg_hash, pru_regs[i].name, &pru_regs[i], 0))
+ as_fatal (_("duplicate %s"), pru_regs[i].name);
linkrelax = pru_opt.link_relax;
/* Initialize the alignment data. */
while (table[i].name)
{
const char *name = table[i].name;
- str_hash_insert (hash, name, (void *) &table[i]);
+ if (str_hash_insert (hash, name, &table[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
i++;
while (table[i].name
const struct opcode_name_t *opcode;
for (opcode = &opcode_name_list[0]; opcode->name != NULL; ++opcode)
- str_hash_insert (opcode_names_hash, opcode->name, (void *)opcode);
+ if (str_hash_insert (opcode_names_hash, opcode->name, opcode, 0) != NULL)
+ as_fatal (_("duplicate %s"), opcode->name);
}
/* Find `s` is a valid opcode name or not,
hash_reg_name (enum reg_class class, const char *name, unsigned n)
{
void *hash = ENCODE_REG_HASH (class, n);
- str_hash_insert (reg_names_hash, name, hash);
+ if (str_hash_insert (reg_names_hash, name, hash, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
}
static void
Otherwise, attach the extra information to the entry which is already
in the hash table. */
if (pre_entry == NULL)
- str_hash_insert (csr_extra_hash, name, (void *) entry);
+ str_hash_insert (csr_extra_hash, name, entry, 0);
else
pre_entry->next = entry;
}
while (opcodes[i].name)
{
const char *name = opcodes[i].name;
- str_hash_insert (hash, name, (void *) &opcodes[i]);
+ if (str_hash_insert (hash, name, &opcodes[i], 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
do
{
f = (op->flags & S390_INSTR_FLAG_FACILITY_MASK);
use_opcode = ((f & current_flags) == f);
}
- if (use_opcode)
- str_hash_insert (s390_opcode_hash, op->name, (void *) op);
+ if (use_opcode
+ && str_hash_insert (s390_opcode_hash, op->name, op, 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), op->name);
+ dup_insn = TRUE;
+ }
while (op < op_end - 1 && strcmp (op->name, op[1].name) == 0)
op++;
op_end = s390_opformats + s390_num_opformats;
for (op = s390_opformats; op < op_end; op++)
- str_hash_insert (s390_opformat_hash, op->name, (void *) op);
+ if (str_hash_insert (s390_opformat_hash, op->name, op, 0) != NULL)
+ as_fatal (_("duplicate %s"), op->name);
s390_setup_opcodes ();
const struct s3_insn_to_dependency *tmp;
strcpy (name, insn_name);
- tmp = (const struct s3_insn_to_dependency *) str_hash_find (s3_dependency_insn_hsh, name);
+ tmp = (const struct s3_insn_to_dependency *)
+ str_hash_find (s3_dependency_insn_hsh, name);
if (tmp)
return tmp->type;
c = *p;
*p = '\0';
- opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh, operator);
+ opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+ operator);
*p = c;
memset (&s3_inst, '\0', sizeof (s3_inst));
c = *p;
*p = '\0';
- opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh, operator);
+ opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+ operator);
*p = c;
memset (&s3_inst, '\0', sizeof (s3_inst));
}
buf2[i] = '\0';
- str_hash_insert (htab, buf, (void *) r);
- str_hash_insert (htab, buf2, (void *) r);
+ str_hash_insert (htab, buf, r, 0);
+ str_hash_insert (htab, buf2, r, 0);
}
static void
new_opcode->type = insn->type;
new_opcode->bitmask = insn->bitmask;
str_hash_insert (s3_score_ops_hsh, new_opcode->template_name,
- (void *) new_opcode);
+ new_opcode, 0);
}
}
strcpy (buf, tmp->insn_name);
new_i2n->insn_name = buf;
new_i2n->type = tmp->type;
- str_hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name,
- (void *) new_i2n);
+ str_hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name, new_i2n, 0);
}
}
const struct s7_insn_to_dependency *tmp;
strcpy (name, insn_name);
- tmp = (const struct s7_insn_to_dependency *) str_hash_find (s7_dependency_insn_hsh, name);
+ tmp = (const struct s7_insn_to_dependency *)
+ str_hash_find (s7_dependency_insn_hsh, name);
if (tmp)
return tmp->type;
c = *p;
*p = '\0';
- opcode = (const struct s7_asm_opcode *) str_hash_find (s7_score_ops_hsh, operator);
+ opcode = (const struct s7_asm_opcode *) str_hash_find (s7_score_ops_hsh,
+ operator);
*p = c;
memset (&s7_inst, '\0', sizeof (s7_inst));
new_opcode->type = insn->type;
new_opcode->bitmask = insn->bitmask;
str_hash_insert (s7_score_ops_hsh, new_opcode->template_name,
- (void *) new_opcode);
+ new_opcode, 0);
}
}
strcpy (insn_name, tmp->insn_name);
new_i2d->insn_name = insn_name;
new_i2d->type = tmp->type;
- str_hash_insert (s7_dependency_insn_hsh, new_i2d->insn_name,
- (void *) new_i2d);
+ str_hash_insert (s7_dependency_insn_hsh, new_i2d->insn_name, new_i2d, 0);
}
}
}
buf2[i] = '\0';
- str_hash_insert (htab, buf, (void *) r);
- str_hash_insert (htab, buf2, (void *) r);
+ str_hash_insert (htab, buf, r, 0);
+ str_hash_insert (htab, buf2, r, 0);
}
static void
if (!SH_MERGE_ARCH_SET_VALID (opcode->arch, target_arch))
continue;
prev_name = opcode->name;
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
}
}
}
while (i < (unsigned int) sparc_num_opcodes)
{
const char *name = sparc_opcodes[i].name;
- str_hash_insert (op_hash, name, (void *) &sparc_opcodes[i]);
+ if (str_hash_insert (op_hash, name, &sparc_opcodes[i], 0) != NULL)
+ {
+ as_bad (_("duplicate %s"), name);
+ lose = 1;
+ }
do
{
if (sparc_opcodes[i].match & sparc_opcodes[i].lose)
name, native_op_table[i].name);
lose = 1;
}
- else
- str_hash_insert (op_hash, native_op_table[i].name,
- (void *) insn);
+ else if (str_hash_insert (op_hash, native_op_table[i].name, insn, 0))
+ {
+ as_bad (_("duplicate %s"), native_op_table[i].name);
+ lose = 1;
+ }
}
if (lose)
{
int i;
- /* initialize hash table */
-
op_hash = str_htab_create ();
- /* loop until you see the end of the list */
-
+ /* Hash each mnemonic and record its position. There are
+ duplicates, keep just the first. */
for (i = 0; i < spu_num_opcodes; i++)
- /* hash each mnemonic and record its position */
- if (str_hash_find (op_hash, spu_opcodes[i].mnemonic) == NULL)
- str_hash_insert (op_hash, spu_opcodes[i].mnemonic,
- (void *) &spu_opcodes[i]);
+ str_hash_insert (op_hash, spu_opcodes[i].mnemonic, &spu_opcodes[i], 0);
}
\f
const char *md_shortopts = "";
const insn_template *current_optab = tic30_optab;
for (; current_optab < tic30_optab_end; current_optab++)
- str_hash_insert (op_hash, current_optab->name,
- (char *) current_optab);
+ if (str_hash_insert (op_hash, current_optab->name, current_optab, 0))
+ as_fatal (_("duplicate %s"), current_optab->name);
}
parop_hash = str_htab_create ();
const partemplate *current_parop = tic30_paroptab;
for (; current_parop < tic30_paroptab_end; current_parop++)
- str_hash_insert (parop_hash, current_parop->name,
- (char *) current_parop);
+ if (str_hash_insert (parop_hash, current_parop->name, current_parop, 0))
+ as_fatal (_("duplicate %s"), current_parop->name);
}
reg_hash = str_htab_create ();
const reg *current_reg = tic30_regtab;
for (; current_reg < tic30_regtab_end; current_reg++)
- str_hash_insert (reg_hash, current_reg->name,
- (char *) current_reg);
+ if (str_hash_insert (reg_hash, current_reg->name, current_reg, 0))
+ as_fatal (_("duplicate %s"), current_reg->name);
}
ind_hash = str_htab_create ();
const ind_addr_type *current_ind = tic30_indaddr_tab;
for (; current_ind < tic30_indaddrtab_end; current_ind++)
- str_hash_insert (ind_hash, current_ind->syntax,
- (char *) current_ind);
+ if (str_hash_insert (ind_hash, current_ind->syntax, current_ind, 0))
+ as_fatal (_("duplicate %s"), current_ind->syntax);
}
/* Fill in lexical tables: opcode_chars, operand_chars, space_chars. */
c = get_symbol_name (&name); /* Get terminator. */
str = xstrdup (str);
name = xstrdup (name);
- str_hash_insert (tic4x_asg_hash, name, str);
+ str_hash_insert (tic4x_asg_hash, name, str, 1);
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
}
if (!strcmp (inst->name, prev_name) || inst->name[0] == '\0')
return;
- str_hash_insert (tic4x_op_hash, inst->name, (void *) inst);
+ if (str_hash_insert (tic4x_op_hash, inst->name, inst, 0) != NULL)
+ as_fatal (_("duplicate %s"), inst->name);
+
strcpy (prev_name, inst->name);
}
replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name,
name + strlen (S_GET_NAME (rootsym)), NULL);
- str_hash_insert (subsym_hash[0], name, replacement);
+ str_hash_insert (subsym_hash[0], name, replacement, 0);
}
/* Recurse if the field is a structure.
/* Nested .structs don't get put in the stag table. */
if (current_stag->outer == NULL)
{
- str_hash_insert (stag_hash, current_stag->name, current_stag);
+ str_hash_insert (stag_hash, current_stag->name, current_stag, 0);
stag_add_field_symbols (current_stag, path,
S_GET_VALUE (current_stag->sym),
NULL, NULL);
c = get_symbol_name (&name);
/* .var symbols start out with a null string. */
name = xstrdup (name);
- str_hash_insert (subsym_hash[macro_level], name, empty);
+ str_hash_insert (subsym_hash[macro_level], name, empty, 0);
c = restore_line_pointer (c);
if (c == ',')
{
name[entry->name.len] = '\0';
value[entry->actual.len] = '\0';
- str_hash_insert (subsym_hash[macro_level], name, value);
+ str_hash_insert (subsym_hash[macro_level], name, value, 0);
}
}
op_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_optab; tm->name; tm++)
- {
- if (str_hash_find (op_hash, tm->name))
- continue;
- str_hash_insert (op_hash, tm->name, (char *) tm);
- }
+ str_hash_insert (op_hash, tm->name, tm, 0);
+
parop_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++)
- {
- if (str_hash_find (parop_hash, tm->name))
- continue;
- str_hash_insert (parop_hash, tm->name, (char *) tm);
- }
+ str_hash_insert (parop_hash, tm->name, tm, 0);
+
reg_hash = str_htab_create ();
for (sym = (tic54x_symbol *) regs; sym->name; sym++)
{
&zero_address_frag, sym->value);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
- str_hash_insert (reg_hash, sym->name, (char *) sym);
+ str_hash_insert (reg_hash, sym->name, sym, 0);
}
for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
- str_hash_insert (reg_hash, sym->name, (char *) sym);
+ str_hash_insert (reg_hash, sym->name, sym, 0);
mmreg_hash = str_htab_create ();
for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
- str_hash_insert (mmreg_hash, sym->name, (char *) sym);
+ str_hash_insert (mmreg_hash, sym->name, sym, 0);
cc_hash = str_htab_create ();
for (sym = (tic54x_symbol *) condition_codes; sym->name; sym++)
- str_hash_insert (cc_hash, sym->name, (char *) sym);
+ str_hash_insert (cc_hash, sym->name, sym, 0);
cc2_hash = str_htab_create ();
for (sym = (tic54x_symbol *) cc2_codes; sym->name; sym++)
- str_hash_insert (cc2_hash, sym->name, (char *) sym);
+ str_hash_insert (cc2_hash, sym->name, sym, 0);
cc3_hash = str_htab_create ();
for (sym = (tic54x_symbol *) cc3_codes; sym->name; sym++)
- str_hash_insert (cc3_hash, sym->name, (char *) sym);
+ str_hash_insert (cc3_hash, sym->name, sym, 0);
sbit_hash = str_htab_create ();
for (sym = (tic54x_symbol *) status_bits; sym->name; sym++)
- str_hash_insert (sbit_hash, sym->name, (char *) sym);
+ str_hash_insert (sbit_hash, sym->name, sym, 0);
misc_symbol_hash = str_htab_create ();
for (symname = (char **) misc_symbols; *symname; symname++)
- str_hash_insert (misc_symbol_hash, *symname, *symname);
+ str_hash_insert (misc_symbol_hash, *symname, *symname, 0);
/* Only the base substitution table and local label table are initialized;
the others (for local macro substitution) get instantiated as needed. */
local_label_hash[0] = str_htab_create ();
subsym_hash[0] = str_htab_create ();
for (subsym_proc = subsym_procs; subsym_proc->name; subsym_proc++)
- str_hash_insert (subsym_hash[0], subsym_proc->name,
- (char *) subsym_proc);
+ str_hash_insert (subsym_hash[0], subsym_proc->name, subsym_proc, 0);
math_hash = str_htab_create ();
for (math_proc = math_procs; math_proc->name; math_proc++)
{
/* Insert into the main subsym hash for recognition; insert into
the math hash to actually store information. */
- str_hash_insert (subsym_hash[0], math_proc->name,
- (char *) math_proc);
- str_hash_insert (math_hash, math_proc->name,
- (char *) math_proc);
+ str_hash_insert (subsym_hash[0], math_proc->name, math_proc, 0);
+ str_hash_insert (math_hash, math_proc->name, math_proc, 0);
}
subsym_recurse_hash = str_htab_create ();
stag_hash = str_htab_create ();
if (optimize_insn (insn))
{
insn->tm = (insn_template *) str_hash_find (op_hash,
- insn->mnemonic);
+ insn->mnemonic);
continue;
}
int i;
for (i = macro_level; i > 0; i--)
- str_hash_insert (subsym_hash[i], name, value);
- str_hash_insert (subsym_hash[0], name, value);
+ if (str_hash_find (subsym_hash[i], name))
+ {
+ str_hash_insert (subsym_hash[i], name, value, 1);
+ return;
+ }
+ str_hash_insert (subsym_hash[0], name, value, 1);
}
/* Look up the substitution string replacement for the given symbol.
value[strlen (value) - 1] = '\0';
sprintf (digit, ".%d", local_label_id++);
strcat (value, digit);
- str_hash_insert (local_label_hash[macro_level], namecopy, value);
+ str_hash_insert (local_label_hash[macro_level],
+ namecopy, value, 0);
}
/* Indicate where to continue looking for substitutions. */
ptr = tail;
try to replace a symbol once. */
if (recurse)
{
- str_hash_insert (subsym_recurse_hash, name, name);
+ str_hash_insert (subsym_recurse_hash, name, name, 0);
value = subsym_substitute (value, macro_level > 0);
str_hash_delete (subsym_recurse_hash, name);
}
tic54x_symbol *sym;
/* Not sure how to handle predefined symbols. */
- if ((sym = (tic54x_symbol *) str_hash_find (cc_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) str_hash_find (cc2_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) str_hash_find (cc3_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) str_hash_find (misc_symbol_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) str_hash_find (sbit_hash, name)) != NULL)
+ if ((sym = (tic54x_symbol *) str_hash_find (cc_hash, name)) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (cc2_hash, name)) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (cc3_hash, name)) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (misc_symbol_hash,
+ name)) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (sbit_hash, name)) != NULL)
{
return symbol_new (name, reg_section, &zero_address_frag, sym->value);
}
- if ((sym = (tic54x_symbol *) str_hash_find (reg_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) str_hash_find (mmreg_hash, name)) != NULL ||
- !strcasecmp (name, "a") || !strcasecmp (name, "b"))
+ if ((sym = (tic54x_symbol *) str_hash_find (reg_hash, name)) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (mmreg_hash, name)) != NULL
+ || !strcasecmp (name, "a")
+ || !strcasecmp (name, "b"))
{
return symbol_new (name, reg_section, &zero_address_frag,
sym ? sym->value : 0);
opc->id = id;
opc->next = str_hash_find (opcode_hash, tic6x_opcode_table[id].name);
- str_hash_insert (opcode_hash, tic6x_opcode_table[id].name, opc);
+ str_hash_insert (opcode_hash, tic6x_opcode_table[id].name, opc, 1);
}
/* Save the current subseg so we can restore it [it's the default one and
/* Initialize special operator hash table. */
special_operator_hash = str_htab_create ();
#define INSERT_SPECIAL_OP(name) \
- str_hash_insert (special_operator_hash, #name, (void *)O_##name)
+ str_hash_insert (special_operator_hash, #name, (void *) O_##name, 0)
INSERT_SPECIAL_OP (hw0);
INSERT_SPECIAL_OP (hw1);
INSERT_SPECIAL_OP (hw1_last);
INSERT_SPECIAL_OP (hw2_last);
/* hw3_last is a convenience alias for the equivalent hw3. */
- str_hash_insert (special_operator_hash, "hw3_last", (void*)O_hw3);
+ str_hash_insert (special_operator_hash, "hw3_last", (void *) O_hw3, 0);
INSERT_SPECIAL_OP (hw0_got);
INSERT_SPECIAL_OP (hw0_last_got);
INSERT_SPECIAL_OP (hw1_last_got);
/* Initialize op_hash hash table. */
op_hash = str_htab_create ();
for (op = &tilegx_opcodes[0]; op->name != NULL; op++)
- str_hash_insert (op_hash, op->name, (void *)op);
+ if (str_hash_insert (op_hash, op->name, op, 0) != NULL)
+ as_fatal (_("duplicate %s"), op->name);
/* Initialize the spr hash table. */
parsing_spr = 0;
spr_hash = str_htab_create ();
for (i = 0; i < tilegx_num_sprs; i++)
- str_hash_insert (spr_hash, tilegx_sprs[i].name,
- (void *) &tilegx_sprs[i]);
+ str_hash_insert (spr_hash, tilegx_sprs[i].name, &tilegx_sprs[i], 0);
/* Set up the main_reg_hash table. We use this instead of
creating a symbol in the register section to avoid ambiguities
char buf[64];
str_hash_insert (main_reg_hash, tilegx_register_names[i],
- (void *) (long) (i | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (i | CANONICAL_REG_NAME_FLAG), 0);
/* See if we should insert a noncanonical alias, like r63. */
sprintf (buf, "r%d", i);
if (strcmp (buf, tilegx_register_names[i]) != 0)
str_hash_insert (main_reg_hash, xstrdup (buf),
- (void *) (long) (i | NONCANONICAL_REG_NAME_FLAG));
+ (void *) (long) (i | NONCANONICAL_REG_NAME_FLAG), 0);
}
}
old_char = str[opname_len];
str[opname_len] = '\0';
- op = str_hash_find(op_hash, str);
+ op = str_hash_find (op_hash, str);
str[opname_len] = old_char;
if (op == NULL)
{
/* Initialize special operator hash table. */
special_operator_hash = str_htab_create ();
#define INSERT_SPECIAL_OP(name) \
- str_hash_insert (special_operator_hash, #name, (void *)O_##name)
+ str_hash_insert (special_operator_hash, #name, (void *) O_##name, 0)
INSERT_SPECIAL_OP(lo16);
INSERT_SPECIAL_OP(hi16);
/* Initialize op_hash hash table. */
op_hash = str_htab_create ();
for (op = &tilepro_opcodes[0]; op->name != NULL; op++)
- str_hash_insert (op_hash, op->name, (void *)op);
+ if (str_hash_insert (op_hash, op->name, op, 0) != NULL)
+ as_fatal (_("duplicate %s"), op->name);
/* Initialize the spr hash table. */
parsing_spr = 0;
spr_hash = str_htab_create ();
for (i = 0; i < tilepro_num_sprs; i++)
- str_hash_insert (spr_hash, tilepro_sprs[i].name,
- (void *) &tilepro_sprs[i]);
+ str_hash_insert (spr_hash, tilepro_sprs[i].name, &tilepro_sprs[i], 0);
/* Set up the main_reg_hash table. We use this instead of
* creating a symbol in the register section to avoid ambiguities
char buf[64];
str_hash_insert (main_reg_hash, tilepro_register_names[i],
- (void *) (long)(i | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (i | CANONICAL_REG_NAME_FLAG), 0);
/* See if we should insert a noncanonical alias, like r63. */
sprintf (buf, "r%d", i);
if (strcmp (buf, tilepro_register_names[i]) != 0)
str_hash_insert (main_reg_hash, xstrdup (buf),
- (void *) (long)(i | NONCANONICAL_REG_NAME_FLAG));
+ (void *) (long) (i | NONCANONICAL_REG_NAME_FLAG), 0);
}
/* Insert obsolete backwards-compatibility register names. */
str_hash_insert (main_reg_hash, "io0",
- (void *) (long) (TREG_IDN0 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_IDN0 | CANONICAL_REG_NAME_FLAG), 0);
str_hash_insert (main_reg_hash, "io1",
- (void *) (long) (TREG_IDN1 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_IDN1 | CANONICAL_REG_NAME_FLAG), 0);
str_hash_insert (main_reg_hash, "us0",
- (void *) (long) (TREG_UDN0 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_UDN0 | CANONICAL_REG_NAME_FLAG), 0);
str_hash_insert (main_reg_hash, "us1",
- (void *) (long) (TREG_UDN1 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_UDN1 | CANONICAL_REG_NAME_FLAG), 0);
str_hash_insert (main_reg_hash, "us2",
- (void *) (long) (TREG_UDN2 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_UDN2 | CANONICAL_REG_NAME_FLAG), 0);
str_hash_insert (main_reg_hash, "us3",
- (void *) (long) (TREG_UDN3 | CANONICAL_REG_NAME_FLAG));
+ (void *) (long) (TREG_UDN3 | CANONICAL_REG_NAME_FLAG), 0);
}
old_char = str[opname_len];
str[opname_len] = '\0';
- op = str_hash_find(op_hash, str);
+ op = str_hash_find (op_hash, str);
str[opname_len] = old_char;
if (op == NULL)
{
if (strcmp (prev_name, op->name))
{
prev_name = (char *) op->name;
- if (str_hash_find (v850_hash, op->name) == NULL)
- str_hash_insert (v850_hash, op->name, (char *) op);
+ str_hash_insert (v850_hash, op->name, op, 0);
}
op++;
}
op_hash = str_htab_create ();
for (vP = votstrs; *vP->vot_name; vP++)
- str_hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
+ if (str_hash_insert (op_hash, vP->vot_name, &vP->vot_detail, 0) != NULL)
+ as_fatal (_("duplicate %s"), vP->vot_name);
if (synthetic_too)
for (vP = synthetic_votstrs; *vP->vot_name; vP++)
- str_hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
+ if (str_hash_insert (op_hash, vP->vot_name, &vP->vot_detail, 0) != NULL)
+ as_fatal (_("duplicate %s"), vP->vot_name);
#ifndef CONST_TABLE
vip_op_defaults (immediate, indirect, displen);
provides a quick index to the first opcode with a particular name
in the opcode table. */
for (opcode = wasm32_opcodes; opcode->name; opcode++)
- str_hash_insert (wasm32_hash, opcode->name, (char *) opcode);
+ str_hash_insert (wasm32_hash, opcode->name, opcode, 0);
linkrelax = 0;
flag_sectname_subst = 1;
j++;
op_handles[j].name = xgate_opcode_ptr->name;
op_handles[j].opc0[0] = xgate_opcode_ptr;
- str_hash_insert (xgate_hash, (char *) op_handles[j].name,
- (char *) &(op_handles[j]));
+ str_hash_insert (xgate_hash, op_handles[j].name, &op_handles[j], 0);
}
op_handles[j].number_of_modes = handle_enum;
prev_op_name = op_handles[j].name;
if (!op_name[0])
as_bad (_("opcode missing or not found on input line"));
- if (!(opcode_handle = (struct xgate_opcode_handle *) str_hash_find (xgate_hash,
- op_name)))
- {
- as_bad (_("opcode %s not found in opcode hash table"), op_name);
- }
+ opcode_handle = (struct xgate_opcode_handle *) str_hash_find (xgate_hash,
+ op_name);
+ if (!opcode_handle)
+ as_bad (_("opcode %s not found in opcode hash table"), op_name);
else
{
/* Parse operands so we can find the proper opcode bin. */
input_line = macro_inline; /* Rewind. */
p = extract_word (p, op_name, 10);
- if (!(opcode_handle = (struct xgate_opcode_handle *)
- str_hash_find (xgate_hash, op_name)))
+ opcode_handle
+ = (struct xgate_opcode_handle *) str_hash_find (xgate_hash,
+ op_name);
+ if (!opcode_handle)
{
as_bad (_(": processing macro, real opcode handle"
" not found in hash"));
{
/* Only enter unique codes into the table. */
if (idx != opcode->idx)
- str_hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
+ str_hash_insert (opcode_hash_control, opcode->name, opcode, 0);
idx = opcode->idx;
}
fake_opcode->name = md_pseudo_table[idx].poc_name;
fake_opcode->func = (void *) (md_pseudo_table + idx);
fake_opcode->opcode = 250;
- str_hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
+ str_hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode, 0);
}
}
{
item = alloc_debugseg_item (make_debug_seg (cseg, name, flags), 0, name);
- str_hash_insert (dwcfi_hash, item->seg_name, (char *) item);
+ str_hash_insert (dwcfi_hash, item->seg_name, item, 0);
}
else
free (name);
strcpy (hash_ptr->string, str);
- str_hash_insert (hash_tbl, str, (char *) hash_ptr);
+ if (str_hash_insert (hash_tbl, str, hash_ptr, 0) != NULL)
+ as_fatal (_("duplicate %s"), str);
}
if (ret_hash != (shash_t **) NULL)
perm = xstrdup (tag);
hash_ptr = allocate_shash ();
- str_hash_insert (tag_hash, perm, (char *) hash_ptr);
+ str_hash_insert (tag_hash, perm, hash_ptr, 0);
hash_ptr->string = perm;
}
#include "as.h"
-/* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */
+/* Insert ELEMENT into HTAB. If REPLACE is non-zero existing elements
+ are overwritten. If ELEMENT already exists, a pointer to the slot
+ is returned. Otherwise NULL is returned. */
-void
-htab_insert (htab_t htab, PTR element)
+void **
+htab_insert (htab_t htab, void *element, int replace)
{
void **slot = htab_find_slot (htab, element, INSERT);
- if (slot != NULL && htab->del_f)
- (*htab->del_f) (*slot);
-
+ if (*slot != NULL)
+ {
+ if (replace)
+ {
+ if (htab->del_f)
+ (*htab->del_f) (*slot);
+ *slot = element;
+ }
+ return slot;
+ }
*slot = element;
+ return NULL;
}
/* Print statistics about a hash table. */
#ifndef HASH_H
#define HASH_H
-/* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */
+/* Insert ELEMENT into HTAB. If REPLACE is non-zero existing elements
+ are overwritten. If ELEMENT already exists, a pointer to the slot
+ is returned. Otherwise NULL is returned. */
-extern void htab_insert (htab_t, void *);
+extern void **htab_insert (htab_t, void * /* element */, int /* replace */);
/* Print statistics about a hash table. */
struct string_tuple
{
const char *key;
- char *value;
+ const void *value;
};
typedef struct string_tuple string_tuple_t;
}
static inline string_tuple_t *
-string_tuple_alloc (const char *key, char *value)
+string_tuple_alloc (const char *key, const void *value)
{
string_tuple_t *tuple = XNEW (string_tuple_t);
tuple->key = key;
{
string_tuple_t needle = { key, NULL };
string_tuple_t *tuple = htab_find (table, &needle);
- return tuple != NULL ? tuple->value : NULL;
+ return tuple != NULL ? (void *) tuple->value : NULL;
}
static inline void *
string_tuple_t needle = { tmp, NULL };
string_tuple_t *tuple = htab_find (table, &needle);
free (tmp);
- return tuple != NULL ? tuple->value : NULL;
+ return tuple != NULL ? (void *) tuple->value : NULL;
}
static inline void
htab_remove_elt (table, &needle);
}
-static inline void
-str_hash_insert (htab_t table, const char *key, void *value)
+static inline void **
+str_hash_insert (htab_t table, const char *key, const void *value, int replace)
{
- htab_insert (table, string_tuple_alloc (key, value));
+ string_tuple_t *elt = string_tuple_alloc (key, value);
+ void **slot = htab_insert (table, elt, replace);
+ if (slot && !replace)
+ free (elt);
+ return slot;
}
static inline htab_t
{
formal_entry *formal = new_formal ();
size_t cidx;
+ formal_hash_entry_t *elt;
idx = get_token (idx, in, &formal->name);
if (formal->name.len == 0)
}
/* Add to macro's hash table. */
- if (formal_entry_find (macro->formal_hash, name) == NULL)
- htab_insert (macro->formal_hash, formal_entry_alloc (name, formal));
- else
- as_bad_where (macro->file,
- macro->line,
- _("A parameter named `%s' already exists for macro `%s'"),
- name,
- macro->name);
+ elt = formal_entry_alloc (name, formal);
+ if (htab_insert (macro->formal_hash, elt, 0) != NULL)
+ {
+ free (elt);
+ as_bad_where (macro->file, macro->line,
+ _("A parameter named `%s' "
+ "already exists for macro `%s'"),
+ name, macro->name);
+ }
formal->index = macro->formal_count++;
*p = formal;
if (macro_mri)
{
formal_entry *formal = new_formal ();
+ formal_hash_entry_t *elt;
/* Add a special NARG formal, which macro_expand will set to the
number of arguments. */
sb_add_string (&formal->name, name);
/* Add to macro's hash table. */
- if (formal_entry_find (macro->formal_hash, name))
- as_bad_where (macro->file,
- macro->line,
- _("Reserved word `%s' used as parameter in macro `%s'"),
- name,
- macro->name);
- htab_insert (macro->formal_hash, formal_entry_alloc (name, formal));
+ elt = formal_entry_alloc (name, formal);
+ if (htab_insert (macro->formal_hash, elt, 0) != NULL)
+ {
+ free (elt);
+ as_bad_where (macro->file, macro->line,
+ _("Reserved word `%s' used as parameter in macro `%s'"),
+ name, macro->name);
+ }
formal->index = NARG_INDEX;
*p = formal;
/* And stick it in the macro hash table. */
for (idx = 0; idx < name.len; idx++)
name.ptr[idx] = TOLOWER (name.ptr[idx]);
- if (macro_entry_find (macro_hash, macro->name))
- error = _("Macro `%s' was already defined");
if (!error)
- htab_insert (macro_hash, macro_entry_alloc (macro->name, macro));
+ {
+ macro_hash_entry_t *elt = macro_entry_alloc (macro->name, macro);
+ if (htab_insert (macro_hash, elt, 0) != NULL)
+ {
+ free (elt);
+ error = _("Macro `%s' was already defined");
+ }
+ }
if (namep != NULL)
*namep = macro->name;
{
const char *name;
formal_entry *f = new_formal ();
+ formal_hash_entry_t *elt;
src = get_token (src, in, &f->name);
name = sb_terminate (&f->name);
- if (formal_entry_find (formal_hash, name) == NULL)
+ elt = formal_entry_alloc (name, f);
+ if (htab_insert (formal_hash, elt, 0) != NULL)
+ {
+ free (elt);
+ as_bad_where (macro->file, macro->line + macro_line,
+ _("`%s' was already used as parameter "
+ "(or another local) name"), name);
+ del_formal (f);
+ }
+ else
{
static int loccnt;
char buf[20];
sprintf (buf, IS_ELF ? ".LL%04x" : "LL%04x", ++loccnt);
sb_add_string (&f->actual, buf);
-
- htab_insert (formal_hash, formal_entry_alloc (name, f));
- }
- else
- {
- as_bad_where (macro->file,
- macro->line + macro_line,
- _("`%s' was already used as parameter (or another local) name"),
- name);
- del_formal (f);
}
src = sb_skip_comma (src, in);
{
char *copy;
size_t i, len;
- macro_entry *macro;
+ void **slot;
+ macro_hash_entry_t needle;
len = strlen (name);
copy = XNEWVEC (char, len + 1);
copy[i] = TOLOWER (name[i]);
copy[i] = '\0';
- /* We can only ask hash_delete to free memory if we are deleting
- macros in reverse order to their definition.
- So just clear out the entry. */
- macro = macro_entry_find (macro_hash, copy);
- if (macro)
+ needle.name = copy;
+ needle.macro = NULL;
+ slot = htab_find_slot (macro_hash, &needle, NO_INSERT);
+ if (slot)
{
- htab_insert (macro_hash, macro_entry_alloc (copy, NULL));
- free_macro (macro);
+ free_macro (((macro_hash_entry_t *) *slot)->macro);
+ htab_clear_slot (macro_hash, slot);
}
else
as_warn (_("Attempt to purge non-existing macro `%s'"), copy);
+ free (copy);
}
/* Handle the MRI IRP and IRPC pseudo-ops. These are handled as a
h = htab_create_alloc (16, hash_formal_entry, eq_formal_entry,
NULL, xcalloc, free);
- htab_insert (h, formal_entry_alloc (sb_terminate (&f.name), &f));
+ htab_insert (h, formal_entry_alloc (sb_terminate (&f.name), &f), 0);
f.index = 1;
f.next = NULL;
const pseudo_typeS *pop;
for (pop = table; pop->poc_name; pop++)
{
- int exists = po_entry_find (po_hash, pop->poc_name) != NULL;
- if (!pop_override_ok && exists)
- as_fatal (_("error constructing %s pseudo-op table"), pop_table_name);
- else if (!exists)
- htab_insert (po_hash, po_entry_alloc (pop->poc_name, pop));
+ po_entry_t *elt = po_entry_alloc (pop->poc_name, pop);
+ if (htab_insert (po_hash, elt, 0) != NULL)
+ {
+ free (elt);
+ if (!pop_override_ok)
+ as_fatal (_("error constructing %s pseudo-op table"),
+ pop_table_name);
+ }
}
}
ret->section = section;
ret->value = val;
- htab_insert (sy_hash, ret);
+ htab_insert (sy_hash, ret, 1);
return ret;
}
{
know (symbolP);
- htab_insert (sy_hash, symbolP);
+ htab_insert (sy_hash, symbolP, 1);
}
\f
/* If a symbol name does not exist, create it as undefined, and insert
--- /dev/null
+#as: -mpower4 -many
+#objdump: -dr -Mpower4
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+ 0: (7d 40 5a 2c|2c 5a 40 7d) dcbt 0,r11,10
--- /dev/null
+ .text
+ dcbt 0,11,0b01010
run_dump_test "xvtlsbb"
run_dump_test "rightmost"
run_dump_test "scalarquad"
+
+run_dump_test "dcbt"