Add ARM v5t, v5te and XScale support
[deliverable/binutils-gdb.git] / opcodes / fr30-asm.c
index 5f5ccdc0b8079af96966ed66f3b0e4d8f97c4904..08092afce6dcd394bea379cf9ca945967406056a 100644 (file)
@@ -177,7 +177,9 @@ fr30_cgen_parse_operand (cd, opindex, strp, fields)
      const char ** strp;
      CGEN_FIELDS * fields;
 {
-  const char * errmsg;
+  const char * errmsg = NULL;
+  /* Used by scalar operands that still need to be parsed.  */
+  long junk;
 
   switch (opindex)
     {
@@ -188,13 +190,13 @@ fr30_cgen_parse_operand (cd, opindex, strp, fields)
       errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_cr_names, & fields->f_CRj);
       break;
     case FR30_OPERAND_R13 :
-      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r13, & fields->f_nil);
+      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r13, & junk);
       break;
     case FR30_OPERAND_R14 :
-      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r14, & fields->f_nil);
+      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r14, & junk);
       break;
     case FR30_OPERAND_R15 :
-      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r15, & fields->f_nil);
+      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_r15, & junk);
       break;
     case FR30_OPERAND_RI :
       errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_gr_names, & fields->f_Ri);
@@ -265,7 +267,7 @@ fr30_cgen_parse_operand (cd, opindex, strp, fields)
       errmsg = cgen_parse_signed_integer (cd, strp, FR30_OPERAND_M4, &fields->f_m4);
       break;
     case FR30_OPERAND_PS :
-      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_ps, & fields->f_nil);
+      errmsg = cgen_parse_keyword (cd, strp, & fr30_cgen_opval_h_ps, & junk);
       break;
     case FR30_OPERAND_REGLIST_HI_LD :
       errmsg = parse_hi_register_list_ld (cd, strp, FR30_OPERAND_REGLIST_HI_LD, &fields->f_reglist_hi_ld);
@@ -362,9 +364,14 @@ parse_insn_normal (cd, insn, strp, fields)
   p = CGEN_INSN_MNEMONIC (insn);
   while (*p && tolower (*p) == tolower (*str))
     ++p, ++str;
-  
-  if (* p || (* str && !isspace (* str)))
+
+  if (* p)
+    return _("unrecognized instruction");
+
+#ifndef CGEN_MNEMONIC_OPERANDS
+  if (* str && !isspace (* str))
     return _("unrecognized instruction");
+#endif
 
   CGEN_INIT_PARSE (cd);
   cgen_init_parse_operand (cd);
@@ -387,7 +394,11 @@ parse_insn_normal (cd, insn, strp, fields)
       /* Non operand chars must match exactly.  */
       if (CGEN_SYNTAX_CHAR_P (* syn))
        {
-         if (*str == CGEN_SYNTAX_CHAR (* syn))
+         /* FIXME: While we allow for non-GAS callers above, we assume the
+            first char after the mnemonic part is a space.  */
+         /* FIXME: We also take inappropriate advantage of the fact that
+            GAS's input scrubber will remove extraneous blanks.  */
+         if (tolower (*str) == tolower (CGEN_SYNTAX_CHAR (* syn)))
            {
 #ifdef CGEN_MNEMONIC_OPERANDS
              if (* syn == ' ')
@@ -399,9 +410,11 @@ parse_insn_normal (cd, insn, strp, fields)
          else
            {
              /* Syntax char didn't match.  Can't be this insn.  */
-             /* FIXME: would like to return something like
-                "expected char `c'" */
-             return _("syntax error");
+             static char msg [80];
+             /* xgettext:c-format */
+             sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
+                      *syn, *str);
+             return msg;
            }
          continue;
        }
@@ -467,6 +480,7 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg)
 {
   const char *start;
   CGEN_INSN_LIST *ilist;
+  const char *tmp_errmsg = NULL;
 
   /* Skip leading white space.  */
   while (isspace (* str))
@@ -483,7 +497,8 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg)
     {
       const CGEN_INSN *insn = ilist->insn;
 
-#if 0 /* not needed as unsupported opcodes shouldn't be in the hash lists */
+#ifdef CGEN_VALIDATE_INSN_SUPPORTED 
+      /* not usually needed as unsupported opcodes shouldn't be in the hash lists */
       /* Is this insn supported by the selected cpu?  */
       if (! fr30_cgen_insn_supported (cd, insn))
        continue;
@@ -500,30 +515,44 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg)
       /* Allow parse/insert handlers to obtain length of insn.  */
       CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
 
-      if (! CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields))
-       {
-         /* ??? 0 is passed for `pc' */
-         if (CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, (bfd_vma) 0)
-             != NULL)
-           continue;
-         /* It is up to the caller to actually output the insn and any
-            queued relocs.  */
-         return insn;
-       }
+      tmp_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields);
+      if (tmp_errmsg != NULL)
+       continue;
+
+      /* ??? 0 is passed for `pc' */
+      tmp_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf,
+                                             (bfd_vma) 0);
+      if (tmp_errmsg != NULL)
+        continue;
 
-      /* Try the next entry.  */
+      /* It is up to the caller to actually output the insn and any
+         queued relocs.  */
+      return insn;
     }
 
-  /* FIXME: We can return a better error message than this.
-     Need to track why it failed and pick the right one.  */
+  /* Make sure we leave this with something at this point. */
+  if (tmp_errmsg == NULL)
+    tmp_errmsg = "unknown mnemonic";
+
   {
-    static char errbuf[100];
+    static char errbuf[150];
+
+#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
+    /* if verbose error messages, use errmsg from CGEN_PARSE_FN */
+    if (strlen (start) > 50)
+      /* xgettext:c-format */
+      sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
+    else 
+      /* xgettext:c-format */
+      sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
+#else
     if (strlen (start) > 50)
       /* xgettext:c-format */
       sprintf (errbuf, _("bad instruction `%.50s...'"), start);
     else 
       /* xgettext:c-format */
       sprintf (errbuf, _("bad instruction `%.50s'"), start);
+#endif
       
     *errmsg = errbuf;
     return NULL;
This page took 0.043079 seconds and 4 git commands to generate.