Rework the R_NEG support on both gas and ld for the PowerPC AIX targets, in order...
[binutils-gdb.git] / gas / config / tc-vax.c
index 89fc6fc5e2637f3a9b2047b0550eff611f836f30..f439f1b52dcb83f7d5b6c51e253ac6633ab96ad2 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-vax.c - vax-specific -
-   Copyright (C) 1987-2016 Free Software Foundation, Inc.
+   Copyright (C) 1987-2021 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -127,7 +127,7 @@ int flag_want_pic;          /* -k */
  bbsc          e4
  bbcc          e5
  Always, you complement 0th bit to reverse condition.
- Always, 1-byte opcde, longword-address, byte-address, 1-byte-displacement
+ Always, 1-byte opcode, longword-address, byte-address, 1-byte-displacement
 
  2c.   J<cond> where cond tests low-order memory bit
  length of byte,word,long.
@@ -188,7 +188,7 @@ int flag_want_pic;          /* -k */
 #define BB (1+-128)
 #define WF (2+ 32767)
 #define WB (2+-32768)
-/* Dont need LF, LB because they always reach. [They are coded as 0.]  */
+/* Don't need LF, LB because they always reach. [They are coded as 0.]  */
 
 #define C(a,b) ENCODE_RELAX(a,b)
 /* This macro has no side-effects.  */
@@ -236,7 +236,7 @@ const relax_typeS md_relax_table[] =
 #undef WB
 
 void float_cons (int);
