[ARC] Rename "class" named attributes.
[deliverable/binutils-gdb.git] / gas / config / tc-arc.c
index 17e0b9aa2298aaafff7f7a94bed0af4c178728ae..7f8ca26fe79e0407508071d8d97223a3300155db 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.  */
@@ -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"));
@@ -897,6 +898,10 @@ arc_option (int ignore ATTRIBUTE_UNUSED)
        {
          md_parse_option (OPTION_MCPU, "archs");
        }
+      else if (!strcmp ("NPS400", cpu))
+       {
+         md_parse_option (OPTION_MCPU, "nps400");
+       }
       else
        as_fatal (_("could not find the architecture"));
 
@@ -1034,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;
@@ -1044,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;
@@ -1055,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.  */
@@ -1160,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;
@@ -1176,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;
@@ -1685,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);
 
@@ -1839,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)
@@ -1876,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?  */
@@ -2256,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;
@@ -2500,7 +2505,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);
@@ -2933,8 +2939,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;
 
@@ -3016,7 +3022,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);
 
@@ -3607,7 +3614,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);
@@ -3624,7 +3631,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);
@@ -4056,7 +4063,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;
            }
@@ -4096,7 +4103,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;
            }
@@ -4110,7 +4117,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;
                }
@@ -4229,13 +4236,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;
@@ -4465,7 +4474,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;
@@ -4482,8 +4491,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.027342 seconds and 4 git commands to generate.