* tc-pdp11.c: Use VAX float format support for PDP-11 target.
[deliverable/binutils-gdb.git] / gas / config / tc-mcore.c
index 3238e66ec065b99f47495ec40c3fb9e6c9781ca9..786ae8b591f63b8251cb2bb018b2c1f67b895d2c 100644 (file)
@@ -24,7 +24,7 @@
 #include "subsegs.h"
 #define DEFINE_TABLE
 #include "../opcodes/mcore-opc.h"
-#include <ctype.h>
+#include "safe-ctype.h"
 #include <string.h>
 
 #ifdef OBJ_ELF
@@ -111,20 +111,24 @@ cpu_type;
 cpu_type cpu = M340;
 
 /* Initialize the relax table.  */
-const relax_typeS md_relax_table[] =
-{
-{    1,     1,      0, 0 },                    /* 0: unused */
-{    1,     1,      0, 0 },                    /* 1: unused */
-{    1,     1,      0, 0 },                    /* 2: unused */
-{    1,     1,      0, 0 },                    /* 3: unused */
-{    1,     1,      0, 0 },                    /* 4: unused */
-{ 2048, -2046, C12_LEN, C(COND_JUMP, DISP32) },        /* 5: C(COND_JUMP, DISP12) */
-{    0,     0, C32_LEN, 0 },                   /* 6: C(COND_JUMP, DISP32) */
-{    1,     1,      0, 0 },                    /* 7: unused */
-{    1,     1,      0, 0 },                    /* 8: unused */
-{ 2048, -2046, U12_LEN, C(UNCD_JUMP, DISP32) },        /* 9: C(UNCD_JUMP, DISP12) */
-{    0,     0, U32_LEN, 0 },                   /*10: C(UNCD_JUMP, DISP32) */
-{    1,     1,      0, 0 },                    /*11: unused */
+const relax_typeS md_relax_table[] = {
+  {    0,     0, 0,      0 },
+  {    0,     0, 0,      0 },
+  {    0,     0, 0,      0 },
+  {    0,     0, 0,      0 },
+
+  /* COND_JUMP */
+  {    0,     0, 0,      0 },                    /* UNDEF_DISP */
+  { 2048, -2046, C12_LEN, C(COND_JUMP, DISP32) }, /* DISP12 */
+  {    0,     0, C32_LEN, 0 },                   /* DISP32 */
+  {    0,     0, C32_LEN, 0 },                   /* UNDEF_WORD_DISP */
+
+  /* UNCD_JUMP */
+  {    0,     0, 0,      0 },                    /* UNDEF_DISP */     
+  { 2048, -2046, U12_LEN, C(UNCD_JUMP, DISP32) }, /* DISP12 */         
+  {    0,     0, U32_LEN, 0 },                   /* DISP32 */         
+  {    0,     0, U32_LEN, 0 }                    /* UNDEF_WORD_DISP */
+
 };
 
 /* Literal pool data structures.  */
@@ -386,11 +390,11 @@ mcore_s_section (ignore)
      pool.  */
   char * ilp = input_line_pointer;
 
-  while (*ilp != 0 && isspace(*ilp))
+  while (*ilp != 0 && ISSPACE (*ilp))
     ++ ilp;
 
   if (strncmp (ilp, ".line", 5) == 0
-      && (isspace (ilp[5]) || *ilp == '\n' || *ilp == '\r'))
+      && (ISSPACE (ilp[5]) || *ilp == '\n' || *ilp == '\r'))
     ;
   else
     dump_literals (0);