-int flonum_gen2vax (char, FLONUM_TYPE *, LITTLENUM_TYPE *);
+int flonum_gen2vax (int, FLONUM_TYPE *, LITTLENUM_TYPE *);
 
 const pseudo_typeS md_pseudo_table[] =
 {
@@ -381,7 +381,7 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
          int old_fr_fix;
 
          old_fr_fix = fragP->fr_fix;
-         p = fragP->fr_literal + old_fr_fix;
+         p = &fragP->fr_literal[0] + old_fr_fix;
 #ifdef OBJ_ELF
          /* If this is to an undefined symbol, then if it's an indirect
             reference indicate that is can mutated into a GLOB_DAT or
@@ -525,7 +525,7 @@ md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
 
   know (fragP->fr_type == rs_machine_dependent);
   where = fragP->fr_fix;
-  addressP = fragP->fr_literal + where;
+  addressP = &fragP->fr_literal[0] + where;
   opcodeP = fragP->fr_opcode;
   symbolP = fragP->fr_symbol;
   know (symbolP);
@@ -736,7 +736,7 @@ md_ri_to_chars (char *the_bytes, struct reloc_info_generic ri)
        source file, and changed the makefile.  */
 
 /* Handle of the OPCODE hash table.  */
-static struct hash_control *op_hash;
+static htab_t op_hash;
 
 /* In: 1 character, from "bdfghloqpw" being the data-type of an operand
        of a vax instruction.
@@ -950,29 +950,28 @@ vip_op_defaults (const char *immediate, const char *indirect, const char *disple
    instruction table.
    You must nominate metacharacters for eg DEC's "#", "@", "^".  */
 
-static const char *
+static void
 vip_begin (int synthetic_too,          /* 1 means include jXXX op-codes.  */
           const char *immediate,
           const char *indirect,
           const char *displen)
 {
   const struct vot *vP;                /* scan votstrs */
-  const char *retval = 0;      /* error text */
 
-  op_hash = hash_new ();
+  op_hash = str_htab_create ();
 
-  for (vP = votstrs; *vP->vot_name && !retval; vP++)
-    retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
+  for (vP = votstrs; *vP->vot_name; vP++)
+    if (str_hash_insert (op_hash, vP->vot_name, &vP->vot_detail, 0) != NULL)
+      as_fatal (_("duplicate %s"), vP->vot_name);
 
   if (synthetic_too)
-    for (vP = synthetic_votstrs; *vP->vot_name && !retval; vP++)
-      retval = hash_insert (op_hash, vP->vot_name, (void *) &vP->vot_detail);
+    for (vP = synthetic_votstrs; *vP->vot_name; vP++)
+      if (str_hash_insert (op_hash, vP->vot_name, &vP->vot_detail, 0) != NULL)
+       as_fatal (_("duplicate %s"), vP->vot_name);
 
 #ifndef CONST_TABLE
   vip_op_defaults (immediate, indirect, displen);
 #endif
-
-  return retval;
 }
 
 /* Take 3 char.s, the last of which may be `\0` (non-existent)
@@ -1796,8 +1795,10 @@ vip_op (char *optext, struct vop *vopP)
        {
        case 'l':
          mode += 2;
+         /* Fall through.  */
        case 'w':
          mode += 2;
+         /* Fall through.  */
        case ' ':       /* Assumed B^ until our caller changes it.  */
        case 'b':
          break;
@@ -1885,7 +1886,7 @@ vip (struct vit *vitP,            /* We build an exploded instruction here.  */
       /* Here with instring pointing to what better be an op-name, and p
          pointing to character just past that.
          We trust instring points to an op-name, with no whitespace.  */
-      vwP = (struct vot_wot *) hash_find (op_hash, instring);
+      vwP = (struct vot_wot *) str_hash_find (op_hash, instring);
       /* Restore char after op-code.  */
       *p = c;
       if (vwP == 0)
@@ -1984,8 +1985,7 @@ main (void)
   printf ("enter displen symbols   eg enter ^   ");
   gets (my_displen);
 
-  if (p = vip_begin (mysynth, my_immediate, my_indirect, my_displen))
-    error ("vip_begin=%s", p);
+  vip_begin (mysynth, my_immediate, my_indirect, my_displen)
 
   printf ("An empty input line will quit you from the vax instruction parser\n");
   for (;;)
@@ -2111,7 +2111,7 @@ main (void)
 
        default:
          my_operand_length = 2;
-         printf ("I dn't understand access width %c\n", mywidth);
+         printf ("I don't understand access width %c\n", mywidth);
          break;
        }
       printf ("VAX assembler instruction operand: ");
@@ -2388,8 +2388,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #undef F
 #undef MAP
 
-  reloc = xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr = 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;
 #ifndef OBJ_ELF
@@ -3127,9 +3127,9 @@ md_assemble (char *instruction_string)
                          || operandP->vop_access == 'a')
                        {
                          if (operandP->vop_access == 'v')
-                           as_warn (_("Invalid operand:  immediate value used as base address."));
+                           as_warn (_("Invalid operand: immediate value used as base address."));
                          else
-                           as_warn (_("Invalid operand:  immediate value used as address."));
+                           as_warn (_("Invalid operand: immediate value used as address."));
                          /* gcc 2.6.3 is known to generate these in at least
                             one case.  */
                        }
@@ -3254,12 +3254,10 @@ md_assemble (char *instruction_string)
 void
 md_begin (void)
 {
-  const char *errtxt;
   FLONUM_TYPE *fP;
   int i;
 
-  if ((errtxt = vip_begin (1, "$", "*", "`")) != 0)
-    as_fatal (_("VIP_BEGIN error:%s"), errtxt);
+  vip_begin (1, "$", "*", "`");
 
   for (i = 0, fP = float_operand;
        fP < float_operand + VIT_MAX_OPERANDS;
@@ -3281,7 +3279,7 @@ vax_cons (expressionS *exp, int size)
   save = input_line_pointer;
   if (input_line_pointer[0] == '%')
     {
-      if (strncmp (input_line_pointer + 1, "pcrel", 5) == 0)
+      if (startswith (input_line_pointer + 1, "pcrel"))
        {
          input_line_pointer += 6;
          vax_cons_special_reloc = "pcrel";
@@ -3403,7 +3401,7 @@ vax_cons_fix_new (fragS *frag, int where, unsigned int nbytes, expressionS *exp,
   fix_new_exp (frag, where, (int) nbytes, exp, 0, r);
 }
 
-char *
+const char *
 md_atof (int type, char * litP, int * sizeP)
 {
   return vax_md_atof (type, litP, sizeP);