aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-arc.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2016-03-28 15:49:25 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2016-04-07 12:42:58 +0100
commit22b92fc42c444bf39044911e8873b42fd3df81ed (patch)
tree93a773864ae31f77730588abbeec67215dc30bea /gas/config/tc-arc.c
parente140100a5da85568e83ffe8e77d3f5e4a59ddee8 (diff)
downloadgdb-22b92fc42c444bf39044911e8873b42fd3df81ed.zip
gdb-22b92fc42c444bf39044911e8873b42fd3df81ed.tar.gz
gdb-22b92fc42c444bf39044911e8873b42fd3df81ed.tar.bz2
gas/arc: Remove preprocess_operands function
The preprocess_operands function changes the incoming list of assembler tokens based on the assumption that the first arc_operand found will be the same instruction class as all of the arc_operands for the same mnemonic. Though this assumption is probably fine, removing this assumption, and pushing the token change down into assemble_tokens makes the code no more complex, and might even be easier to follow. There should be no user visible changes after this commit. gas/ChangeLog: * config/tc-arc.c (find_opcode_match): Handle O_symbol case, add new de_fault label. (preprocess_operands): Delete. (assemble_tokens): Remove call to preprocess_operands.
Diffstat (limited to 'gas/config/tc-arc.c')
-rw-r--r--gas/config/tc-arc.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 42b0f8f..04ccd07 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -1506,6 +1506,38 @@ find_opcode_match (const struct arc_opcode *first_opcode,
++ntok;
break;
+ case O_symbol:
+ {
+ const char *p;
+ size_t len;
+ const struct arc_aux_reg *auxr;
+ unsigned j;
+
+ if (opcode->class != AUXREG)
+ goto de_fault;
+ p = S_GET_NAME (tok[tokidx].X_add_symbol);
+ len = strlen (p);
+
+ auxr = &arc_aux_regs[0];
+ for (j = 0; j < arc_num_aux_regs; j++, auxr++)
+ if (len == auxr->length
+ && strcasecmp (auxr->name, p) == 0
+ && ((auxr->subclass == NONE)
+ || check_cpu_feature (auxr->subclass)))
+ {
+ /* We modify the token array here, safe in the
+ knowledge, that if this was the wrong choice
+ then the original contents will be restored
+ from BKTOK. */
+ tok[tokidx].X_op = O_constant;
+ tok[tokidx].X_add_number = auxr->address;
+ break;
+ }
+
+ if (tok[tokidx].X_op != O_constant)
+ goto de_fault;
+ }
+ /* Fall-through */
case O_constant:
/* Check the range. */
if (operand->bits != 32
@@ -1578,6 +1610,7 @@ find_opcode_match (const struct arc_opcode *first_opcode,
break;
}
default:
+ de_fault:
if (operand->default_reloc == 0)
goto match_failed; /* The operand needs relocation. */
@@ -1970,50 +2003,6 @@ find_special_case (const char *opname,
return opcode;
}
-static void
-preprocess_operands (const struct arc_opcode *opcode,
- expressionS *tok,
- int ntok)
-{
- int i;
- size_t len;
- const char *p;
- unsigned j;
- const struct arc_aux_reg *auxr;
-
- for (i = 0; i < ntok; i++)
- {
- switch (tok[i].X_op)
- {
- case O_illegal:
- case O_absent:
- break; /* Throw and error. */
-
- case O_symbol:
- if (opcode->class != AUXREG)
- break;
- /* Convert the symbol to a constant if possible. */
- p = S_GET_NAME (tok[i].X_add_symbol);
- len = strlen (p);
-
- auxr = &arc_aux_regs[0];
- for (j = 0; j < arc_num_aux_regs; j++, auxr++)
- if (len == auxr->length
- && (strcasecmp (auxr->name, p) == 0)
- && ((auxr->subclass == NONE)
- || check_cpu_feature (auxr->subclass)))
- {
- tok[i].X_op = O_constant;
- tok[i].X_add_number = auxr->address;
- break;
- }
- break;
- default:
- break;
- }
- }
-}
-
/* Given an opcode name, pre-tockenized set of argumenst and the
opcode flags, take it all the way through emission. */
@@ -2041,8 +2030,6 @@ assemble_tokens (const char *opname,
frag_now->fr_file, frag_now->fr_line, opcode->name,
opcode->opcode);
- preprocess_operands (opcode, tok, ntok);
-
found_something = TRUE;
opcode = find_opcode_match (opcode, tok, &ntok, pflags, nflgs, &cpumatch);
if (opcode)