* config/tc-hppa.c (strict): Don't initialize. Update comment.
[binutils-gdb.git] / gas / config / tc-hppa.c
index 398e7462cc8759a63e3af480074a128e0e2b7b7f..7615eb068d4147c53a44d3da69ad8402966f9559 100644 (file)
@@ -1,6 +1,6 @@
 /* tc-hppa.c -- Assemble for the PA
    Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -771,11 +771,15 @@ static label_symbol_struct *label_symbols_rootp = NULL;
 /* Holds the last field selector.  */
 static int hppa_field_selector;
 
-/* Nonzero when strict syntax checking is enabled.  Zero otherwise.
+/* Nonzero when strict matching is enabled.  Zero otherwise.
 
-   Each opcode in the table has a flag which indicates whether or not
-   strict syntax checking should be enabled for that instruction.  */
-static int strict = 0;
+   Each opcode in the table has a flag which indicates whether or
+   not strict matching should be enabled for that instruction.
+
+   Mainly, strict causes errors to be ignored when a match failure
+   occurs.  However, it also affects the parsing of register fields
+   by pa_parse_number.  */
+static int strict;
 
 /* pa_parse_number returns values in `pa_number'.  Mostly
    pa_parse_number is used to return a register number, with floating
@@ -1175,7 +1179,7 @@ static struct default_space_dict pa_def_spaces[] =
       } \
   }
 
-/* Variant of CHECK_FIELD for use in md_apply_fix3 and other places where
+/* Variant of CHECK_FIELD for use in md_apply_fix and other places where
    the current file and line number are not valid.  */
 
 #define CHECK_FIELD_WHERE(FIELD, HIGH, LOW, FILENAME, LINE) \
@@ -1287,6 +1291,10 @@ pa_define_label (symbol)
 
       label_symbols_rootp = label_chain;
     }
+
+#ifdef OBJ_ELF
+  dwarf2_emit_label (symbol);
+#endif
 }
 
 /* Removes a label definition for the current space.
@@ -1641,7 +1649,7 @@ pa_ip (str)
 
       the_insn.reloc = R_HPPA_NONE;
 
-      if (insn->arch >= 20
+      if (insn->arch >= pa20
          && bfd_get_mach (stdoutput) < insn->arch)
        goto failed;
 
@@ -1838,9 +1846,9 @@ pa_ip (str)
                        else if ((strncasecmp (s, "s ", 2) == 0)
                                 || (strncasecmp (s, "s,", 2) == 0))
                          uu = 1;
-                       /* When in strict mode this is a match failure.  */
                        else if (strict)
                          {
+                           /* This is a match failure.  */
                            s--;
                            break;
                          }
@@ -1866,28 +1874,25 @@ pa_ip (str)
                    int m = 0;
                    if (*s == ',')
                      {
-                       int found = 0;
                        s++;
                        if (strncasecmp (s, "ma", 2) == 0)
                          {
                            a = 0;
                            m = 1;
-                           found = 1;
+                           s += 2;
                          }
                        else if (strncasecmp (s, "mb", 2) == 0)
                          {
                            a = 1;
                            m = 1;
-                           found = 1;
+                           s += 2;
                          }
-
-                       /* When in strict mode, pass through for cache op.  */
-                       if (!found && strict)
+                       else if (strict)
+                         /* This is a match failure.  */
                          s--;
                        else
                          {
-                           if (!found)
-                             as_bad (_("Invalid Short Load/Store Completer."));
+                           as_bad (_("Invalid Short Load/Store Completer."));
                            s += 2;
                          }
                      }
@@ -1940,7 +1945,7 @@ pa_ip (str)
                          a = 0;
                        else if (strncasecmp (s, "e", 1) == 0)
                          a = 1;
-                       /* When in strict mode this is a match failure.  */
+                       /* In strict mode, this is a match failure.  */
                        else if (strict)
                          {
                            s--;
@@ -3064,6 +3069,8 @@ pa_ip (str)
 
            /* Handle 14 bit immediate, shifted left three times.  */
            case '#':
+             if (bfd_get_mach (stdoutput) != pa20)
+               break;
              the_insn.field_selector = pa_chk_field_selector (&s);
              get_expression (s);
              s = expr_end;
@@ -3954,10 +3961,11 @@ pa_ip (str)
         then set a new architecture.  This automatic promotion crud is
         for compatibility with HP's old assemblers only.  */
       if (match == TRUE
-         && bfd_get_mach (stdoutput) < insn->arch)
+         && bfd_get_mach (stdoutput) < insn->arch
+         && !bfd_set_arch_mach (stdoutput, bfd_arch_hppa, insn->arch))
        {
-         if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, insn->arch))
-           as_warn (_("could not update architecture and machine"));
+         as_warn (_("could not update architecture and machine"));
+         match = FALSE;
        }
 
  failed:
@@ -4422,7 +4430,7 @@ md_undefined_symbol (name)
 /* Apply a fixup to an instruction.  */
 
 void
-md_apply_fix3 (fixP, valP, seg)
+md_apply_fix (fixP, valP, seg)
      fixS *fixP;
      valueT *valP;
      segT seg ATTRIBUTE_UNUSED;
@@ -5937,10 +5945,7 @@ static void
 pa_block (z)
      int z ATTRIBUTE_UNUSED;
 {
-  char *p;
-  long int temp_fill;
   unsigned int temp_size;
-  unsigned int i;
 
 #ifdef OBJ_SOM
   /* We must have a valid space and subspace.  */
@@ -5954,21 +5959,11 @@ pa_block (z)
       as_bad (_("Argument to .BLOCK/.BLOCKZ must be between 0 and 0x3fffffff"));
       temp_size = 0;
     }
-
-  /* Always fill with zeros, that's what the HP assembler does.  */
-  temp_fill = 0;
-
-  p = frag_var (rs_fill, (int) temp_size, (int) temp_size,
-               (relax_substateT) 0, (symbolS *) 0, (offsetT) 1, NULL);
-  memset (p, 0, temp_size);
-
-  /* Convert 2 bytes at a time.  */
-
-  for (i = 0; i < temp_size; i += 2)
+  else
     {
-      md_number_to_chars (p + i,
-                         (valueT) temp_fill,
-                         (int) ((temp_size - i) > 2 ? 2 : (temp_size - i)));
+      /* Always fill with zeros, that's what the HP assembler does.  */
+      char *p = frag_var (rs_fill, 1, 1, 0, NULL, temp_size, NULL);
+      *p = 0;
     }
 
   pa_undefine_label ();