@@ -476,10 +480,10 @@ parse_reg (s, reg)
      unsigned * reg;
 {
   /* Strip leading whitespace.  */
-  while (isspace (* s))
+  while (ISSPACE (* s))
     ++ s;
 
-  if (tolower (s[0]) == 'r')
+  if (TOLOWER (s[0]) == 'r')
     {
       if (s[1] == '1' && s[2] >= '0' && s[2] <= '5')
        {
@@ -493,9 +497,9 @@ parse_reg (s, reg)
          return s + 2;
        }
     }
-  else if (   tolower (s[0]) == 's'
-          && tolower (s[1]) == 'p'
-          && ! isalnum (s[2]))
+  else if (   TOLOWER (s[0]) == 's'
+          && TOLOWER (s[1]) == 'p'
+          && ! ISALNUM (s[2]))
     {
       * reg = 0;
       return s + 2;
@@ -536,10 +540,10 @@ parse_creg (s, reg)
   int i;
 
   /* Strip leading whitespace.  */
-  while (isspace (* s))
+  while (ISSPACE (* s))
     ++s;
 
-  if ((tolower (s[0]) == 'c' && tolower (s[1]) == 'r'))
+  if ((TOLOWER (s[0]) == 'c' && TOLOWER (s[1]) == 'r'))
     {
       if (s[2] == '3' && s[3] >= '0' && s[3] <= '1')
        {
@@ -576,7 +580,7 @@ parse_creg (s, reg)
       length = strlen (cregs[i].name);
 
       for (j = 0; j < length; j++)
-       buf[j] = tolower (s[j]);
+       buf[j] = TOLOWER (s[j]);
 
       if (strncmp (cregs[i].name, buf, length) == 0)
        {
@@ -611,7 +615,7 @@ parse_psrmod (s, reg)
   };
 
   for (i = 0; i < 2; i++)
-    buf[i] = isascii (s[i]) ? tolower (s[i]) : 0;
+    buf[i] = TOLOWER (s[i]);
 
   for (i = sizeof (psrmods) / sizeof (psrmods[0]); i--;)
     {
@@ -639,7 +643,7 @@ parse_exp (s, e)
   char * new;
 
   /* Skip whitespace.  */
-  while (isspace (* s))
+  while (ISSPACE (* s))
     ++ s;
 
   save = input_line_pointer;
@@ -899,14 +903,14 @@ parse_mem (s, reg, off, siz)
 
   * off = 0;
 
-  while (isspace (* s))
+  while (ISSPACE (* s))
     ++ s;
 
   if (* s == '(')
     {
       s = parse_reg (s + 1, reg);
 
-      while (isspace (* s))
+      while (ISSPACE (* s))
        ++ s;
 
       if (* s == ',')
@@ -932,7 +936,7 @@ parse_mem (s, reg, off, siz)
            }
        }
 
-      while (isspace (* s))
+      while (ISSPACE (* s))
        ++ s;
 
       if (* s == ')')
@@ -965,7 +969,7 @@ md_assemble (str)
   char name[20];
 
   /* Drop leading whitespace.  */
-  while (isspace (* str))
+  while (ISSPACE (* str))
     str ++;
 
   /* Find the op code end.  */
@@ -1064,7 +1068,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (*op_end == ',')
@@ -1088,7 +1092,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1106,7 +1110,7 @@ md_assemble (str)
       op_end = parse_reg (op_end + 1, & reg);
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')     /* xtrb- r1,rx */
@@ -1126,7 +1130,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1146,7 +1150,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1165,7 +1169,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1184,7 +1188,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1213,7 +1217,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1240,7 +1244,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1279,7 +1283,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1312,7 +1316,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1331,7 +1335,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1350,7 +1354,7 @@ md_assemble (str)
       inst |= reg << 8;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1386,7 +1390,7 @@ md_assemble (str)
       inst |= (reg << 8);
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1417,7 +1421,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == '-')
@@ -1428,7 +1432,7 @@ md_assemble (str)
            as_bad (_("ending register must be r15"));
 
          /* Skip whitespace.  */
-         while (isspace (* op_end))
+         while (ISSPACE (* op_end))
            ++ op_end;
        }
 
@@ -1437,7 +1441,7 @@ md_assemble (str)
          op_end ++;
 
          /* Skip whitespace.  */
-         while (isspace (* op_end))
+         while (ISSPACE (* op_end))
            ++ op_end;
 
          if (* op_end == '(')
@@ -1466,7 +1470,7 @@ md_assemble (str)
        as_fatal (_("first register must be r4"));
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == '-')
@@ -1477,7 +1481,7 @@ md_assemble (str)
            as_fatal (_("last register must be r7"));
 
          /* Skip whitespace.  */
-         while (isspace (* op_end))
+         while (ISSPACE (* op_end))
            ++ op_end;
 
          if (* op_end == ',')
@@ -1485,7 +1489,7 @@ md_assemble (str)
              op_end ++;
 
              /* Skip whitespace.  */
-             while (isspace (* op_end))
+             while (ISSPACE (* op_end))
                ++ op_end;
 
              if (* op_end == '(')
@@ -1498,7 +1502,7 @@ md_assemble (str)
                  inst |= reg;
 
                  /* Skip whitespace.  */
-                 while (isspace (* op_end))
+                 while (ISSPACE (* op_end))
                    ++ op_end;
 
                  if (* op_end == ')')
@@ -1531,7 +1535,7 @@ md_assemble (str)
       inst |= reg << 4;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1591,7 +1595,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1613,7 +1617,7 @@ md_assemble (str)
       inst |= reg << 4;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1634,7 +1638,7 @@ md_assemble (str)
       inst |= reg;
 
       /* Skip whitespace.  */
-      while (isspace (* op_end))
+      while (ISSPACE (* op_end))
        ++ op_end;
 
       if (* op_end == ',')
@@ -1686,7 +1690,7 @@ md_assemble (str)
     }
 
   /* Drop whitespace after all the operands have been parsed.  */
-  while (isspace (* op_end))
+  while (ISSPACE (* op_end))
     op_end ++;
 
   /* Give warning message if the insn has more operands than required.  */
