[AArch64][PATCH 11/14] Add support for the 2H vector type.
[deliverable/binutils-gdb.git] / gas / config / tc-tic4x.c
index 3ff6cbc0457ea87e2f829e11895a9e517ab39b8e..a4ca8b702d7fdde9064ad9bc02bbcf1abc7c5170 100644 (file)
@@ -1,6 +1,5 @@
 /* tc-tic4x.c -- Assemble for the Texas Instruments TMS320C[34]x.
-   Copyright (C) 1997,1998, 2002, 2003, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation. Inc.
+   Copyright (C) 1997-2015 Free Software Foundation, Inc.
 
    Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
 
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to
-   the Free Software Foundation, 51 Franklin Street - Fifth Floor, 
+   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 /*
   TODOs:
   ------
-  
+
   o .align cannot handle fill-data-width larger than 0xFF/8-bits. It
     should be possible to define a 32-bits pattern.
 
-  o .align fills all section with NOP's when used regardless if has
-    been used in .text or .data. (However the .align is primarily
-    intended used in .text sections. If you require something else,
-    use .align <size>,0x00)
-
   o .align: Implement a 'bu' insn if the number of nop's exceeds 4
     within the align frag. if(fragsize>4words) insert bu fragend+1
     first.
   o Evaluation of constant floating point expressions (expr.c needs
     work!)
 
-  o Support 'abc' constants (that is 0x616263)
-*/
+  o Support 'abc' constants (that is 0x616263).  */
 
-#include "safe-ctype.h"
 #include "as.h"
+#include "safe-ctype.h"
 #include "opcode/tic4x.h"
 #include "subsegs.h"
-#include "obstack.h"
 
 /* OK, we accept a syntax similar to the other well known C30
    assembly tools.  With TIC4X_ALT_SYNTAX defined we are more
@@ -88,7 +80,7 @@ static unsigned long tic4x_oplevel = 0;   /* Opcode level */
 #define OPTION_ENHANCED (OPTION_MD_BASE + 7)
 #define OPTION_REV      (OPTION_MD_BASE + 8)
 
-CONST char *md_shortopts = "bm:prs";
+const char *md_shortopts = "bm:prs";
 struct option md_longopts[] =
 {
   { "mcpu",   required_argument, NULL, OPTION_CPU },
@@ -203,10 +195,10 @@ const char comment_chars[] = ";";
 
 /* This array holds the chars that only start a comment at the beginning of
    a line.  If the line seems to have the form '# 123 filename'
-   .line and .file directives will appear in the pre-processed output. 
+   .line and .file directives will appear in the pre-processed output.
    Note that input_file.c hand checks for '#' at the beginning of the
    first line of the input file.  This is because the compiler outputs
-   #NO_APP at the beginning of its output. 
+   #NO_APP at the beginning of its output.
    Also note that comments like this one will always work.  */
 const char line_comment_chars[] = "#*";
 
@@ -258,7 +250,7 @@ tic4x_gen_to_words (FLONUM_TYPE flonum, LITTLENUM_TYPE *words, int precision)
      The code in this function is altered slightly to support floats
      with 31-bits mantissas, thus the documentation below may be a
      little bit inaccurate.
-     
+
      By Michael P. Hayes <m.hayes@elec.canterbury.ac.nz>
      Here is how a generic floating point number is stored using
      flonums (an extension of bignums) where p is a pointer to an
@@ -406,7 +398,7 @@ tic4x_gen_to_words (FLONUM_TYPE flonum, LITTLENUM_TYPE *words, int precision)
       /* +INF:  Replace with maximum float.  */
       if (precision == S_PRECISION)
        words[0] = 0x77ff;
-      else 
+      else
        {
          words[0] = 0x7f7f;
          words[1] = 0xffff;
@@ -423,7 +415,7 @@ tic4x_gen_to_words (FLONUM_TYPE flonum, LITTLENUM_TYPE *words, int precision)
       /* -INF:  Replace with maximum float.  */
       if (precision == S_PRECISION)
        words[0] = 0x7800;
-      else 
+      else
         words[0] = 0x7f80;
       if (precision == E_PRECISION)
         words[2] = 0x8000;
@@ -625,7 +617,7 @@ tic4x_atof (char *str, char what_kind, LITTLENUM_TYPE *words)
   return return_value;
 }
 
-static void 
+static void
 tic4x_insert_reg (char *regname, int regnum)
 {
   char buf[32];
@@ -641,7 +633,7 @@ tic4x_insert_reg (char *regname, int regnum)
                                   &zero_address_frag));
 }
 
