Use bool in gas
[binutils-gdb.git] / gas / config / tc-frv.c
index e29810c421706b30345883036eb79467c79d3382..7b31263ec4c5502148c4a0abf4f904dff25a6d5d 100644 (file)
@@ -1,6 +1,5 @@
 /* tc-frv.c -- Assembler for the Fujitsu FRV.
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation. Inc.
+   Copyright (C) 2002-2021 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    Boston, MA 02110-1301, USA.  */
 
 #include "as.h"
-#include "subsegs.h"     
+#include "subsegs.h"
 #include "symcat.h"
 #include "opcodes/frv-desc.h"
 #include "opcodes/frv-opc.h"
 #include "cgen.h"
-#include "libbfd.h"
 #include "elf/common.h"
 #include "elf/frv.h"
 #include "dwarf2dbg.h"
@@ -61,14 +59,14 @@ enum vliw_insn_type
   VLIW_BRANCH_HAS_NOPS         /* A Branch that requires NOPS.  */
 };
 
-/* We're going to use these in the fr_subtype field to mark 
+/* We're going to use these in the fr_subtype field to mark
    whether to keep inserted nops.  */
 
 #define NOP_KEEP 1             /* Keep these NOPS.  */
 #define NOP_DELETE 2           /* Delete these NOPS.  */
 
-#define DO_COUNT    TRUE
-#define DONT_COUNT  FALSE
+#define DO_COUNT    true
+#define DONT_COUNT  false
 
 /* A list of insns within a VLIW insn.  */
 struct vliw_insn_list
@@ -116,7 +114,7 @@ static struct vliw_insn_list        *current_vliw_insn;
 
 const char comment_chars[]        = ";";
 const char line_comment_chars[]   = "#";
-const char line_separator_chars[] = "!"; 
+const char line_separator_chars[] = "!";
 const char EXP_CHARS[]            = "eE";
 const char FLT_CHARS[]            = "dD";
 
@@ -170,7 +168,7 @@ static FRV_VLIW vliw;
 #endif
 
 static unsigned long frv_mach = bfd_mach_frv;
-static bfd_boolean fr400_audio;
+static bool fr400_audio;
 
 /* Flags to set in the elf header */
 static flagword frv_flags = DEFAULT_FLAGS | DEFAULT_FDPIC;
