Add dependencies to configure rule
[deliverable/binutils-gdb.git] / gas / config / tc-arc.c
index 169b05c348f5f1a00bdc84bdcbaaed5de7c9a1eb..7eb577f5e5b0d731d341c28484dd14be6c3d1867 100644 (file)
@@ -98,8 +98,8 @@ enum arc_rlx_types
 #define is_spfp_p(op)           (((sc) == SPX))
 #define is_dpfp_p(op)           (((sc) == DPX))
 #define is_fpuda_p(op)          (((sc) == DPA))
-#define is_br_jmp_insn_p(op)    (((op)->class == BRANCH || (op)->class == JUMP))
-#define is_kernel_insn_p(op)    (((op)->class == KERNEL))
+#define is_br_jmp_insn_p(op)    (((op)->insn_class == BRANCH || (op)->insn_class == JUMP))
+#define is_kernel_insn_p(op)    (((op)->insn_class == KERNEL))
 
 /* Generic assembler global variables which must be defined by all
    targets.  */
@@ -323,7 +323,7 @@ typedef struct
 {
   const char *name;
   int  len;
-  int  class;
+  int  attr_class;
 } attributes_t;
 
 static const attributes_t suffixclass[] =
@@ -337,7 +337,9 @@ static const attributes_t suffixclass[] =
 static const attributes_t syntaxclass[] =
 {
   { "SYNTAX_3OP", 10, ARC_SYNTAX_3OP },
-  { "SYNTAX_2OP", 10, ARC_SYNTAX_2OP }
+  { "SYNTAX_2OP", 10, ARC_SYNTAX_2OP },
+  { "SYNTAX_1OP", 10, ARC_SYNTAX_1OP },
+  { "SYNTAX_NOP", 10, ARC_SYNTAX_NOP }
 };
 
 /* Extension instruction syntax classes modifiers.  */
@@ -426,7 +428,7 @@ static const struct cpu_type
   { "nps400", ARC_OPCODE_ARC700 | ARC_OPCODE_NPS400, bfd_mach_arc_nps400,
     E_ARC_MACH_NPS400,  0x00},
   { "arcem",  ARC_OPCODE_ARCv2EM, bfd_mach_arc_arcv2,
-    EF_ARC_CPU_ARCV2EM, ARC_CD},
+    EF_ARC_CPU_ARCV2EM, 0x00},
   { "archs",  ARC_OPCODE_ARCv2HS, bfd_mach_arc_arcv2,
     EF_ARC_CPU_ARCV2HS, ARC_CD},
   { 0, 0, 0, 0, 0 }
@@ -672,8 +674,8 @@ arc_opcode_hash_entry_iterator_next (const struct arc_opcode_hash_entry *entry,
       const char *old_name = iter->opcode->name;
 
       iter->opcode++;
-      if (iter->opcode->name
-         && (strcmp (old_name, iter->opcode->name) != 0))
+      if (iter->opcode->name == NULL
+         || strcmp (old_name, iter->opcode->name) != 0)
        {
          iter->index++;
          if (iter->index == entry->count)
@@ -698,7 +700,7 @@ arc_insert_opcode (const struct arc_opcode *opcode)
   entry = hash_find (arc_opcode_hash, name);
   if (entry == NULL)
     {
-      entry = xmalloc (sizeof (*entry));
+      entry = XNEW (struct arc_opcode_hash_entry);
       entry->count = 0;
       entry->opcode = NULL;
 
@@ -708,9 +710,8 @@ arc_insert_opcode (const struct arc_opcode *opcode)
                  name, retval);
     }
 
-  entry->opcode = xrealloc (entry->opcode,
-                           sizeof (const struct arc_opcode *)
-                           * (entry->count + 1));
+  entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode,
+                             entry->count + 1);
 
   if (entry->opcode == NULL)
     as_fatal (_("Virtual memory exhausted"));
