Move fixup fx_bit_fixP and fx_im_disp fields to TC_FIX_TYPE
authorAlan Modra <amodra@gmail.com>
Tue, 16 Apr 2019 06:17:02 +0000 (15:47 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 16 Apr 2019 08:09:28 +0000 (17:39 +0930)
These are only used by dlx and ns32k.

* write.h: Don't include bit_fix.h.
(struct fix): Rearrange some fields.  Delete fx_im_disp and
fx_bit_fixP.  Use bitfields for fx_size and fx_pcrel_adjust.
* write.c (fix_new_internal): Don't init fx_im_disp and fx_bit_fixP.
(fixup_segment): Don't exclude overflow checks on fx_bit_fixP.
(print_fixup): Don't print im_disp.
* config/tc-cris.c (md_apply_fix): Remove tests of fx_bit_fixP
and fx_im_disp.
* config/tc-dlx.c (md_apply_fix): Remove wrong debug code.  Set
fx_no_overflow when fx_bit_fixP.
* config/tc-dlx.h: Include bit_fix.h.
(TC_FIX_TYPE, tc_fix_data, TC_INIT_FIX_DATA): Define.
* config/tc-ns32k.c (fix_new_ns32k, fix_new_ns32k_exp): Set
fx_no_overflow when bit_fixP.
* config/tc-ns32k.h (TC_FIX_TYPE): Add fx_bit_fixP and fx_im_disp.
(fix_im_disp, fix_bit_fixP): Adjust to suit.
(TC_INIT_FIX_DATA, TC_FIX_DATA_PRINT): Likewise.

gas/ChangeLog
gas/config/tc-cris.c
gas/config/tc-dlx.c
gas/config/tc-dlx.h
gas/config/tc-ns32k.c
gas/config/tc-ns32k.h
gas/write.c
gas/write.h

index 4a08de155cd16bf97916646b3b9d4f6be1ea414c..d74071bf12f5c11cac3acd49b9253d5bff171610 100644 (file)
@@ -1,3 +1,23 @@
+2019-04-16  Alan Modra  <amodra@gmail.com>
+
+       * write.h: Don't include bit_fix.h.
+       (struct fix): Rearrange some fields.  Delete fx_im_disp and
+       fx_bit_fixP.  Use bitfields for fx_size and fx_pcrel_adjust.
+       * write.c (fix_new_internal): Don't init fx_im_disp and fx_bit_fixP.
+       (fixup_segment): Don't exclude overflow checks on fx_bit_fixP.
+       (print_fixup): Don't print im_disp.
+       * config/tc-cris.c (md_apply_fix): Remove tests of fx_bit_fixP
+       and fx_im_disp.
+       * config/tc-dlx.c (md_apply_fix): Remove wrong debug code.  Set
+       fx_no_overflow when fx_bit_fixP.
+       * config/tc-dlx.h: Include bit_fix.h.
+       (TC_FIX_TYPE, tc_fix_data, TC_INIT_FIX_DATA): Define.
+       * config/tc-ns32k.c (fix_new_ns32k, fix_new_ns32k_exp): Set
+       fx_no_overflow when bit_fixP.
+       * config/tc-ns32k.h (TC_FIX_TYPE): Add fx_bit_fixP and fx_im_disp.
+       (fix_im_disp, fix_bit_fixP): Adjust to suit.
+       (TC_INIT_FIX_DATA, TC_FIX_DATA_PRINT): Likewise.
+
 2019-04-16  Alan Modra  <amodra@gmail.com>
 
        * write.h (struct fix <fx_where>): Make unsigned.
index 07f685752805cfd1b14e30870e227b33b5d40c4b..198a2d71c9e7b88d6e26ddadd3f7c16f7eba0efd 100644 (file)
@@ -4054,23 +4054,15 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
   if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
     fixP->fx_done = 1;
 
-  if (fixP->fx_bit_fixP || fixP->fx_im_disp != 0)
-    {
-      as_bad_where (fixP->fx_file, fixP->fx_line, _("Invalid relocation"));
-      fixP->fx_done = 1;
-    }
-  else
-    {
-      /* We can't actually support subtracting a symbol.  */
-      if (fixP->fx_subsy != (symbolS *) NULL)
-       as_bad_where (fixP->fx_file, fixP->fx_line,
-                     _("expression too complex"));
+  /* We can't actually support subtracting a symbol.  */
+  if (fixP->fx_subsy != (symbolS *) NULL)
+    as_bad_where (fixP->fx_file, fixP->fx_line,
+                 _("expression too complex"));
 
-      /* This operand-type is scaled.  */
-      if (fixP->fx_r_type == BFD_RELOC_CRIS_LAPCQ_OFFSET)
-       val /= 2;
-      cris_number_to_imm (buf, val, fixP->fx_size, fixP, seg);
-    }
+  /* This operand-type is scaled.  */
+  if (fixP->fx_r_type == BFD_RELOC_CRIS_LAPCQ_OFFSET)
+    val /= 2;
+  cris_number_to_imm (buf, val, fixP->fx_size, fixP, seg);
 }
 
 /* All relocations are relative to the location just after the fixup;
index f1be6dba91520958e9a5e6c490184d3a13899b2c..0b0fe2f1502fa6196a4d8a2d0e22e470ae479bdb 100644 (file)
@@ -1014,10 +1014,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          free (fixP->fx_bit_fixP);
          fixP->fx_bit_fixP = NULL;
        }
-#ifdef DEBUG
-      else
-       know ((fixP->fx_bit_fixP != NULL));
-#endif
       break;
 
     case RELOC_DLX_HI16:
@@ -1027,10 +1023,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          free (fixP->fx_bit_fixP);
          fixP->fx_bit_fixP = NULL;
        }
-#ifdef DEBUG
-      else
-       know ((fixP->fx_bit_fixP != NULL));
-#endif
       break;
 
     case RELOC_DLX_REL26:
@@ -1040,10 +1032,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          free (fixP->fx_bit_fixP);
          fixP->fx_bit_fixP = NULL;
        }
-#ifdef DEBUG
-      else
-       know ((fixP->fx_bit_fixP != NULL));
-#endif
       break;
 
     case BFD_RELOC_VTABLE_INHERIT:
@@ -1066,6 +1054,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
   number_to_chars_bigendian (place, val, fixP->fx_size);
   if (fixP->fx_addsy == NULL)
     fixP->fx_done = 1;
+  if (fixP->fx_bit_fixP != NULL)
+    fixP->fx_no_overflow = 1;
 }
 
 const char *md_shortopts = "";
index b6450aec36abf32cf1d490ba37e57143f5400337..03659345d9660b834d6ee81b97a7909124010661 100644 (file)
 
 #define LEX_DOLLAR 1
 
+#include "bit_fix.h"
+
+#define TC_FIX_TYPE bit_fixS *
+#define tc_fix_data fx_bit_fixP
+#define TC_INIT_FIX_DATA(FIX) do (FIX)->fx_bit_fixP = NULL; while (0)
+
 extern void dlx_pop_insert         (void);
 extern int dlx_unrecognized_line   (int);
 extern bfd_boolean md_dlx_fix_adjustable  (struct fix *);
index 357cf00ff71aaf9462ebcd759629ae5e732ae8e5..75cdabae8857a4d2fa2dfa5155cd0a7e172f3b2c 100644 (file)
@@ -1331,7 +1331,7 @@ fix_new_ns32k (fragS *frag,               /* Which frag? */
   fix_bsr (fixP) = bsr;
   fix_bit_fixP (fixP) = bit_fixP;
   /* We have a MD overflow check for displacements.  */
