OSDN Git Service

2003-02-12 Phil Edwards <pme@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / genattrtab.c
index d3f77b0..0270945 100644 (file)
@@ -1,24 +1,24 @@
 /* Generate code from machine description to compute values of attributes.
    Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000 Free Software Foundation, Inc.
+   1999, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
 
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
 
 /* This program handles insn attributes and the DEFINE_DELAY and
    DEFINE_FUNCTION_UNIT definitions.
@@ -86,17 +86,24 @@ Boston, MA 02111-1307, USA.  */
    definitions (each would be accessed through a pointer).
 
    We use the flags in an RTX as follows:
-   `unchanging' (RTX_UNCHANGING_P): This rtx is fully simplified
+   `unchanging' (ATTR_IND_SIMPLIFIED_P): This rtx is fully simplified
       independent of the insn code.
-   `in_struct' (MEM_IN_STRUCT_P): This rtx is fully simplified
+   `in_struct' (ATTR_CURR_SIMPLIFIED_P): This rtx is fully simplified
       for the insn code currently being processed (see optimize_attrs).
-   `integrated' (RTX_INTEGRATED_P): This rtx is permanent and unique
+   `integrated' (ATTR_PERMANENT_P): This rtx is permanent and unique
       (see attr_rtx).
-   `volatil' (MEM_VOLATILE_P): During simplify_by_exploding the value of an
+   `volatil' (ATTR_EQ_ATTR_P): During simplify_by_exploding the value of an
       EQ_ATTR rtx is true if !volatil and false if volatil.  */
 
-#include "hconfig.h"
+#define ATTR_IND_SIMPLIFIED_P(RTX) (RTX_FLAG((RTX), unchanging))
+#define ATTR_CURR_SIMPLIFIED_P(RTX) (RTX_FLAG((RTX), in_struct))
+#define ATTR_PERMANENT_P(RTX) (RTX_FLAG((RTX), integrated))
+#define ATTR_EQ_ATTR_P(RTX) (RTX_FLAG((RTX), volatil))
+
+#include "bconfig.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "rtl.h"
 #include "ggc.h"
 #include "gensupport.h"
@@ -110,13 +117,12 @@ Boston, MA 02111-1307, USA.  */
 #include "obstack.h"
 #include "errors.h"
 
+#include "genattrtab.h"
+
 static struct obstack obstack1, obstack2;
 struct obstack *hash_obstack = &obstack1;
 struct obstack *temp_obstack = &obstack2;
 
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
 /* enough space to reserve for printing out ints */
 #define MAX_DIGITS (HOST_BITS_PER_INT * 3 / 10 + 3)
 
@@ -231,7 +237,7 @@ struct function_unit
   struct function_unit_op *ops;        /* Pointer to first operation type.  */
   int needs_conflict_function; /* Nonzero if a conflict function required.  */
   int needs_blockage_function; /* Nonzero if a blockage function required.  */
-  int needs_range_function;    /* Nonzero if blockage range function needed.*/
+  int needs_range_function;    /* Nonzero if blockage range function needed.  */
   rtx default_cost;            /* Conflict cost, if constant.  */
   struct range issue_delay;    /* Range of issue delay values.  */
   int max_blockage;            /* Maximum time an insn blocks the unit.  */
@@ -262,7 +268,7 @@ static struct function_unit *units;
 
    The algorithm relies on sharing EQ_ATTR nodes: if two nodes in an
    expression are the same, the will also have the same address.  We find
-   all the EQ_ATTR nodes by marking them MEM_VOLATILE_P.  This bit later
+   all the EQ_ATTR nodes by marking them ATTR_EQ_ATTR_P.  This bit later
    represents the value of an EQ_ATTR node, so once all nodes are marked,
    they are also given an initial value of FALSE.
 
@@ -304,6 +310,8 @@ static int have_annul_true, have_annul_false;
 static int num_units, num_unit_opclasses;
 static int num_insn_ents;
 
+int num_dfa_decls;
+
 /* Used as operand to `operate_exp':  */
 
 enum operator {PLUS_OP, MINUS_OP, POS_MINUS_OP, EQ_OP, OR_OP, ORX_OP, MAX_OP, MIN_OP, RANGE_OP};
@@ -344,7 +352,7 @@ int optimize = 0;
 /* Simplify an expression.  Only call the routine if there is something to
    simplify.  */
 #define SIMPLIFY_TEST_EXP(EXP,INSN_CODE,INSN_INDEX)    \
