Automatic date update in version.in
[deliverable/binutils-gdb.git] / gas / config / tc-d10v.c
index 6c94edbb4ef3fc6cf7124f93f541dba7508bcccc..2eb679bb44267d6d52f3c1469861a11a428981fa 100644 (file)
@@ -1,12 +1,11 @@
 /* tc-d10v.c -- Assembler code for the Mitsubishi D10V
 /* tc-d10v.c -- Assembler code for the Mitsubishi D10V
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2019 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
 
    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,
    any later version.
 
    GAS is distributed in the hope that it will be useful,
    the Free Software Foundation, 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, 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 "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[]   = "#";
 
 const char comment_chars[]        = ";";
 const char line_comment_chars[]   = "#";
@@ -105,7 +104,7 @@ size_t md_longopts_size = sizeof (md_longopts);
 static struct hash_control *d10v_hash;
 
 /* Do a binary search of the d10v_predefined_registers array to see if
 static struct hash_control *d10v_hash;
 
 /* Do a binary search of the d10v_predefined_registers array to see if
-   NAME is a valid regiter name.  Return the register number from the
+   NAME is a valid register name.  Return the register number from the
    array on success, or -1 on failure.  */
 
 static int
    array on success, or -1 on failure.  */
 
 static int
@@ -223,7 +222,7 @@ md_show_usage (FILE *stream)
 }
 
 int
 }
 
 int
