* config/tc-mn10300.c (md_assemble): Subtract operand->shift
[deliverable/binutils-gdb.git] / gas / config / tc-mn10300.c
index 5137bf41b81b5f5ab3fe57e4fbf40d343414406f..59e13c7063149ca15989cf8e066850c9e51ac9c2 100644 (file)
@@ -1,5 +1,6 @@
 /* tc-mn10300.c -- Assembler code for the Matsushita 10300
-   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -32,8 +33,6 @@ struct reg_name
   int value;
 };
 
-struct dwarf2_line_info debug_line;
-
 /* Generic assembler global variables which must be defined by all
    targets.  */
 
@@ -213,6 +212,7 @@ static const struct reg_name xr_registers[] =
   { "mcrl", 3 },
   { "mcvf", 4 },
   { "mdrq", 1 },
+  { "pc", 0 },
   { "sp", 0 },
   { "xr0", 0 },
   { "xr1", 1 },
@@ -937,7 +937,7 @@ md_assemble (str)
   struct mn10300_opcode *next_opcode;
   const unsigned char *opindex_ptr;
   int next_opindex, relaxable;
-  unsigned long insn, extension, size = 0, real_size;
+  unsigned long insn, extension, size = 0;
   char *f;
   int i;
   int match;
@@ -1513,8 +1513,6 @@ keep_going:
   if (opcode->format == FMT_D4)
     size = 6;
 
-  real_size = size;
-
   if (relaxable && fc > 0)
     {
       int type;
@@ -1729,24 +1727,7 @@ keep_going:
              /* Is the reloc pc-relative?  */
              pcrel = (operand->flags & MN10300_OPERAND_PCREL) != 0;
 
-             /* Gross.  This disgusting hack is to make sure we
-                get the right offset for the 16/32 bit reloc in
-                "call" instructions.  Basically they're a pain
-                because the reloc isn't at the end of the instruction.  */
-             if ((size == 5 || size == 7)
-                 && (((insn >> 24) & 0xff) == 0xcd
-                     || ((insn >> 24) & 0xff) == 0xdd))
-               size -= 2;
-
-             /* Similarly for certain bit instructions which don't
-                hav their 32bit reloc at the tail of the instruction.  */
-             if (size == 7
-                 && (((insn >> 16) & 0xffff) == 0xfe00
-                     || ((insn >> 16) & 0xffff) == 0xfe01
-                     || ((insn >> 16) & 0xffff) == 0xfe02))
-               size -= 1;
-
-             offset = size - reloc_size / 8;
+             offset = size - (reloc_size + operand->shift) / 8;
 
              /* Choose a proper BFD relocation type.  */
              if (pcrel)
@@ -1791,20 +1772,7 @@ keep_going:
        }
     }
 
-  if (debug_type == DEBUG_DWARF2)
-    {
-      bfd_vma addr;
-
-      /* First update the notion of the current source line.  */
-      dwarf2_where (&debug_line);
-
-      /* We want the offset of the start of this instruction within the
-         the current frag.  */
-      addr = frag_now->fr_address + frag_now_fix () - real_size;
-
-      /* And record the information.  */
-      dwarf2_gen_line_info (addr, &debug_line);
-    }
+  dwarf2_emit_insn (size);
 }
 
 /* If while processing a fixup, a reloc really needs to be created
@@ -1857,44 +1825,23 @@ md_estimate_size_before_relax (fragp, seg)
      fragS *fragp;
      asection *seg;
 {
-  if (fragp->fr_subtype == 0)
-    return 2;
-  if (fragp->fr_subtype == 3)
-    return 3;
-  if (fragp->fr_subtype == 6)
-    {
-      if (!S_IS_DEFINED (fragp->fr_symbol)
-         || seg != S_GET_SEGMENT (fragp->fr_symbol))
-       {
-         fragp->fr_subtype = 7;
-         return 7;
-       }
-      else
-       return 5;
-    }
-  if (fragp->fr_subtype == 8)
-    {
-      if (!S_IS_DEFINED (fragp->fr_symbol)
-         || seg != S_GET_SEGMENT (fragp->fr_symbol))
-       {
-         fragp->fr_subtype = 9;
-         return 6;
-       }
-      else
-       return 4;
-    }
-  if (fragp->fr_subtype == 10)
-    {
-      if (!S_IS_DEFINED (fragp->fr_symbol)
-         || seg != S_GET_SEGMENT (fragp->fr_symbol))
-       {
-         fragp->fr_subtype = 12;
-         return 5;
-       }
-      else
-       return 2;
-    }
-  abort ();
+  if (fragp->fr_subtype == 6
+      && (!S_IS_DEFINED (fragp->fr_symbol)
+         || seg != S_GET_SEGMENT (fragp->fr_symbol)))
+    fragp->fr_subtype = 7;
+  else if (fragp->fr_subtype == 8
+          && (!S_IS_DEFINED (fragp->fr_symbol)
+              || seg != S_GET_SEGMENT (fragp->fr_symbol)))
+    fragp->fr_subtype = 9;
+  else if (fragp->fr_subtype == 10
+          &&  (!S_IS_DEFINED (fragp->fr_symbol)
+               || seg != S_GET_SEGMENT (fragp->fr_symbol)))
+    fragp->fr_subtype = 12;
+
+  if (fragp->fr_subtype >= sizeof (md_relax_table) / sizeof (md_relax_table[0]))
+    abort ();
+
+  return md_relax_table[fragp->fr_subtype].rlx_length;
 }
 
 long
@@ -1941,7 +1888,6 @@ md_apply_fix3 (fixp, valuep, seg)
   else
     value = fixp->fx_offset;
 
-
   /* If the fix is relative to a symbol which is not defined, or not
      in the same segment as the fix, we cannot resolve it here.  */
   if (fixp->fx_addsy != NULL
@@ -1979,9 +1925,11 @@ md_apply_fix3 (fixp, valuep, seg)
 
   md_number_to_chars (fixpos, value, size);
 
-  fixp->fx_done = 1;
-  return 0;
+  /* If a symbol remains, pass the fixup, as a reloc, onto the linker.  */
+  if (fixp->fx_addsy == NULL)
+    fixp->fx_done = 1;
 
+  return 0;
 }
 
 /* Return nonzero if the fixup in FIXP will require a relocation,
@@ -2150,10 +2098,3 @@ set_arch_mach (mach)
 
   current_machine = mach;
 }
-
-void
-mn10300_finalize ()
-{
-  if (debug_type == DEBUG_DWARF2)
-    dwarf2_finish ();
-}
This page took 0.025089 seconds and 4 git commands to generate.