-  (RTX_UNCHANGING_P (EXP) || MEM_IN_STRUCT_P (EXP) ? (EXP)     \
+  (ATTR_IND_SIMPLIFIED_P (EXP) || ATTR_CURR_SIMPLIFIED_P (EXP) ? (EXP) \
    : simplify_test_exp (EXP, INSN_CODE, INSN_INDEX))
 
 /* Simplify (eq_attr ("alternative") ...)
@@ -365,10 +373,8 @@ rtx pic_offset_table_rtx;
 static void attr_hash_add_rtx  PARAMS ((int, rtx));
 static void attr_hash_add_string PARAMS ((int, char *));
 static rtx attr_rtx            PARAMS ((enum rtx_code, ...));
-static char *attr_printf       PARAMS ((int, const char *, ...))
-  ATTRIBUTE_PRINTF_2;
+static rtx attr_rtx_1          PARAMS ((enum rtx_code, va_list));
 static char *attr_string        PARAMS ((const char *, int));
-static rtx check_attr_test     PARAMS ((rtx, int, int));
 static rtx check_attr_value    PARAMS ((rtx, struct attr_desc *));
 static rtx convert_set_attr_alternative PARAMS ((rtx, struct insn_def *));
 static rtx convert_set_attr    PARAMS ((rtx, struct insn_def *));
@@ -386,7 +392,6 @@ static void expand_units    PARAMS ((void));
 static rtx simplify_knowing    PARAMS ((rtx, rtx));
 static rtx encode_units_mask   PARAMS ((rtx));
 static void fill_attr          PARAMS ((struct attr_desc *));
-/* dpx2 compiler chokes if we specify the arg types of the args.  */
 static rtx substitute_address  PARAMS ((rtx, rtx (*) (rtx), rtx (*) (rtx)));
 static void make_length_attrs  PARAMS ((void));
 static rtx identity_fn         PARAMS ((rtx));
@@ -417,6 +422,7 @@ static rtx evaluate_eq_attr PARAMS ((rtx, rtx, int, int));
 static rtx simplify_and_tree   PARAMS ((rtx, rtx *, int, int));
 static rtx simplify_or_tree    PARAMS ((rtx, rtx *, int, int));
 static rtx simplify_test_exp   PARAMS ((rtx, int, int));
+static rtx simplify_test_exp_in_temp PARAMS ((rtx, int, int));
 static void optimize_attrs     PARAMS ((void));
 static void gen_attr           PARAMS ((rtx, int));
 static int count_alternatives  PARAMS ((rtx));
@@ -448,18 +454,16 @@ static void write_complex_function PARAMS ((struct function_unit *, const char *
 static int write_expr_attr_cache PARAMS ((rtx, struct attr_desc *));
 static void write_toplevel_expr        PARAMS ((rtx));
 static void write_const_num_delay_slots PARAMS ((void));
-static int n_comma_elts                PARAMS ((const char *));
 static char *next_comma_elt    PARAMS ((const char **));
 static struct attr_desc *find_attr PARAMS ((const char *, int));
-static void make_internal_attr PARAMS ((const char *, rtx, int));
 static struct attr_value *find_most_used  PARAMS ((struct attr_desc *));
 static rtx find_single_value   PARAMS ((struct attr_desc *));
-static rtx make_numeric_value  PARAMS ((int));
 static void extend_range       PARAMS ((struct range *, int, int));
 static rtx attr_eq             PARAMS ((const char *, const char *));
 static const char *attr_numeral        PARAMS ((int));
 static int attr_equal_p                PARAMS ((rtx, rtx));
 static rtx attr_copy_rtx       PARAMS ((rtx));
+static int attr_rtx_cost       PARAMS ((rtx));
 
 #define oballoc(size) obstack_alloc (hash_obstack, size)
 \f
@@ -501,7 +505,7 @@ attr_hash_add_rtx (hashcode, rtl)
      int hashcode;
      rtx rtl;
 {
-  register struct attr_hash *h;
+  struct attr_hash *h;
 
   h = (struct attr_hash *) obstack_alloc (hash_obstack,
                                          sizeof (struct attr_hash));
@@ -518,7 +522,7 @@ attr_hash_add_string (hashcode, str)
      int hashcode;
      char *str;
 {
-  register struct attr_hash *h;
+  struct attr_hash *h;
 
   h = (struct attr_hash *) obstack_alloc (hash_obstack,
                                          sizeof (struct attr_hash));
@@ -529,35 +533,25 @@ attr_hash_add_string (hashcode, str)
 }
 
 /* Generate an RTL expression, but avoid duplicates.
-   Set the RTX_INTEGRATED_P flag for these permanent objects.
+   Set the ATTR_PERMANENT_P flag for these permanent objects.
 
    In some cases we cannot uniquify; then we return an ordinary
-   impermanent rtx with RTX_INTEGRATED_P clear.
+   impermanent rtx with ATTR_PERMANENT_P clear.
 
    Args are like gen_rtx, but without the mode:
 
    rtx attr_rtx (code, [element1, ..., elementn])  */
 
 static rtx
-attr_rtx VPARAMS ((enum rtx_code code, ...))
+attr_rtx_1 (code, p)
+     enum rtx_code code;
+     va_list p;
 {
-#ifndef ANSI_PROTOTYPES
-  enum rtx_code code;
-#endif
-  va_list p;
-  register int i;              /* Array indices...                     */
-  register const char *fmt;    /* Current rtx's format...              */
-  register rtx rt_val = NULL_RTX;/* RTX to return to caller...         */
+  rtx rt_val = NULL_RTX;/* RTX to return to caller...          */
   int hashcode;
-  register struct attr_hash *h;
+  struct attr_hash *h;
   struct obstack *old_obstack = rtl_obstack;
 
-  VA_START (p, code);
-
-#ifndef ANSI_PROTOTYPES
-  code = va_arg (p, enum rtx_code);
-#endif
-
   /* For each of several cases, search the hash table for an existing entry.
      Use that entry if one is found; otherwise create a new RTL and add it
      to the table.  */
@@ -567,11 +561,10 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
       rtx arg0 = va_arg (p, rtx);
 
       /* A permanent object cannot point to impermanent ones.  */
-      if (! RTX_INTEGRATED_P (arg0))
+      if (! ATTR_PERMANENT_P (arg0))
        {
          rt_val = rtx_alloc (code);
          XEXP (rt_val, 0) = arg0;
-         va_end (p);
          return rt_val;
        }
 
@@ -580,7 +573,7 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
        if (h->hashcode == hashcode
            && GET_CODE (h->u.rtl) == code
            && XEXP (h->u.rtl, 0) == arg0)
-         goto found;
+         return h->u.rtl;
 
       if (h == 0)
        {
@@ -597,12 +590,11 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
       rtx arg1 = va_arg (p, rtx);
 
       /* A permanent object cannot point to impermanent ones.  */
-      if (! RTX_INTEGRATED_P (arg0) || ! RTX_INTEGRATED_P (arg1))
+      if (! ATTR_PERMANENT_P (arg0) || ! ATTR_PERMANENT_P (arg1))
        {
          rt_val = rtx_alloc (code);
          XEXP (rt_val, 0) = arg0;
          XEXP (rt_val, 1) = arg1;
-         va_end (p);
          return rt_val;
        }
 
@@ -612,7 +604,7 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
            && GET_CODE (h->u.rtl) == code
            && XEXP (h->u.rtl, 0) == arg0
            && XEXP (h->u.rtl, 1) == arg1)
-         goto found;
+         return h->u.rtl;
 
       if (h == 0)
        {
@@ -635,7 +627,7 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
        if (h->hashcode == hashcode
            && GET_CODE (h->u.rtl) == code
            && XSTR (h->u.rtl, 0) == arg0)
-         goto found;
+         return h->u.rtl;
 
       if (h == 0)
        {
@@ -657,7 +649,7 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
            && GET_CODE (h->u.rtl) == code
            && XSTR (h->u.rtl, 0) == arg0
            && XSTR (h->u.rtl, 1) == arg1)
-         goto found;
+         return h->u.rtl;
 
       if (h == 0)
        {
@@ -671,19 +663,16 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
     {
       HOST_WIDE_INT arg0 = va_arg (p, HOST_WIDE_INT);
       if (arg0 == 0)
-       {
-         va_end (p);
-         return false_rtx;
-       }
-      if (arg0 == 1)
-       {
-         va_end (p);
-         return true_rtx;
-       }
-      goto nohash;
+       return false_rtx;
+      else if (arg0 == 1)
+       return true_rtx;
+      else
+       goto nohash;
     }
   else
     {
+      int i;           /* Array indices...                     */
+      const char *fmt; /* Current rtx's format...              */
     nohash:
       rt_val = rtx_alloc (code);       /* Allocate the storage space.  */
 
@@ -720,19 +709,25 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
              abort ();
            }
        }
-      va_end (p);
       return rt_val;
     }
 
   rtl_obstack = old_obstack;
-  va_end (p);
   attr_hash_add_rtx (hashcode, rt_val);
-  RTX_INTEGRATED_P (rt_val) = 1;
+  ATTR_PERMANENT_P (rt_val) = 1;
   return rt_val;
+}
 
- found:
-  va_end (p);
-  return h->u.rtl;
+static rtx
+attr_rtx VPARAMS ((enum rtx_code code, ...))
+{
+  rtx result;
+  
+  VA_OPEN (p, code);
+  VA_FIXEDARG (p, enum rtx_code, code);
+  result = attr_rtx_1 (code, p);
+  VA_CLOSE (p);
+  return result;
 }
 
 /* Create a new string printed with the printf line arguments into a space
@@ -740,27 +735,20 @@ attr_rtx VPARAMS ((enum rtx_code code, ...))
 
    rtx attr_printf (len, format, [arg1, ..., argn])  */
 
-static char *
-attr_printf VPARAMS ((register int len, const char *fmt, ...))
+char *
+attr_printf VPARAMS ((unsigned int len, const char *fmt, ...))
 {
-#ifndef ANSI_PROTOTYPES
-  register int len;
-  const char *fmt;
-#endif
-  va_list p;
-  register char *str;
+  char str[256];
 
-  VA_START (p, fmt);
-
-#ifndef ANSI_PROTOTYPES
-  len = va_arg (p, int);
-  fmt = va_arg (p, const char *);
-#endif
+  VA_OPEN (p, fmt);
+  VA_FIXEDARG (p, unsigned int, len);
+  VA_FIXEDARG (p, const char *, fmt);
+  
+  if (len > sizeof str - 1) /* Leave room for \0.  */
+    abort ();
 
-  /* Print the string into a temporary location.  */
-  str = (char *) alloca (len);
   vsprintf (str, fmt, p);
-  va_end (p);
+  VA_CLOSE (p);
 
   return attr_string (str, strlen (str));
 }
@@ -788,10 +776,10 @@ attr_string (str, len)
      const char *str;
      int len;
 {
-  register struct attr_hash *h;
+  struct attr_hash *h;
   int hashcode;
   int i;
-  register char *new_str;
+  char *new_str;
 
   /* Compute the hash code.  */
   hashcode = (len + 1) * 613 + (unsigned) str[0];
@@ -808,7 +796,7 @@ attr_string (str, len)
 
   /* Not found; create a permanent copy and add it to the hash table.  */
   new_str = (char *) obstack_alloc (hash_obstack, len + 1);
-  bcopy (str, new_str, len);
+  memcpy (new_str, str, len);
   new_str[len] = '\0';
   attr_hash_add_string (hashcode, new_str);
 
@@ -823,7 +811,7 @@ static int
 attr_equal_p (x, y)
      rtx x, y;
 {
-  return (x == y || (! (RTX_INTEGRATED_P (x) && RTX_INTEGRATED_P (y))
+  return (x == y || (! (ATTR_PERMANENT_P (x) && ATTR_PERMANENT_P (y))
                     && rtx_equal_p (x, y)));
 }
 \f
@@ -833,15 +821,15 @@ attr_equal_p (x, y)
 
 static rtx
 attr_copy_rtx (orig)
-     register rtx orig;
+     rtx orig;
 {
-  register rtx copy;
-  register int i, j;
-  register RTX_CODE code;
-  register const char *format_ptr;
+  rtx copy;
+  int i, j;
+  RTX_CODE code;
+  const char *format_ptr;
 
   /* No need to copy a permanent object.  */
-  if (RTX_INTEGRATED_P (orig))
+  if (ATTR_PERMANENT_P (orig))
     return orig;
 
   code = GET_CODE (orig);
@@ -852,6 +840,7 @@ attr_copy_rtx (orig)
     case QUEUED:
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_VECTOR:
     case SYMBOL_REF:
     case CODE_LABEL:
     case PC:
@@ -864,10 +853,10 @@ attr_copy_rtx (orig)
 
   copy = rtx_alloc (code);
   PUT_MODE (copy, GET_MODE (orig));
-  copy->in_struct = orig->in_struct;
-  copy->volatil = orig->volatil;
-  copy->unchanging = orig->unchanging;
-  copy->integrated = orig->integrated;
+  ATTR_IND_SIMPLIFIED_P (copy) = ATTR_IND_SIMPLIFIED_P (orig);
+  ATTR_CURR_SIMPLIFIED_P (copy) = ATTR_CURR_SIMPLIFIED_P (orig);
+  ATTR_PERMANENT_P (copy) = ATTR_PERMANENT_P (orig);
+  ATTR_EQ_ATTR_P (copy) = ATTR_EQ_ATTR_P (orig);
 
   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
 
@@ -925,9 +914,9 @@ attr_copy_rtx (orig)
    in the attribute (or `alternative_name') to speed up subsequent
    `find_attr' calls and eliminate most `strcmp' calls.
 
-   Return the new expression, if any.   */
+   Return the new expression, if any.  */
 
-static rtx
+rtx
 check_attr_test (exp, is_const, lineno)
      rtx exp;
      int is_const;
@@ -957,15 +946,15 @@ check_attr_test (exp, is_const, lineno)
                {
                  XSTR (exp, 0) = alternative_name;
                  /* This can't be simplified any further.  */
-                 RTX_UNCHANGING_P (exp) = 1;
+                 ATTR_IND_SIMPLIFIED_P (exp) = 1;
                  return exp;
                }
              else
-               fatal ("Unknown attribute `%s' in EQ_ATTR", XSTR (exp, 0));
+               fatal ("unknown attribute `%s' in EQ_ATTR", XSTR (exp, 0));
            }
 
          if (is_const && ! attr->is_const)
-           fatal ("Constant expression uses insn attribute `%s' in EQ_ATTR",
+           fatal ("constant expression uses insn attribute `%s' in EQ_ATTR",
                   XSTR (exp, 0));
 
          /* Copy this just to make it permanent,
@@ -976,13 +965,13 @@ check_attr_test (exp, is_const, lineno)
             constant attribute, so don't expand this until it's time to
             write the test expression.  */
          if (attr->is_const)
-           RTX_UNCHANGING_P (exp) = 1;
+           ATTR_IND_SIMPLIFIED_P (exp) = 1;
 
          if (attr->is_numeric)
            {
              for (p = XSTR (exp, 1); *p; p++)
-               if (*p < '0' || *p > '9')
-                 fatal ("Attribute `%s' takes only numeric values",
+               if (! ISDIGIT (*p))
+                 fatal ("attribute `%s' takes only numeric values",
                         XSTR (exp, 0));
            }
          else
@@ -993,7 +982,7 @@ check_attr_test (exp, is_const, lineno)
                  break;
 
              if (av == NULL)
-               fatal ("Unknown value `%s' for `%s' attribute",
+               fatal ("unknown value `%s' for `%s' attribute",
                       XSTR (exp, 1), XSTR (exp, 0));
            }
        }
@@ -1038,7 +1027,7 @@ check_attr_test (exp, is_const, lineno)
        fatal ("RTL operator \"%s\" not valid in constant attribute test",
               GET_RTX_NAME (GET_CODE (exp)));
       /* These cases can't be simplified.  */
-      RTX_UNCHANGING_P (exp) = 1;
+      ATTR_IND_SIMPLIFIED_P (exp) = 1;
       break;
 
     case LE:  case LT:  case GT:  case GE:
@@ -1050,7 +1039,7 @@ check_attr_test (exp, is_const, lineno)
                        attr_rtx (SYMBOL_REF, XSTR (XEXP (exp, 0), 0)),
                        attr_rtx (SYMBOL_REF, XSTR (XEXP (exp, 1), 0)));
       /* These cases can't be simplified.  */
-      RTX_UNCHANGING_P (exp) = 1;
+      ATTR_IND_SIMPLIFIED_P (exp) = 1;
       break;
 
     case SYMBOL_REF:
@@ -1059,7 +1048,7 @@ check_attr_test (exp, is_const, lineno)
          /* These cases are valid for constant attributes, but can't be
             simplified.  */
          exp = attr_rtx (SYMBOL_REF, XSTR (exp, 0));
-         RTX_UNCHANGING_P (exp) = 1;
+         ATTR_IND_SIMPLIFIED_P (exp) = 1;
          break;
        }
     default:
@@ -1117,7 +1106,7 @@ check_attr_value (exp, attr)
          if (attr && attr->negative_ok && *p == '-')
            p++;
          for (; *p; p++)
-           if (*p > '9' || *p < '0')
+           if (! ISDIGIT (*p))
              {
                message_with_line (attr ? attr->lineno : 0,
                                   "non-numeric value for numeric attribute %s",
@@ -1172,6 +1161,10 @@ check_attr_value (exp, attr)
       break;
 
     case FFS:
+    case CLZ:
+    case CTZ:
+    case POPCOUNT:
+    case PARITY:
       XEXP (exp, 0) = check_attr_value (XEXP (exp, 0), attr);
       break;
 
@@ -1417,7 +1410,7 @@ convert_const_symbol_ref (exp, attr)
        *p = TOUPPER (*p);
 
       value = attr_rtx (SYMBOL_REF, string);
-      RTX_UNCHANGING_P (value) = 1;
+      ATTR_IND_SIMPLIFIED_P (value) = 1;
 
       XVECEXP (condexp, 0, 2 * i) = attr_rtx (EQ, exp, value);
 
@@ -1451,25 +1444,25 @@ make_canonical (attr, exp)
       if (! strcmp (XSTR (exp, 0), "*"))
        {
          if (attr == 0 || attr->default_val == 0)
-           fatal ("(attr_value \"*\") used in invalid context.");
+           fatal ("(attr_value \"*\") used in invalid context");
          exp = attr->default_val->value;
        }
 
       break;
 
     case SYMBOL_REF:
-      if (!attr->is_const || RTX_UNCHANGING_P (exp))
+      if (!attr->is_const || ATTR_IND_SIMPLIFIED_P (exp))
        break;
       /* The SYMBOL_REF is constant for a given run, so mark it as unchanging.
         This makes the COND something that won't be considered an arbitrary
         expression by walk_attr_value.  */
-      RTX_UNCHANGING_P (exp) = 1;
+      ATTR_IND_SIMPLIFIED_P (exp) = 1;
 #if 0
       /* ??? Why do we do this?  With attribute values { A B C D E }, this
          tends to generate (!(x==A) && !(x==B) && !(x==C) && !(x==D)) rather
         than (x==E).  */
       exp = convert_const_symbol_ref (exp, attr);
-      RTX_UNCHANGING_P (exp) = 1;
+      ATTR_IND_SIMPLIFIED_P (exp) = 1;
       exp = check_attr_value (exp, attr);
       /* Goto COND case since this is now a COND.  Note that while the
          new expression is rescanned, all symbol_ref notes are marked as
@@ -1642,9 +1635,8 @@ expand_delays ()
          newexp = attr_rtx (IF_THEN_ELSE, condexp,
                             make_numeric_value (1), make_numeric_value (0));
 
-         p = attr_printf (sizeof ("*delay__") + MAX_DIGITS * 2,
-                          "*delay_%d_%d",
-                          delay->num, i / 3);
+         p = attr_printf (sizeof "*delay__" + MAX_DIGITS * 2,
+                          "*delay_%d_%d", delay->num, i / 3);
          make_internal_attr (p, newexp, 1);
 
          if (have_annul_true)
@@ -1654,7 +1646,7 @@ expand_delays ()
              newexp = attr_rtx (IF_THEN_ELSE, condexp,
                                 make_numeric_value (1),
                                 make_numeric_value (0));
-             p = attr_printf (sizeof ("*annul_true__") + MAX_DIGITS * 2,
+             p = attr_printf (sizeof "*annul_true__" + MAX_DIGITS * 2,
                               "*annul_true_%d_%d", delay->num, i / 3);
              make_internal_attr (p, newexp, 1);
            }
@@ -1666,7 +1658,7 @@ expand_delays ()
              newexp = attr_rtx (IF_THEN_ELSE, condexp,
                                 make_numeric_value (1),
                                 make_numeric_value (0));
-             p = attr_printf (sizeof ("*annul_false__") + MAX_DIGITS * 2,
+             p = attr_printf (sizeof "*annul_false__" + MAX_DIGITS * 2,
                               "*annul_false_%d_%d", delay->num, i / 3);
              make_internal_attr (p, newexp, 1);
            }
@@ -1789,7 +1781,7 @@ operate_exp (op, left, right)
          return newexp;
        }
       else
-       fatal ("Badly formed attribute value");
+       fatal ("badly formed attribute value");
     }
 
   /* A hack to prevent expand_units from completely blowing up: ORX_OP does
@@ -1841,7 +1833,7 @@ operate_exp (op, left, right)
     }
 
   else
-    fatal ("Badly formed attribute value.");
+    fatal ("badly formed attribute value");
   /* NOTREACHED */
   return NULL;
 }
@@ -1852,7 +1844,7 @@ operate_exp (op, left, right)
    The first produces a function `function_units_used' which is given an
    insn and produces an encoding showing which function units are required
    for the execution of that insn.  If the value is non-negative, the insn
-   uses that unit; otherwise, the value is a one's compliment mask of units
+   uses that unit; otherwise, the value is a one's complement mask of units
    used.
 
    The second produces a function `result_ready_cost' which is used to
@@ -1919,7 +1911,8 @@ expand_units ()
                                           != unit->issue_delay.max);
          if (unit->needs_conflict_function)
            {
-             str = attr_printf (strlen (unit->name) + sizeof ("*_cost_") + MAX_DIGITS,
+             str = attr_printf ((strlen (unit->name) + sizeof "*_cost_"
+                                 + MAX_DIGITS),
                                 "*%s_cost_%d", unit->name, op->num);
              make_internal_attr (str, issue_exp, 1);
            }
@@ -1982,12 +1975,12 @@ expand_units ()
   /* Create an array of ops for each unit.  Add an extra unit for the
      result_ready_cost function that has the ops of all other units.  */
   unit_ops = (struct function_unit_op ***)
-    alloca ((num_units + 1) * sizeof (struct function_unit_op **));
+    xmalloc ((num_units + 1) * sizeof (struct function_unit_op **));
   unit_num = (struct function_unit **)
-    alloca ((num_units + 1) * sizeof (struct function_unit *));
+    xmalloc ((num_units + 1) * sizeof (struct function_unit *));
 
   unit_num[num_units] = unit = (struct function_unit *)
-    alloca (sizeof (struct function_unit));
+    xmalloc (sizeof (struct function_unit));
   unit->num = num_units;
   unit->num_opclasses = 0;
 
@@ -1996,7 +1989,7 @@ expand_units ()
       unit_num[num_units]->num_opclasses += unit->num_opclasses;
       unit_num[unit->num] = unit;
       unit_ops[unit->num] = op_array = (struct function_unit_op **)
-       alloca (unit->num_opclasses * sizeof (struct function_unit_op *));
+       xmalloc (unit->num_opclasses * sizeof (struct function_unit_op *));
 
       for (op = unit->ops; op; op = op->next)
        op_array[op->num] = op;
@@ -2004,12 +1997,12 @@ expand_units ()
 
   /* Compose the array of ops for the extra unit.  */
   unit_ops[num_units] = op_array = (struct function_unit_op **)
-    alloca (unit_num[num_units]->num_opclasses
+    xmalloc (unit_num[num_units]->num_opclasses
            * sizeof (struct function_unit_op *));
 
   for (unit = units, i = 0; unit; i += unit->num_opclasses, unit = unit->next)
-    bcopy ((char *) unit_ops[unit->num], (char *) &op_array[i],
-          unit->num_opclasses * sizeof (struct function_unit_op *));
+    memcpy (&op_array[i], unit_ops[unit->num],
+           unit->num_opclasses * sizeof (struct function_unit_op *));
 
   /* Compute the ready cost function for each unit by computing the
      condition for each non-default value.  */
@@ -2096,7 +2089,7 @@ expand_units ()
             every possible C.
 
             The issue delay function for C is op->issue_exp and is used to
-            write the `<name>_unit_conflict_cost' function.  Symbolicly
+            write the `<name>_unit_conflict_cost' function.  Symbolically
             this is "ISSUE-DELAY (E,C)".
 
             The pipeline delay results form the FIFO constraint on the
@@ -2106,7 +2099,7 @@ expand_units ()
             fill the unit given the minimum issue delay.  FILL-TIME is the
             constant "MIN (ISSUE-DELAY (*,*)) * (SIMULTANEITY - 1)", and
             the simultaneity constraint is "READY-COST (E) - FILL-TIME"
-            if SIMULTANEITY is non-zero and zero otherwise.
+            if SIMULTANEITY is nonzero and zero otherwise.
 
             Thus, BLOCKAGE (E,C) when SIMULTANEITY is zero is
 
@@ -2148,7 +2141,8 @@ expand_units ()
                }
 
              /* Make an attribute for use in the blockage function.  */
-             str = attr_printf (strlen (unit->name) + sizeof ("*_block_") + MAX_DIGITS,
+             str = attr_printf ((strlen (unit->name) + sizeof "*_block_"
+                                 + MAX_DIGITS),
                                 "*%s_block_%d", unit->name, op->num);
              make_internal_attr (str, blockage, 1);
            }
@@ -2181,12 +2175,13 @@ expand_units ()
              newexp = operate_exp (RANGE_OP, min_blockage, max_blockage);
              newexp = simplify_knowing (newexp, unit->condexp);
 
-             str = attr_printf (strlen (unit->name) + sizeof ("*_unit_blockage_range"),
+             str = attr_printf ((strlen (unit->name)
+                                 + sizeof "*_unit_blockage_range"),
                                 "*%s_unit_blockage_range", unit->name);
              make_internal_attr (str, newexp, 20);
            }
 
-         str = attr_printf (strlen (unit->name) + sizeof ("*_unit_ready_cost"),
+         str = attr_printf (strlen (unit->name) + sizeof "*_unit_ready_cost",
                             "*%s_unit_ready_cost", unit->name);
        }
       else
@@ -2228,7 +2223,7 @@ expand_units ()
        }
 
       /* Simplifying caseexp with simplify_by_exploding doesn't win.  */
-      str = attr_printf (strlen (unit->name) + sizeof ("*_cases"),
+      str = attr_printf (strlen (unit->name) + sizeof "*_cases",
                         "*%s_cases", unit->name);
       make_internal_attr (str, caseexp, 1);
     }
@@ -2257,16 +2252,16 @@ simplify_knowing (exp, known_true)
 /* Translate the CONST_STRING expressions in X to change the encoding of
    value.  On input, the value is a bitmask with a one bit for each unit
    used; on output, the value is the unit number (zero based) if one
-   and only one unit is used or the one's compliment of the bitmask.  */
+   and only one unit is used or the one's complement of the bitmask.  */
 
 static rtx
 encode_units_mask (x)
      rtx x;
 {
-  register int i;
-  register int j;
-  register enum rtx_code code;
-  register const char *fmt;
+  int i;
+  int j;
+  enum rtx_code code;
+  const char *fmt;
 
   code = GET_CODE (x);
 
@@ -2275,7 +2270,7 @@ encode_units_mask (x)
     case CONST_STRING:
       i = atoi (XSTR (x, 0));
       if (i < 0)
-       /* The sign bit encodes a one's compliment mask.  */
+       /* The sign bit encodes a one's complement mask.  */
        abort ();
       else if (i != 0 && i == (i & -i))
        /* Only one bit is set, so yield that unit number.  */
@@ -2289,6 +2284,7 @@ encode_units_mask (x)
     case QUEUED:
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_VECTOR:
     case SYMBOL_REF:
     case CODE_LABEL:
     case PC:
@@ -2448,11 +2444,11 @@ substitute_address (exp, no_address_fn, address_fn)
 static void
 make_length_attrs ()
 {
-  static const char *new_names[] = {"*insn_default_length",
+  static const char *const new_names[] = {"*insn_default_length",
                                      "*insn_variable_length_p",
                                      "*insn_current_length"};
-  static rtx (*no_address_fn[]) PARAMS ((rtx)) = {identity_fn, zero_fn, zero_fn};
-  static rtx (*address_fn[]) PARAMS ((rtx)) = {max_fn, one_fn, identity_fn};
+  static rtx (*const no_address_fn[]) PARAMS ((rtx)) = {identity_fn, zero_fn, zero_fn};
+  static rtx (*const address_fn[]) PARAMS ((rtx)) = {max_fn, one_fn, identity_fn};
   size_t i;
   struct attr_desc *length_attr, *new_attr;
   struct attr_value *av, *new_av;
@@ -2465,7 +2461,7 @@ make_length_attrs ()
     return;
 
   if (! length_attr->is_numeric)
-    fatal ("length attribute must be numeric.");
+    fatal ("length attribute must be numeric");
 
   length_attr->is_const = 0;
   length_attr->is_special = 1;
@@ -2570,14 +2566,14 @@ simplify_cond (exp, insn_code, insn_index)
   rtx defval = XEXP (exp, 1);
   rtx new_defval = XEXP (exp, 1);
   int len = XVECLEN (exp, 0);
-  rtx *tests = (rtx *) alloca (len * sizeof (rtx));
+  rtx *tests = (rtx *) xmalloc (len * sizeof (rtx));
   int allsame = 1;
-  char *first_spacer;
+  rtx ret;
 
   /* This lets us free all storage allocated below, if appropriate.  */
-  first_spacer = (char *) obstack_finish (rtl_obstack);
+  obstack_finish (rtl_obstack);
 
-  bcopy ((char *) XVEC (exp, 0)->elem, (char *) tests, len * sizeof (rtx));
+  memcpy (tests, XVEC (exp, 0)->elem, len * sizeof (rtx));
 
   /* See if default value needs simplification.  */
   if (GET_CODE (defval) == COND)
@@ -2590,7 +2586,7 @@ simplify_cond (exp, insn_code, insn_index)
       rtx newtest, newval;
 
       /* Simplify this test.  */
-      newtest = SIMPLIFY_TEST_EXP (tests[i], insn_code, insn_index);
+      newtest = simplify_test_exp_in_temp (tests[i], insn_code, insn_index);
       tests[i] = newtest;
 
       newval = tests[i + 1];
@@ -2655,21 +2651,23 @@ simplify_cond (exp, insn_code, insn_index)
   if (len == 0)
     {
       if (GET_CODE (defval) == COND)
-       return simplify_cond (defval, insn_code, insn_index);
-      return defval;
+       ret = simplify_cond (defval, insn_code, insn_index);
+      else
+       ret = defval;
     }
   else if (allsame)
-    return exp;
+    ret = exp;
   else
     {
       rtx newexp = rtx_alloc (COND);
 
       XVEC (newexp, 0) = rtvec_alloc (len);
-      bcopy ((char *) tests, (char *) XVEC (newexp, 0)->elem,
-            len * sizeof (rtx));
+      memcpy (XVEC (newexp, 0)->elem, tests, len * sizeof (rtx));
       XEXP (newexp, 1) = new_defval;
-      return newexp;
+      ret = newexp;
     }
+  free (tests);
+  return ret;
 }
 \f
 /* Remove an insn entry from an attribute value.  */
@@ -2777,7 +2775,7 @@ insert_right_side (code, exp, term, insn_code, insn_index)
       newexp = attr_rtx (code, exp, term);
     }
 
-  return SIMPLIFY_TEST_EXP (newexp, insn_code, insn_index);
+  return simplify_test_exp_in_temp (newexp, insn_code, insn_index);
 }
 \f
 /* If we have an expression which AND's a bunch of
@@ -2830,7 +2828,7 @@ make_alternative_compare (mask)
     ;
 
   newexp = attr_rtx (EQ_ATTR, alternative_name, attr_numeral (i));
-  RTX_UNCHANGING_P (newexp) = 1;
+  ATTR_IND_SIMPLIFIED_P (newexp) = 1;
 
   return newexp;
 }
@@ -2864,13 +2862,15 @@ evaluate_eq_attr (exp, value, insn_code, insn_index)
     }
   else if (GET_CODE (value) == SYMBOL_REF)
     {
-      char *p, *string;
+      char *p;
+      char string[256];
 
       if (GET_CODE (exp) != EQ_ATTR)
        abort ();
 
-      string = (char *) alloca (2 + strlen (XSTR (exp, 0))
-                               + strlen (XSTR (exp, 1)));
+      if (strlen (XSTR (exp, 0)) + strlen (XSTR (exp, 1)) + 2 > 256)
+       abort ();
+
       strcpy (string, XSTR (exp, 0));
       strcat (string, "_");
       strcat (string, XSTR (exp, 1));
@@ -2903,8 +2903,8 @@ evaluate_eq_attr (exp, value, insn_code, insn_index)
 
       for (i = 0; i < XVECLEN (value, 0); i += 2)
        {
-         rtx this = SIMPLIFY_TEST_EXP (XVECEXP (value, 0, i),
-                                       insn_code, insn_index);
+         rtx this = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
+                                               insn_code, insn_index);
 
          SIMPLIFY_ALTERNATIVE (this);
 
@@ -2936,7 +2936,7 @@ evaluate_eq_attr (exp, value, insn_code, insn_index)
     abort ();
 
   /* If uses an address, must return original expression.  But set the
-     RTX_UNCHANGING_P bit so we don't try to simplify it again.  */
+     ATTR_IND_SIMPLIFIED_P bit so we don't try to simplify it again.  */
 
   address_used = 0;
   walk_attr_value (newexp);
@@ -2944,7 +2944,7 @@ evaluate_eq_attr (exp, value, insn_code, insn_index)
   if (address_used)
     {
       /* This had `&& current_alternative_string', which seems to be wrong.  */
-      if (! RTX_UNCHANGING_P (exp))
+      if (! ATTR_IND_SIMPLIFIED_P (exp))
        return copy_rtx_unchanging (exp);
       return exp;
     }
@@ -2985,7 +2985,7 @@ simplify_and_tree (exp, pterm, insn_code, insn_index)
        {
          newexp = attr_rtx (GET_CODE (exp), left, right);
 
-         exp = SIMPLIFY_TEST_EXP (newexp, insn_code, insn_index);
+         exp = simplify_test_exp_in_temp (newexp, insn_code, insn_index);
        }
     }
 
@@ -3008,7 +3008,7 @@ simplify_and_tree (exp, pterm, insn_code, insn_index)
        {
          newexp = attr_rtx (GET_CODE (exp), left, right);
 
-         exp = SIMPLIFY_TEST_EXP (newexp, insn_code, insn_index);
+         exp = simplify_test_exp_in_temp (newexp, insn_code, insn_index);
        }
     }
 
@@ -3104,7 +3104,7 @@ simplify_or_tree (exp, pterm, insn_code, insn_index)
        {
          newexp = attr_rtx (GET_CODE (exp), left, right);
 
-         exp = SIMPLIFY_TEST_EXP (newexp, insn_code, insn_index);
+         exp = simplify_test_exp_in_temp (newexp, insn_code, insn_index);
        }
     }
 
@@ -3127,7 +3127,7 @@ simplify_or_tree (exp, pterm, insn_code, insn_index)
        {
          newexp = attr_rtx (GET_CODE (exp), left, right);
 
-         exp = SIMPLIFY_TEST_EXP (newexp, insn_code, insn_index);
+         exp = simplify_test_exp_in_temp (newexp, insn_code, insn_index);
        }
     }
 
@@ -3152,7 +3152,77 @@ simplify_or_tree (exp, pterm, insn_code, insn_index)
 
   return exp;
 }
+/* Compute approximate cost of the expression.  Used to decide whether
+   expression is cheap enough for inline.  */
+static int
+attr_rtx_cost (x)
+     rtx x;
+{
+  int cost = 0;
+  enum rtx_code code;
+  if (!x)
+    return 0;
+  code = GET_CODE (x);
+  switch (code)
+    {
+    case MATCH_OPERAND:
+      if (XSTR (x, 1)[0])
+       return 10;
+      else
+       return 0;
+    case EQ_ATTR:
+      /* Alternatives don't result into function call.  */
+      if (!strcmp (XSTR (x, 0), "alternative"))
+       return 0;
+      else
+       return 5;
+    default:
+      {
+       int i, j;
+       const char *fmt = GET_RTX_FORMAT (code);
+       for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+         {
+           switch (fmt[i])
+             {
+             case 'V':
+             case 'E':
+               for (j = 0; j < XVECLEN (x, i); j++)
+                 cost += attr_rtx_cost (XVECEXP (x, i, j));
+               break;
+             case 'e':
+               cost += attr_rtx_cost (XEXP (x, i));
+               break;
+             }
+         }
+      }
+      break;
+    }
+  return cost;
+}
 \f
+
+/* Simplify test expression and use temporary obstack in order to avoid
+   memory bloat.  Use ATTR_IND_SIMPLIFIED to avoid unnecessary simplifications
+   and avoid unnecessary copying if possible.  */
+
+static rtx
+simplify_test_exp_in_temp (exp, insn_code, insn_index)
+  rtx exp;
+  int insn_code, insn_index;
+{
+  rtx x;
+  struct obstack *old;
+  if (ATTR_IND_SIMPLIFIED_P (exp))
+    return exp;
+  old = rtl_obstack;
+  rtl_obstack = temp_obstack;
+  x = simplify_test_exp (exp, insn_code, insn_index);
+  rtl_obstack = old;
+  if (x == exp || rtl_obstack == temp_obstack)
+    return x;
+  return attr_copy_rtx (x);
+}
+
 /* Given an expression, see if it can be simplified for a particular insn
    code based on the values of other attributes being tested.  This can
    eliminate nested get_attr_... calls.
@@ -3175,7 +3245,7 @@ simplify_test_exp (exp, insn_code, insn_index)
   rtx newexp = exp;
 
   /* Don't re-simplify something we already simplified.  */
-  if (RTX_UNCHANGING_P (exp) || MEM_IN_STRUCT_P (exp))
+  if (ATTR_IND_SIMPLIFIED_P (exp) || ATTR_CURR_SIMPLIFIED_P (exp))
     return exp;
 
   switch (GET_CODE (exp))
@@ -3241,7 +3311,7 @@ simplify_test_exp (exp, insn_code, insn_index)
        {
          i = compute_alternative_mask (exp, AND);
          if (i & ~insn_alternatives[insn_code])
-           fatal ("Invalid alternative specified for pattern number %d",
+           fatal ("invalid alternative specified for pattern number %d",
                   insn_index);
 
          /* If all alternatives are excluded, this is false.  */
@@ -3325,7 +3395,7 @@ simplify_test_exp (exp, insn_code, insn_index)
        {
          i = compute_alternative_mask (exp, IOR);
          if (i & ~insn_alternatives[insn_code])
-           fatal ("Invalid alternative specified for pattern number %d",
+           fatal ("invalid alternative specified for pattern number %d",
                   insn_index);
 
          /* If all alternatives are included, this is true.  */
@@ -3402,13 +3472,19 @@ simplify_test_exp (exp, insn_code, insn_index)
 
       /* Look at the value for this insn code in the specified attribute.
         We normally can replace this comparison with the condition that
-        would give this insn the values being tested for.   */
+        would give this insn the values being tested for.  */
       if (XSTR (exp, 0) != alternative_name
          && (attr = find_attr (XSTR (exp, 0), 0)) != NULL)
        for (av = attr->first_value; av; av = av->next)
          for (ie = av->first_insn; ie; ie = ie->next)
            if (ie->insn_code == insn_code)
-             return evaluate_eq_attr (exp, av->value, insn_code, insn_index);
+             {
+               rtx x;
+               x = evaluate_eq_attr (exp, av->value, insn_code, insn_index);
+               x = SIMPLIFY_TEST_EXP (x, insn_code, insn_index);
+               if (attr_rtx_cost(x) < 20)
+                 return x;
+             }
       break;
 
     default:
@@ -3419,7 +3495,7 @@ simplify_test_exp (exp, insn_code, insn_index)
      won't buy anything unless we weren't given a valid insn code
      to process (i.e., we are canonicalizing something.).  */
   if (insn_code != -2 /* Seems wrong: && current_alternative_string.  */
-      && ! RTX_UNCHANGING_P (newexp))
+      && ! ATTR_IND_SIMPLIFIED_P (newexp))
     return copy_rtx_unchanging (newexp);
 
   return newexp;
@@ -3436,7 +3512,6 @@ optimize_attrs ()
   struct attr_value *av;
   struct insn_ent *ie;
   rtx newexp;
-  int something_changed = 1;
   int i;
   struct attr_value_list
   {
@@ -3457,7 +3532,7 @@ optimize_attrs ()
 
   /* Make 2 extra elements, for "code" values -2 and -1.  */
   insn_code_values
-    = (struct attr_value_list **) alloca ((insn_code_number + 2)
+    = (struct attr_value_list **) xmalloc ((insn_code_number + 2)
                                          * sizeof (struct attr_value_list *));
   memset ((char *) insn_code_values, 0,
         (insn_code_number + 2) * sizeof (struct attr_value_list *));
@@ -3465,9 +3540,6 @@ optimize_attrs ()
   /* Offset the table address so we can index by -2 or -1.  */
   insn_code_values += 2;
 
-  /* Allocate the attr_value_list structures using xmalloc rather than
-     alloca, because using alloca can overflow the maximum permitted
-     stack limit on SPARC Lynx.  */
   iv = ivbuf = ((struct attr_value_list *)
                xmalloc (num_insn_ents * sizeof (struct attr_value_list)));
 
@@ -3491,52 +3563,53 @@ optimize_attrs ()
   /* Process one insn code at a time.  */
   for (i = -2; i < insn_code_number; i++)
     {
-      /* Clear the MEM_IN_STRUCT_P flag everywhere relevant.
+      /* Clear the ATTR_CURR_SIMPLIFIED_P flag everywhere relevant.
         We use it to mean "already simplified for this insn".  */
       for (iv = insn_code_values[i]; iv; iv = iv->next)
        clear_struct_flag (iv->av->value);
 
-      /* Loop until nothing changes for one iteration.  */
-      something_changed = 1;
-      while (something_changed)
+      for (iv = insn_code_values[i]; iv; iv = iv->next)
        {
-         something_changed = 0;
-         for (iv = insn_code_values[i]; iv; iv = iv->next)
-           {
-             struct obstack *old = rtl_obstack;
+         struct obstack *old = rtl_obstack;
 
-             attr = iv->attr;
-             av = iv->av;
-             ie = iv->ie;
-             if (GET_CODE (av->value) != COND)
-               continue;
+         attr = iv->attr;
+         av = iv->av;
+         ie = iv->ie;
+         if (GET_CODE (av->value) != COND)
+           continue;
 
-             rtl_obstack = temp_obstack;
+         rtl_obstack = temp_obstack;
 #if 0 /* This was intended as a speed up, but it was slower.  */
-             if (insn_n_alternatives[ie->insn_code] > 6
-                 && count_sub_rtxs (av->value, 200) >= 200)
-               newexp = simplify_by_alternatives (av->value, ie->insn_code,
-                                                  ie->insn_index);
-             else
+         if (insn_n_alternatives[ie->insn_code] > 6
+             && count_sub_rtxs (av->value, 200) >= 200)
+           newexp = simplify_by_alternatives (av->value, ie->insn_code,
+                                              ie->insn_index);
+         else
 #endif
-               newexp = simplify_cond (av->value, ie->insn_code,
-                                       ie->insn_index);
+         newexp = av->value;
+         while (GET_CODE (newexp) == COND)
+           {
+             rtx newexp2 = simplify_cond (newexp, ie->insn_code,
+                                          ie->insn_index);
+             if (newexp2 == newexp)
+               break;
+             newexp = newexp2;
+           }
 
-             rtl_obstack = old;
-             if (newexp != av->value)
-               {
-                 newexp = attr_copy_rtx (newexp);
-                 remove_insn_ent (av, ie);
-                 av = get_attr_value (newexp, attr, ie->insn_code);
-                 iv->av = av;
-                 insert_insn_ent (av, ie);
-                 something_changed = 1;
-               }
+         rtl_obstack = old;
+         if (newexp != av->value)
+           {
+             newexp = attr_copy_rtx (newexp);
+             remove_insn_ent (av, ie);
+             av = get_attr_value (newexp, attr, ie->insn_code);
+             iv->av = av;
+             insert_insn_ent (av, ie);
            }
        }
     }
 
   free (ivbuf);
+  free (insn_code_values - 2);
 }
 
 #if 0
@@ -3585,6 +3658,7 @@ simplify_by_exploding (exp)
   rtx *condtest, *condval;
   int i, j, total, ndim = 0;
   int most_tests, num_marks, new_marks;
+  rtx ret;
 
   /* Locate all the EQ_ATTR expressions.  */
   if (! find_and_mark_used_attributes (exp, &list, &ndim) || ndim == 0)
@@ -3599,7 +3673,7 @@ simplify_by_exploding (exp)
      cover the domain of the attribute.  This makes the expanded COND form
      order independent.  */
 
-  space = (struct dimension *) alloca (ndim * sizeof (struct dimension));
+  space = (struct dimension *) xmalloc (ndim * sizeof (struct dimension));
 
   total = 1;
   for (ndim = 0; list; ndim++)
@@ -3654,8 +3728,8 @@ simplify_by_exploding (exp)
   for (i = 0; i < ndim; i++)
     space[i].current_value = space[i].values;
 
-  condtest = (rtx *) alloca (total * sizeof (rtx));
-  condval = (rtx *) alloca (total * sizeof (rtx));
+  condtest = (rtx *) xmalloc (total * sizeof (rtx));
+  condval = (rtx *) xmalloc (total * sizeof (rtx));
 
   /* Expand the tests and values by iterating over all values in the
      attribute space.  */
@@ -3671,18 +3745,19 @@ simplify_by_exploding (exp)
 
   /* We are now finished with the original expression.  */
   unmark_used_attributes (0, space, ndim);
+  free (space);
 
   /* Find the most used constant value and make that the default.  */
   most_tests = -1;
   for (i = num_marks = 0; i < total; i++)
     if (GET_CODE (condval[i]) == CONST_STRING
-       && ! MEM_VOLATILE_P (condval[i]))
+       && ! ATTR_EQ_ATTR_P (condval[i]))
       {
        /* Mark the unmarked constant value and count how many are marked.  */
-       MEM_VOLATILE_P (condval[i]) = 1;
+       ATTR_EQ_ATTR_P (condval[i]) = 1;
        for (j = new_marks = 0; j < total; j++)
          if (GET_CODE (condval[j]) == CONST_STRING
-             && MEM_VOLATILE_P (condval[j]))
+             && ATTR_EQ_ATTR_P (condval[j]))
            new_marks++;
        if (new_marks - num_marks > most_tests)
          {
@@ -3693,34 +3768,39 @@ simplify_by_exploding (exp)
       }
   /* Clear all the marks.  */
   for (i = 0; i < total; i++)
-    MEM_VOLATILE_P (condval[i]) = 0;
+    ATTR_EQ_ATTR_P (condval[i]) = 0;
 
   /* Give up if nothing is constant.  */
   if (num_marks == 0)
-    return exp;
-
+    ret = exp;
+  
   /* If all values are the default, use that.  */
-  if (total == most_tests)
-    return defval;
+  else if (total == most_tests)
+    ret = defval;
 
   /* Make a COND with the most common constant value the default.  (A more
      complex method where tests with the same value were combined didn't
      seem to improve things.)  */
-  condexp = rtx_alloc (COND);
-  XVEC (condexp, 0) = rtvec_alloc ((total - most_tests) * 2);
-  XEXP (condexp, 1) = defval;
-  for (i = j = 0; i < total; i++)
-    if (condval[i] != defval)
-      {
-       XVECEXP (condexp, 0, 2 * j) = condtest[i];
-       XVECEXP (condexp, 0, 2 * j + 1) = condval[i];
-       j++;
-      }
-
-  return condexp;
+  else
+    {
+      condexp = rtx_alloc (COND);
+      XVEC (condexp, 0) = rtvec_alloc ((total - most_tests) * 2);
+      XEXP (condexp, 1) = defval;
+      for (i = j = 0; i < total; i++)
+       if (condval[i] != defval)
+         {
+           XVECEXP (condexp, 0, 2 * j) = condtest[i];
+           XVECEXP (condexp, 0, 2 * j + 1) = condval[i];
+           j++;
+         }
+      ret = condexp;
+    }
+  free (condtest);
+  free (condval);
+  return ret;
 }
 
-/* Set the MEM_VOLATILE_P flag for all EQ_ATTR expressions in EXP and
+/* Set the ATTR_EQ_ATTR_P flag for all EQ_ATTR expressions in EXP and
    verify that EXP can be simplified to a constant term if all the EQ_ATTR
    tests have known value.  */
 
@@ -3734,14 +3814,14 @@ find_and_mark_used_attributes (exp, terms, nterms)
   switch (GET_CODE (exp))
     {
     case EQ_ATTR:
-      if (! MEM_VOLATILE_P (exp))
+      if (! ATTR_EQ_ATTR_P (exp))
        {
          rtx link = rtx_alloc (EXPR_LIST);
          XEXP (link, 0) = exp;
          XEXP (link, 1) = *terms;
          *terms = link;
          *nterms += 1;
-         MEM_VOLATILE_P (exp) = 1;
+         ATTR_EQ_ATTR_P (exp) = 1;
        }
       return 1;
 
@@ -3774,7 +3854,7 @@ find_and_mark_used_attributes (exp, terms, nterms)
     }
 }
 
-/* Clear the MEM_VOLATILE_P flag in all EQ_ATTR expressions on LIST and
+/* Clear the ATTR_EQ_ATTR_P flag in all EQ_ATTR expressions on LIST and
    in the values of the NDIM-dimensional attribute space SPACE.  */
 
 static void
@@ -3793,7 +3873,7 @@ unmark_used_attributes (list, space, ndim)
     {
       exp = XEXP (link, 0);
       if (GET_CODE (exp) == EQ_ATTR)
-       MEM_VOLATILE_P (exp) = 0;
+       ATTR_EQ_ATTR_P (exp) = 0;
     }
 }
 
@@ -3829,7 +3909,7 @@ add_values_to_cover (dim)
        if (GET_CODE (av->value) == CONST_STRING)
          {
            exp = attr_eq (dim->attr->name, XSTR (av->value, 0));
-           if (MEM_VOLATILE_P (exp))
+           if (ATTR_EQ_ATTR_P (exp))
              continue;
 
            link = rtx_alloc (EXPR_LIST);
@@ -3919,7 +3999,7 @@ simplify_with_current_value (exp, space, ndim)
     {
       x = XEXP (space[i].current_value, 0);
       if (GET_CODE (x) == EQ_ATTR)
-       MEM_VOLATILE_P (x) = 0;
+       ATTR_EQ_ATTR_P (x) = 0;
     }
 
   exp = simplify_with_current_value_aux (exp);
@@ -3929,26 +4009,26 @@ simplify_with_current_value (exp, space, ndim)
     {
       x = XEXP (space[i].current_value, 0);
       if (GET_CODE (x) == EQ_ATTR)
-       MEM_VOLATILE_P (x) = 1;
+       ATTR_EQ_ATTR_P (x) = 1;
     }
 
   return exp;
 }
 
-/* Reduce the expression EXP based on the MEM_VOLATILE_P settings of
+/* Reduce the expression EXP based on the ATTR_EQ_ATTR_P settings of
    all EQ_ATTR expressions.  */
 
 static rtx
 simplify_with_current_value_aux (exp)
      rtx exp;
 {
-  register int i;
+  int i;
   rtx cond;
 
   switch (GET_CODE (exp))
     {
     case EQ_ATTR:
-      if (MEM_VOLATILE_P (exp))
+      if (ATTR_EQ_ATTR_P (exp))
        return false_rtx;
       else
        return true_rtx;
@@ -4015,19 +4095,19 @@ simplify_with_current_value_aux (exp)
     }
 }
 \f
-/* Clear the MEM_IN_STRUCT_P flag in EXP and its subexpressions.  */
+/* Clear the ATTR_CURR_SIMPLIFIED_P flag in EXP and its subexpressions.  */
 
 static void
 clear_struct_flag (x)
      rtx x;
 {
-  register int i;
-  register int j;
-  register enum rtx_code code;
-  register const char *fmt;
+  int i;
+  int j;
+  enum rtx_code code;
+  const char *fmt;
 
-  MEM_IN_STRUCT_P (x) = 0;
-  if (RTX_UNCHANGING_P (x))
+  ATTR_CURR_SIMPLIFIED_P (x) = 0;
+  if (ATTR_IND_SIMPLIFIED_P (x))
     return;
 
   code = GET_CODE (x);
@@ -4038,6 +4118,7 @@ clear_struct_flag (x)
     case QUEUED:
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_VECTOR:
     case SYMBOL_REF:
     case CODE_LABEL:
     case PC:
@@ -4079,10 +4160,10 @@ count_sub_rtxs (x, max)
      rtx x;
      int max;
 {
-  register int i;
-  register int j;
-  register enum rtx_code code;
-  register const char *fmt;
+  int i;
+  int j;
+  enum rtx_code code;
+  const char *fmt;
   int total = 0;
 
   code = GET_CODE (x);
@@ -4093,6 +4174,7 @@ count_sub_rtxs (x, max)
     case QUEUED:
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_VECTOR:
     case SYMBOL_REF:
     case CODE_LABEL:
     case PC:
@@ -4238,7 +4320,7 @@ count_alternatives (exp)
   return 0;
 }
 \f
-/* Returns non-zero if the given expression contains an EQ_ATTR with the
+/* Returns nonzero if the given expression contains an EQ_ATTR with the
    `alternative' attribute.  */
 
 static int
@@ -4271,7 +4353,7 @@ compares_alternatives_p (exp)
   return 0;
 }
 \f
-/* Returns non-zero is INNER is contained in EXP.  */
+/* Returns nonzero is INNER is contained in EXP.  */
 
 static int
 contained_in_p (inner, exp)
@@ -4481,7 +4563,7 @@ gen_unit (def, lineno)
 /* Given a piece of RTX, print a C expression to test its truth value.
    We use AND and IOR both for logical and bit-wise operations, so
    interpret them as logical unless they are inside a comparison expression.
-   The first bit of FLAGS will be non-zero in that case.
+   The first bit of FLAGS will be nonzero in that case.
 
    Set the second bit of FLAGS to make references to attribute values use
    a cached local variable instead of calling a function.  */
@@ -4671,7 +4753,7 @@ write_test_expr (exp, flags)
       if (XSTR (exp, 1) == NULL || *XSTR (exp, 1) == '\0')
        {
          if (GET_MODE (exp) == VOIDmode)
-           fatal ("Null MATCH_OPERAND specified as test");
+           fatal ("null MATCH_OPERAND specified as test");
          else
            printf ("GET_MODE (operands[%d]) == %smode",
                    XINT (exp, 0), GET_MODE_NAME (GET_MODE (exp)));
@@ -4825,8 +4907,8 @@ static void
 walk_attr_value (exp)
      rtx exp;
 {
-  register int i, j;
-  register const char *fmt;
+  int i, j;
+  const char *fmt;
   RTX_CODE code;
 
   if (exp == NULL)
@@ -4836,7 +4918,7 @@ walk_attr_value (exp)
   switch (code)
     {
     case SYMBOL_REF:
-      if (! RTX_UNCHANGING_P (exp))
+      if (! ATTR_IND_SIMPLIFIED_P (exp))
        /* Since this is an arbitrary expression, it can look at anything.
           However, constant expressions do not depend on any particular
           insn.  */
@@ -4943,7 +5025,7 @@ write_attr_get (attr)
       return;
     }
 
-  printf ("     rtx insn;\n");
+  printf ("     rtx insn ATTRIBUTE_UNUSED;\n");
   printf ("{\n");
 
   if (GET_CODE (common_av->value) == FFS)
@@ -5194,11 +5276,11 @@ write_expr_attr_cache (p, attr)
        return 0;
 
       if (!attr->is_numeric)
-       printf ("  register enum attr_%s ", attr->name);
+       printf ("  enum attr_%s ", attr->name);
       else if (attr->unsigned_p)
-       printf ("  register unsigned int ");
+       printf ("  unsigned int ");
       else
-       printf ("  register int ");
+       printf ("  int ");
 
       printf ("attr_%s = get_attr_%s (insn);\n", attr->name, attr->name);
       return 1;
@@ -5243,7 +5325,7 @@ write_toplevel_expr (p)
       if (!attr->is_const)
        write_expr_attr_cache (p, attr);
 
-  printf ("  register unsigned long accum = 0;\n\n");
+  printf ("  unsigned long accum = 0;\n\n");
 
   while (GET_CODE (p) == IOR)
     {
@@ -5411,7 +5493,7 @@ write_indent (indent)
 }
 \f
 /* Write a subroutine that is given an insn that requires a delay slot, a
-   delay slot ordinal, and a candidate insn.  It returns non-zero if the
+   delay slot ordinal, and a candidate insn.  It returns nonzero if the
    candidate can be placed in the specified delay slot of the insn.
 
    We can write as many as three subroutines.  `eligible_for_delay'
@@ -5446,7 +5528,7 @@ write_eligible_delay (kind)
   printf ("int\n");
   printf ("eligible_for_%s (delay_insn, slot, candidate_insn, flags)\n",
          kind);
-  printf ("     rtx delay_insn;\n");
+  printf ("     rtx delay_insn ATTRIBUTE_UNUSED;\n");
   printf ("     int slot;\n");
   printf ("     rtx candidate_insn;\n");
   printf ("     int flags ATTRIBUTE_UNUSED;\n");
@@ -5575,7 +5657,7 @@ write_function_unit_info ()
      the function units.   The name is included for documentation purposes
      only.  */
 
-  printf ("struct function_unit_desc function_units[] = {\n");
+  printf ("const struct function_unit_desc function_units[] = {\n");
 
   /* Write out the descriptions in numeric order, but don't force that order
      on the list.  Doing so increases the runtime of genattrtab.c.  */
@@ -5610,6 +5692,8 @@ write_function_unit_info ()
       printf ("}, \n");
     }
 
+  if (num_units == 0)
+    printf ("{\"dummy\", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* a dummy element */");
   printf ("};\n\n");
 }
 
@@ -5621,7 +5705,7 @@ write_complex_function (unit, name, connection)
   struct attr_desc *case_attr, *attr;
   struct attr_value *av, *common_av;
   rtx value;
-  char *str;
+  char str[256];
   int using_case;
   int i;
 
@@ -5638,7 +5722,8 @@ write_complex_function (unit, name, connection)
   printf ("    {\n");
 
   /* Write the `switch' statement to get the case value.  */
-  str = (char *) alloca (strlen (unit->name) + strlen (name) + strlen (connection) + 10);
+  if (strlen (unit->name) + sizeof "*_cases" > 256)
+    abort ();
   sprintf (str, "*%s_cases", unit->name);
   case_attr = find_attr (str, 0);
   if (! case_attr)
@@ -5708,25 +5793,6 @@ write_complex_function (unit, name, connection)
 \f
 /* This page contains miscellaneous utility routines.  */
 
-/* Given a string, return the number of comma-separated elements in it.
-   Return 0 for the null string.  */
-
-static int
-n_comma_elts (s)
-     const char *s;
-{
-  int n;
-
-  if (*s == '\0')
-    return 0;
-
-  for (n = 1; *s; s++)
-    if (*s == ',')
-      n++;
-
-  return n;
-}
-
 /* Given a pointer to a (char *), return a malloc'ed string containing the
    next comma-separated element.  Advance the pointer to after the string
    scanned, or the end-of-string.  Return NULL if at end of string.  */
@@ -5735,27 +5801,18 @@ static char *
 next_comma_elt (pstr)
      const char **pstr;
 {
-  char *out_str;
-  const char *p;
+  const char *start;
 
-  if (**pstr == '\0')
-    return NULL;
-
-  /* Find end of string to compute length.  */
-  for (p = *pstr; *p != ',' && *p != '\0'; p++)
-    ;
+  start = scan_comma_elt (pstr);
 
-  out_str = attr_string (*pstr, p - *pstr);
-  *pstr = p;
-
-  if (**pstr == ',')
-    (*pstr)++;
+  if (start == NULL)
+    return NULL;
 
-  return out_str;
+  return attr_string (start, *pstr - start);
 }
 
 /* Return a `struct attr_desc' pointer for a given named attribute.  If CREATE
-   is non-zero, build a new attribute, if one does not exist.  */
+   is nonzero, build a new attribute, if one does not exist.  */
 
 static struct attr_desc *
 find_attr (name, create)
@@ -5796,7 +5853,7 @@ find_attr (name, create)
 
 /* Create internal attribute with the given default value.  */
 
-static void
+void
 make_internal_attr (name, value, special)
      const char *name;
      rtx value;
@@ -5863,7 +5920,7 @@ find_single_value (attr)
 
 /* Return (attr_value "n") */
 
-static rtx
+rtx
 make_numeric_value (n)
      int n;
 {
@@ -5900,17 +5957,17 @@ extend_range (range, min, max)
 
 static rtx
 copy_rtx_unchanging (orig)
-     register rtx orig;
+     rtx orig;
 {
 #if 0
-  register rtx copy;
-  register RTX_CODE code;
+  rtx copy;
+  RTX_CODE code;
 #endif
 
-  if (RTX_UNCHANGING_P (orig) || MEM_IN_STRUCT_P (orig))
+  if (ATTR_IND_SIMPLIFIED_P (orig) || ATTR_CURR_SIMPLIFIED_P (orig))
     return orig;
 
-  MEM_IN_STRUCT_P (orig) = 1;
+  ATTR_CURR_SIMPLIFIED_P (orig) = 1;
   return orig;
 
 #if 0
@@ -5929,10 +5986,10 @@ copy_rtx_unchanging (orig)
 
   copy = rtx_alloc (code);
   PUT_MODE (copy, GET_MODE (orig));
-  RTX_UNCHANGING_P (copy) = 1;
+  ATTR_IND_SIMPLIFIED_P (copy) = 1;
 
-  bcopy ((char *) &XEXP (orig, 0), (char *) &XEXP (copy, 0),
-        GET_RTX_LENGTH (GET_CODE (copy)) * sizeof (rtx));
+  memcpy (&XEXP (copy, 0), &XEXP (orig, 0),
+         GET_RTX_LENGTH (GET_CODE (copy)) * sizeof (rtx));
   return copy;
 #endif
 }
@@ -5990,21 +6047,9 @@ main (argc, argv)
   progname = "genattrtab";
 
   if (argc <= 1)
-    fatal ("No input file name.");
-
-#if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
-  /* Get rid of any avoidable limit on stack size.  */
-  {
-    struct rlimit rlim;
-
-    /* Set the stack limit huge so that alloca does not fail.  */
-    getrlimit (RLIMIT_STACK, &rlim);
-    rlim.rlim_cur = rlim.rlim_max;
-    setrlimit (RLIMIT_STACK, &rlim);
-  }
-#endif
+    fatal ("no input file name");
 
-  if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
+  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
     return (FATAL_EXIT_CODE);
 
   obstack_init (hash_obstack);
@@ -6015,8 +6060,8 @@ main (argc, argv)
   XWINT (true_rtx, 0) = 1;
   false_rtx = rtx_alloc (CONST_INT);
   XWINT (false_rtx, 0) = 0;
-  RTX_UNCHANGING_P (true_rtx) = RTX_UNCHANGING_P (false_rtx) = 1;
-  RTX_INTEGRATED_P (true_rtx) = RTX_INTEGRATED_P (false_rtx) = 1;
+  ATTR_IND_SIMPLIFIED_P (true_rtx) = ATTR_IND_SIMPLIFIED_P (false_rtx) = 1;
+  ATTR_PERMANENT_P (true_rtx) = ATTR_PERMANENT_P (false_rtx) = 1;
 
   alternative_name = attr_string ("alternative", strlen ("alternative"));
 
@@ -6025,6 +6070,7 @@ from the machine description file `md'.  */\n\n");
 
   /* Read the machine description.  */
 
+  initiate_automaton_gen (argc, argv);
   while (1)
     {
       int lineno;
@@ -6053,6 +6099,54 @@ from the machine description file `md'.  */\n\n");
          gen_unit (desc, lineno);
          break;
 
+       case DEFINE_CPU_UNIT:
+         gen_cpu_unit (desc);
+         break;
+         
+       case DEFINE_QUERY_CPU_UNIT:
+         gen_query_cpu_unit (desc);
+         break;
+         
+       case DEFINE_BYPASS:
+         gen_bypass (desc);
+         break;
+         
+       case EXCLUSION_SET:
+         gen_excl_set (desc);
+         break;
+         
+       case PRESENCE_SET:
+         gen_presence_set (desc);
+         break;
+         
+       case FINAL_PRESENCE_SET:
+         gen_final_presence_set (desc);
+         break;
+         
+       case ABSENCE_SET:
+         gen_absence_set (desc);
+         break;
+         
+       case FINAL_ABSENCE_SET:
+         gen_final_absence_set (desc);
+         break;
+         
+       case DEFINE_AUTOMATON:
+         gen_automaton (desc);
+         break;
+         
+       case AUTOMATA_OPTION:
+         gen_automata_option (desc);
+         break;
+         
+       case DEFINE_RESERVATION:
+         gen_reserv (desc);
+         break;
+         
+       case DEFINE_INSN_RESERVATION:
+         gen_insn_reserv (desc);
+         break;
+
        default:
          break;
        }
@@ -6077,12 +6171,19 @@ from the machine description file `md'.  */\n\n");
   if (num_delays)
     expand_delays ();
 
-  /* Expand DEFINE_FUNCTION_UNIT information into new attributes.  */
-  if (num_units)
-    expand_units ();
+  if (num_units || num_dfa_decls)
+    {
+      /* Expand DEFINE_FUNCTION_UNIT information into new attributes.  */
+      expand_units ();
+      /* Build DFA, output some functions and expand DFA information
+        into new attributes.  */
+      expand_automata ();
+    }
 
   printf ("#include \"config.h\"\n");
   printf ("#include \"system.h\"\n");
+  printf ("#include \"coretypes.h\"\n");
+  printf ("#include \"tm.h\"\n");
   printf ("#include \"rtl.h\"\n");
   printf ("#include \"tm_p.h\"\n");
   printf ("#include \"insn-config.h\"\n");
@@ -6092,6 +6193,8 @@ from the machine description file `md'.  */\n\n");
   printf ("#include \"output.h\"\n");
   printf ("#include \"insn-attr.h\"\n");
   printf ("#include \"toplev.h\"\n");
+  printf ("#include \"flags.h\"\n");
+  printf ("#include \"function.h\"\n");
   printf ("\n");
   printf ("#define operands recog_data.operand\n\n");
 
@@ -6138,7 +6241,18 @@ from the machine description file `md'.  */\n\n");
     for (attr = attrs[i]; attr; attr = attr->next)
       {
        if (! attr->is_special && ! attr->is_const)
-         write_attr_get (attr);
+         {
+           int insn_alts_p;
+
+           insn_alts_p
+             = (attr->name [0] == '*'
+                && strcmp (&attr->name [1], INSN_ALTS_FUNC_NAME) == 0);
+           if (insn_alts_p)
+             printf ("\n#if AUTOMATON_ALTS\n");
+           write_attr_get (attr);
+           if (insn_alts_p)
+             printf ("#endif\n\n");
+         }
       }
 
   /* Write out delay eligibility information, if DEFINE_DELAY present.
@@ -6153,9 +6267,14 @@ from the machine description file `md'.  */\n\n");
        write_eligible_delay ("annul_false");
     }
 
-  /* Write out information about function units.  */
-  if (num_units)
-    write_function_unit_info ();
+  if (num_units || num_dfa_decls)
+    {
+      /* Write out information about function units.  */
+      write_function_unit_info ();
+      /* Output code for pipeline hazards recognition based on DFA
+        (deterministic finite state automata.  */
+      write_automata ();
+    }
 
   /* Write out constant delay slot info */
   write_const_num_delay_slots ();