-md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
+md_parse_option (int c, const char *arg ATTRIBUTE_UNUSED)
 {
   switch (c)
     {
 {
   switch (c)
     {
@@ -252,44 +251,10 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
   return 0;
 }
 
   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 *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
 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
 }
 
 void
@@ -303,14 +268,14 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
 valueT
 md_section_align (asection *seg, valueT addr)
 {
 valueT
 md_section_align (asection *seg, valueT addr)
 {
-  int align = bfd_get_section_alignment (stdoutput, seg);
-  return ((addr + (1 << align) - 1) & (-1 << align));
+  int align = bfd_section_alignment (seg);
+  return ((addr + (1 << align) - 1) & -(1 << align));
 }
 
 void
 md_begin (void)
 {
 }
 
 void
 md_begin (void)
 {
-  char *prev_name = "";
+  const char *prev_name = "";
   struct d10v_opcode *opcode;
   d10v_hash = hash_new ();
 
   struct d10v_opcode *opcode;
   d10v_hash = hash_new ();
 
@@ -645,6 +610,7 @@ write_long (unsigned long insn, Fixups *fx)
   int i, where;
   char *f = frag_more (4);
 
   int i, where;
   char *f = frag_more (4);
 
+  dwarf2_emit_insn (4);
   insn |= FM11;
   number_to_chars_bigendian (f, insn, 4);
 
   insn |= FM11;
   number_to_chars_bigendian (f, insn, 4);
 
@@ -680,6 +646,7 @@ write_1_short (struct d10v_opcode *opcode,
   char *f = frag_more (4);
   int i, where;
 
   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."));
 
   if (opcode->exec_type & PARONLY)
     as_fatal (_("Instruction must be executed in parallel with another instruction."));
 
@@ -1094,6 +1061,7 @@ write_2_short (struct d10v_opcode *opcode1,
     }
 
   f = frag_more (4);
     }
 
   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
   number_to_chars_bigendian (f, insn, 4);
 
   /* Process fixup chains.  fx refers to insn2 when j == 0, and to
@@ -1149,7 +1117,7 @@ write_2_short (struct d10v_opcode *opcode1,
 static unsigned long prev_insn;
 static struct d10v_opcode *prev_opcode = 0;
 static subsegT prev_subseg;
 static unsigned long prev_insn;
 static struct d10v_opcode *prev_opcode = 0;
 static subsegT prev_subseg;
-static segT prev_seg = 0;;
+static segT prev_seg = 0;
 
 /* Find the symbol which has the same name as the register in exp.  */
 
 
 /* Find the symbol which has the same name as the register in exp.  */
 
@@ -1231,7 +1199,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;
          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;
 
              if (flags & OPERAND_ADDR)
                bits += 2;
 
@@ -1256,9 +1226,7 @@ find_opcode (struct d10v_opcode *opcode, expressionS myops[])
                  sym_frag = symbol_get_frag (myops[opnum].X_add_symbol);
                  found_symbol = FALSE;
 
                  sym_frag = symbol_get_frag (myops[opnum].X_add_symbol);
                  found_symbol = FALSE;
 
-                 current_position =
-                   obstack_next_free (&frchain_now->frch_obstack)
-                   - frag_now->fr_literal;
+                 current_position = frag_now_fix_octets ();
                  symbol_position = S_GET_VALUE (myops[opnum].X_add_symbol);
 
                  for (f = frchain_now->frch_root; f; f = f->fr_next)
                  symbol_position = S_GET_VALUE (myops[opnum].X_add_symbol);
 
                  for (f = frchain_now->frch_root; f; f = f->fr_next)
@@ -1441,7 +1409,6 @@ do_assemble (char *str, struct d10v_opcode **opcode)
   char name[20];
   int nlen = 0;
   expressionS myops[6];
   char name[20];
   int nlen = 0;
   expressionS myops[6];
-  unsigned long insn;
 
   /* Drop leading whitespace.  */
   while (*str == ' ')
 
   /* Drop leading whitespace.  */
   while (*str == ' ')
@@ -1449,11 +1416,13 @@ do_assemble (char *str, struct d10v_opcode **opcode)
 
   /* Find the opcode end.  */
   for (op_start = op_end = (unsigned char *) str;
 
   /* 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++;
        op_end++)
     {
       name[nlen] = TOLOWER (op_start[nlen]);
       nlen++;
+      if (nlen == sizeof (name) - 1)
+       break;
     }
   name[nlen] = 0;
 
     }
   name[nlen] = 0;
 
@@ -1463,7 +1432,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)
   /* 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;
 
   save = input_line_pointer;
   input_line_pointer = (char *) op_end;
@@ -1472,8 +1441,7 @@ do_assemble (char *str, struct d10v_opcode **opcode)
     return -1;
   input_line_pointer = save;
 
     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.
 }
 
 /* If while processing a fixup, a reloc really needs to be created.
@@ -1483,8 +1451,8 @@ arelent *
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
-  reloc = xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+  reloc = XNEW (arelent);
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
@@ -1580,7 +1548,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          if ( segf && segf->sym != fixP->fx_addsy)
            value = 0;
         }
          if ( segf && segf->sym != fixP->fx_addsy)
            value = 0;
         }
-      /* Drop through.  */
+      /* Fall through.  */
     case BFD_RELOC_D10V_18:
       /* Instruction addresses are always right-shifted by 2.  */
       value >>= AT_WORD_RIGHT_SHIFT;
     case BFD_RELOC_D10V_18:
       /* Instruction addresses are always right-shifted by 2.  */
       value >>= AT_WORD_RIGHT_SHIFT;
@@ -1612,6 +1580,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
     case BFD_RELOC_16:
       bfd_putb16 ((bfd_vma) value, (unsigned char *) where);
       break;
     case BFD_RELOC_16:
       bfd_putb16 ((bfd_vma) value, (unsigned char *) where);
       break;
+    case BFD_RELOC_8:
+      *where = value;
+      break;
 
     case BFD_RELOC_VTABLE_INHERIT:
     case BFD_RELOC_VTABLE_ENTRY:
 
     case BFD_RELOC_VTABLE_INHERIT:
     case BFD_RELOC_VTABLE_ENTRY:
@@ -1663,6 +1634,15 @@ d10v_cleanup (void)
   return 1;
 }
 
   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.  */
 
 /* Like normal .word, except support @word.
    Clobbers input_line_pointer, checks end-of-line.  */
 
@@ -1779,7 +1759,7 @@ md_assemble (char *str)
          prev_seg = now_seg;
          prev_subseg = now_subseg;
          if (prev_insn == (unsigned long) -1)
          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;
        }
          fixups = fixups->next;
          str = str2 + 2;
        }
@@ -1789,11 +1769,10 @@ md_assemble (char *str)
   if (insn == (unsigned long) -1)
     {
       if (extype != PACK_UNSPEC)
   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)
     }
 
   if (etype != PACK_UNSPEC)
This page took 0.028029 seconds and 4 git commands to generate.