-static void 
+static void
 tic4x_insert_sym (char *symname, int value)
 {
   symbolS *symbolP;
@@ -680,7 +672,7 @@ tic4x_expression_abs (char *str, offsetT *value)
   return s;
 }
 
-static void 
+static void
 tic4x_emit_char (char c, int b)
 {
   expressionS exp;
@@ -690,7 +682,7 @@ tic4x_emit_char (char c, int b)
   emit_expr (&exp, b);
 }
 
-static void 
+static void
 tic4x_seg_alloc (char *name ATTRIBUTE_UNUSED,
                 segT seg ATTRIBUTE_UNUSED,
                 int size,
@@ -715,7 +707,7 @@ tic4x_seg_alloc (char *name ATTRIBUTE_UNUSED,
 }
 
 /* .asg ["]character-string["], symbol */
-static void 
+static void
 tic4x_asg (int x ATTRIBUTE_UNUSED)
 {
   char c;
@@ -735,8 +727,7 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
       return;
     }
   *input_line_pointer++ = '\0';
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&name); /* Get terminator.  */
   tmp = xmalloc (strlen (str) + 1);
   strcpy (tmp, str);
   str = tmp;
@@ -747,12 +738,12 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
     hash_replace (tic4x_asg_hash, name, (void *) str);
   else
     hash_insert (tic4x_asg_hash, name, (void *) str);
-  *input_line_pointer = c;
+  (void) restore_line_pointer (c);
   demand_empty_rest_of_line ();
 }
 
 /* .bss symbol, size  */
