This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/6] 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.

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.
---
 gas/ChangeLog       |  7 +++++
 gas/config/tc-arc.c | 75 ++++++++++++++++++++++-------------------------------
 2 files changed, 38 insertions(+), 44 deletions(-)

diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 3c093ca..814691c 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -1512,6 +1512,36 @@ 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)
+			{
+			  /* 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
@@ -1584,6 +1614,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.  */
 
@@ -1973,48 +2004,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)
-	      {
-		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.  */
 
@@ -2042,8 +2031,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)
-- 
2.5.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]