import insight-2000-02-04 snapshot (2nd try)
[external/binutils.git] / gas / config / tc-m32r.c
index f0e76df..a1de5cc 100644 (file)
@@ -91,7 +91,6 @@ static const char * m32r_cpu_desc;
    shouldn't assume or require it to).  */
 static int warn_unmatched_high = 0;
 
-/* start-sanitize-cygnus */
 /* Non-zero if -m32rx has been specified, in which case support for the
    extended M32RX instruction set should be enabled.  */
 static int enable_m32rx = 0;
@@ -106,7 +105,6 @@ static int warn_explicit_parallel_conflicts = 1;
 
 /* Non-zero if insns can be made parallel.  */
 static int optimize;
-/* end-sanitize-cygnus */
 
 /* stuff for .scomm symbols.  */
 static segT     sbss_section;
@@ -143,7 +141,6 @@ struct m32r_hi_fixup
 static struct m32r_hi_fixup * m32r_hi_fixup_list;
 
 \f
-/* start-sanitize-cygnus */
 static void
 allow_m32rx (on)
      int on;
@@ -154,18 +151,12 @@ allow_m32rx (on)
     bfd_set_arch_mach (stdoutput, TARGET_ARCH,
                       enable_m32rx ? bfd_mach_m32rx : bfd_mach_m32r);
 }
-/* end-sanitize-cygnus */
 \f
-#define M32R_SHORTOPTS ""
-/* start-sanitize-cygnus */
-#undef M32R_SHORTOPTS
 #define M32R_SHORTOPTS "O"
-/* end-sanitize-cygnus */
 const char * md_shortopts = M32R_SHORTOPTS;
 
 struct option md_longopts[] =
 {
-/* start-sanitize-cygnus */
 #define OPTION_M32RX   (OPTION_MD_BASE)
   {"m32rx", no_argument, NULL, OPTION_M32RX},
 #define OPTION_WARN_PARALLEL   (OPTION_MD_BASE + 1)
@@ -176,15 +167,14 @@ struct option md_longopts[] =
   {"Wnp", no_argument, NULL, OPTION_NO_WARN_PARALLEL},
 #define OPTION_SPECIAL (OPTION_MD_BASE + 3)
   {"hidden", no_argument, NULL, OPTION_SPECIAL},
-/* end-sanitize-cygnus */
 
   /* Sigh.  I guess all warnings must now have both variants.  */
 #define OPTION_WARN_UNMATCHED (OPTION_MD_BASE + 4)
-  {"warn-unmatched-high", OPTION_WARN_UNMATCHED},
-  {"Wuh", OPTION_WARN_UNMATCHED},
+  {"warn-unmatched-high", no_argument, NULL, OPTION_WARN_UNMATCHED},
+  {"Wuh", no_argument, NULL, OPTION_WARN_UNMATCHED},
 #define OPTION_NO_WARN_UNMATCHED (OPTION_MD_BASE + 5)
-  {"no-warn-unmatched-high", OPTION_WARN_UNMATCHED},
-  {"Wnuh", OPTION_WARN_UNMATCHED},
+  {"no-warn-unmatched-high", no_argument, NULL, OPTION_NO_WARN_UNMATCHED},
+  {"Wnuh", no_argument, NULL, OPTION_NO_WARN_UNMATCHED},
 
 #if 0 /* not supported yet */
 #define OPTION_RELAX  (OPTION_MD_BASE + 6)
@@ -192,7 +182,6 @@ struct option md_longopts[] =
 #define OPTION_CPU_DESC (OPTION_MD_BASE + 7)
   {"cpu-desc", required_argument, NULL, OPTION_CPU_DESC},
 #endif
-
   {NULL, no_argument, NULL, 0}
 };
 size_t md_longopts_size = sizeof (md_longopts);
@@ -204,7 +193,6 @@ md_parse_option (c, arg)
 {
   switch (c)
     {
-/* start-sanitize-cygnus */
     case 'O':
       optimize = 1;
       break;
@@ -226,14 +214,11 @@ md_parse_option (c, arg)
        enable_special = 1;
       else
        {
-         extern char * myname;
-
          /* Pretend that we do not recognise this option.  */
-         fprintf (stderr, _("%s: unrecognised option: -hidden\n"), myname);
+         as_bad (_("Unrecognised option: -hidden"));
          return 0;
        }
       break;
-/* end-sanitize-cygnus */
 
     case OPTION_WARN_UNMATCHED:
       warn_unmatched_high = 1;
@@ -255,6 +240,7 @@ md_parse_option (c, arg)
     default:
       return 0;
     }
+  
   return 1;
 }
 