@@ -1896,7 +1900,6 @@ md_convert_frag (abfd, sec, fragP)
   int targ_addr = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
 
   buffer = (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
-  targ_addr += symbol_get_frag (fragP->fr_symbol)->fr_address;
 
   switch (fragP->fr_subtype)
     {
@@ -1931,7 +1934,6 @@ md_convert_frag (abfd, sec, fragP)
          }
 
        fragP->fr_fix += 2;
-       fragP->fr_var = 0;
       }
       break;
 
@@ -2022,8 +2024,6 @@ md_convert_frag (abfd, sec, fragP)
            else
              buffer[1] = 4;    /* jmpi, ptr, and the 'tail pad' */
          }
-
-       fragP->fr_var = 0;
       }
       break;
 
@@ -2078,8 +2078,6 @@ md_convert_frag (abfd, sec, fragP)
                     fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32);
            fragP->fr_fix += U32_LEN;
          }
-
-       fragP->fr_var = 0;
       }
       break;
 
@@ -2090,17 +2088,18 @@ md_convert_frag (abfd, sec, fragP)
 
 /* Applies the desired value to the specified location.
    Also sets up addends for 'rela' type relocations.  */
-int
-md_apply_fix3 (fixP, valp, segment)
+
+void
+md_apply_fix3 (fixP, valP, segment)
      fixS *   fixP;
-     valueT * valp;
+     valueT * valP;
      segT     segment;
 {
   char *       buf  = fixP->fx_where + fixP->fx_frag->fr_literal;
   char *       file = fixP->fx_file ? fixP->fx_file : _("unknown");
   const char * symname;
   /* Note: use offsetT because it is signed, valueT is unsigned.  */
-  offsetT      val  = (offsetT) * valp;
+  offsetT      val  = * (offsetT *)  valP;
 
   symname = fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : _("<unknown>");
   /* Save this for the addend in the relocation record.  */
@@ -2117,7 +2116,7 @@ md_apply_fix3 (fixP, valp, segment)
       /* For ELF we can just return and let the reloc that will be generated
         take care of everything.  For COFF we still have to insert 'val'
         into the insn since the addend field will be ignored.  */
-      return 0;
+      return;
 #endif
     }
   else
@@ -2216,8 +2215,6 @@ md_apply_fix3 (fixP, valp, segment)
        }
       break;
     }
-
-  return 0; /* Return value is ignored.  */
 }
 
 void
@@ -2251,17 +2248,14 @@ md_estimate_size_before_relax (fragP, segment_type)
       if (!fragP->fr_symbol)
        {
          fragP->fr_subtype = C (UNCD_JUMP, DISP12);
-         fragP->fr_var = md_relax_table[C (UNCD_JUMP, DISP12)].rlx_length;
        }
       else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
        {
          fragP->fr_subtype = C (UNCD_JUMP, DISP12);
-         fragP->fr_var = md_relax_table[C (UNCD_JUMP, DISP12)].rlx_length;
        }
       else
        {
          fragP->fr_subtype = C (UNCD_JUMP, UNDEF_WORD_DISP);
-         fragP->fr_var = md_relax_table[C (UNCD_JUMP, DISP32)].rlx_length;
        }
       break;
 
@@ -2273,32 +2267,31 @@ md_estimate_size_before_relax (fragP, segment_type)
          /* Got a symbol and it's defined in this segment, become byte
             sized - maybe it will fix up */
          fragP->fr_subtype = C (COND_JUMP, DISP12);
-         fragP->fr_var = md_relax_table[C (COND_JUMP, DISP12)].rlx_length;
        }
       else if (fragP->fr_symbol)
        {
          /* Its got a segment, but its not ours, so it will always be long.  */
          fragP->fr_subtype = C (COND_JUMP, UNDEF_WORD_DISP);
-         fragP->fr_var = md_relax_table[C (COND_JUMP, DISP32)].rlx_length;
        }
       else
        {
          /* We know the abs value.  */
          fragP->fr_subtype = C (COND_JUMP, DISP12);
-         fragP->fr_var = md_relax_table[C (COND_JUMP, DISP12)].rlx_length;
        }
       break;
 
     case C (UNCD_JUMP, DISP12):
+    case C (UNCD_JUMP, DISP32):
     case C (UNCD_JUMP, UNDEF_WORD_DISP):
     case C (COND_JUMP, DISP12):
+    case C (COND_JUMP, DISP32):
     case C (COND_JUMP, UNDEF_WORD_DISP):
       /* When relaxing a section for the second time, we don't need to
-        do anything.  */
+        do anything besides return the current size.  */
       break;
     }
 
-  return fragP->fr_var;
+  return md_relax_table[fragP->fr_subtype].rlx_length;
 }
 
 /* Put number into target byte order.  */
This page took 0.033805 seconds and 4 git commands to generate.