-  fixP->fx_no_overflow = (im_disp != 0);
+  fixP->fx_no_overflow = im_disp != 0 || bit_fixP != NULL;
 }
 
 static void
@@ -1359,7 +1359,7 @@ fix_new_ns32k_exp (fragS *frag,           /* Which frag? */
   fix_bsr (fixP) = bsr;
   fix_bit_fixP (fixP) = bit_fixP;
   /* We have a MD overflow check for displacements.  */
-  fixP->fx_no_overflow = (im_disp != 0);
+  fixP->fx_no_overflow = im_disp != 0 || bit_fixP != NULL;
 }
 
 /* Convert number to chars in correct order.  */
index a53ef976e44f8c71af0d64b9f7e8da787b7f007a..d905f663845945a0a3749ea0f4bcb91c5c25ee3c 100644 (file)
@@ -91,14 +91,16 @@ extern const struct relax_type md_relax_table[];
   struct                                       \
     {                                          \
       fragS *      opcode_fragP;               \
+      bit_fixS *   fx_bit_fixP;                        \
       unsigned int opcode_offset;              \
       unsigned int bsr : 1;                    \
+      unsigned int fx_im_disp : 2;             \
     }
 
 /* Accessor macros for things which may move around.
    See comments in write.h.  */
-#define fix_im_disp(X)       (X)->fx_im_disp
-#define fix_bit_fixP(X)      (X)->fx_bit_fixP
+#define fix_im_disp(X)       (X)->tc_fix_data.fx_im_disp
+#define fix_bit_fixP(X)      (X)->tc_fix_data.fx_bit_fixP
 #define fix_opcode_frag(X)   (X)->tc_fix_data.opcode_fragP
 #define fix_opcode_offset(X) (X)->tc_fix_data.opcode_offset
 #define fix_bsr(X)           (X)->tc_fix_data.bsr
@@ -108,16 +110,20 @@ extern const struct relax_type md_relax_table[];
      {                                         \
        fix_opcode_frag(X) = NULL;              \
        fix_opcode_offset(X) = 0;               \
+       fix_bit_fixP(X) = NULL;                 \
        fix_bsr(X) = 0;                         \
+       fix_im_disp(X) = 0;                     \
      }                                         \
   while (0)
 
 #define TC_FIX_DATA_PRINT(FILE, FIX)                                   \
   do                                                                   \
     {                                                                  \
-      fprintf ((FILE), "opcode_frag=%ld, operand offset=%d, bsr=%d\n", \
-             (unsigned long) fix_opcode_frag (FIX),                    \
-             fix_opcode_offset (FIX),                                  \
-             fix_bsr (FIX));                                           \
+      fprintf ((FILE), "opcode_frag=%ld, operand offset=%d, bsr=%d, "  \
+              "im_disp=%d\n",                                          \
+              (unsigned long) fix_opcode_frag (FIX),                   \
+              fix_opcode_offset (FIX),                                 \
+              fix_bsr (FIX),                                           \
+              fix_im_disp (FIX));                                      \
     }                                                                  \
   while (0)