@@ -264,7 +250,6 @@ md_show_usage (stream)
 {
   fprintf (stream, _(" M32R specific command line options:\n"));
 
-/* start-sanitize-cygnus */
   fprintf (stream, _("\
   -m32rx                  support the extended m32rx instruction set\n"));
   fprintf (stream, _("\
@@ -282,7 +267,6 @@ md_show_usage (stream)
   -Wp                     synonym for -warn-explicit-parallel-conflicts\n"));
   fprintf (stream, _("\
   -Wnp                    synonym for -no-warn-explicit-parallel-conflicts\n"));
-/* end-sanitize-cygnus */
 
   fprintf (stream, _("\
   -warn-unmatched-high    warn when an (s)high reloc has no matching low reloc\n"));
@@ -317,11 +301,9 @@ const pseudo_typeS md_pseudo_table[] =
   { "fillinsn", fill_insn,     0 },
   { "scomm",   m32r_scomm,     0 },
   { "debugsym",        debug_sym,      0 },
-/* start-sanitize-cygnus */
   /* Not documented as so far there is no need for them.... */  
   { "m32r",    allow_m32rx,    0 },
   { "m32rx",   allow_m32rx,    1 },
-/* end-sanitize-cygnus */
   { NULL, NULL, 0 }
 };
 
@@ -343,7 +325,7 @@ m32r_do_align (n, fill, len, max)
 {
   /* Only do this if the fill pattern wasn't specified.  */
   if (fill == NULL
-      && (now_seg->flags & SEC_CODE) != 0
+      && subseg_text_p (now_seg)
       /* Only do this special handling if aligning to at least a
         4 byte boundary.  */
       && n > 1
@@ -434,7 +416,7 @@ debug_sym (ignore)
       link->symbol = symbolP;
       link->next = debug_sym_link;
       debug_sym_link = link;
-      symbolP->local = 1;
+      symbol_get_obj (symbolP)->local = 1;
     }
 
   *end_name = delim;
@@ -507,10 +489,10 @@ md_begin ()
   /* Initialize the `cgen' interface.  */
   
   /* Set the machine number and endian.  */
-  gas_cgen_cpu_desc = m32r_cgen_cpu_open (0 /* mach number */,
-                                         target_big_endian ?
-                                         CGEN_ENDIAN_BIG
-                                         : CGEN_ENDIAN_LITTLE);
+  gas_cgen_cpu_desc = m32r_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
+                                         CGEN_CPU_OPEN_ENDIAN,
+                                         CGEN_ENDIAN_BIG,
+                                         CGEN_CPU_OPEN_END);
   m32r_cgen_init_asm (gas_cgen_cpu_desc);
 
   /* The operand instance table is used during optimization to determine
@@ -562,17 +544,13 @@ md_begin ()
   scom_symbol.name            = ".scommon";
   scom_symbol.section         = & scom_section;
 
-/* start-sanitize-cygnus */
   allow_m32rx (enable_m32rx);
-/* end-sanitize-cygnus */
 }
 
-/* start-sanitize-cygnus */
-
 #define OPERAND_IS_COND_BIT(operand, indices, index) \
-  ((operand)->hw->type == HW_H_COND                    \
-   || ((operand)->hw->type == HW_H_PSW)                        \
-   || ((operand)->hw->type == HW_H_CR                  \
+  ((operand)->hw_type == HW_H_COND                     \
+   || ((operand)->hw_type == HW_H_PSW)                 \
+   || ((operand)->hw_type == HW_H_CR                   \
        && (indices [index] == 0 || indices [index] == 1)))
 
 /* Returns true if an output of instruction 'a' is referenced by an operand
@@ -640,7 +618,7 @@ first_writes_to_seconds_operands (a, b, check_outputs)
                       == (check_outputs
                           ? CGEN_OPINST_OUTPUT
                           : CGEN_OPINST_INPUT))
-                     && (b_operands->hw == a_operands->hw)
+                     && (b_operands->hw_type == a_operands->hw_type)
                      && (a->indices [a_index] == b->indices [b_index]))
                    return 1;
                }
@@ -988,9 +966,6 @@ assemble_two_insns (str, str2, parallel_p)
   prev_subseg = now_subseg;
 }
 
-/* end-sanitize-cygnus */
-
-
 void
 md_assemble (str)
      char * str;
@@ -1002,7 +977,6 @@ md_assemble (str)
   /* Initialize GAS's cgen interface for a new instruction.  */
   gas_cgen_init_parse ();
 
-/* start-sanitize-cygnus */
   /* Look for a parallel instruction seperator.  */
   if ((str2 = strstr (str, "||")) != NULL)
     {
@@ -1016,7 +990,6 @@ md_assemble (str)
       assemble_two_insns (str, str2, 0);
       return;
     }
-/* end-sanitize-cygnus */
   
   insn.debug_sym_link = debug_sym_link;
   debug_sym_link = (sym_linkS *)0;
@@ -1030,7 +1003,6 @@ md_assemble (str)
       return;
     }
 
-/* start-sanitize-cygnus */
   if (! enable_special
       && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_SPECIAL))
     {
@@ -1045,7 +1017,6 @@ md_assemble (str)
       as_bad (_("instruction '%s' is for the M32RX only"), str);
       return;
     }
-/* end-sanitize-cygnus */
   
   if (CGEN_INSN_BITSIZE (insn.insn) == 32)
     {
@@ -1067,15 +1038,13 @@ md_assemble (str)
   else
     {
       int on_32bit_boundary_p;
-/* start-sanitize-cygnus */
       int swap = false;
-/* end-sanitize-cygnus */
 
       if (CGEN_INSN_BITSIZE (insn.insn) != 16)
        abort();
 
       insn.orig_insn = insn.insn;
-/* start-sanitize-cygnus */
+
       /* If the previous insn was relaxable, then it may be expanded
         to fill the current 16 bit slot.  Emit a NOP here to occupy
         this slot, so that we can start at optimizing at a 32 bit
@@ -1097,13 +1066,11 @@ md_assemble (str)
          if (insn.insn == NULL)
            as_fatal (_("internal error: lookup/get operands failed"));
        }
-/* end-sanitize-cygnus */
 
       /* Compute whether we're on a 32 bit boundary or not.
         prev_insn.insn is NULL when we're on a 32 bit boundary.  */
       on_32bit_boundary_p = prev_insn.insn == NULL;
 
-/* start-sanitize-cygnus */
       /* Look to see if this instruction can be combined with the
         previous instruction to make one, parallel, 32 bit instruction.
         If the previous instruction (potentially) changed the flow of
@@ -1127,7 +1094,6 @@ md_assemble (str)
          else if (can_make_parallel (& insn, & prev_insn) == NULL)
            swap = true;
        }
-/* end-sanitize-cygnus */
 
       expand_debug_syms (insn.debug_sym_link, 1);
 
@@ -1148,7 +1114,6 @@ md_assemble (str)
          insn.fixups[i] = fi.fixups[i];
       }
 
-/* start-sanitize-cygnus */
       if (swap)
        {
          int i,tmp;
@@ -1176,7 +1141,6 @@ md_assemble (str)
          for (i = 0; i < insn.num_fixups; ++i)
            insn.fixups[i]->fx_where -= 2;
        }
-/* end-sanitize-cygnus */
 
       /* Keep track of whether we've seen a pair of 16 bit insns.
         prev_insn.insn is NULL when we're on a 32 bit boundary.  */
@@ -1328,7 +1292,7 @@ m32r_scomm (ignore)
       return;
     }
 
-  if (symbolP->local)
+  if (symbol_get_obj (symbolP)->local)
     {
       segT   old_sec    = now_seg;
       int    old_subsec = now_subseg;
@@ -1341,9 +1305,9 @@ m32r_scomm (ignore)
        frag_align (align2, 0, 0);
       
       if (S_GET_SEGMENT (symbolP) == sbss_section)
-       symbolP->sy_frag->fr_symbol = 0;
+       symbol_get_frag (symbolP)->fr_symbol = 0;
       
-      symbolP->sy_frag = frag_now;
+      symbol_set_frag (symbolP, frag_now);
       
       pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
                        (char *) 0);
@@ -1570,7 +1534,7 @@ md_convert_frag (abfd, sec, fragP)
     {
       /* Address we want to reach in file space.  */
       target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
-      target_address += fragP->fr_symbol->sy_frag->fr_address;
+      target_address += symbol_get_frag (fragP->fr_symbol)->fr_address;
       addend = (target_address - (opcode_address & -4)) >> 2;
     }
 
@@ -1588,11 +1552,11 @@ md_convert_frag (abfd, sec, fragP)
                             4 /*length*/,
                             /* FIXME: quick hack */
 #if 0
-                            CGEN_OPERAND_ENTRY (gas_cgen_cpu_desc,
-                                                fragP->fr_cgen.opindex),
+                            cgen_operand_lookup_by_num (gas_cgen_cpu_desc,
+                                                        fragP->fr_cgen.opindex),
 #else
-                            CGEN_OPERAND_ENTRY (gas_cgen_cpu_desc,
-                                                M32R_OPERAND_DISP24),
+                            cgen_operand_lookup_by_num (gas_cgen_cpu_desc,
+                                                        M32R_OPERAND_DISP24),
 #endif
                             fragP->fr_cgen.opinfo,
                             fragP->fr_symbol, fragP->fr_offset);