@@ -1038,7 +1039,7 @@ tokenize_arguments (char *str,
        case ']':
          ++input_line_pointer;
          --brk_lvl;
-         if (!saw_arg)
+         if (!saw_arg || num_args == ntok)
            goto err;
          tok->X_op = O_bracket;
          ++tok;
@@ -1048,7 +1049,7 @@ tokenize_arguments (char *str,
        case '{':
        case '[':
          input_line_pointer++;
-         if (brk_lvl)
+         if (brk_lvl || num_args == ntok)
            goto err;
          ++brk_lvl;
          tok->X_op = O_bracket;
@@ -1059,7 +1060,7 @@ tokenize_arguments (char *str,
        case '@':
          /* We have labels, function names and relocations, all
             starting with @ symbol.  Sort them out.  */
-         if (saw_arg && !saw_comma)
+         if ((saw_arg && !saw_comma) || num_args == ntok)
            goto err;
 
          /* Parse @label.  */
@@ -1164,7 +1165,7 @@ tokenize_arguments (char *str,
          /* Fall through.  */
        default:
 
-         if (saw_arg && !saw_comma)
+         if ((saw_arg && !saw_comma) || num_args == ntok)
            goto err;
 
          tok->X_op = O_absent;
@@ -1180,7 +1181,9 @@ tokenize_arguments (char *str,
        normalsymbol:
          debug_exp (tok);
 
-         if (tok->X_op == O_illegal || tok->X_op == O_absent)
+         if (tok->X_op == O_illegal
+              || tok->X_op == O_absent
+              || num_args == ntok)
            goto err;
 
          saw_comma = FALSE;
@@ -1689,7 +1692,7 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry,
                    const char *p;
                    const struct arc_aux_reg *auxr;
 
-                   if (opcode->class != AUXREG)
+                   if (opcode->insn_class != AUXREG)
                      goto de_fault;
                    p = S_GET_NAME (tok[tokidx].X_add_symbol);
 
@@ -1843,7 +1846,7 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry,
 
          /* Check for extension conditional codes.  */
          if (ext_condcode.arc_ext_condcode
-             && cl_flags->class & F_CLASS_EXTEND)
+             && cl_flags->flag_class & F_CLASS_EXTEND)
            {
              struct arc_flag_operand *pf = ext_condcode.arc_ext_condcode;
              while (pf->name)
@@ -1880,16 +1883,16 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry,
                      if (pflag->flgp != NULL)
                        goto match_failed;
                      cl_matches++;
-                     pflag->flgp = (struct arc_flag_operand *) flg_operand;
+                     pflag->flgp = flg_operand;
                      lnflg--;
                      break; /* goto next flag class and parsed flag.  */
                    }
                }
            }
 
-         if ((cl_flags->class & F_CLASS_REQUIRED) && cl_matches == 0)
+         if ((cl_flags->flag_class & F_CLASS_REQUIRED) && cl_matches == 0)
            goto match_failed;
-         if ((cl_flags->class & F_CLASS_OPTIONAL) && cl_matches > 1)
+         if ((cl_flags->flag_class & F_CLASS_OPTIONAL) && cl_matches > 1)
            goto match_failed;
        }
       /* Did I check all the parsed flags?  */
@@ -2260,9 +2263,7 @@ md_assemble (char *str)
 
   /* Split off the opcode.  */
   opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_0123468");
-  opname = xmalloc (opnamelen + 1);
-  memcpy (opname, str, opnamelen);
-  opname[opnamelen] = '\0';
+  opname = xmemdup0 (str, opnamelen);
 
   /* Signalize we are assmbling the instructions.  */
   assembling_insn = TRUE;
@@ -2380,6 +2381,32 @@ md_begin (void)
   declare_register ("ilink2", 30);
   declare_register ("blink", 31);
 
+  /* XY memory registers.  */
+  declare_register ("x0_u0", 32);
+  declare_register ("x0_u1", 33);
+  declare_register ("x1_u0", 34);
+  declare_register ("x1_u1", 35);
+  declare_register ("x2_u0", 36);
+  declare_register ("x2_u1", 37);
+  declare_register ("x3_u0", 38);
+  declare_register ("x3_u1", 39);
+  declare_register ("y0_u0", 40);
+  declare_register ("y0_u1", 41);
+  declare_register ("y1_u0", 42);
+  declare_register ("y1_u1", 43);
+  declare_register ("y2_u0", 44);
+  declare_register ("y2_u1", 45);
+  declare_register ("y3_u0", 46);
+  declare_register ("y3_u1", 47);
+  declare_register ("x0_nu", 48);
+  declare_register ("x1_nu", 49);
+  declare_register ("x2_nu", 50);
+  declare_register ("x3_nu", 51);
+  declare_register ("y0_nu", 52);
+  declare_register ("y1_nu", 53);
+  declare_register ("y2_nu", 54);
+  declare_register ("y3_nu", 55);
+
   declare_register ("mlo", 57);
   declare_register ("mmid", 58);
   declare_register ("mhi", 59);
@@ -2504,7 +2531,8 @@ md_pcrel_from_section (fixS *fixP,
        }
     }
 