@@ -263,7 +261,7 @@ size_t md_longopts_size = sizeof (md_longopts);
 static int g_switch_value = 8;
 
 int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
 {
   switch (c)
     {
@@ -338,7 +336,7 @@ md_parse_option (int c, char *arg)
 
     case OPTION_CPU:
       {
-       char *p;
+       const char *p;
        int cpu_flags = EF_FRV_CPU_GENERIC;
 
        /* Identify the processor type */
@@ -371,14 +369,14 @@ md_parse_option (int c, char *arg)
          {
            cpu_flags = EF_FRV_CPU_FR405;
            frv_mach = bfd_mach_fr400;
-           fr400_audio = TRUE;
+           fr400_audio = true;
          }
 
        else if (strcmp (p, "fr400") == 0)
          {
            cpu_flags = EF_FRV_CPU_FR400;
            frv_mach = bfd_mach_fr400;
-           fr400_audio = FALSE;
+           fr400_audio = false;
          }
 
        else if (strcmp (p, "fr300") == 0)
@@ -471,21 +469,21 @@ md_show_usage (FILE * stream)
   fprintf (stream, _("-mno-pack       Do not allow instructions to be packed\n"));
   fprintf (stream, _("-mpic           Mark generated file as using small position independent code\n"));
   fprintf (stream, _("-mPIC           Mark generated file as using large position independent code\n"));
-  fprintf (stream, _("-mlibrary-pic   Mark generated file as using position indepedent code for libraries\n"));
+  fprintf (stream, _("-mlibrary-pic   Mark generated file as using position independent code for libraries\n"));
   fprintf (stream, _("-mfdpic         Assemble for the FDPIC ABI\n"));
   fprintf (stream, _("-mnopic         Disable -mpic, -mPIC, -mlibrary-pic and -mfdpic\n"));
   fprintf (stream, _("-mcpu={fr500|fr550|fr400|fr405|fr450|fr300|frv|simple|tomcat}\n"));
   fprintf (stream, _("                Record the cpu type\n"));
   fprintf (stream, _("-mtomcat-stats  Print out stats for tomcat workarounds\n"));
   fprintf (stream, _("-mtomcat-debug  Debug tomcat workarounds\n"));
-} 
+}
 
 \f
 void
 md_begin (void)
 {
   /* Initialize the `cgen' interface.  */
-  
+
   /* Set the machine number and endian.  */
   gas_cgen_cpu_desc = frv_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
                                         CGEN_CPU_OPEN_ENDIAN,
@@ -509,7 +507,7 @@ md_begin (void)
   frv_vliw_reset (& vliw, frv_mach, frv_flags);
 }
 
-bfd_boolean
+bool
 frv_md_fdpic_enabled (void)
 {
   return (frv_flags & EF_FRV_FDPIC) != 0;
@@ -518,14 +516,14 @@ frv_md_fdpic_enabled (void)
 int chain_num = 0;
 
 static struct vliw_insn_list *
-frv_insert_vliw_insn (bfd_boolean count)
+frv_insert_vliw_insn (bool count)
 {
   struct vliw_insn_list *vliw_insn_list_entry;
   struct vliw_chain     *vliw_chain_entry;
 
   if (current_vliw_chain == NULL)
     {
-      vliw_chain_entry = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
+      vliw_chain_entry = XNEW (struct vliw_chain);
       vliw_chain_entry->insn_count = 0;
       vliw_chain_entry->insn_list  = NULL;
       vliw_chain_entry->next       = NULL;
@@ -538,7 +536,7 @@ frv_insert_vliw_insn (bfd_boolean count)
        previous_vliw_chain->next = vliw_chain_entry;
     }
 
-  vliw_insn_list_entry = (struct vliw_insn_list *) xmalloc (sizeof (struct vliw_insn_list));
+  vliw_insn_list_entry = XNEW (struct vliw_insn_list);
   vliw_insn_list_entry->type      = VLIW_GENERIC_TYPE;
   vliw_insn_list_entry->insn      = NULL;
   vliw_insn_list_entry->sym       = NULL;
@@ -560,26 +558,26 @@ frv_insert_vliw_insn (bfd_boolean count)
 }
 
   /* Identify the following cases:
+
      1) A VLIW insn that contains both a branch and the branch destination.
         This requires the insertion of two vliw instructions before the
         branch.  The first consists of two nops.  The second consists of
         a single nop.
+
      2) A single instruction VLIW insn which is the destination of a branch
         that is in the next VLIW insn.  This requires the insertion of a vliw
         insn containing two nops before the branch.
+
      3) A double instruction VLIW insn which contains the destination of a
         branch that is in the next VLIW insn.  This requires the insertion of
         a VLIW insn containing a single nop before the branch.
+
      4) A single instruction VLIW insn which contains branch destination (x),
         followed by a single instruction VLIW insn which does not contain
         the branch to (x), followed by a VLIW insn which does contain the branch
         to (x).  This requires the insertion of a VLIW insn containing a single
         nop before the VLIW instruction containing the branch.
+
   */
 #define FRV_IS_NOP(insn) (insn.buffer[0] == FRV_NOP_PACK || insn.buffer[0] == FRV_NOP_NOPACK)
 #define FRV_NOP_PACK   0x00880000  /* ori.p  gr0,0,gr0 */
@@ -612,11 +610,11 @@ enum vliw_nop_type
 {
   /* A Vliw insn containing a single nop insn.  */
   VLIW_SINGLE_NOP,
-  
+
   /* A Vliw insn containing two nop insns.  */
   VLIW_DOUBLE_NOP,
 
-  /* Two vliw insns.  The first containing two nop insns.  
+  /* Two vliw insns.  The first containing two nop insns.
      The second contain a single nop insn.  */
   VLIW_DOUBLE_THEN_SINGLE_NOP
 };
@@ -674,14 +672,14 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
                    struct vliw_insn_list *insert_before_insn)
 {
 
-  bfd_boolean pack_prev = FALSE;
+  bool pack_prev = false;
   struct vliw_chain *return_me = NULL;
   struct vliw_insn_list *prev_insn = NULL;
   struct vliw_insn_list *curr_insn = vliw_to_split->insn_list;
 
-  struct vliw_chain *double_nop = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
-  struct vliw_chain *single_nop = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
-  struct vliw_chain *second_part = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
+  struct vliw_chain *double_nop = XNEW (struct vliw_chain);
+  struct vliw_chain *single_nop = XNEW (struct vliw_chain);
+  struct vliw_chain *second_part = XNEW (struct vliw_chain);
   struct vliw_chain *curr_vliw = vliw_chain_top;
   struct vliw_chain *prev_vliw = NULL;
 
@@ -695,10 +693,10 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
        Then don't set pack bit later.  */
 
       if (curr_insn->type != VLIW_LABEL_TYPE)
-       pack_prev = TRUE;
+       pack_prev = true;
       prev_insn = curr_insn;
       curr_insn = curr_insn->next;
-    } 
+    }
 
   while (curr_vliw && curr_vliw != vliw_to_split)
     {
@@ -729,7 +727,7 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
              buffer[0] |= 0x80;
            }
          /* The branch is in the middle.  Split this vliw insn into first
-            and second parts.  Insert the NOP inbetween.  */
+            and second parts.  Insert the NOP between.  */
 
           second_part->insn_list = insert_before_insn;
          second_part->insn_list->type = VLIW_BRANCH_HAS_NOPS;
