This commit was manufactured by cvs2svn to create branch 'binutils-
[external/binutils.git] / gas / config / tc-d10v.c
index 14450bb..8ba4f30 100644 (file)
@@ -1,12 +1,13 @@
 /* tc-d10v.c -- Assembler code for the Mitsubishi D10V
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
+   2007, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to
-   the Free Software Foundation, 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
-#include <stdio.h>
 #include "as.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
 #include "opcode/d10v.h"
 #include "elf/ppc.h"
+#include "dwarf2dbg.h"
 
 const char comment_chars[]        = ";";
 const char line_comment_chars[]   = "#";
@@ -252,44 +253,10 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
   return 0;
 }
 
-/* Turn a string in input_line_pointer into a floating point constant
-   of type TYPE, and store the appropriate bytes in *LITP.  The number
-   of LITTLENUMS emitted is stored in *SIZEP.  An error message is
-   returned, or NULL on OK.  */
-
 char *
 md_atof (int type, char *litP, int *sizeP)
 {
-  int prec;
-  LITTLENUM_TYPE words[4];
-  char *t;
-  int i;
-
-  switch (type)
-    {
-    case 'f':
-      prec = 2;
-      break;
-    case 'd':
-      prec = 4;
-      break;
-    default:
-      *sizeP = 0;
-      return _("bad call to md_atof");
-    }
-
-  t = atof_ieee (input_line_pointer, type, words);
-  if (t)
-    input_line_pointer = t;
-
-  *sizeP = prec * 2;
-
-  for (i = 0; i < prec; i++)
-    {
-      md_number_to_chars (litP, (valueT) words[i], 2);
-      litP += 2;
-    }
-  return NULL;
+  return ieee_md_atof (type, litP, sizeP, TRUE);
 }
 
 void
@@ -645,6 +612,7 @@ write_long (unsigned long insn, Fixups *fx)
   int i, where;
   char *f = frag_more (4);
 
+  dwarf2_emit_insn (4);
   insn |= FM11;
   number_to_chars_bigendian (f, insn, 4);
 
@@ -680,6 +648,7 @@ write_1_short (struct d10v_opcode *opcode,
   char *f = frag_more (4);
   int i, where;
 
+  dwarf2_emit_insn (4);
   if (opcode->exec_type & PARONLY)
     as_fatal (_("Instruction must be executed in parallel with another instruction."));
 
@@ -1094,6 +1063,7 @@ write_2_short (struct d10v_opcode *opcode1,
     }
 
   f = frag_more (4);
+  dwarf2_emit_insn (4);
   number_to_chars_bigendian (f, insn, 4);
 
   /* Process fixup chains.  fx refers to insn2 when j == 0, and to
@@ -1231,7 +1201,9 @@ find_opcode (struct d10v_opcode *opcode, expressionS myops[])
          for (i = 0; opcode->operands[i + 1]; i++)
            {
              int bits = d10v_operands[next_opcode->operands[opnum]].bits;
-             int flags = d10v_operands[next_opcode->operands[opnum]].flags;
+
+             flags = d10v_operands[next_opcode->operands[opnum]].flags;
+
              if (flags & OPERAND_ADDR)
                bits += 2;
 
@@ -1441,7 +1413,6 @@ do_assemble (char *str, struct d10v_opcode **opcode)
   char name[20];
   int nlen = 0;
   expressionS myops[6];
-  unsigned long insn;
 
   /* Drop leading whitespace.  */
   while (*str == ' ')
@@ -1449,11 +1420,13 @@ do_assemble (char *str, struct d10v_opcode **opcode)
 
   /* Find the opcode end.  */
   for (op_start = op_end = (unsigned char *) str;
-       *op_end && nlen < 20 && !is_end_of_line[*op_end] && *op_end != ' ';
+       *op_end && !is_end_of_line[*op_end] && *op_end != ' ';
        op_end++)
     {
       name[nlen] = TOLOWER (op_start[nlen]);
       nlen++;
+      if (nlen == sizeof (name) - 1)
+       break;
     }
   name[nlen] = 0;
 
@@ -1463,7 +1436,7 @@ do_assemble (char *str, struct d10v_opcode **opcode)
   /* Find the first opcode with the proper name.  */
   *opcode = (struct d10v_opcode *) hash_find (d10v_hash, name);
   if (*opcode == NULL)
-    as_fatal (_("unknown opcode: %s"), name);
+    return -1;
 
   save = input_line_pointer;
   input_line_pointer = (char *) op_end;
@@ -1472,8 +1445,7 @@ do_assemble (char *str, struct d10v_opcode **opcode)
     return -1;
   input_line_pointer = save;
 
-  insn = build_insn ((*opcode), myops, 0);
-  return insn;
+  return build_insn ((*opcode), myops, 0);
 }
 
 /* If while processing a fixup, a reloc really needs to be created.
@@ -1523,7 +1495,7 @@ md_pcrel_from_section (fixS *fixp, segT sec)
 }
 
 void
-md_apply_fix3 (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
+md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 {
   char *where;
   unsigned long insn;
@@ -1663,6 +1635,15 @@ d10v_cleanup (void)
   return 1;
 }
 
+void
+d10v_frob_label (symbolS *lab)
+{
+  d10v_cleanup ();
+  symbol_set_frag (lab, frag_now);
+  S_SET_VALUE (lab, (valueT) frag_now_fix ());
+  dwarf2_emit_label (lab);
+}
+
 /* Like normal .word, except support @word.
    Clobbers input_line_pointer, checks end-of-line.  */
 
@@ -1779,7 +1760,7 @@ md_assemble (char *str)
          prev_seg = now_seg;
          prev_subseg = now_subseg;
          if (prev_insn == (unsigned long) -1)
-           as_fatal (_("can't find opcode "));
+           as_fatal (_("can't find previous opcode "));
          fixups = fixups->next;
          str = str2 + 2;
        }
@@ -1789,11 +1770,10 @@ md_assemble (char *str)
   if (insn == (unsigned long) -1)
     {
       if (extype != PACK_UNSPEC)
-       {
-         etype = extype;
-         return;
-       }
-      as_fatal (_("can't find opcode "));
+       etype = extype;
+      else
+       as_bad (_("could not assemble: %s"), str);
+      return;
     }
 
   if (etype != PACK_UNSPEC)