/* tc-tic54x.c -- Assembly code for the Texas Instruments TMS320C54X
- Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
Contributed by Timothy Wall (twall@cygnus.com)
This file is part of GAS, the GNU Assembler.
/* This ensures that all new labels are unique. */
static int local_label_id;
-static struct hash_control *subsym_recurse_hash; /* Prevent infinite recurse. */
-static struct hash_control *math_hash; /* Built-in math functions. */
+static htab_t subsym_recurse_hash; /* Prevent infinite recurse. */
+static htab_t math_hash; /* Built-in math functions. */
/* Allow maximum levels of macro nesting; level 0 is the main substitution
symbol table. The other assembler only does 32 levels, so there! */
-static struct hash_control *subsym_hash[100];
+#define MAX_SUBSYM_HASH 100
+static htab_t subsym_hash[MAX_SUBSYM_HASH];
/* 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
We use our own macro nesting counter, since GAS overloads it when expanding
other things (like conditionals and repeat loops). */
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. */
-static struct hash_control *stag_hash;
-static struct hash_control *op_hash;
-static struct hash_control *parop_hash;
-static struct hash_control *reg_hash;
-static struct hash_control *mmreg_hash;
-static struct hash_control *cc_hash;
-static struct hash_control *cc2_hash;
-static struct hash_control *cc3_hash;
-static struct hash_control *sbit_hash;
-static struct hash_control *misc_symbol_hash;
+static htab_t stag_hash;
+static htab_t op_hash;
+static htab_t parop_hash;
+static htab_t reg_hash;
+static htab_t mmreg_hash;
+static htab_t cc_hash;
+static htab_t cc2_hash;
+static htab_t cc3_hash;
+static htab_t sbit_hash;
+static htab_t misc_symbol_hash;
/* Only word (et al.), align, or conditionals are allowed within
.struct/.union. */
str = input_line_pointer;
while ((c = *input_line_pointer) != ',')
{
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) c])
break;
++input_line_pointer;
}
ignore_rest_of_line ();
return;
}
- symbolP = symbol_new (name, absolute_section,
- (valueT) value, &zero_address_frag);
+ symbolP = symbol_new (name, absolute_section, &zero_address_frag, value);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
while (field != NULL)
{
char *name = concat (prefix, field->name, NULL);
+ char *freename = name;
if (rootsym == NULL)
{
symbolS *sym;
- sym = symbol_new (name, absolute_section,
- (field->stag ? field->offset :
- (valueT) (base_offset + field->offset)),
- &zero_address_frag);
+ sym = symbol_new (name, absolute_section, &zero_address_frag,
+ (field->stag ? field->offset
+ : base_offset + field->offset));
SF_SET_LOCAL (sym);
symbol_table_insert (sym);
}
replacement = concat (S_GET_NAME (rootsym), "+", root_stag_name,
name + strlen (S_GET_NAME (rootsym)), NULL);
- hash_insert (subsym_hash[0], name, replacement);
+ str_hash_insert (subsym_hash[0], name, replacement, 0);
+ freename = NULL;
}
/* Recurse if the field is a structure.
field->offset,
rootsym, root_stag_name);
field = field->next;
- free (name);
+ free (freename);
}
free (prefix);
}
/* Only create a symbol for this field if the parent has no name. */
if (!strncmp (".fake", parent->name, 5))
{
- symbolS *sym = symbol_new (name, absolute_section,
- (valueT) offset, &zero_address_frag);
+ symbolS *sym = symbol_new (name, absolute_section, &zero_address_frag,
+ offset);
SF_SET_LOCAL (sym);
symbol_table_insert (sym);
}
{
/* Offset is ignored in inner structs. */
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
start_offset = get_absolute_expression ();
else
start_offset = 0;
char fake[] = ".fake_stagNNNNNNN";
sprintf (fake, ".fake_stag%d", struct_count++);
current_stag->sym = symbol_new (fake, absolute_section,
- (valueT) abs_section_offset,
- &zero_address_frag);
+ &zero_address_frag,
+ abs_section_offset);
}
else
{
char * label = xstrdup (S_GET_NAME (line_label));
current_stag->sym = symbol_new (label,
absolute_section,
- (valueT) abs_section_offset,
- &zero_address_frag);
+ &zero_address_frag,
+ abs_section_offset);
free (label);
}
current_stag->name = S_GET_NAME (current_stag->sym);
/* Nested .structs don't get put in the stag table. */
if (current_stag->outer == NULL)
{
- 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);
{
char *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)
{
int longword_align = 0;
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
count = get_absolute_expression ();
switch (type)
if (c == ',')
{
input_line_pointer++;
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) *input_line_pointer])
c = *input_line_pointer;
}
}
/* Remove the symbol from the local label hash lookup. */
-static void
-tic54x_remove_local_label (const char *key, void *value ATTRIBUTE_UNUSED)
+static int
+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);
+ return 0;
}
/* Reset all local labels. */
static void
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
blocking_flag = alignment_flag = 0;
seg = subseg_new (name, 0);
- flags = bfd_get_section_flags (stdoutput, seg) | SEC_ALLOC;
+ flags = bfd_section_flags (seg) | SEC_ALLOC;
if (alignment_flag)
{
if (blocking_flag)
flags |= SEC_TIC54X_BLOCK;
- if (!bfd_set_section_flags (stdoutput, seg, flags))
+ if (!bfd_set_section_flags (seg, flags))
as_warn (_("Error setting flags for \"%s\": %s"), name,
bfd_errmsg (bfd_get_error ()));
if (version == V545LP || version == V546LP)
{
symbolS *symbolP = symbol_new ("__allow_lp", absolute_section,
- (valueT) 1, &zero_address_frag);
+ &zero_address_frag, 1);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
}
SKIP_WHITESPACE ();
ver = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
/* Only ".align" with no argument is allowed within .struct/.union. */
int count = arg;
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
{
if (arg == 2)
as_warn (_("Argument to .even ignored"));
else
{
filename = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = '\0';
else
{
msg = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
absolute local symbols. */
static void
-tic54x_mmregs (int ignored ATTRIBUTE_UNUSED)
+tic54x_register_mmregs (int ignored ATTRIBUTE_UNUSED)
{
- tic54x_symbol *sym;
+ const tic54x_symbol *sym;
ILLEGAL_WITHIN_STRUCT ();
- for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
+ for (sym = tic54x_mmregs; sym->name; sym++)
{
symbolS *symbolP = symbol_new (sym->name, absolute_section,
- (valueT) sym->value, &zero_address_frag);
+ &zero_address_frag, sym->value);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
}
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
count = get_absolute_expression ();
do_repeat ((size_t) count, "LOOP", "ENDLOOP");
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
cond = get_absolute_expression ();
if (cond)
if (mode == far_mode)
{
symbolS *symbolP = symbol_new ("__allow_far", absolute_section,
- (valueT) 1, &zero_address_frag);
+ &zero_address_frag, 1);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
}
seg->flags |= SEC_TIC54X_BLOCK;
c = *input_line_pointer;
- if (!is_end_of_line[(int) c])
+ if (!is_end_of_line[(unsigned char) c])
++input_line_pointer;
}
if ((symbolP = symbol_find (name)) == NULL
&& (symbolP = md_undefined_symbol (name)) == NULL)
{
- symbolP = symbol_new (name, absolute_section, 0, &zero_address_frag);
+ symbolP = symbol_new (name, absolute_section, &zero_address_frag, 0);
S_SET_STORAGE_CLASS (symbolP, C_STAT);
}
free (name);
c = get_symbol_name (&name);
/* .var symbols start out with a null string. */
name = xstrdup (name);
- 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 == ',')
{
++input_line_pointer;
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) *input_line_pointer])
c = *input_line_pointer;
}
}
{
SKIP_WHITESPACE ();
len = 0;
- while (!is_end_of_line[(int) *input_line_pointer]
+ while (!is_end_of_line[(unsigned char) *input_line_pointer]
&& !ISSPACE (*input_line_pointer))
{
obstack_1grow (¬es, *input_line_pointer);
{ "mlib" , tic54x_mlib , 0 },
{ "mlist" , s_ignore , 0 },
{ "mnolist" , s_ignore , 0 },
- { "mmregs" , tic54x_mmregs , 0 },
+ { "mmregs" , tic54x_register_mmregs , 0 },
{ "newblock" , tic54x_clear_local_labels, 0 },
{ "option" , s_ignore , 0 },
{ "p2align" , tic54x_p2align , 0 },
void
tic54x_macro_start (void)
{
- ++macro_level;
- subsym_hash[macro_level] = hash_new ();
- local_label_hash[macro_level] = hash_new ();
+ if (++macro_level >= MAX_SUBSYM_HASH)
+ {
+ as_fatal (_("Macro nesting is too deep"));
+ return;
+ }
+ subsym_hash[macro_level] = str_htab_create ();
+ local_label_hash[macro_level] = str_htab_create ();
}
void
name[entry->name.len] = '\0';
value[entry->actual.len] = '\0';
- hash_insert (subsym_hash[macro_level], name, value);
+ str_hash_insert (subsym_hash[macro_level], name, value, 0);
}
}
void
tic54x_macro_end (void)
{
- hash_die (subsym_hash[macro_level]);
+ htab_delete (subsym_hash[macro_level]);
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;
--macro_level;
}
static int
subsym_isreg (char *a, char *ignore ATTRIBUTE_UNUSED)
{
- if (hash_find (reg_hash, a))
+ if (str_hash_find (reg_hash, a))
return 1;
- if (hash_find (mmreg_hash, a))
+ if (str_hash_find (mmreg_hash, a))
return 1;
return 0;
}
static int
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)
return stag->size;
md_begin (void)
{
insn_template *tm;
- tic54x_symbol *sym;
+ const tic54x_symbol *sym;
const subsym_proc_entry *subsym_proc;
const math_proc_entry *math_proc;
- const char *hash_err;
- char **symname;
+ const char **symname;
char *TIC54X_DIR = getenv ("TIC54X_DIR");
char *A_DIR = TIC54X_DIR ? TIC54X_DIR : getenv ("A_DIR");
while (tmp != NULL);
}
- op_hash = hash_new ();
+ op_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_optab; tm->name; tm++)
- {
- if (hash_find (op_hash, tm->name))
- continue;
- hash_err = 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 ();
+ str_hash_insert (op_hash, tm->name, tm, 0);
+
+ parop_hash = str_htab_create ();
for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++)
- {
- if (hash_find (parop_hash, tm->name))
- continue;
- hash_err = 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 ();
- for (sym = (tic54x_symbol *) regs; sym->name; sym++)
+ str_hash_insert (parop_hash, tm->name, tm, 0);
+
+ reg_hash = str_htab_create ();
+ for (sym = tic54x_regs; sym->name; sym++)
{
/* Add basic registers to the symbol table. */
symbolS *symbolP = symbol_new (sym->name, absolute_section,
- (valueT) sym->value, &zero_address_frag);
+ &zero_address_frag, sym->value);
SF_SET_LOCAL (symbolP);
symbol_table_insert (symbolP);
- hash_err = 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++)
- hash_err = hash_insert (reg_hash, sym->name, (char *) sym);
- mmreg_hash = hash_new ();
- for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
- hash_err = hash_insert (mmreg_hash, sym->name, (char *) sym);
+ for (sym = tic54x_mmregs; sym->name; sym++)
+ str_hash_insert (reg_hash, sym->name, sym, 0);
+ mmreg_hash = str_htab_create ();
+ for (sym = tic54x_mmregs; sym->name; sym++)
+ str_hash_insert (mmreg_hash, sym->name, sym, 0);
- cc_hash = hash_new ();
- for (sym = (tic54x_symbol *) condition_codes; sym->name; sym++)
- hash_err = hash_insert (cc_hash, sym->name, (char *) sym);
+ cc_hash = str_htab_create ();
+ for (sym = tic54x_condition_codes; sym->name; sym++)
+ str_hash_insert (cc_hash, sym->name, sym, 0);
- cc2_hash = hash_new ();
- for (sym = (tic54x_symbol *) cc2_codes; sym->name; sym++)
- hash_err = hash_insert (cc2_hash, sym->name, (char *) sym);
+ cc2_hash = str_htab_create ();
+ for (sym = tic54x_cc2_codes; sym->name; sym++)
+ str_hash_insert (cc2_hash, sym->name, sym, 0);
- cc3_hash = hash_new ();
- for (sym = (tic54x_symbol *) cc3_codes; sym->name; sym++)
- hash_err = hash_insert (cc3_hash, sym->name, (char *) sym);
+ cc3_hash = str_htab_create ();
+ for (sym = tic54x_cc3_codes; sym->name; sym++)
+ str_hash_insert (cc3_hash, sym->name, sym, 0);
- sbit_hash = hash_new ();
- for (sym = (tic54x_symbol *) status_bits; sym->name; sym++)
- hash_err = hash_insert (sbit_hash, sym->name, (char *) sym);
+ sbit_hash = str_htab_create ();
+ for (sym = tic54x_status_bits; sym->name; sym++)
+ str_hash_insert (sbit_hash, sym->name, sym, 0);
- misc_symbol_hash = hash_new ();
- for (symname = (char **) misc_symbols; *symname; symname++)
- hash_err = hash_insert (misc_symbol_hash, *symname, *symname);
+ misc_symbol_hash = str_htab_create ();
+ for (symname = tic54x_misc_symbols; *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] = hash_new ();
- subsym_hash[0] = hash_new ();
+ local_label_hash[0] = str_htab_create ();
+ subsym_hash[0] = str_htab_create ();
for (subsym_proc = subsym_procs; subsym_proc->name; subsym_proc++)
- hash_err = 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 = hash_new ();
+ 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. */
- hash_err = hash_insert (subsym_hash[0], math_proc->name,
- (char *) math_proc);
- hash_err = 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 = hash_new ();
- stag_hash = hash_new ();
+ subsym_recurse_hash = str_htab_create ();
+ stag_hash = str_htab_create ();
}
static int
int expecting_operand = 0;
int i;
- while (numexp < MAX_OPERANDS && !is_end_of_line[(int) *lptr])
+ while (numexp < MAX_OPERANDS && !is_end_of_line[(unsigned char) *lptr])
{
int paren_not_balanced = 0;
char *op_start, *op_end;
while (*lptr && ISSPACE (*lptr++))
;
- if (!is_end_of_line[(int) *lptr])
+ if (!is_end_of_line[(unsigned char) *lptr])
{
as_bad (_("Extra junk on line"));
return -1;
{
return (is_absolute (operand)
|| is_immediate (operand)
- || hash_find (mmreg_hash, operand->buf) != 0);
+ || str_hash_find (mmreg_hash, operand->buf) != 0);
}
static int
return strncasecmp ("ar", operand->buf, 2) == 0
&& ISDIGIT (operand->buf[2]);
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:
- return hash_find (cc_hash, operand->buf) != 0;
+ return str_hash_find (cc_hash, operand->buf) != 0;
case OP_CC2:
- return hash_find (cc2_hash, operand->buf) != 0;
+ return str_hash_find (cc2_hash, operand->buf) != 0;
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);
case OP_16:
return (is_immediate (operand) || is_absolute (operand))
static int
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)
{
as_bad (_("Unrecognized condition code \"%s\""), operand->buf);
static int
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;
if ((value & 0x0300) != value)
static int
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)
{
case OP_SBIT:
{
tic54x_symbol *sbit = (tic54x_symbol *)
- hash_find (sbit_hash, operand->buf);
+ str_hash_find (sbit_hash, operand->buf);
int value = is_absolute (operand) ?
operand->exp.X_add_number : (sbit ? sbit->value : -1);
int reg = 0;
}
/* Guess the register based on the status bit; "ovb" is the last
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;
}
if (value == -1)
emit_insn (tic54x_insn *insn)
{
int i;
- flagword oldflags = bfd_get_section_flags (stdoutput, now_seg);
+ flagword oldflags = bfd_section_flags (now_seg);
flagword flags = oldflags | SEC_CODE;
- if (! bfd_set_section_flags (stdoutput, now_seg, flags))
+ if (!bfd_set_section_flags (now_seg, flags))
as_warn (_("error setting flags for \"%s\": %s"),
- bfd_section_name (stdoutput, now_seg),
+ bfd_section_name (now_seg),
bfd_errmsg (bfd_get_error ()));
for (i = 0; i < insn->words; i++)
static int
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)
{
as_bad (_("Unrecognized instruction \"%s\""), insn->mnemonic);
/* SUCCESS! now try some optimizations. */
if (optimize_insn (insn))
{
- insn->tm = (insn_template *) hash_find (op_hash,
- insn->mnemonic);
+ insn->tm = (insn_template *) str_hash_find (op_hash,
+ insn->mnemonic);
continue;
}
next_line_shows_parallel (char *next_line)
{
/* Look for the second half. */
- while (ISSPACE (*next_line))
+ while (*next_line != 0 && ISSPACE (*next_line))
++next_line;
return (next_line[0] == PARALLEL_SEPARATOR
static int
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)
{
as_bad (_("Unrecognized parallel instruction \"%s\""),
int i;
for (i = macro_level; i > 0; i--)
- {
- if (hash_find (subsym_hash[i], name))
- {
- 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);
+ 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.
static char *
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)
return value;
if (strstr (line, ".macro"))
return line;
- while (!is_end_of_line[(int) *ptr])
+ unsigned char current_char;
+ while (!is_end_of_line[(current_char = * (unsigned char *) ptr)])
{
- int current_char = *ptr;
-
/* Need to update this since LINE may have been modified. */
if (eval_line)
eval_end = strrchr (ptr, ',');
}
/* Avoid infinite recursion; if a symbol shows up a second time for
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);
else
as_warn (_("%s symbol recursion stopped at "
{
/* Use an existing identifier for that label if, available, or
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)
{
char digit[11];
value[strlen (value) - 1] = '\0';
sprintf (digit, ".%d", local_label_id++);
strcat (value, digit);
- 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;
else if (value != NULL && *name == '$')
{
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;
*ptr = c;
try to replace a symbol once. */
if (recurse)
{
- hash_insert (subsym_recurse_hash, name, name);
+ str_hash_insert (subsym_recurse_hash, name, name, 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. */
char *replacement = NULL;
/* Work with a copy of the input line, including EOL char. */
- endp = input_line_pointer;
- while (!is_end_of_line[(int) *endp++])
- ;
+ for (endp = input_line_pointer; *endp != 0; )
+ if (is_end_of_line[(unsigned char) *endp++])
+ break;
+
line = xmemdup0 (input_line_pointer, endp - input_line_pointer);
/* Scan ahead for parallel insns. */
tic54x_symbol *sym;
/* Not sure how to handle predefined symbols. */
- if ((sym = (tic54x_symbol *) hash_find (cc_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) hash_find (cc2_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) hash_find (cc3_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) hash_find (misc_symbol_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) 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
+ || str_hash_find (misc_symbol_hash, name) != NULL
+ || (sym = (tic54x_symbol *) str_hash_find (sbit_hash, name)) != NULL
+ || (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,
- (valueT) sym->value,
- &zero_address_frag);
- }
-
- if ((sym = (tic54x_symbol *) hash_find (reg_hash, name)) != NULL ||
- (sym = (tic54x_symbol *) hash_find (mmreg_hash, name)) != NULL ||
- !strcasecmp (name, "a") || !strcasecmp (name, "b"))
- {
- return symbol_new (name, reg_section,
- (valueT) sym ? sym->value : 0,
- &zero_address_frag);
+ return symbol_new (name, reg_section, &zero_address_frag,
+ sym ? sym->value : 0);
}
return NULL;
Don't allow labels to start with '.' */
int
-tic54x_start_label (int nul_char, int next_char)
+tic54x_start_label (char * label_start, int nul_char, int next_char)
{
char *rest;
/* Disallow labels starting with "." */
if (next_char != ':')
{
- char *label = input_line_pointer;
-
- while (!is_end_of_line[(int) label[-1]])
- --label;
- if (*label == '.')
+ if (*label_start == '.')
{
- as_bad (_("Invalid label '%s'"), label);
+ as_bad (_("Invalid label '%s'"), label_start);
return 0;
}
}
- if (is_end_of_line[(int) next_char])
+ if (is_end_of_line[(unsigned char) next_char])
return 1;
rest = input_line_pointer;