bfd_section_* macros
[deliverable/binutils-gdb.git] / gas / config / tc-spu.c
index 0b40a562f1f366dab54df4d1bc304213052dbe44..bdb22e72ba79c23a7d52ae74cb47fd5f6d9ebf51 100644 (file)
@@ -1,6 +1,6 @@
 /* spu.c -- Assembler for the IBM Synergistic Processing Unit (SPU)
 
-   Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
 #include "as.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
-#include "dwarf2dbg.h" 
+#include "dwarf2dbg.h"
 
 const struct spu_opcode spu_opcodes[] = {
 #define APUOP(TAG,MACFORMAT,OPCODE,MNEMONIC,ASMFORMAT,DEP,PIPE) \
-       { MACFORMAT, (OPCODE) << (32-11), MNEMONIC, ASMFORMAT },
+       { MACFORMAT, (OPCODE ## u) << (32-11), MNEMONIC, ASMFORMAT },
 #define APUOPFB(TAG,MACFORMAT,OPCODE,FB,MNEMONIC,ASMFORMAT,DEP,PIPE) \
        { MACFORMAT, ((OPCODE) << (32-11)) | ((FB) << (32-18)), MNEMONIC, ASMFORMAT },
 #include "opcode/spu-insns.h"
@@ -101,8 +101,6 @@ const pseudo_typeS md_pseudo_table[] =
   /* Likewise for eqv.  */
   {"eqv", NULL, 0},
   {".eqv", s_set, -1},
-  {"file", (void (*) (int)) dwarf2_directive_file, 0 }, 
-  {"loc", dwarf2_directive_loc, 0}, 
   {0,0,0}
 };
 
@@ -158,7 +156,7 @@ static int emulate_apuasm;
 static int use_dd2 = 1;
 
 int