-static void 
+static void
 tic4x_bss (int x ATTRIBUTE_UNUSED)
 {
   char c;
@@ -767,8 +758,9 @@ tic4x_bss (int x ATTRIBUTE_UNUSED)
   current_subseg = now_subseg; /* Save current subseg.  */
 
   SKIP_WHITESPACE ();
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   if (c != ',')
     {
       as_bad (_(".bss size argument missing\n"));
@@ -815,11 +807,10 @@ tic4x_globl (int ignore ATTRIBUTE_UNUSED)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (&name);
       symbolP = symbol_find_or_make (name);
       *input_line_pointer = c;
-      SKIP_WHITESPACE ();
+      SKIP_WHITESPACE_AFTER_NAME ();
       S_SET_STORAGE_CLASS (symbolP, C_EXT);
       S_SET_EXTERNAL (symbolP);
       if (c == ',')
@@ -836,10 +827,10 @@ tic4x_globl (int ignore ATTRIBUTE_UNUSED)
 }
 
 /* Handle .byte, .word. .int, .long */
-static void 
+static void
 tic4x_cons (int bytes)
 {
-  register unsigned int c;
+  unsigned int c;
   do
     {
       SKIP_WHITESPACE ();
@@ -879,11 +870,11 @@ tic4x_cons (int bytes)
 }
 
 /* Handle .ascii, .asciz, .string */
-static void 
+static void
 tic4x_stringer (int append_zero)
 {
   int bytes;
-  register unsigned int c;
+  unsigned int c;
 
   bytes = 0;
   do
@@ -932,7 +923,7 @@ tic4x_stringer (int append_zero)
 }
 
 /* .eval expression, symbol */
-static void 
+static void
 tic4x_eval (int x ATTRIBUTE_UNUSED)
 {
   char c;
@@ -947,14 +938,14 @@ tic4x_eval (int x ATTRIBUTE_UNUSED)
       as_bad (_("Symbol missing\n"));
       return;
     }
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
-  demand_empty_rest_of_line ();
+  c = get_symbol_name (&name); /* Get terminator.  */
   tic4x_insert_sym (name, value);
+  (void) restore_line_pointer (c);
+  demand_empty_rest_of_line ();
 }
 
 /* Reset local labels.  */
-static void 
+static void
 tic4x_newblock (int x ATTRIBUTE_UNUSED)
 {
   dollar_label_clear ();
@@ -962,12 +953,11 @@ tic4x_newblock (int x ATTRIBUTE_UNUSED)
 
 /* .sect "section-name" [, value] */
 /* .sect ["]section-name[:subsection-name]["] [, value] */
-static void 
+static void
 tic4x_sect (int x ATTRIBUTE_UNUSED)
 {
   char c;
   char *section_name;
-  char *subsection_name;
   char *name;
   segT seg;
   offsetT num;
@@ -975,8 +965,9 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
     input_line_pointer++;
-  section_name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&section_name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   input_line_pointer++;                /* Skip null symbol terminator.  */
   name = xmalloc (input_line_pointer - section_name + 1);
   strcpy (name, section_name);
@@ -988,14 +979,16 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
      Volker Kuhlmann  <v.kuhlmann@elec.canterbury.ac.nz>.  */
   if (c == ':')
     {
-      subsection_name = input_line_pointer;
-      c = get_symbol_end ();   /* Get terminator.  */
+      char *subname;
+      c = get_symbol_name (&subname);  /* Get terminator.  */
+      if (c == '"')
+       c = * ++ input_line_pointer;
       input_line_pointer++;    /* Skip null symbol terminator.  */
       as_warn (_(".sect: subsection name ignored"));
     }
 
   /* We might still have a '"' to discard, but the character after a
-     symbol name will be overwritten with a \0 by get_symbol_end()
+     symbol name will be overwritten with a \0 by get_symbol_name()
      [VK].  */
 
   if (c == ',')
@@ -1023,7 +1016,7 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
                 bfd_errmsg (bfd_get_error ()));
     }
 
-  /* If the last character overwritten by get_symbol_end() was an
+  /* If the last character overwritten by get_symbol_name() was an
      end-of-line, we must restore it or the end of the line will not be
      recognised and scanning extends into the next line, stopping with
      an error (blame Volker Kuhlmann <v.kuhlmann@elec.canterbury.ac.nz>
@@ -1035,7 +1028,7 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
 }
 
 /* symbol[:] .set value  or  .set symbol, value */
-static void 
+static void
 tic4x_set (int x ATTRIBUTE_UNUSED)
 {
   symbolS *symbolP;
@@ -1046,8 +1039,9 @@ tic4x_set (int x ATTRIBUTE_UNUSED)
       char c;
       char *name;
 
-      name = input_line_pointer;
-      c = get_symbol_end ();   /* Get terminator.  */
+      c = get_symbol_name (&name);     /* Get terminator.  */
+      if (c == '"')
+       c = * ++ input_line_pointer;
       if (c != ',')
        {
          as_bad (_(".set syntax invalid\n"));
@@ -1065,7 +1059,7 @@ tic4x_set (int x ATTRIBUTE_UNUSED)
 }
 
 /* [symbol] .usect ["]section-name["], size-in-words [, alignment-flag] */
-static void 
+static void
 tic4x_usect (int x ATTRIBUTE_UNUSED)
 {
   char c;
@@ -1082,8 +1076,9 @@ tic4x_usect (int x ATTRIBUTE_UNUSED)
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
     input_line_pointer++;
-  section_name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&section_name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   input_line_pointer++;                /* Skip null symbol terminator.  */
   name = xmalloc (input_line_pointer - section_name + 1);
   strcpy (name, section_name);
@@ -1131,7 +1126,7 @@ tic4x_usect (int x ATTRIBUTE_UNUSED)
 }
 
 /* .version cpu-version.  */
-static void 
+static void
 tic4x_version (int x ATTRIBUTE_UNUSED)
 {
   offsetT temp;
@@ -1148,7 +1143,7 @@ tic4x_version (int x ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
-static void 
+static void
 tic4x_init_regtable (void)
 {
   unsigned int i;
@@ -1166,7 +1161,7 @@ tic4x_init_regtable (void)
     }
 }
 
-static void 
+static void
 tic4x_init_symbols (void)
 {
   /* The TI tools accept case insensitive versions of these symbols,
@@ -1197,7 +1192,7 @@ tic4x_init_symbols (void)
      Source: TI: TMS320C3x/C4x Assembly Language Tools User's Guide,
      1997, SPRU035C, p. 3-17/3-18.  */
   tic4x_insert_sym (".REGPARM", tic4x_reg_args);
-  tic4x_insert_sym (".MEMPARM", !tic4x_reg_args);      
+  tic4x_insert_sym (".MEMPARM", !tic4x_reg_args);
   tic4x_insert_sym (".BIGMODEL", tic4x_big_model);
   tic4x_insert_sym (".C30INTERRUPT", 0);
   tic4x_insert_sym (".TMS320xx", tic4x_cpu == 0 ? 40 : tic4x_cpu);
@@ -1223,7 +1218,7 @@ tic4x_init_symbols (void)
 }
 
 /* Insert a new instruction template into hash table.  */
-static int 
+static int
 tic4x_inst_insert (const tic4x_inst_t *inst)
 {
   static char prev_name[16];
@@ -1248,7 +1243,7 @@ tic4x_inst_make (char *name, unsigned long opcode, char *args)
 {
   static tic4x_inst_t *insts = NULL;
   static char *names = NULL;
-  static int index = 0;
+  static int iindex = 0;
 
   if (insts == NULL)
     {
@@ -1258,22 +1253,22 @@ tic4x_inst_make (char *name, unsigned long opcode, char *args)
       insts = (tic4x_inst_t *)
        xmalloc (sizeof (tic4x_inst_t) * 1024);
     }
-  insts[index].name = names;
-  insts[index].opcode = opcode;
-  insts[index].opmask = 0xffffffff;
-  insts[index].args = args;
-  index++;
+  insts[iindex].name = names;
+  insts[iindex].opcode = opcode;
+  insts[iindex].opmask = 0xffffffff;
+  insts[iindex].args = args;
+  iindex++;
 
   do
     *names++ = *name++;
   while (*name);
   *names++ = '\0';
 
-  return &insts[index - 1];
+  return &insts[iindex - 1];
 }
 
 /* Add instruction template, creating dynamic templates as required.  */
-static int 
+static int
 tic4x_inst_add (const tic4x_inst_t *insts)
 {
   char *s = insts->name;
@@ -1344,7 +1339,7 @@ tic4x_inst_add (const tic4x_inst_t *insts)
 /* This function is called once, at assembler startup time.  It should
    set up all the tables, etc., that the MD part of the assembler will
    need.  */
-void 
+void
 md_begin (void)
 {
   int ok = 1;
@@ -1401,14 +1396,14 @@ md_begin (void)
   tic4x_init_symbols ();
 }
 
-void 
+void
 tic4x_end (void)
 {
-  bfd_set_arch_mach (stdoutput, bfd_arch_tic4x, 
+  bfd_set_arch_mach (stdoutput, bfd_arch_tic4x,
                     IS_CPU_TIC4X (tic4x_cpu) ? bfd_mach_tic4x : bfd_mach_tic3x);
 }
 
-static int 
+static int
 tic4x_indirect_parse (tic4x_operand_t *operand,
                      const tic4x_indirect_t *indirect)
 {
@@ -1522,17 +1517,16 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
   input_line_pointer = s;
   SKIP_WHITESPACE ();
 
-  str = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&str);  /* Get terminator.  */
   new_pointer = input_line_pointer;
   if (strlen (str) && (entry = hash_find (tic4x_asg_hash, str)) != NULL)
     {
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       input_line_pointer = (char *) entry;
     }
   else
     {
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       input_line_pointer = str;
     }
 
@@ -1671,13 +1665,13 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
   return new_pointer;
 }
 
-static int 
-tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
+static int
+tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *tinsn, int check)
 {
   const char *args = inst->args;
   unsigned long opcode = inst->opcode;
-  int num_operands = insn->num_operands;
-  tic4x_operand_t *operand = insn->operands;
+  int num_operands = tinsn->num_operands;
+  tic4x_operand_t *operand = tinsn->operands;
   expressionS *exp = &operand->expr;
   int ret = 1;
   int reg;
@@ -1688,13 +1682,13 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
      If an operand matches, we modify insn or opcode appropriately,
      and do a "continue".  If an operand fails to match, we "break".  */
 
-  insn->nchars = 4;            /* Instructions always 4 bytes.  */
-  insn->reloc = NO_RELOC;
-  insn->pcrel = 0;
+  tinsn->nchars = 4;           /* Instructions always 4 bytes.  */
+  tinsn->reloc = NO_RELOC;
+  tinsn->pcrel = 0;
 
   if (*args == '\0')
     {
-      insn->opcode = opcode;
+      tinsn->opcode = opcode;
       return num_operands == 0;
     }
 
@@ -1706,7 +1700,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
        case '\0':              /* End of args.  */
          if (num_operands == 1)
            {
-             insn->opcode = opcode;
+             tinsn->opcode = opcode;
              return ret;
            }
          break;                /* Too many operands.  */
@@ -1735,8 +1729,8 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
            }
          else if (exp->X_op == O_symbol)
            {
-             insn->reloc = BFD_RELOC_HI16;
-             insn->exp = *exp;
+             tinsn->reloc = BFD_RELOC_HI16;
+             tinsn->exp = *exp;
              continue;
            }
          break;                /* Not direct (dp) addressing.  */
@@ -1752,8 +1746,8 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
            }
          else if (exp->X_op == O_symbol)
            {
-             insn->reloc = BFD_RELOC_LO16;
-             insn->exp = *exp;
+             tinsn->reloc = BFD_RELOC_LO16;
+             tinsn->exp = *exp;
              continue;
            }
          break;                /* Not direct addressing.  */
@@ -1794,15 +1788,15 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
            }
          if (IS_CPU_TIC4X (tic4x_cpu))
            {
-             insn->reloc = BFD_RELOC_24_PCREL;
-             insn->pcrel = 1;
+             tinsn->reloc = BFD_RELOC_24_PCREL;
+             tinsn->pcrel = 1;
            }
          else
            {
-             insn->reloc = BFD_RELOC_24;
-             insn->pcrel = 0;
+             tinsn->reloc = BFD_RELOC_24;
+             tinsn->pcrel = 0;
            }
-         insn->exp = *exp;
+         tinsn->exp = *exp;
          continue;
 
        case 'C':
@@ -1833,7 +1827,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
           if (!(operand->mode == M_REGISTER))
             break;
          reg = exp->X_add_number;
-         if ( (reg >= REG_R0 && reg <= REG_R7) 
+         if ( (reg >= REG_R0 && reg <= REG_R7)
                || (IS_CPU_TIC4X (tic4x_cpu) && reg >= REG_R8 && reg <= REG_R11) )
            INSERTU (opcode, reg, 7, 0);
          else
@@ -1873,7 +1867,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
          if (operand->mode != M_REGISTER)
            break;
          reg = exp->X_add_number;
-         if ( (reg >= REG_R0 && reg <= REG_R7) 
+         if ( (reg >= REG_R0 && reg <= REG_R7)
                || (IS_CPU_TIC4X (tic4x_cpu) && reg >= REG_R8 && reg <= REG_R11) )
            INSERTU (opcode, reg, 15, 8);
          else
@@ -2048,9 +2042,9 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
                  continue;
                }
            }
-         insn->reloc = BFD_RELOC_16_PCREL;
-         insn->pcrel = 1;
-         insn->exp = *exp;
+         tinsn->reloc = BFD_RELOC_16_PCREL;
+         tinsn->pcrel = 1;
+         tinsn->exp = *exp;
          continue;
 
        case 'Q':
@@ -2064,7 +2058,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
          if (operand->mode != M_REGISTER)
            break;
          reg = exp->X_add_number;
-         if ( (reg >= REG_R0 && reg <= REG_R7) 
+         if ( (reg >= REG_R0 && reg <= REG_R7)
                || (IS_CPU_TIC4X (tic4x_cpu) && reg >= REG_R8 && reg <= REG_R11) )
            INSERTU (opcode, reg, 15, 0);
          else
@@ -2086,7 +2080,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
          if (operand->mode != M_REGISTER)
            break;
          reg = exp->X_add_number;
-         if ( (reg >= REG_R0 && reg <= REG_R7) 
+         if ( (reg >= REG_R0 && reg <= REG_R7)
                || (IS_CPU_TIC4X (tic4x_cpu) && reg >= REG_R8 && reg <= REG_R11) )
            INSERTU (opcode, reg, 20, 16);
          else
@@ -2127,21 +2121,21 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
            {
              if (operand->mode == M_HI)
                {
-                 insn->reloc = BFD_RELOC_HI16;
+                 tinsn->reloc = BFD_RELOC_HI16;
                }
              else
                {
-                 insn->reloc = BFD_RELOC_LO16;
+                 tinsn->reloc = BFD_RELOC_LO16;
                }
-             insn->exp = *exp;
+             tinsn->exp = *exp;
              continue;
            }
          /* Handle cases like ldi foo - $, ar0  where foo
             is a forward reference.  Perhaps we should check
             for X_op == O_symbol and disallow things like
             ldi foo, ar0.  */
-         insn->reloc = BFD_RELOC_16;
-         insn->exp = *exp;
+         tinsn->reloc = BFD_RELOC_16;
+         tinsn->exp = *exp;
          continue;
 
        case 'T':               /* 5-bit immediate value for tic4x stik.  */
@@ -2189,15 +2183,15 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
          else if (exp->X_op == O_symbol)
            {
              if (operand->mode == M_HI)
-               insn->reloc = BFD_RELOC_HI16;
+               tinsn->reloc = BFD_RELOC_HI16;
              else
-               insn->reloc = BFD_RELOC_LO16;
+               tinsn->reloc = BFD_RELOC_LO16;
 
-             insn->exp = *exp;
+             tinsn->exp = *exp;
              continue;
            }
-         insn->reloc = BFD_RELOC_16;
-         insn->exp = *exp;
+         tinsn->reloc = BFD_RELOC_16;
+         tinsn->exp = *exp;
          continue;
 
        case 'V':               /* Trap numbers (immediate field).  */
@@ -2254,8 +2248,8 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
                  continue;
                }
            }
-         insn->reloc = BFD_RELOC_16;
-         insn->exp = *exp;
+         tinsn->reloc = BFD_RELOC_16;
+         tinsn->exp = *exp;
          continue;
 
        case 'X':               /* Expansion register for tic4x.  */
@@ -2309,7 +2303,7 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
          continue;
 
        case '|':               /* treat as `,' if have ldi_ldi form.  */
-         if (insn->parallel)
+         if (tinsn->parallel)
            {
              if (--num_operands < 0)
                break;          /* Too few operands.  */
@@ -2343,62 +2337,62 @@ tic4x_operands_match (tic4x_inst_t *inst, tic4x_insn_t *insn, int check)
 }
 
 static void
-tic4x_insn_check (tic4x_insn_t *insn)
+tic4x_insn_check (tic4x_insn_t *tinsn)
 {
-  
-  if (!strcmp(insn->name, "lda"))
+
+  if (!strcmp (tinsn->name, "lda"))
     {
-      if (insn->num_operands < 2 || insn->num_operands > 2)
+      if (tinsn->num_operands < 2 || tinsn->num_operands > 2)
         as_fatal ("Illegal internal LDA insn definition");
 
-      if ( insn->operands[0].mode == M_REGISTER
-           && insn->operands[1].mode == M_REGISTER
-           && insn->operands[0].expr.X_add_number == insn->operands[1].expr.X_add_number )
+      if (tinsn->operands[0].mode == M_REGISTER
+         && tinsn->operands[1].mode == M_REGISTER
+         && tinsn->operands[0].expr.X_add_number == tinsn->operands[1].expr.X_add_number )
         as_bad (_("Source and destination register should not be equal"));
     }
-  else if( !strcmp(insn->name, "ldi_ldi")
-           || !strcmp(insn->name, "ldi1_ldi2")
-           || !strcmp(insn->name, "ldi2_ldi1")
-           || !strcmp(insn->name, "ldf_ldf")
-           || !strcmp(insn->name, "ldf1_ldf2")
-           || !strcmp(insn->name, "ldf2_ldf1") )
+  else if (!strcmp (tinsn->name, "ldi_ldi")
+           || !strcmp (tinsn->name, "ldi1_ldi2")
+           || !strcmp (tinsn->name, "ldi2_ldi1")
+           || !strcmp (tinsn->name, "ldf_ldf")
+           || !strcmp (tinsn->name, "ldf1_ldf2")
+           || !strcmp (tinsn->name, "ldf2_ldf1") )
     {
-      if ( insn->num_operands < 4 && insn->num_operands > 5 )
-        as_fatal ("Illegal internal %s insn definition", insn->name);
-      
-      if ( insn->operands[1].mode == M_REGISTER
-           && insn->operands[insn->num_operands-1].mode == M_REGISTER
-           && insn->operands[1].expr.X_add_number == insn->operands[insn->num_operands-1].expr.X_add_number )
+      if (tinsn->num_operands < 4 || tinsn->num_operands > 5)
+        as_fatal ("Illegal internal %s insn definition", tinsn->name);
+
+      if (tinsn->operands[1].mode == M_REGISTER
+         && tinsn->operands[tinsn->num_operands-1].mode == M_REGISTER
+         && tinsn->operands[1].expr.X_add_number == tinsn->operands[tinsn->num_operands-1].expr.X_add_number )
         as_warn (_("Equal parallell destination registers, one result will be discarded"));
     }
 }
 
-static void 
-tic4x_insn_output (tic4x_insn_t *insn)
+static void
+tic4x_insn_output (tic4x_insn_t *tinsn)
 {
   char *dst;
 
   /* Grab another fragment for opcode.  */
-  dst = frag_more (insn->nchars);
+  dst = frag_more (tinsn->nchars);
 
   /* Put out opcode word as a series of bytes in little endian order.  */
-  md_number_to_chars (dst, insn->opcode, insn->nchars);
+  md_number_to_chars (dst, tinsn->opcode, tinsn->nchars);
 
   /* Put out the symbol-dependent stuff.  */
-  if (insn->reloc != NO_RELOC)
+  if (tinsn->reloc != NO_RELOC)
     {
       /* Where is the offset into the fragment for this instruction.  */
       fix_new_exp (frag_now,
                   dst - frag_now->fr_literal,  /* where */
-                  insn->nchars,        /* size */
-                  &insn->exp,
-                  insn->pcrel,
-                  insn->reloc);
+                  tinsn->nchars,       /* size */
+                  &tinsn->exp,
+                  tinsn->pcrel,
+                  tinsn->reloc);
     }
 }
 
 /* Parse the operands.  */
-static int 
+static int
 tic4x_operands_parse (char *s, tic4x_operand_t *operands, int num_operands)
 {
   if (!*s)
@@ -2419,13 +2413,14 @@ tic4x_operands_parse (char *s, tic4x_operand_t *operands, int num_operands)
 /* Assemble a single instruction.  Its label has already been handled
    by the generic front end.  We just parse mnemonic and operands, and
    produce the bytes of data and relocation.  */
-void 
+void
 md_assemble (char *str)
 {
   int ok = 0;
   char *s;
   int i;
   int parsed = 0;
+  size_t len;
   tic4x_inst_t *inst;          /* Instruction template.  */
   tic4x_inst_t *first_inst;
 
@@ -2435,7 +2430,7 @@ md_assemble (char *str)
       s = str;
       while (*s && *s != '|')
         s++;
-      
+
       if (*s && s[1]=='|')
         {
           if(insn->parallel)
@@ -2445,7 +2440,7 @@ md_assemble (char *str)
               insn->in_use = 0;
               return;
             }
-          
+
           /* Lets take care of the first part of the parallel insn */
           *s++ = 0;
           md_assemble(str);
@@ -2454,7 +2449,7 @@ md_assemble (char *str)
           /* .. and let the second run though here */
         }
     }
-  
+
   if (str && insn->parallel)
     {
       /* Find mnemonic (second part of parallel instruction).  */
@@ -2464,8 +2459,8 @@ md_assemble (char *str)
        s++;
       if (*s)                  /* Null terminate for hash_find.  */
        *s++ = '\0';            /* and skip past null.  */
-      strcat (insn->name, "_");
-      strncat (insn->name, str, TIC4X_NAME_MAX - strlen (insn->name));
+      len = strlen (insn->name);
+      snprintf (insn->name + len, TIC4X_NAME_MAX - len, "_%s", str);
 
       insn->operands[insn->num_operands++].mode = M_PARALLEL;
 
@@ -2527,7 +2522,8 @@ md_assemble (char *str)
        s++;
       if (*s)                  /* Null terminate for hash_find.  */
        *s++ = '\0';            /* and skip past null.  */
-      strncpy (insn->name, str, TIC4X_NAME_MAX - 3);
+      strncpy (insn->name, str, TIC4X_NAME_MAX - 1);
+      insn->name[TIC4X_NAME_MAX - 1] = '\0';
 
       if ((i = tic4x_operands_parse (s, insn->operands, 0)) < 0)
        {
@@ -2629,7 +2625,7 @@ md_atof (int type, char *litP, int *sizeP)
   return NULL;
 }
 
-void 
+void
 md_apply_fix (fixS *fixP, valueT *value, segT seg ATTRIBUTE_UNUSED)
 {
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
@@ -2673,7 +2669,7 @@ md_apply_fix (fixS *fixP, valueT *value, segT seg ATTRIBUTE_UNUSED)
 }
 
 /* Should never be called for tic4x.  */
-void 
+void
 md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
                 segT sec ATTRIBUTE_UNUSED,
                 fragS *fragP ATTRIBUTE_UNUSED)
@@ -2742,7 +2738,7 @@ md_parse_option (int c, char *arg)
       tic4x_reg_args = 0;
       break;
 
-    case 'r':                  
+    case 'r':
       as_warn (_("Option -r is depreciated, please use -mregparm"));
     case OPTION_REGPARM:        /* register args */
       tic4x_reg_args = 1;
@@ -2801,7 +2797,7 @@ md_show_usage (FILE *stream)
 /* This is called when a line is unrecognized.  This is used to handle
    definitions of TI C3x tools style local labels $n where n is a single
    decimal digit.  */
-int 
+int
 tic4x_unrecognized_line (int c)
 {
   int lab;
@@ -2878,7 +2874,7 @@ md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
   return size;                 /* Byte (i.e., 32-bit) alignment is fine?  */
 }
 
-static int 
+static int
 tic4x_pc_offset (unsigned int op)
 {
   /* Determine the PC offset for a C[34]x instruction.
@@ -2955,39 +2951,41 @@ md_pcrel_from (fixS *fixP)
 
 /* Fill the alignment area with NOP's on .text, unless fill-data
    was specified. */
-int 
-tic4x_do_align (int alignment ATTRIBUTE_UNUSED,
-               const char *fill ATTRIBUTE_UNUSED,
-               int len ATTRIBUTE_UNUSED,
-               int max ATTRIBUTE_UNUSED)
+int
+tic4x_do_align (int alignment,
+               const char *fill,
+               int len,
+               int max)
 {
-  unsigned long nop = TIC_NOP_OPCODE;
-
   /* Because we are talking lwords, not bytes, adjust alignment to do words */
   alignment += 2;
-  
+
   if (alignment != 0 && !need_pass_2)
     {
       if (fill == NULL)
         {
-          /*if (subseg_text_p (now_seg))*/  /* FIXME: doesn't work for .text for some reason */
-          frag_align_pattern( alignment, (const char *)&nop, sizeof(nop), max);
-          return 1;
-          /*else
-            frag_align (alignment, 0, max);*/
+          if (subseg_text_p (now_seg))
+           {
+             char nop[4];
+
+             md_number_to_chars (nop, TIC_NOP_OPCODE, 4);
+             frag_align_pattern (alignment, nop, sizeof (nop), max);
+           }
+          else
+            frag_align (alignment, 0, max);
        }
       else if (len <= 1)
        frag_align (alignment, *fill, max);
       else
        frag_align_pattern (alignment, fill, len, max);
     }
-  
+
   /* Return 1 to skip the default alignment function */
   return 1;
 }
 
 /* Look for and remove parallel instruction operator ||.  */
-void 
+void
 tic4x_start_line (void)
 {
   char *s = input_line_pointer;
This page took 0.038445 seconds and 4 git commands to generate.