index 91767fbb36d181b0cd8ea97170a9c0fbddff7014..050fbe8da62e7e14ebf390fde333f9b3b8df394b 100644 (file)
@@ -174,9 +174,7 @@ fix_new_internal (fragS *frag,              /* Which frag?  */
   fixP->fx_dot_frag = dot_frag;
   fixP->fx_pcrel = pcrel;
   fixP->fx_r_type = r_type;
-  fixP->fx_im_disp = 0;
   fixP->fx_pcrel_adjust = 0;
-  fixP->fx_bit_fixP = 0;
   fixP->fx_addnumber = 0;
   fixP->fx_tcbit = 0;
   fixP->fx_tcbit2 = 0;
@@ -1093,7 +1091,7 @@ fixup_segment (fixS *fixP, segT this_segment)
            symbol_mark_used_in_reloc (fixP->fx_subsy);
        }
 
-      if (!fixP->fx_bit_fixP && !fixP->fx_no_overflow && fixP->fx_size != 0)
+      if (!fixP->fx_no_overflow && fixP->fx_size != 0)
        {
          if (fixP->fx_size < sizeof (valueT))
            {
@@ -1131,7 +1129,7 @@ fixup_segment (fixS *fixP, segT this_segment)
                          (long) add_number,
                          (long) (fragP->fr_address + fixP->fx_where));
 #endif
-       }                       /* Not a bit fix.  */
+       }
 
 #ifdef TC_VALIDATE_FIX
     skip:  ATTRIBUTE_UNUSED_LABEL
@@ -3142,14 +3140,6 @@ print_fixup (fixS *fixp)
     fprintf (stderr, " pcrel");
   if (fixp->fx_pcrel_adjust)
     fprintf (stderr, " pcrel_adjust=%d", fixp->fx_pcrel_adjust);
-  if (fixp->fx_im_disp)
-    {
-#ifdef TC_NS32K
-      fprintf (stderr, " im_disp=%d", fixp->fx_im_disp);
-#else
-      fprintf (stderr, " im_disp");
-#endif
-    }
   if (fixp->fx_tcbit)
     fprintf (stderr, " tcbit");
   if (fixp->fx_done)
index a69ec3cd17c5dc90e4c3e977d34435b56dfc04a4..96ad791d228cf475e58fa8d66dff6c75011277d8 100644 (file)
 #define FAKE_LABEL_CHAR '\001'
 #endif
 
-#include "bit_fix.h"
-
 /*
  * FixSs may be built up in any order.
  */
 
 struct fix
 {
+  /* Next fixS in linked list, or NULL.  */
+  struct fix *fx_next;
+
   /* These small fields are grouped together for compactness of
      this structure, and efficiency of access on some architectures.  */
 
   /* Is this a pc-relative relocation?  */
   unsigned fx_pcrel : 1;
 
-  /* Is this value an immediate displacement?  */
-  /* Only used on ns32k; merge it into TC_FIX_TYPE sometime.  */
-  unsigned fx_im_disp : 2;
-
-  /* Some bits for the CPU specific code.  */
-  unsigned fx_tcbit : 1;
-  unsigned fx_tcbit2 : 1;
-
   /* Has this relocation already been applied?  */
   unsigned fx_done : 1;
 
@@ -75,11 +68,20 @@ struct fix
   /* The value is signed when checking for overflow.  */
   unsigned fx_signed : 1;
 
+  /* Some bits for the CPU specific code.  */
+  unsigned fx_tcbit : 1;
+  unsigned fx_tcbit2 : 1;
+
+  /* Spare bits.  */
+  unsigned fx_unused : 10;
+
   /* pc-relative offset adjust (only used by some CPU specific code) */
-  signed char fx_pcrel_adjust;
+  int fx_pcrel_adjust : 8;
 
   /* How many bytes are involved? */
-  unsigned char fx_size;
+  unsigned fx_size : 8;
+
+  bfd_reloc_code_real_type fx_r_type;
 
   /* Which frag does this fix apply to?  */
   fragS *fx_frag;
@@ -102,14 +104,6 @@ struct fix
   /* The frag fx_dot_value is based on.  */
   fragS *fx_dot_frag;
 
-  /* Next fixS in linked list, or NULL.  */
-  struct fix *fx_next;
-
-  /* If NULL, no bitfix's to do.  */
-  bit_fixS *fx_bit_fixP;
-
-  bfd_reloc_code_real_type fx_r_type;
-
   /* This field is sort of misnamed.  It appears to be a sort of random
      scratch field, for use by the back ends.  The main gas code doesn't
      do anything but initialize it to zero.  The use of it does need to
This page took 0.035045 seconds and 4 git commands to generate.