-  pr_debug ("pcrel from %x + %lx = %x, symbol: %s (%x)\n",
+  pr_debug ("pcrel from %"BFD_VMA_FMT"x + %lx = %"BFD_VMA_FMT"x, "
+           "symbol: %s (%"BFD_VMA_FMT"x)\n",
            fixP->fx_frag->fr_address, fixP->fx_where, base,
            fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "(null)",
            fixP->fx_addsy ? S_GET_VALUE (fixP->fx_addsy) : 0);
@@ -2937,8 +2965,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = (arelent *) xmalloc (sizeof (* reloc));
-  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;
 
@@ -3020,7 +3048,8 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
   dest = fragP->fr_literal + fix;
   table_entry = TC_GENERIC_RELAX_TABLE + fragP->fr_subtype;
 
-  pr_debug ("%s:%d: md_convert_frag, subtype: %d, fix: %d, var: %d\n",
+  pr_debug ("%s:%d: md_convert_frag, subtype: %d, fix: %d, "
+           "var: %"BFD_VMA_FMT"d\n",
            fragP->fr_file, fragP->fr_line,
            fragP->fr_subtype, fix, fragP->fr_var);
 
@@ -3611,7 +3640,7 @@ assemble_insn (const struct arc_opcode *opcode,
          switch (t->X_md)
            {
            case O_plt:
-             if (opcode->class == JUMP)
+             if (opcode->insn_class == JUMP)
                as_bad_where (frag_now->fr_file, frag_now->fr_line,
                              _("Unable to use @plt relocatio for insn %s"),
                              opcode->name);
@@ -3628,7 +3657,7 @@ assemble_insn (const struct arc_opcode *opcode,
              break;
            case O_pcl:
              reloc = ARC_RELOC_TABLE (t->X_md)->reloc;
-             if (ARC_SHORT (opcode->mask) || opcode->class == JUMP)
+             if (ARC_SHORT (opcode->mask) || opcode->insn_class == JUMP)
                as_bad_where (frag_now->fr_file, frag_now->fr_line,
                              _("Unable to use @pcl relocation for insn %s"),
                              opcode->name);
@@ -4060,7 +4089,7 @@ tokenize_extinsn (extInstruction_t *einsn)
          if (!strncmp (suffixclass[i].name, input_line_pointer,
                        suffixclass[i].len))
            {
-             suffix_class |= suffixclass[i].class;
+             suffix_class |= suffixclass[i].attr_class;
              input_line_pointer += suffixclass[i].len;
              break;
            }
@@ -4100,7 +4129,7 @@ tokenize_extinsn (extInstruction_t *einsn)
                        input_line_pointer,
                        syntaxclassmod[i].len))
            {
-             syntax_class_modifiers |= syntaxclassmod[i].class;
+             syntax_class_modifiers |= syntaxclassmod[i].attr_class;
              input_line_pointer += syntaxclassmod[i].len;
              break;
            }
@@ -4114,7 +4143,7 @@ tokenize_extinsn (extInstruction_t *einsn)
                            input_line_pointer,
                            syntaxclass[i].len))
                {
-                 syntax_class |= syntaxclass[i].class;
+                 syntax_class |= syntaxclass[i].attr_class;
                  input_line_pointer += syntaxclass[i].len;
                  break;
                }
@@ -4233,13 +4262,15 @@ arc_extinsn (int ignore ATTRIBUTE_UNUSED)
       && (einsn.major != 5) && (einsn.major != 9))
     as_fatal (_("minor opcode not in range [0x00 - 0x3f]"));
 
-  switch (einsn.syntax & (ARC_SYNTAX_3OP | ARC_SYNTAX_2OP))
+  switch (einsn.syntax & ARC_SYNTAX_MASK)
     {
     case ARC_SYNTAX_3OP:
       if (einsn.modsyn & ARC_OP1_IMM_IMPLIED)
        as_fatal (_("Improper use of OP1_IMM_IMPLIED"));
       break;
     case ARC_SYNTAX_2OP:
+    case ARC_SYNTAX_1OP:
+    case ARC_SYNTAX_NOP:
       if (einsn.modsyn & ARC_OP1_MUST_BE_IMM)
        as_fatal (_("Improper use of OP1_MUST_BE_IMM"));
       break;
@@ -4469,7 +4500,7 @@ arc_extcorereg (int opertype)
       break;
     case EXT_AUX_REGISTER:
       /* Auxiliary register.  */
-      auxr = xmalloc (sizeof (struct arc_aux_reg));
+      auxr = XNEW (struct arc_aux_reg);
       auxr->name = ereg.name;
       auxr->cpu = arc_target;
       auxr->subclass = NONE;
@@ -4486,8 +4517,8 @@ arc_extcorereg (int opertype)
                ereg.number);
       ext_condcode.size ++;
       ext_condcode.arc_ext_condcode =
-       xrealloc (ext_condcode.arc_ext_condcode,
-                 (ext_condcode.size + 1) * sizeof (struct arc_flag_operand));
+       XRESIZEVEC (struct arc_flag_operand, ext_condcode.arc_ext_condcode,
+                   ext_condcode.size + 1);
       if (ext_condcode.arc_ext_condcode == NULL)
        as_fatal (_("Virtual memory exhausted"));
 
This page took 0.065609 seconds and 4 git commands to generate.