@@ -737,10 +735,10 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
          frv_adjust_vliw_count (second_part);
 
           single_nop->next       = second_part;
+
           vliw_to_split->next    = single_nop;
           prev_insn->next        = NULL;
+
           return_me = second_part;
          frv_adjust_vliw_count (vliw_to_split);
        }
@@ -769,18 +767,18 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
            }
 
        /* The branch is in the middle.  Split this vliw insn into first
-          and second parts.  Insert the NOP inbetween.  */
+          and second parts.  Insert the NOP in between.  */
           second_part->insn_list = insert_before_insn;
          second_part->insn_list->type = VLIW_BRANCH_HAS_NOPS;
           second_part->next      = vliw_to_split->next;
          frv_adjust_vliw_count (second_part);
+
           double_nop->next       = second_part;
+
           vliw_to_split->next    = single_nop;
           prev_insn->next        = NULL;
          frv_adjust_vliw_count (vliw_to_split);
+
           return_me = second_part;
        }
       break;
@@ -800,7 +798,7 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
             prev_vliw->next = double_nop;
           else
             vliw_chain_top = double_nop;
+
          single_nop->next = vliw_to_split;
          return_me = vliw_to_split;
          vliw_to_split->insn_list->type = VLIW_BRANCH_HAS_NOPS;
@@ -815,7 +813,7 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
            }
 
          /* The branch is in the middle of this vliw insn.  Split into first and
-            second parts.  Insert the nop vliws in between.  */  
+            second parts.  Insert the nop vliws in between.  */
          second_part->insn_list = insert_before_insn;
          second_part->insn_list->type = VLIW_BRANCH_HAS_NOPS;
          second_part->next      = vliw_to_split->next;
@@ -860,7 +858,7 @@ frv_tomcat_analyze_vliw_chains (void)
 
   vliw1 = vliw_chain_top;
 
-workaround_top:
+ workaround_top:
 
   FRV_SET_VLIW_WINDOW (vliw1, vliw2, vliw3);
 