@@ -1638,7 +1602,7 @@ md_cgen_lookup_reloc (insn, operand, fixP)
      const CGEN_OPERAND * operand;
      fixS *               fixP;
 {
-  switch (CGEN_OPERAND_TYPE (gas_cgen_cpu_desc, operand))
+  switch (operand->type)
     {
     case M32R_OPERAND_DISP8 : return  BFD_RELOC_M32R_10_PCREL;
     case M32R_OPERAND_DISP16 : return BFD_RELOC_M32R_18_PCREL;
@@ -1648,8 +1612,8 @@ md_cgen_lookup_reloc (insn, operand, fixP)
     case M32R_OPERAND_SLO16 :
     case M32R_OPERAND_ULO16 :
       /* If low/high/shigh/sda was used, it is recorded in `opinfo'.  */
-      if (fixP->tc_fix_data.opinfo != 0)
-       return fixP->tc_fix_data.opinfo;
+      if (fixP->fx_cgen.opinfo != 0)
+       return fixP->fx_cgen.opinfo;
       break;
     default : /* avoid -Wall warning */
       break;
@@ -1695,13 +1659,13 @@ m32r_cgen_record_fixup_exp (frag, where, insn, length, operand, opinfo, exp)
   fixS * fixP = gas_cgen_record_fixup_exp (frag, where, insn, length,
                                           operand, opinfo, exp);
 
-  switch (CGEN_OPERAND_TYPE (gas_cgen_cpu_desc, operand))
+  switch (operand->type)
     {
     case M32R_OPERAND_HI16 :
       /* If low/high/shigh/sda was used, it is recorded in `opinfo'.  */
-      if (fixP->tc_fix_data.opinfo == BFD_RELOC_M32R_HI16_SLO
-         || fixP->tc_fix_data.opinfo == BFD_RELOC_M32R_HI16_ULO)
-       m32r_record_hi16 (fixP->tc_fix_data.opinfo, fixP, now_seg);
+      if (fixP->fx_cgen.opinfo == BFD_RELOC_M32R_HI16_SLO
+         || fixP->fx_cgen.opinfo == BFD_RELOC_M32R_HI16_ULO)
+       m32r_record_hi16 (fixP->fx_cgen.opinfo, fixP, now_seg);
       break;
     default : /* avoid -Wall warning */
       break;
@@ -1713,7 +1677,7 @@ m32r_cgen_record_fixup_exp (frag, where, insn, length, operand, opinfo, exp)
 /* Return BFD reloc type from opinfo field in a fixS.
    It's tricky using fx_r_type in m32r_frob_file because the values
    are BFD_RELOC_UNUSED + operand number.  */
-#define FX_OPINFO_R_TYPE(f) ((f)->tc_fix_data.opinfo)
+#define FX_OPINFO_R_TYPE(f) ((f)->fx_cgen.opinfo)
 
 /* Sort any unmatched HI16 relocs so that they immediately precede
    the corresponding LO16 reloc.  This is called before md_apply_fix and