/* tc-score.c -- Assembler for Score
- Copyright (C) 2006-2020 Free Software Foundation, Inc.
+ Copyright (C) 2006-2021 Free Software Foundation, Inc.
Contributed by:
Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
{
const struct s3_reg_entry *names;
int max_regno;
- struct hash_control *htab;
+ htab_t htab;
const char *expected;
};
{s3_score_crn_table, 31, NULL, N_("S+core co-processor register expected")},
};
-static struct hash_control *s3_score_ops_hsh = NULL;
-static struct hash_control *s3_dependency_insn_hsh = NULL;
+static htab_t s3_score_ops_hsh = NULL;
+static htab_t s3_dependency_insn_hsh = NULL;
struct s3_datafield_range
}
static int
-s3_score_reg_parse (char **ccp, struct hash_control *htab)
+s3_score_reg_parse (char **ccp, htab_t htab)
{
char *start = *ccp;
char c;
c = *p++;
*--p = 0;
- reg = (struct s3_reg_entry *) hash_find (htab, start);
+ reg = (struct s3_reg_entry *) str_hash_find (htab, start);
*p = c;
if (reg)
const struct s3_insn_to_dependency *tmp;
strcpy (name, insn_name);
- tmp = (const struct s3_insn_to_dependency *) hash_find (s3_dependency_insn_hsh, name);
+ tmp = (const struct s3_insn_to_dependency *)
+ str_hash_find (s3_dependency_insn_hsh, name);
if (tmp)
return tmp->type;
c = *p;
*p = '\0';
- opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator);
+ opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+ operator);
*p = c;
memset (&s3_inst, '\0', sizeof (s3_inst));
c = *p;
*p = '\0';
- opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator);
+ opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+ operator);
*p = c;
memset (&s3_inst, '\0', sizeof (s3_inst));
}
static void
-s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
+s3_insert_reg (const struct s3_reg_entry *r, htab_t htab)
{
int i = 0;
int len = strlen (r->name) + 2;
}
buf2[i] = '\0';
- hash_insert (htab, buf, (void *) r);
- hash_insert (htab, buf2, (void *) r);
+ str_hash_insert (htab, buf, r, 0);
+ str_hash_insert (htab, buf2, r, 0);
}
static void
{
const struct s3_reg_entry *r;
- if ((map->htab = hash_new ()) == NULL)
- {
- as_fatal (_("virtual memory exhausted"));
- }
+ map->htab = str_htab_create ();
for (r = map->names; r->name != NULL; r++)
- {
- s3_insert_reg (r, map->htab);
- }
+ s3_insert_reg (r, map->htab);
}
/* Iterate over the base tables to create the instruction patterns. */
new_opcode->relax_value = insn->relax_value;
new_opcode->type = insn->type;
new_opcode->bitmask = insn->bitmask;
- hash_insert (s3_score_ops_hsh, new_opcode->template_name,
- (void *) new_opcode);
+ str_hash_insert (s3_score_ops_hsh, new_opcode->template_name,
+ new_opcode, 0);
}
}
strcpy (buf, tmp->insn_name);
new_i2n->insn_name = buf;
new_i2n->type = tmp->type;
- 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);
}
}
segT seg;
subsegT subseg;
- if ((s3_score_ops_hsh = hash_new ()) == NULL)
- as_fatal (_("virtual memory exhausted"));
+ s3_score_ops_hsh = str_htab_create ();
s3_build_score_ops_hsh ();
- if ((s3_dependency_insn_hsh = hash_new ()) == NULL)
- as_fatal (_("virtual memory exhausted"));
+ s3_dependency_insn_hsh = str_htab_create ();
s3_build_dependency_insn_hsh ();
static void
s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
{
- offsetT value = *valP;
- offsetT newval;
- offsetT content;
- unsigned short HI, LO;
+ valueT value = *valP;
+ valueT newval;
+ valueT content;
+ valueT HI, LO;
char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
if (fixP->fx_done) /* For la rd, imm32. */
{
newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
- HI = (value) >> 16; /* mul to 2, then take the hi 16 bit. */
+ HI = value >> 16; /* mul to 2, then take the hi 16 bit. */
newval |= (HI & 0x3fff) << 1;
newval |= ((HI >> 14) & 0x3) << 16;
s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
if (fixP->fx_done) /* For la rd, imm32. */
{
newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
- LO = (value) & 0xffff;
+ LO = value & 0xffff;
newval |= (LO & 0x3fff) << 1; /* 16 bit: imm -> 14 bit in lo, 2 bit in hi. */
newval |= ((LO >> 14) & 0x3) << 16;
s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);