@@ -882,7 +880,7 @@ workaround_top:
                tomcat_doubles++;
              goto workaround_top;
            }
-         else if (vliw2 
+         else if (vliw2
                   && vliw2->insn_count == 1
                   && (temp_insn = frv_find_in_vliw (VLIW_BRANCH_TYPE, vliw3, vliw1->insn_list->sym)) != NULL)
            {
@@ -897,9 +895,7 @@ workaround_top:
 
   if (vliw1->insn_count == 2)
     {
-      struct vliw_insn_list *this_insn;
-      /* check vliw1 for a label. */
+      /* Check vliw1 for a label. */
       for (this_insn = vliw1->insn_list; this_insn; this_insn = this_insn->next)
        {
          if (this_insn->type == VLIW_LABEL_TYPE)
@@ -1003,7 +999,7 @@ fr550_check_insn_acc_range (frv_insn *insn, int low, int hi)
     case FRV_INSN_CMQMULHU:
     case FRV_INSN_MMACHS:
     case FRV_INSN_MMRDHS:
-    case FRV_INSN_CMMACHS: 
+    case FRV_INSN_CMMACHS:
     case FRV_INSN_MQMACHS:
     case FRV_INSN_CMQMACHS:
     case FRV_INSN_MQXMACHS:
@@ -1041,9 +1037,9 @@ fr550_check_insn_acc_range (frv_insn *insn, int low, int hi)
 }
 
 static int
-fr550_check_acc_range (FRV_VLIW *vliw, frv_insn *insn)
+fr550_check_acc_range (FRV_VLIW *vlw, frv_insn *insn)
 {
-  switch ((*vliw->current_vliw)[vliw->next_slot - 1])
+  switch ((*vlw->current_vliw)[vlw->next_slot - 1])
     {
     case UNIT_FM0:
     case UNIT_FM2:
@@ -1059,14 +1055,14 @@ fr550_check_acc_range (FRV_VLIW *vliw, frv_insn *insn)
 
 /* Return true if the target implements instruction INSN.  */
 
-static bfd_boolean
+static bool
 target_implements_insn_p (const CGEN_INSN *insn)
 {
   switch (frv_mach)
     {
     default:
       /* bfd_mach_frv or generic.  */
-      return TRUE;
+      return true;
 
     case bfd_mach_fr300:
     case bfd_mach_frvsimple:
@@ -1105,13 +1101,13 @@ md_assemble (char *str)
 
   insn.insn = frv_cgen_assemble_insn
     (gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, &errmsg);
-  
+
   if (!insn.insn)
     {
       as_bad ("%s", errmsg);
       return;
     }
-  
+
   /* If the cpu is tomcat, then we need to insert nops to workaround
      hardware limitations.  We need to keep track of each vliw unit
      and examine the length of the unit and the individual insns
@@ -1121,7 +1117,7 @@ md_assemble (char *str)
     {
       /* If we've just finished a VLIW insn OR this is a branch,
         then start up a new frag.  Fill it with nops.  We will get rid
-        of those that are not required after we've seen all of the 
+        of those that are not required after we've seen all of the
         instructions but before we start resolving fixups.  */
       if ( !FRV_IS_NOP (insn)
          && (frv_is_branch_insn (insn.insn) || insn.fields.f_pack))
@@ -1209,14 +1205,14 @@ md_assemble (char *str)
          previous_vliw_chain = current_vliw_chain;
          current_vliw_chain = NULL;
          current_vliw_insn  = NULL;
-        } 
+        }
     }
 }
 
 /* The syntax in the manual says constants begin with '#'.
    We just ignore it.  */
 
-void 
+void
 md_operand (expressionS *expressionP)
 {
   if (* input_line_pointer == '#')
@@ -1229,8 +1225,8 @@ md_operand (expressionS *expressionP)
 valueT
 md_section_align (segT segment, valueT size)
 {
-  int align = bfd_get_section_alignment (stdoutput, segment);
-  return ((size + (1 << align) - 1) & (-1 << align));
+  int align = bfd_section_alignment (segment);
+  return ((size + (1 << align) - 1) & -(1 << align));
 }
 
 symbolS *
@@ -1278,8 +1274,8 @@ md_estimate_size_before_relax (fragS *fragP, segT segment ATTRIBUTE_UNUSED)
     default:
     case NOP_DELETE:
       return 0;
-    }     
-} 
+    }
+}
 
 /* *fragP has been relaxed to its final size, and now needs to have
    the bytes inside it modified to conform to the new size.
@@ -1302,7 +1298,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
     case NOP_KEEP:
       fragP->fr_fix = fragP->fr_var;
       fragP->fr_var = 0;
-      return;   
+      return;
     }
 }
 \f
@@ -1340,11 +1336,11 @@ md_cgen_lookup_reloc (const CGEN_INSN *insn ATTRIBUTE_UNUSED,
   switch (operand->type)
     {
     case FRV_OPERAND_LABEL16:
-      fixP->fx_pcrel = TRUE;
+      fixP->fx_pcrel = true;
       return BFD_RELOC_FRV_LABEL16;
 
     case FRV_OPERAND_LABEL24:
-      fixP->fx_pcrel = TRUE;
+      fixP->fx_pcrel = true;
 
       if (fixP->fx_cgen.opinfo != 0)
        return fixP->fx_cgen.opinfo;
@@ -1372,7 +1368,7 @@ md_cgen_lookup_reloc (const CGEN_INSN *insn ATTRIBUTE_UNUSED,
     case FRV_OPERAND_U12:
       return BFD_RELOC_FRV_GPRELU12;
 
-    default: 
+    default:
       break;
     }
   return BFD_RELOC_NONE;
@@ -1516,13 +1512,13 @@ frv_md_number_to_chars (char *buf, valueT val, int n)
   number_to_chars_bigendian (buf, val, n);
 }
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
-  return ieee_md_atof (type, litP, sizeP, TRUE);
+  return ieee_md_atof (type, litP, sizeP, true);
 }
 
-bfd_boolean
+bool
 frv_fix_adjustable (fixS *fixP)
 {
   bfd_reloc_code_real_type reloc_type;
@@ -1596,7 +1592,7 @@ frv_pic_ptr (int nbytes)
   do
     {
       bfd_reloc_code_real_type reloc_type = BFD_RELOC_CTOR;
-      
+
       if (strncasecmp (input_line_pointer, "funcdesc(", 9) == 0)
        {
          input_line_pointer += 9;
@@ -1655,7 +1651,7 @@ frv_frob_file_section (bfd *abfd, asection *sec, void *ptr ATTRIBUTE_UNUSED)
   segment_info_type *seginfo = seg_info (sec);
   fixS *fixp;
   CGEN_CPU_DESC cd = gas_cgen_cpu_desc;
-  flagword flags = bfd_get_section_flags (abfd, sec);
+  flagword flags = bfd_section_flags (sec);
 
   /* Skip relocations in known sections (.ctors, .dtors, and .gcc_except_table)
      since we can fix those up by hand.  */
@@ -1811,7 +1807,7 @@ frv_frob_label (symbolS *this_label)
 
   vliw_insn_list_entry = frv_insert_vliw_insn(DONT_COUNT);
   vliw_insn_list_entry->type = VLIW_LABEL_TYPE;
-  vliw_insn_list_entry->sym  = this_label; 
+  vliw_insn_list_entry->sym  = this_label;
 }
 
 fixS *
@@ -1831,6 +1827,6 @@ frv_cgen_record_fixup_exp (fragS *frag,
       && current_vliw_insn->type == VLIW_BRANCH_TYPE
       && exp != NULL)
     current_vliw_insn->sym = exp->X_add_symbol;
-    
+
   return fixP;
 }