Automatic date update in version.in
[deliverable/binutils-gdb.git] / gas / config / tc-bfin.c
index 6eaf4c7985ae67587233aa0e6b02dfe2eb78bb72..5f10cb7fb4c77f6de1d093bcaec9b84224329512 100644 (file)
@@ -1,6 +1,5 @@
 /* tc-bfin.c -- Assembler for the ADI Blackfin.
-   Copyright 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    02110-1301, USA.  */
 
 #include "as.h"
-#include "struc-symbol.h"
 #include "bfin-defs.h"
 #include "obstack.h"
 #include "safe-ctype.h"
 #ifdef OBJ_ELF
 #include "dwarf2dbg.h"
 #endif
-#include "libbfd.h"
 #include "elf/common.h"
 #include "elf/bfin.h"
 
@@ -85,7 +82,7 @@ bfin_pic_ptr (int nbytes)
   do
     {
       bfd_reloc_code_real_type reloc_type = BFD_RELOC_BFIN_FUNCDESC;
-      
+
       if (strncasecmp (input_line_pointer, "funcdesc(", 9) == 0)
        {
          input_line_pointer += 9;
@@ -112,7 +109,7 @@ bfin_pic_ptr (int nbytes)
 static void
 bfin_s_bss (int ignore ATTRIBUTE_UNUSED)
 {
-  register int temp;
+  int temp;
 
   temp = get_absolute_expression ();
   subseg_set (bss_section, (subsegT) temp);
@@ -136,7 +133,7 @@ const pseudo_typeS md_pseudo_table[] = {
 };
 
 /* Characters that are used to denote comments and line separators. */
-const char comment_chars[] = "";
+const char comment_chars[] = "#";
 const char line_comment_chars[] = "#";
 const char line_separator_chars[] = ";";
 
@@ -151,6 +148,8 @@ const char FLT_CHARS[] = "fFdDxX";
 typedef enum bfin_cpu_type
 {
   BFIN_CPU_UNKNOWN,
+  BFIN_CPU_BF504,
+  BFIN_CPU_BF506,
   BFIN_CPU_BF512,
   BFIN_CPU_BF514,
   BFIN_CPU_BF516,
@@ -179,7 +178,8 @@ typedef enum bfin_cpu_type
   BFIN_CPU_BF548M,
   BFIN_CPU_BF549,
   BFIN_CPU_BF549M,
-  BFIN_CPU_BF561
+  BFIN_CPU_BF561,
+  BFIN_CPU_BF592,
 } bfin_cpu_t;
 
 bfin_cpu_t bfin_cpu_type = BFIN_CPU_UNKNOWN;
@@ -200,15 +200,23 @@ struct bfin_cpu
 
 struct bfin_cpu bfin_cpus[] =
 {
+  {"bf504", BFIN_CPU_BF504, 0x0000, AC_05000074},
+
+  {"bf506", BFIN_CPU_BF506, 0x0000, AC_05000074},
+
+  {"bf512", BFIN_CPU_BF512, 0x0002, AC_05000074},
   {"bf512", BFIN_CPU_BF512, 0x0001, AC_05000074},
   {"bf512", BFIN_CPU_BF512, 0x0000, AC_05000074},
 
+  {"bf514", BFIN_CPU_BF514, 0x0002, AC_05000074},
   {"bf514", BFIN_CPU_BF514, 0x0001, AC_05000074},
   {"bf514", BFIN_CPU_BF514, 0x0000, AC_05000074},
 
+  {"bf516", BFIN_CPU_BF516, 0x0002, AC_05000074},
   {"bf516", BFIN_CPU_BF516, 0x0001, AC_05000074},
   {"bf516", BFIN_CPU_BF516, 0x0000, AC_05000074},
 
+  {"bf518", BFIN_CPU_BF518, 0x0002, AC_05000074},
   {"bf518", BFIN_CPU_BF518, 0x0001, AC_05000074},
   {"bf518", BFIN_CPU_BF518, 0x0000, AC_05000074},
 
@@ -275,30 +283,35 @@ struct bfin_cpu bfin_cpus[] =
 
   {"bf542m", BFIN_CPU_BF542M, 0x0003, AC_05000074},
 
+  {"bf542", BFIN_CPU_BF542, 0x0004, AC_05000074},
   {"bf542", BFIN_CPU_BF542, 0x0002, AC_05000074},
   {"bf542", BFIN_CPU_BF542, 0x0001, AC_05000074},
   {"bf542", BFIN_CPU_BF542, 0x0000, AC_05000074},
 
   {"bf544m", BFIN_CPU_BF544M, 0x0003, AC_05000074},
 
+  {"bf544", BFIN_CPU_BF544, 0x0004, AC_05000074},
   {"bf544", BFIN_CPU_BF544, 0x0002, AC_05000074},
   {"bf544", BFIN_CPU_BF544, 0x0001, AC_05000074},
   {"bf544", BFIN_CPU_BF544, 0x0000, AC_05000074},
 
   {"bf547m", BFIN_CPU_BF547M, 0x0003, AC_05000074},
 
+  {"bf547", BFIN_CPU_BF547, 0x0004, AC_05000074},
   {"bf547", BFIN_CPU_BF547, 0x0002, AC_05000074},
   {"bf547", BFIN_CPU_BF547, 0x0001, AC_05000074},
   {"bf547", BFIN_CPU_BF547, 0x0000, AC_05000074},
 
   {"bf548m", BFIN_CPU_BF548M, 0x0003, AC_05000074},
 
+  {"bf548", BFIN_CPU_BF548, 0x0004, AC_05000074},
   {"bf548", BFIN_CPU_BF548, 0x0002, AC_05000074},
   {"bf548", BFIN_CPU_BF548, 0x0001, AC_05000074},
   {"bf548", BFIN_CPU_BF548, 0x0000, AC_05000074},
 
   {"bf549m", BFIN_CPU_BF549M, 0x0003, AC_05000074},
 
+  {"bf549", BFIN_CPU_BF549, 0x0004, AC_05000074},
   {"bf549", BFIN_CPU_BF549, 0x0002, AC_05000074},
   {"bf549", BFIN_CPU_BF549, 0x0001, AC_05000074},
   {"bf549", BFIN_CPU_BF549, 0x0000, AC_05000074},
@@ -307,7 +320,8 @@ struct bfin_cpu bfin_cpus[] =
   {"bf561", BFIN_CPU_BF561, 0x0003, AC_05000074},
   {"bf561", BFIN_CPU_BF561, 0x0002, AC_05000074},
 
-  {NULL, 0, 0, 0}
+  {"bf592", BFIN_CPU_BF592, 0x0001, AC_05000074},
+  {"bf592", BFIN_CPU_BF592, 0x0000, AC_05000074},
 };
 
 /* Define bfin-specific command-line options (there are none). */
@@ -330,7 +344,7 @@ size_t md_longopts_size = sizeof (md_longopts);
 
 
 int
-md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
+md_parse_option (int c ATTRIBUTE_UNUSED, const char *arg ATTRIBUTE_UNUSED)
 {
   switch (c)
     {
@@ -339,26 +353,22 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
 
     case OPTION_MCPU:
       {
-       const char *p, *q;
-       int i;
+       const char *q;
+       unsigned int i;
 
-       i = 0;
-       while ((p = bfin_cpus[i].name) != NULL)
+       for (i = 0; i < ARRAY_SIZE (bfin_cpus); i++)
          {
+           const char *p = bfin_cpus[i].name;
            if (strncmp (arg, p, strlen (p)) == 0)
              break;
-           i++;
          }
 
-       if (p == NULL)
-         {
-           error ("-mcpu=%s is not valid", arg);
-           return 0;
-         }
+       if (i == ARRAY_SIZE (bfin_cpus))
+         as_fatal ("-mcpu=%s is not valid", arg);
 
        bfin_cpu_type = bfin_cpus[i].type;
 
-       q = arg + strlen (p);
+       q = arg + strlen (bfin_cpus[i].name);
 
        if (*q == '\0')
          {
@@ -370,7 +380,8 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
        else if (strcmp (q, "-any") == 0)
          {
            bfin_si_revision = 0xffff;
-           while (bfin_cpus[i].type == bfin_cpu_type)
+           while (i < ARRAY_SIZE (bfin_cpus)
+                  && bfin_cpus[i].type == bfin_cpu_type)
              {
                bfin_anomaly_checks |= bfin_cpus[i].anomaly_checks;
                i++;
@@ -388,17 +399,18 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
                || si_major > 0xff || si_minor > 0xff)
              {
              invalid_silicon_revision:
-               error ("-mcpu=%s has invalid silicon revision", arg);
-               return 0;
+               as_fatal ("-mcpu=%s has invalid silicon revision", arg);
              }
 
            bfin_si_revision = (si_major << 8) | si_minor;
 
-           while (bfin_cpus[i].type == bfin_cpu_type
+           while (i < ARRAY_SIZE (bfin_cpus)
+                  && bfin_cpus[i].type == bfin_cpu_type
                   && bfin_cpus[i].si_revision != bfin_si_revision)
              i++;
 
-           if (bfin_cpus[i].type != bfin_cpu_type)
+           if (i == ARRAY_SIZE (bfin_cpus)
+               || bfin_cpus[i].type != bfin_cpu_type)
              goto invalid_silicon_revision;
 
            bfin_anomaly_checks |= bfin_cpus[i].anomaly_checks;
@@ -422,14 +434,17 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
 }
 
 void
-md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
+md_show_usage (FILE * stream)
 {
-  fprintf (stream, _(" BFIN specific command line options:\n"));
+  fprintf (stream, _(" Blackfin specific assembler options:\n"));
+  fprintf (stream, _("  -mcpu=<cpu[-sirevision]> specify the name of the target CPU\n"));
+  fprintf (stream, _("  -mfdpic                  assemble for the FDPIC ABI\n"));
+  fprintf (stream, _("  -mno-fdpic/-mnopic       disable -mfdpic\n"));
 }
 
 /* Perform machine-specific initializations.  */
 void
-md_begin ()
+md_begin (void)
 {
   /* Set the ELF flags if desired. */
   if (bfin_flags)
@@ -442,7 +457,7 @@ md_begin ()
   /* Ensure that lines can begin with '(', for multiple
      register stack pops. */
   lex_type ['('] = LEX_BEGIN_NAME;
-  
+
 #ifdef OBJ_ELF
   record_alignment (text_section, 2);
   record_alignment (data_section, 2);
@@ -455,7 +470,7 @@ md_begin ()
 #ifdef DEBUG
   extern int debug_codeselection;
   debug_codeselection = 1;
-#endif 
+#endif
 
   last_insn_size = 0;
 }
@@ -468,20 +483,18 @@ void
 md_assemble (char *line)
 {
   char *toP = 0;
-  extern char *current_inputline;
   int size, insn_size;
   struct bfin_insn *tmp_insn;
   size_t len;
   static size_t buffer_len = 0;
+  static char *current_inputline;
   parse_state state;
 
   len = strlen (line);
   if (len + 2 > buffer_len)
     {
-      if (buffer_len > 0)
-       free (current_inputline);
       buffer_len = len + 40;
-      current_inputline = xmalloc (buffer_len);
+      current_inputline = XRESIZEVEC (char, current_inputline, buffer_len);
     }
   memcpy (current_inputline, line, len);
   current_inputline[len] = ';';
@@ -774,16 +787,14 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED)
 
 /* Round up a section size to the appropriate boundary.  */
 valueT
-md_section_align (segment, size)
-     segT segment;
-     valueT size;
+md_section_align (segT segment, valueT size)
 {
-  int boundary = bfd_get_section_alignment (stdoutput, segment);
-  return ((size + (1 << boundary) - 1) & (-1 << boundary));
+  int boundary = bfd_section_alignment (segment);
+  return ((size + (1 << boundary) - 1) & -(1 << boundary));
 }
 
 
-char *
+const char *
 md_atof (int type, char * litP, int * sizeP)
 {
   return ieee_md_atof (type, litP, sizeP, FALSE);
@@ -794,14 +805,12 @@ md_atof (int type, char * litP, int * sizeP)
    then it is done here.  */
 
 arelent *
-tc_gen_reloc (seg, fixp)
-     asection *seg ATTRIBUTE_UNUSED;
-     fixS *fixp;
+tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc                      = (arelent *) xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr  = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc                      = XNEW (arelent);
+  reloc->sym_ptr_ptr  = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -827,9 +836,7 @@ tc_gen_reloc (seg, fixp)
     given a PC relative reloc.  */
 
 long
-md_pcrel_from_section (fixP, sec)
-     fixS *fixP;
-     segT sec;
+md_pcrel_from_section (fixS *fixP, segT sec)
 {
   if (fixP->fx_addsy != (symbolS *) NULL
       && (!S_IS_DEFINED (fixP->fx_addsy)
@@ -845,11 +852,11 @@ md_pcrel_from_section (fixP, sec)
 /* Return true if the fix can be handled by GAS, false if it must
    be passed through to the linker.  */
 
-bfd_boolean  
+bfd_boolean
 bfin_fix_adjustable (fixS *fixP)
-{         
+{
   switch (fixP->fx_r_type)
-    {     
+    {
   /* Adjust_reloc_syms doesn't know about the GOT.  */
     case BFD_RELOC_BFIN_GOT:
     case BFD_RELOC_BFIN_PLTPC:
@@ -857,10 +864,10 @@ bfin_fix_adjustable (fixS *fixP)
     case BFD_RELOC_VTABLE_INHERIT:
     case BFD_RELOC_VTABLE_ENTRY:
       return 0;
-        
+
     default:
       return 1;
-    }     
+    }
 }
 
 /* Special extra functions that help bfin-parse.y perform its job.  */
@@ -920,7 +927,7 @@ note_reloc2 (INSTR_T code, const char *symbol, int reloc, int value, int pcrel)
 INSTR_T
 gencode (unsigned long x)
 {
-  INSTR_T cell = obstack_alloc (&mempool, sizeof (struct bfin_insn));
+  INSTR_T cell = XOBNEW (&mempool, struct bfin_insn);
   memset (cell, 0, sizeof (struct bfin_insn));
   cell->value = (x);
   return cell;
@@ -931,7 +938,7 @@ int ninsns;
 int count_insns;
 
 static void *
-allocate (int n)
+allocate (size_t n)
 {
   return obstack_alloc (&mempool, n);
 }
@@ -960,13 +967,13 @@ INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
 INSTR_T
 Expr_Node_Gen_Reloc (Expr_Node * head, int parent_reloc)
 {
-  /* Top level reloction expression generator VDSP style.
+  /* Top level relocation expression generator VDSP style.
    If the relocation is just by itself, generate one item
    else generate this convoluted expression.  */
 
   INSTR_T note = NULL_CODE;
   INSTR_T note1 = NULL_CODE;
-  int pcrel = 1;  /* Is the parent reloc pcrelative?
+  int pcrel = 1;  /* Is the parent reloc pc-relative?
                  This calculation here and HOWTO should match.  */
 
   if (parent_reloc)
@@ -1138,6 +1145,7 @@ Expr_Node_Gen_Reloc_R (Expr_Node * head)
 
 #define INIT(t)  t c_code = init_##t
 #define ASSIGN(x) c_code.opcode |= ((x & c_code.mask_##x)<<c_code.bits_##x)
+#define ASSIGNF(x,f) c_code.opcode |= ((x & c_code.mask_##f)<<c_code.bits_##f)
 #define ASSIGN_R(x) c_code.opcode |= (((x ? (x->regno & CODE_MASK) : 0) & c_code.mask_##x)<<c_code.bits_##x)
 
 #define HI(x) ((x >> 16) & 0xffff)
@@ -1306,13 +1314,13 @@ bfin_gen_calla (Expr_Node * addr, int S)
 {
   int val;
   int high_val;
-  int reloc = 0;
+  int rel = 0;
   INIT (CALLa);
 
   switch(S){
-   case 0 : reloc = BFD_RELOC_BFIN_24_PCREL_JUMP_L; break;
-   case 1 : reloc = BFD_RELOC_24_PCREL; break;
-   case 2 : reloc = BFD_RELOC_BFIN_PLTPC; break;
+   case 0 : rel = BFD_RELOC_BFIN_24_PCREL_JUMP_L; break;
+   case 1 : rel = BFD_RELOC_24_PCREL; break;
+   case 2 : rel = BFD_RELOC_BFIN_PLTPC; break;
    default : break;
   }
 
@@ -1322,7 +1330,7 @@ bfin_gen_calla (Expr_Node * addr, int S)
   high_val = val >> 16;
 
   return conscode (gencode (HI (c_code.opcode) | (high_val & 0xff)),
-                     Expr_Node_Gen_Reloc (addr, reloc));
+                     Expr_Node_Gen_Reloc (addr, rel));
   }
 
 INSTR_T
@@ -1340,7 +1348,7 @@ bfin_gen_linkage (int R, int framesize)
 /* Load and Store.  */
 
 INSTR_T
-bfin_gen_ldimmhalf (REG_T reg, int H, int S, int Z, Expr_Node * phword, int reloc)
+bfin_gen_ldimmhalf (REG_T reg, int H, int S, int Z, Expr_Node * phword, int rel)
 {
   int grp, hword;
   unsigned val = EXPR_VALUE (phword);
@@ -1353,11 +1361,11 @@ bfin_gen_ldimmhalf (REG_T reg, int H, int S, int Z, Expr_Node * phword, int relo
   ASSIGN_R (reg);
   grp = (GROUP (reg));
   ASSIGN (grp);
-  if (reloc == 2)
+  if (rel == 2)
     {
       return conscode (gencode (HI (c_code.opcode)), Expr_Node_Gen_Reloc (phword, BFD_RELOC_BFIN_16_IMM));
     }
-  else if (reloc == 1)
+  else if (rel == 1)
     {
       return conscode (gencode (HI (c_code.opcode)), Expr_Node_Gen_Reloc (phword, IS_H (*reg) ? BFD_RELOC_BFIN_16_HIGH : BFD_RELOC_BFIN_16_LOW));
     }
@@ -1454,20 +1462,19 @@ bfin_gen_ldst (REG_T ptr, REG_T reg, int aop, int sz, int Z, int W)
 }
 
 INSTR_T
-bfin_gen_ldstii (REG_T ptr, REG_T reg, Expr_Node * poffset, int W, int op)
+bfin_gen_ldstii (REG_T ptr, REG_T reg, Expr_Node * poffset, int W, int opc)
 {
   int offset;
   int value = 0;
   INIT (LDSTii);
 
-
   if (!IS_PREG (*ptr))
     {
       fprintf (stderr, "Warning: possible mixup of Preg/Dreg\n");
       return 0;
     }
 
-  switch (op)
+  switch (opc)
     {
     case 1:
     case 2:
@@ -1485,7 +1492,7 @@ bfin_gen_ldstii (REG_T ptr, REG_T reg, Expr_Node * poffset, int W, int op)
   offset = value;
   ASSIGN (offset);
   ASSIGN (W);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
 
   return GEN_OPCODE16 ();
 }
@@ -1584,48 +1591,48 @@ bfin_gen_alu2op (REG_T dst, REG_T src, int opc)
 }
 
 INSTR_T
-bfin_gen_compi2opd (REG_T dst, int src, int op)
+bfin_gen_compi2opd (REG_T dst, int src, int opc)
 {
   INIT (COMPI2opD);
 
   ASSIGN_R (dst);
   ASSIGN (src);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
 
   return GEN_OPCODE16 ();
 }
 
 INSTR_T
-bfin_gen_compi2opp (REG_T dst, int src, int op)
+bfin_gen_compi2opp (REG_T dst, int src, int opc)
 {
   INIT (COMPI2opP);
 
   ASSIGN_R (dst);
   ASSIGN (src);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
 
   return GEN_OPCODE16 ();
 }
 
 INSTR_T
-bfin_gen_dagmodik (REG_T i, int op)
+bfin_gen_dagmodik (REG_T i, int opc)
 {
   INIT (DagMODik);
 
   ASSIGN_R (i);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
 
   return GEN_OPCODE16 ();
 }
 
 INSTR_T
-bfin_gen_dagmodim (REG_T i, REG_T m, int op, int br)
+bfin_gen_dagmodim (REG_T i, REG_T m, int opc, int br)
 {
   INIT (DagMODim);
 
   ASSIGN_R (i);
   ASSIGN_R (m);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
   ASSIGN (br);
 
   return GEN_OPCODE16 ();
@@ -1688,12 +1695,12 @@ bfin_gen_ccmv (REG_T src, REG_T dst, int T)
 }
 
 INSTR_T
-bfin_gen_cc2stat (int cbit, int op, int D)
+bfin_gen_cc2stat (int cbit, int opc, int D)
 {
   INIT (CC2stat);
 
   ASSIGN (cbit);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
   ASSIGN (D);
 
   return GEN_OPCODE16 ();
@@ -1717,11 +1724,11 @@ bfin_gen_regmv (REG_T src, REG_T dst)
 }
 
 INSTR_T
-bfin_gen_cc2dreg (int op, REG_T reg)
+bfin_gen_cc2dreg (int opc, REG_T reg)
 {
   INIT (CC2dreg);
 
-  ASSIGN (op);
+  ASSIGNF (opc, op);
   ASSIGN_R (reg);
 
   return GEN_OPCODE16 ();
@@ -1739,13 +1746,13 @@ bfin_gen_progctrl (int prgfunc, int poprnd)
 }
 
 INSTR_T
-bfin_gen_cactrl (REG_T reg, int a, int op)
+bfin_gen_cactrl (REG_T reg, int a, int opc)
 {
   INIT (CaCTRL);
 
   ASSIGN_R (reg);
   ASSIGN (a);
-  ASSIGN (op);
+  ASSIGNF (opc, op);
 
   return GEN_OPCODE16 ();
 }
@@ -1795,15 +1802,28 @@ bfin_gen_pseudodbg (int fn, int reg, int grp)
 INSTR_T
 bfin_gen_pseudodbg_assert (int dbgop, REG_T regtest, int expected)
 {
+  int grp;
   INIT (PseudoDbg_Assert);
 
   ASSIGN (dbgop);
   ASSIGN_R (regtest);
+  grp = GROUP (regtest);
+  ASSIGN (grp);
   ASSIGN (expected);
 
   return GEN_OPCODE32 ();
 }
 
+INSTR_T
+bfin_gen_pseudochr (int ch)
+{
+  INIT (PseudoChr);
+
+  ASSIGN (ch);
+
+  return GEN_OPCODE16 ();
+}
+
 /* Multiple instruction generation.  */
 
 INSTR_T
@@ -1842,14 +1862,15 @@ bfin_gen_multi_instr (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2)
 }
 
 INSTR_T
-bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg)
+bfin_gen_loop (Expr_Node *exp, REG_T reg, int rop, REG_T preg)
 {
   const char *loopsym;
   char *lbeginsym, *lendsym;
   Expr_Node_Value lbeginval, lendval;
   Expr_Node *lbegin, *lend;
+  symbolS *sym;
 
-  loopsym = expr->value.s_value;
+  loopsym = exp->value.s_value;
   lbeginsym = (char *) xmalloc (strlen (loopsym) + strlen ("__BEGIN") + 5);
   lendsym = (char *) xmalloc (strlen (loopsym) + strlen ("__END") + 5);
 
@@ -1870,20 +1891,31 @@ bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg)
   lbegin = Expr_Node_Create (Expr_Node_Reloc, lbeginval, NULL, NULL);
   lend   = Expr_Node_Create (Expr_Node_Reloc, lendval, NULL, NULL);
 
-  symbol_remove (symbol_find (loopsym), &symbol_rootP, &symbol_lastP);
+  sym = symbol_find(loopsym);
+  if (!S_IS_LOCAL (sym) || (S_IS_LOCAL (sym) && !symbol_used_p (sym)))
+    symbol_remove (sym, &symbol_rootP, &symbol_lastP);
+
+  return bfin_gen_loopsetup (lbegin, reg, rop, lend, preg);
+}
 
-  return bfin_gen_loopsetup(lbegin, reg, rop, lend, preg);
+void
+bfin_loop_attempt_create_label (Expr_Node *exp, int is_begin)
+{
+  char *name;
+  name = fb_label_name (exp->value.i_value, is_begin);
+  exp->value.s_value = xstrdup (name);
+  exp->type = Expr_Node_Reloc;
 }
 
 void
-bfin_loop_beginend (Expr_Node *expr, int begin)
+bfin_loop_beginend (Expr_Node *exp, int begin)
 {
   const char *loopsym;
   char *label_name;
-  symbolS *line_label;
+  symbolS *linelabel;
   const char *suffix = begin ? "__BEGIN" : "__END";
 
-  loopsym = expr->value.s_value;
+  loopsym = exp->value.s_value;
   label_name = (char *) xmalloc (strlen (loopsym) + strlen (suffix) + 5);
 
   label_name[0] = 0;
@@ -1892,12 +1924,12 @@ bfin_loop_beginend (Expr_Node *expr, int begin)
   strcat (label_name, loopsym);
   strcat (label_name, suffix);
 
-  line_label = colon (label_name);
+  linelabel = colon (label_name);
 
   /* LOOP_END follows the last instruction in the loop.
      Adjust label address.  */
   if (!begin)
-    ((struct local_symbol *) line_label)->lsy_value -= last_insn_size;
+    *symbol_X_add_number (linelabel) -= last_insn_size;
 }
 
 bfd_boolean
@@ -1928,9 +1960,9 @@ bfin_eol_in_insn (char *line)
 }
 
 bfd_boolean
-bfin_start_label (char *s, char *ptr)
+bfin_start_label (char *s)
 {
-  while (s != ptr)
+  while (*s != 0)
     {
       if (*s == '(' || *s == '[')
        return FALSE;
@@ -1938,7 +1970,7 @@ bfin_start_label (char *s, char *ptr)
     }
 
   return TRUE;
-} 
+}
 
 int
 bfin_force_relocation (struct fix *fixp)
@@ -2019,9 +2051,9 @@ decode_dagMODim_0 (int iw0)
      | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 |.br| 1 | 1 |.op|.m.....|.i.....|
      +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+  */
   int i  = ((iw0 >> DagMODim_i_bits) & DagMODim_i_mask);
-  int op  = ((iw0 >> DagMODim_op_bits) & DagMODim_op_mask);
+  int opc  = ((iw0 >> DagMODim_op_bits) & DagMODim_op_mask);
 
-  if (op == 0 || op == 1)
+  if (opc == 0 || opc == 1)
     return IREG_MASK (i);
   else
     return 0;
@@ -2200,18 +2232,18 @@ decode_LDSTii_0 (int iw0)
      | 1 | 0 | 1 |.W.|.op....|.offset........|.ptr.......|.reg.......|
      +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+  */
   int reg = ((iw0 >> LDSTii_reg_bit) & LDSTii_reg_mask);
-  int op = ((iw0 >> LDSTii_op_bit) & LDSTii_op_mask);
+  int opc = ((iw0 >> LDSTii_op_bit) & LDSTii_op_mask);
   int W = ((iw0 >> LDSTii_W_bit) & LDSTii_W_mask);
 
-  if (W == 0 && op != 3)
+  if (W == 0 && opc != 3)
     return DREG_MASK (reg);
-  else if (W == 0 && op == 3)
+  else if (W == 0 && opc == 3)
    return 0;
-  else if (W == 1 && op == 0)
+  else if (W == 1 && opc == 0)
     return 0;
-  else if (W == 1 && op == 1)
+  else if (W == 1 && opc == 1)
     return 0;
-  else if (W == 1 && op == 3)
+  else if (W == 1 && opc == 3)
     return 0;
 
   abort ();
@@ -2431,7 +2463,7 @@ decode_dsp32alu_0 (int iw0, int iw1)
 
   else if (aop == 0 && aopcde == 24)
     return DREG_MASK (dst0);
-  else if (aop == 1 && aopcde == 24) 
+  else if (aop == 1 && aopcde == 24)
     return DREG_MASK (dst0) | DREG_MASK (dst1);
   else if (aopcde == 13)
     return DREG_MASK (dst0) | DREG_MASK (dst1);
This page took 0.033465 seconds and 4 git commands to generate.