-md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
+md_parse_option (int c, const char *arg ATTRIBUTE_UNUSED)
 {
   switch (c)
     {
@@ -247,17 +245,17 @@ insn_fmt_string (struct spu_opcode *format)
   for (i = 1; i <= format->arg[0]; i++)
     {
       int arg = format->arg[i];
-      char *exp;
-      if (i > 1 && arg != A_P && format->arg[i-1] != A_P) 
+      const char *exp;
+      if (i > 1 && arg != A_P && format->arg[i-1] != A_P)
        buf[len++] =  ',';
       if (arg == A_P)
        exp = "(";
       else if (arg < A_P)
        exp = i == syntax_error_arg ? "REG" : "reg";
-      else 
+      else
        exp = i == syntax_error_arg ? "IMM" : "imm";
       len += sprintf (&buf[len], "%s", exp);
-      if (i > 1 && format->arg[i-1] == A_P) 
+      if (i > 1 && format->arg[i-1] == A_P)
        buf[len++] =  ')';
     }
   buf[len] = 0;
@@ -273,7 +271,7 @@ md_assemble (char *op)
   struct spu_insn insn;
   int i;
 
-  assert (op);
+  gas_assert (op);
 
   /* skip over instruction to find parameters */
 
@@ -365,7 +363,7 @@ md_assemble (char *op)
   /* if this instruction requires labels mark it for later */
 
   for (i = 0; i < MAX_RELOCS; i++)
-    if (insn.reloc_arg[i] >= 0) 
+    if (insn.reloc_arg[i] >= 0)
       {
         fixS *fixP;
         bfd_reloc_code_real_type reloc = insn.reloc[i];
@@ -506,7 +504,7 @@ get_reg (const char *param, struct spu_insn *insn, int arg, int accept_expr)
       saw_prefix = 1;
       param++;
     }
-    
+
   if (arg == A_H) /* Channel */
     {
       if ((param[0] == 'c' || param[0] == 'C')
@@ -622,7 +620,7 @@ get_imm (const char *param, struct spu_insn *insn, int arg)
         i.e. for code loaded at address 0 $toc will be 0.  */
       param += 4;
     }
-      
+
   if (*param == '$')
     {
       /* Symbols can start with $, but if this symbol matches a register
@@ -634,7 +632,7 @@ get_imm (const char *param, struct spu_insn *insn, int arg)
       if (np)
        syntax_error_param = np;
     }
-      
+
   save_ptr = input_line_pointer;
   input_line_pointer = (char *) param;
   expression (&insn->exp[reloc_i]);
@@ -663,12 +661,12 @@ get_imm (const char *param, struct spu_insn *insn, int arg)
 
       if (emulate_apuasm)
        {
-         /* Convert the value to a format we expect. */ 
+         /* Convert the value to a format we expect. */
           val <<= arg_encode[arg].rshift;
          if (arg == A_U7A)
            val = 173 - val;
          else if (arg == A_U7B)
-           val = 155 - val; 
+           val = 155 - val;
        }
 
       if (high)
@@ -694,7 +692,7 @@ get_imm (const char *param, struct spu_insn *insn, int arg)
       if (arg == A_U7A)
         val = 173 - val;
       else if (arg == A_U7B)
-        val = 155 - val; 
+        val = 155 - val;
 
       /* Branch hints have a split encoding.  Do the bottom part. */
       if (arg == A_S11 || arg == A_S11I)
@@ -718,7 +716,7 @@ get_imm (const char *param, struct spu_insn *insn, int arg)
   return param;
 }
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   return ieee_md_atof (type, litP, sizeP, TRUE);
@@ -817,6 +815,11 @@ spu_cons (int nbytes)
 
   do
     {
+      char *save = input_line_pointer;
+
+      /* Use deferred_expression here so that an expression involving
+        a symbol that happens to be defined already as an spu symbol,
+        is not resolved.  */
       deferred_expression (&exp);
       if ((exp.X_op == O_symbol
           || exp.X_op == O_constant)
@@ -831,9 +834,12 @@ spu_cons (int nbytes)
            {
              expressionS new_exp;
 
+             save = input_line_pointer;
              expression (&new_exp);
              if (new_exp.X_op == O_constant)
                exp.X_add_number += new_exp.X_add_number;
+             else
+               input_line_pointer = save;
            }
 
          reloc = nbytes == 4 ? BFD_RELOC_SPU_PPU32 : BFD_RELOC_SPU_PPU64;
@@ -841,7 +847,14 @@ spu_cons (int nbytes)
                       &exp, 0, reloc);
        }
       else
-       emit_expr (&exp, nbytes);
+       {
+         /* Don't use deferred_expression for anything else.
+            deferred_expression won't evaulate dot at the point it is
+            used.  */
+         input_line_pointer = save;
+         expression (&exp);
+         emit_expr (&exp, nbytes);
+       }
     }
   while (*input_line_pointer++ == ',');
 
@@ -865,8 +878,8 @@ arelent *
 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 *);
   if (fixp->fx_addsy)
     *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   else if (fixp->fx_subsy)
@@ -891,7 +904,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 valueT
 md_section_align (segT seg, valueT size)
 {
-  int align = bfd_get_section_alignment (stdoutput, seg);
+  int align = bfd_section_alignment (seg);
   valueT mask = ((valueT) 1 << align) - 1;
 
   return (size + mask) & ~mask;
@@ -989,7 +1002,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
   fixP->fx_addnumber = val;
 
   if (fixP->fx_r_type == BFD_RELOC_SPU_PPU32
-      || fixP->fx_r_type == BFD_RELOC_SPU_PPU64)
+      || fixP->fx_r_type == BFD_RELOC_SPU_PPU64
+      || fixP->fx_r_type == BFD_RELOC_SPU_ADD_PIC)
     return;
 
   if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
@@ -1003,7 +1017,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          int lo = arg_encode[fixP->tc_fix_data.arg_format].lo;
          if (hi > lo && ((offsetT) val < lo || (offsetT) val > hi))
            as_bad_where (fixP->fx_file, fixP->fx_line,
-                         "Relocation doesn't fit. (relocation value = 0x%lx)",
+                         _("Relocation doesn't fit. (relocation value = 0x%lx)"),
                          (long) val);
        }
 
This page took 0.032182 seconds and 4 git commands to generate.