OSDN Git Service

* ChangeLog: Additional fixes for AVX2 ChangeLog entry.
[pf3gnuchains/gcc-fork.git] / gcc / genattrtab.c
index f1bbaf5..a3da978 100644 (file)
@@ -1,13 +1,14 @@
 /* Generate code from machine description to compute values of attributes.
-   Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GCC.
 
 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
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,9 +17,8 @@ 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 GCC; 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 COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 /* This program handles insn attributes and the DEFINE_DELAY and
    DEFINE_INSN_RESERVATION definitions.
@@ -90,21 +90,16 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    `in_struct' (ATTR_CURR_SIMPLIFIED_P): This rtx is fully simplified
       for the insn code currently being processed (see optimize_attrs).
    `return_val' (ATTR_PERMANENT_P): This rtx is permanent and unique
-      (see attr_rtx).
-   `volatil' (ATTR_EQ_ATTR_P): During simplify_by_exploding the value of an
-      EQ_ATTR rtx is true if !volatil and false if volatil.  */
+      (see attr_rtx).  */
 
 #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), return_val))
-#define ATTR_EQ_ATTR_P(RTX) (RTX_FLAG((RTX), volatil))
 
 #if 0
 #define strcmp_check(S1, S2) ((S1) == (S2)             \
                              ? 0                       \
-                             : (strcmp ((S1), (S2))    \
-                                ? 1                    \
-                                : (abort (), 0)))
+                             : (gcc_assert (strcmp ((S1), (S2))), 1))
 #else
 #define strcmp_check(S1, S2) ((S1) != (S2))
 #endif
@@ -114,23 +109,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "coretypes.h"
 #include "tm.h"
 #include "rtl.h"
-#include "ggc.h"
-#include "gensupport.h"
-
-#ifdef HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-/* We must include obstack.h after <sys/time.h>, to avoid lossage with
-   /usr/include/sys/stdtypes.h on Sun OS 4.x.  */
 #include "obstack.h"
 #include "errors.h"
+#include "read-md.h"
+#include "gensupport.h"
+#include "vecprim.h"
+#include "fnmatch.h"
 
-#include "genattrtab.h"
+/* Flags for make_internal_attr's `special' parameter.  */
+#define ATTR_NONE              0
+#define ATTR_SPECIAL           (1 << 0)
 
 static struct obstack obstack1, obstack2;
-struct obstack *hash_obstack = &obstack1;
-struct obstack *temp_obstack = &obstack2;
+static struct obstack *hash_obstack = &obstack1;
+static struct obstack *temp_obstack = &obstack2;
 
 /* enough space to reserve for printing out ints */
 #define MAX_DIGITS (HOST_BITS_PER_INT * 3 / 10 + 3)
@@ -147,7 +139,7 @@ struct insn_def
   struct insn_def *next;       /* Next insn in chain.  */
   rtx def;                     /* The DEFINE_...  */
   int insn_code;               /* Instruction number.  */
-  int insn_index;              /* Expression numer in file, for errors.  */
+  int insn_index;              /* Expression number in file, for errors.  */
   int lineno;                  /* Line number.  */
   int num_alternatives;                /* Number of alternatives.  */
   int vec_idx;                 /* Index of attribute vector in `def'.  */
@@ -160,9 +152,7 @@ struct insn_def
 struct insn_ent
 {
   struct insn_ent *next;       /* Next in chain.  */
-  int insn_code;               /* Instruction number.  */
-  int insn_index;              /* Index of definition in file */
-  int lineno;                  /* Line number.  */
+  struct insn_def *def;                /* Instruction definition.  */
 };
 
 /* Each value of an attribute (either constant or computed) is assigned a
@@ -183,20 +173,16 @@ struct attr_value
 struct attr_desc
 {
   char *name;                  /* Name of attribute.  */
+  const char *enum_name;       /* Enum name for DEFINE_ENUM_NAME.  */
   struct attr_desc *next;      /* Next attribute.  */
   struct attr_value *first_value; /* First value of this attribute.  */
   struct attr_value *default_val; /* Default value for this attribute.  */
   int lineno : 24;             /* Line number.  */
   unsigned is_numeric  : 1;    /* Values of this attribute are numeric.  */
-  unsigned negative_ok : 1;    /* Allow negative numeric values.  */
-  unsigned unsigned_p  : 1;    /* Make the output function unsigned int.  */
   unsigned is_const    : 1;    /* Attribute value constant for each run.  */
   unsigned is_special  : 1;    /* Don't call `write_attr_set'.  */
-  unsigned static_p    : 1;    /* Make the output function static.  */
 };
 
-#define NULL_ATTR (struct attr_desc *) NULL
-
 /* Structure for each DEFINE_DELAY.  */
 
 struct delay_desc
@@ -207,6 +193,14 @@ struct delay_desc
   int lineno;                  /* Line number.  */
 };
 
+struct attr_value_list
+{
+  struct attr_value *av;
+  struct insn_ent *ie;
+  struct attr_desc *attr;
+  struct attr_value_list *next;
+};
+
 /* Listheads of above structures.  */
 
 /* This one is indexed by the first character of the attribute name.  */
@@ -214,6 +208,7 @@ struct delay_desc
 static struct attr_desc *attrs[MAX_ATTRS_INDEX];
 static struct insn_def *defs;
 static struct delay_desc *delays;
+struct attr_value_list **insn_code_values;
 
 /* Other variables.  */
 
@@ -228,8 +223,6 @@ static int num_delays;
 static int have_annul_true, have_annul_false;
 static int num_insn_ents;
 
-int num_dfa_decls;
-
 /* Stores, for each insn code, the number of constraint alternatives.  */
 
 static int *insn_n_alternatives;
@@ -239,133 +232,67 @@ static int *insn_n_alternatives;
 
 static int *insn_alternatives;
 
-/* If nonzero, assume that the `alternative' attr has this value.
-   This is the hashed, unique string for the numeral
-   whose value is chosen alternative.  */
-
-static const char *current_alternative_string;
-
 /* Used to simplify expressions.  */
 
 static rtx true_rtx, false_rtx;
 
 /* Used to reduce calls to `strcmp' */
 
-static char *alternative_name;
+static const char *alternative_name;
 static const char *length_str;
 static const char *delay_type_str;
 static const char *delay_1_0_str;
 static const char *num_delay_slots_str;
 
-/* Indicate that REG_DEAD notes are valid if dead_or_set_p is ever
-   called.  */
-
-int reload_completed = 0;
-
-/* Some machines test `optimize' in macros called from rtlanal.c, so we need
-   to define it here.  */
-
-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)    \
   (ATTR_IND_SIMPLIFIED_P (EXP) || ATTR_CURR_SIMPLIFIED_P (EXP) ? (EXP) \
    : simplify_test_exp (EXP, INSN_CODE, INSN_INDEX))
 
-/* Simplify (eq_attr ("alternative") ...)
-   when we are working with a particular alternative.  */
-#define SIMPLIFY_ALTERNATIVE(EXP)                              \
-  if (current_alternative_string                               \
-      && GET_CODE ((EXP)) == EQ_ATTR                           \
-      && XSTR ((EXP), 0) == alternative_name)                  \
-    (EXP) = (XSTR ((EXP), 1) == current_alternative_string     \
-           ? true_rtx : false_rtx);
-
 #define DEF_ATTR_STRING(S) (attr_string ((S), strlen (S)))
 
-/* These are referenced by rtlanal.c and hence need to be defined somewhere.
-   They won't actually be used.  */
-
-rtx global_rtl[GR_MAX];
-rtx pic_offset_table_rtx;
-
-static void attr_hash_add_rtx  (int, rtx);
-static void attr_hash_add_string (int, char *);
-static rtx attr_rtx            (enum rtx_code, ...);
-static rtx attr_rtx_1          (enum rtx_code, va_list);
-static char *attr_string        (const char *, int);
-static rtx check_attr_value    (rtx, struct attr_desc *);
-static rtx convert_set_attr_alternative (rtx, struct insn_def *);
-static rtx convert_set_attr    (rtx, struct insn_def *);
-static void check_defs         (void);
-static rtx make_canonical      (struct attr_desc *, rtx);
-static struct attr_value *get_attr_value (rtx, struct attr_desc *, int);
-static rtx copy_rtx_unchanging (rtx);
-static rtx copy_boolean                (rtx);
-static void expand_delays      (void);
-static void fill_attr          (struct attr_desc *);
-static rtx substitute_address  (rtx, rtx (*) (rtx), rtx (*) (rtx));
-static void make_length_attrs  (void);
-static rtx identity_fn         (rtx);
-static rtx zero_fn             (rtx);
-static rtx one_fn              (rtx);
-static rtx max_fn              (rtx);
-static void write_length_unit_log (void);
-static rtx simplify_cond       (rtx, int, int);
-static void clear_struct_flag (rtx);
-static void remove_insn_ent  (struct attr_value *, struct insn_ent *);
-static void insert_insn_ent  (struct attr_value *, struct insn_ent *);
-static rtx insert_right_side   (enum rtx_code, rtx, rtx, int, int);
-static rtx make_alternative_compare (int);
-static int compute_alternative_mask (rtx, enum rtx_code);
-static rtx evaluate_eq_attr    (rtx, rtx, int, int);
-static rtx simplify_and_tree   (rtx, rtx *, int, int);
-static rtx simplify_or_tree    (rtx, rtx *, int, int);
-static rtx simplify_test_exp   (rtx, int, int);
-static rtx simplify_test_exp_in_temp (rtx, int, int);
-static void optimize_attrs     (void);
-static void gen_attr           (rtx, int);
-static int count_alternatives  (rtx);
-static int compares_alternatives_p (rtx);
-static int contained_in_p      (rtx, rtx);
-static void gen_insn           (rtx, int);
-static void gen_delay          (rtx, int);
-static void write_test_expr    (rtx, int);
-static int max_attr_value      (rtx, int*);
-static int or_attr_value       (rtx, int*);
-static void walk_attr_value    (rtx);
-static void write_attr_get     (struct attr_desc *);
-static rtx eliminate_known_true (rtx, rtx, int, int);
-static void write_attr_set     (struct attr_desc *, int, rtx,
-                                const char *, const char *, rtx,
-                                int, int);
-static void write_attr_case    (struct attr_desc *, struct attr_value *,
-                                int, const char *, const char *, int, rtx);
-static void write_attr_valueq  (struct attr_desc *, const char *);
-static void write_attr_value   (struct attr_desc *, rtx);
-static void write_upcase       (const char *);
-static void write_indent       (int);
-static void write_eligible_delay (const char *);
-static int write_expr_attr_cache (rtx, struct attr_desc *);
-static void write_const_num_delay_slots (void);
-static char *next_comma_elt    (const char **);
+/* Forward declarations of functions used before their definitions, only.  */
+static char *attr_string           (const char *, int);
+static char *attr_printf           (unsigned int, const char *, ...)
+  ATTRIBUTE_PRINTF_2;
+static rtx make_numeric_value      (int);
 static struct attr_desc *find_attr (const char **, int);
-static struct attr_value *find_most_used  (struct attr_desc *);
-static rtx attr_eq             (const char *, const char *);
-static const char *attr_numeral        (int);
-static int attr_equal_p                (rtx, rtx);
-static rtx attr_copy_rtx       (rtx);
-static int attr_rtx_cost       (rtx);
-static bool attr_alt_subset_p (rtx, rtx);
+static rtx mk_attr_alt             (int);
+static char *next_comma_elt       (const char **);
+static rtx insert_right_side      (enum rtx_code, rtx, rtx, int, int);
+static rtx copy_boolean                   (rtx);
+static int compares_alternatives_p (rtx);
+static void make_internal_attr     (const char *, rtx, int);
+static void insert_insn_ent        (struct attr_value *, struct insn_ent *);
+static void walk_attr_value       (rtx);
+static int max_attr_value         (rtx, int*);
+static int min_attr_value         (rtx, int*);
+static int or_attr_value          (rtx, int*);
+static rtx simplify_test_exp      (rtx, int, int);
+static rtx simplify_test_exp_in_temp (rtx, int, int);
+static rtx copy_rtx_unchanging    (rtx);
+static bool attr_alt_subset_p      (rtx, rtx);
 static bool attr_alt_subset_of_compl_p (rtx, rtx);
-static rtx attr_alt_intersection (rtx, rtx);
-static rtx attr_alt_union (rtx, rtx);
-static rtx attr_alt_complement (rtx);
-static bool attr_alt_bit_p (rtx, int);
-static rtx mk_attr_alt (int);
-
-#define oballoc(size) obstack_alloc (hash_obstack, size)
+static void clear_struct_flag      (rtx);
+static void write_attr_valueq     (struct attr_desc *, const char *);
+static struct attr_value *find_most_used  (struct attr_desc *);
+static void write_attr_set        (struct attr_desc *, int, rtx,
+                                   const char *, const char *, rtx,
+                                   int, int, unsigned int);
+static void write_attr_case       (struct attr_desc *, struct attr_value *,
+                                   int, const char *, const char *, int, rtx);
+static void write_attr_value      (struct attr_desc *, rtx);
+static void write_upcase          (const char *);
+static void write_indent          (int);
+static rtx identity_fn            (rtx);
+static rtx zero_fn                (rtx);
+static rtx one_fn                 (rtx);
+static rtx max_fn                 (rtx);
+static rtx min_fn                 (rtx);
+
+#define oballoc(T) XOBNEW (hash_obstack, T)
+#define oballocvec(T, N) XOBNEWVEC (hash_obstack, T, (N))
 
 /* Hash table for sharing RTL and strings.  */
 
@@ -392,11 +319,11 @@ struct attr_hash
    for each.  */
 
 #define RTL_HASH_SIZE 4093
-struct attr_hash *attr_hash_table[RTL_HASH_SIZE];
+static struct attr_hash *attr_hash_table[RTL_HASH_SIZE];
 
 /* Here is how primitive or already-shared RTL's hash
    codes are made.  */
-#define RTL_HASH(RTL) ((long) (RTL) & 0777777)
+#define RTL_HASH(RTL) ((intptr_t) (RTL) & 0777777)
 
 /* Add an entry to the hash table for RTL with hash code HASHCODE.  */
 
@@ -405,7 +332,7 @@ attr_hash_add_rtx (int hashcode, rtx rtl)
 {
   struct attr_hash *h;
 
-  h = obstack_alloc (hash_obstack, sizeof (struct attr_hash));
+  h = XOBNEW (hash_obstack, struct attr_hash);
   h->hashcode = hashcode;
   h->u.rtl = rtl;
   h->next = attr_hash_table[hashcode % RTL_HASH_SIZE];
@@ -419,7 +346,7 @@ attr_hash_add_string (int hashcode, char *str)
 {
   struct attr_hash *h;
 
-  h = obstack_alloc (hash_obstack, sizeof (struct attr_hash));
+  h = XOBNEW (hash_obstack, struct attr_hash);
   h->hashcode = -hashcode;
   h->u.str = str;
   h->next = attr_hash_table[hashcode % RTL_HASH_SIZE];
@@ -598,7 +525,7 @@ attr_rtx_1 (enum rtx_code code, va_list p)
              break;
 
            default:
-             abort ();
+             gcc_unreachable ();
            }
        }
       return rt_val;
@@ -627,7 +554,7 @@ attr_rtx (enum rtx_code code, ...)
 
    rtx attr_printf (len, format, [arg1, ..., argn])  */
 
-char *
+static char *
 attr_printf (unsigned int len, const char *fmt, ...)
 {
   char str[256];
@@ -635,8 +562,7 @@ attr_printf (unsigned int len, const char *fmt, ...)
 
   va_start (p, fmt);
 
-  if (len > sizeof str - 1) /* Leave room for \0.  */
-    abort ();
+  gcc_assert (len < sizeof str); /* Leave room for \0.  */
 
   vsprintf (str, fmt, p);
   va_end (p);
@@ -669,7 +595,7 @@ attr_string (const char *str, int len)
 
   /* Compute the hash code.  */
   hashcode = (len + 1) * 613 + (unsigned) str[0];
-  for (i = 1; i <= len; i += 2)
+  for (i = 1; i < len; i += 2)
     hashcode = ((hashcode * 613) + (unsigned) str[i]);
   if (hashcode < 0)
     hashcode = -hashcode;
@@ -681,7 +607,7 @@ attr_string (const char *str, int len)
       return h->u.str;                 /* <-- return if found.  */
 
   /* Not found; create a permanent copy and add it to the hash table.  */
-  new_str = obstack_alloc (hash_obstack, len + 1);
+  new_str = XOBNEWVAR (hash_obstack, char, len + 1);
   memcpy (new_str, str, len);
   new_str[len] = '\0';
   attr_hash_add_string (hashcode, new_str);
@@ -739,7 +665,6 @@ attr_copy_rtx (rtx orig)
   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));
 
@@ -779,7 +704,7 @@ attr_copy_rtx (rtx orig)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
   return copy;
@@ -799,7 +724,7 @@ attr_copy_rtx (rtx orig)
 
    Return the new expression, if any.  */
 
-rtx
+static rtx
 check_attr_test (rtx exp, int is_const, int lineno)
 {
   struct attr_desc *attr;
@@ -964,19 +889,17 @@ check_attr_value (rtx exp, struct attr_desc *attr)
     case CONST_INT:
       if (attr && ! attr->is_numeric)
        {
-         message_with_line (attr->lineno,
-                            "CONST_INT not valid for non-numeric attribute %s",
-                            attr->name);
-         have_error = 1;
+         error_with_line (attr->lineno,
+                          "CONST_INT not valid for non-numeric attribute %s",
+                          attr->name);
          break;
        }
 
-      if (INTVAL (exp) < 0 && ! attr->negative_ok)
+      if (INTVAL (exp) < 0)
        {
-         message_with_line (attr->lineno,
-                            "negative numeric value specified for attribute %s",
-                            attr->name);
-         have_error = 1;
+         error_with_line (attr->lineno,
+                          "negative numeric value specified for attribute %s",
+                          attr->name);
          break;
        }
       break;
@@ -988,15 +911,12 @@ check_attr_value (rtx exp, struct attr_desc *attr)
       if (attr == 0 || attr->is_numeric)
        {
          p = XSTR (exp, 0);
-         if (attr && attr->negative_ok && *p == '-')
-           p++;
          for (; *p; p++)
            if (! ISDIGIT (*p))
              {
-               message_with_line (attr ? attr->lineno : 0,
-                                  "non-numeric value for numeric attribute %s",
-                                  attr ? attr->name : "internal");
-               have_error = 1;
+               error_with_line (attr ? attr->lineno : 0,
+                                "non-numeric value for numeric attribute %s",
+                                attr ? attr->name : "internal");
                break;
              }
          break;
@@ -1008,12 +928,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
          break;
 
       if (av == NULL)
-       {
-         message_with_line (attr->lineno,
-                            "unknown value `%s' for `%s' attribute",
-                            XSTR (exp, 0), attr ? attr->name : "internal");
-         have_error = 1;
-       }
+       error_with_line (attr->lineno,
+                        "unknown value `%s' for `%s' attribute",
+                        XSTR (exp, 0), attr ? attr->name : "internal");
       break;
 
     case IF_THEN_ELSE:
@@ -1031,10 +948,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
     case MOD:
       if (attr && !attr->is_numeric)
        {
-         message_with_line (attr->lineno,
-                            "invalid operation `%s' for non-numeric attribute value",
-                            GET_RTX_NAME (GET_CODE (exp)));
-         have_error = 1;
+         error_with_line (attr->lineno,
+                          "invalid operation `%s' for non-numeric"
+                          " attribute value", GET_RTX_NAME (GET_CODE (exp)));
          break;
        }
       /* Fall through.  */
@@ -1050,15 +966,15 @@ check_attr_value (rtx exp, struct attr_desc *attr)
     case CTZ:
     case POPCOUNT:
     case PARITY:
+    case BSWAP:
       XEXP (exp, 0) = check_attr_value (XEXP (exp, 0), attr);
       break;
 
     case COND:
       if (XVECLEN (exp, 0) % 2 != 0)
        {
-         message_with_line (attr->lineno,
-                            "first operand of COND must have even length");
-         have_error = 1;
+         error_with_line (attr->lineno,
+                          "first operand of COND must have even length");
          break;
        }
 
@@ -1078,28 +994,18 @@ check_attr_value (rtx exp, struct attr_desc *attr)
       {
        struct attr_desc *attr2 = find_attr (&XSTR (exp, 0), 0);
        if (attr2 == NULL)
-         {
-           message_with_line (attr ? attr->lineno : 0,
-                              "unknown attribute `%s' in ATTR",
-                              XSTR (exp, 0));
-           have_error = 1;
-         }
+         error_with_line (attr ? attr->lineno : 0,
+                          "unknown attribute `%s' in ATTR",
+                          XSTR (exp, 0));
        else if (attr && attr->is_const && ! attr2->is_const)
-         {
-           message_with_line (attr->lineno,
-               "non-constant attribute `%s' referenced from `%s'",
-               XSTR (exp, 0), attr->name);
-           have_error = 1;
-         }
+         error_with_line (attr->lineno,
+                          "non-constant attribute `%s' referenced from `%s'",
+                          XSTR (exp, 0), attr->name);
        else if (attr
-                && (attr->is_numeric != attr2->is_numeric
-                    || (! attr->negative_ok && attr2->negative_ok)))
-         {
-           message_with_line (attr->lineno,
-               "numeric attribute mismatch calling `%s' from `%s'",
-               XSTR (exp, 0), attr->name);
-           have_error = 1;
-         }
+                && attr->is_numeric != attr2->is_numeric)
+         error_with_line (attr->lineno,
+                          "numeric attribute mismatch calling `%s' from `%s'",
+                          XSTR (exp, 0), attr->name);
       }
       break;
 
@@ -1110,10 +1016,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
       return attr_rtx (SYMBOL_REF, XSTR (exp, 0));
 
     default:
-      message_with_line (attr ? attr->lineno : 0,
-                        "invalid operation `%s' for attribute value",
-                        GET_RTX_NAME (GET_CODE (exp)));
-      have_error = 1;
+      error_with_line (attr ? attr->lineno : 0,
+                      "invalid operation `%s' for attribute value",
+                      GET_RTX_NAME (GET_CODE (exp)));
       break;
     }
 
@@ -1121,7 +1026,7 @@ check_attr_value (rtx exp, struct attr_desc *attr)
 }
 
 /* Given an SET_ATTR_ALTERNATIVE expression, convert to the canonical SET.
-   It becomes a COND with each test being (eq_attr "alternative "n") */
+   It becomes a COND with each test being (eq_attr "alternative" "n") */
 
 static rtx
 convert_set_attr_alternative (rtx exp, struct insn_def *id)
@@ -1132,9 +1037,8 @@ convert_set_attr_alternative (rtx exp, struct insn_def *id)
 
   if (XVECLEN (exp, 1) != num_alt)
     {
-      message_with_line (id->lineno,
-                        "bad number of entries in SET_ATTR_ALTERNATIVE");
-      have_error = 1;
+      error_with_line (id->lineno,
+                      "bad number of entries in SET_ATTR_ALTERNATIVE");
       return NULL_RTX;
     }
 
@@ -1213,8 +1117,7 @@ check_defs (void)
            case SET:
              if (GET_CODE (XEXP (value, 0)) != ATTR)
                {
-                 message_with_line (id->lineno, "bad attribute set");
-                 have_error = 1;
+                 error_with_line (id->lineno, "bad attribute set");
                  value = NULL_RTX;
                }
              break;
@@ -1228,9 +1131,8 @@ check_defs (void)
              break;
 
            default:
-             message_with_line (id->lineno, "invalid attribute code %s",
-                                GET_RTX_NAME (GET_CODE (value)));
-             have_error = 1;
+             error_with_line (id->lineno, "invalid attribute code %s",
+                              GET_RTX_NAME (GET_CODE (value)));
              value = NULL_RTX;
            }
          if (value == NULL_RTX)
@@ -1238,9 +1140,8 @@ check_defs (void)
 
          if ((attr = find_attr (&XSTR (XEXP (value, 0), 0), 0)) == NULL)
            {
-             message_with_line (id->lineno, "unknown attribute %s",
-                                XSTR (XEXP (value, 0), 0));
-             have_error = 1;
+             error_with_line (id->lineno, "unknown attribute %s",
+                              XSTR (XEXP (value, 0), 0));
              continue;
            }
 
@@ -1377,10 +1278,10 @@ get_attr_value (rtx value, struct attr_desc *attr, int insn_code)
   for (av = attr->first_value; av; av = av->next)
     if (rtx_equal_p (value, av->value)
        && (num_alt == 0 || av->first_insn == NULL
-           || insn_alternatives[av->first_insn->insn_code]))
+           || insn_alternatives[av->first_insn->def->insn_code]))
       return av;
 
-  av = oballoc (sizeof (struct attr_value));
+  av = oballoc (struct attr_value);
   av->value = value;
   av->next = attr->first_value;
   attr->first_value = av;
@@ -1523,9 +1424,8 @@ fill_attr (struct attr_desc *attr)
       else
        av = get_attr_value (value, attr, id->insn_code);
 
-      ie = oballoc (sizeof (struct insn_ent));
-      ie->insn_code = id->insn_code;
-      ie->insn_index = id->insn_code;
+      ie = oballoc (struct insn_ent);
+      ie->def = id;
       insert_insn_ent (av, ie);
     }
 }
@@ -1615,11 +1515,14 @@ make_length_attrs (void)
   static const char *new_names[] =
     {
       "*insn_default_length",
+      "*insn_min_length",
       "*insn_variable_length_p",
       "*insn_current_length"
     };
-  static rtx (*const no_address_fn[]) (rtx) = {identity_fn, zero_fn, zero_fn};
-  static rtx (*const address_fn[]) (rtx) = {max_fn, one_fn, identity_fn};
+  static rtx (*const no_address_fn[]) (rtx)
+    = {identity_fn,identity_fn, zero_fn, zero_fn};
+  static rtx (*const address_fn[]) (rtx)
+    = {max_fn, min_fn, one_fn, identity_fn};
   size_t i;
   struct attr_desc *length_attr, *new_attr;
   struct attr_value *av, *new_av;
@@ -1651,10 +1554,9 @@ make_length_attrs (void)
            new_av = get_attr_value (substitute_address (av->value,
                                                         no_address_fn[i],
                                                         address_fn[i]),
-                                    new_attr, ie->insn_code);
-           new_ie = oballoc (sizeof (struct insn_ent));
-           new_ie->insn_code = ie->insn_code;
-           new_ie->insn_index = ie->insn_index;
+                                    new_attr, ie->def->insn_code);
+           new_ie = oballoc (struct insn_ent);
+           new_ie->def = ie->def;
            insert_insn_ent (new_av, new_ie);
          }
     }
@@ -1687,6 +1589,13 @@ max_fn (rtx exp)
   return make_numeric_value (max_attr_value (exp, &unknown));
 }
 
+static rtx
+min_fn (rtx exp)
+{
+  int unknown;
+  return make_numeric_value (min_attr_value (exp, &unknown));
+}
+
 static void
 write_length_unit_log (void)
 {
@@ -1711,7 +1620,7 @@ write_length_unit_log (void)
       for (length_unit_log = 0; length_or & 1; length_or >>= 1)
        length_unit_log++;
     }
-  printf ("int length_unit_log = %u;\n", length_unit_log);
+  printf ("EXPORTED_CONST int length_unit_log = %u;\n", length_unit_log);
 }
 
 /* Take a COND expression and see if any of the conditions in it can be
@@ -1731,7 +1640,7 @@ simplify_cond (rtx exp, int insn_code, int insn_index)
   rtx defval = XEXP (exp, 1);
   rtx new_defval = XEXP (exp, 1);
   int len = XVECLEN (exp, 0);
-  rtx *tests = xmalloc (len * sizeof (rtx));
+  rtx *tests = XNEWVEC (rtx, len);
   int allsame = 1;
   rtx ret;
 
@@ -1854,7 +1763,7 @@ remove_insn_ent (struct attr_value *av, struct insn_ent *ie)
     }
 
   av->num_insns--;
-  if (ie->insn_code == -1)
+  if (ie->def->insn_code == -1)
     av->has_asm_insn = 0;
 
   num_insn_ents--;
@@ -1868,7 +1777,7 @@ insert_insn_ent (struct attr_value *av, struct insn_ent *ie)
   ie->next = av->first_insn;
   av->first_insn = ie;
   av->num_insns++;
-  if (ie->insn_code == -1)
+  if (ie->def->insn_code == -1)
     av->has_asm_insn = 1;
 
   num_insn_ents++;
@@ -1920,11 +1829,11 @@ insert_right_side (enum rtx_code code, rtx exp, rtx term, int insn_code, int ins
 
   if (GET_CODE (exp) == code)
     {
-      rtx new = insert_right_side (code, XEXP (exp, 1),
-                                  term, insn_code, insn_index);
-      if (new != XEXP (exp, 1))
+      rtx new_rtx = insert_right_side (code, XEXP (exp, 1),
+                                      term, insn_code, insn_index);
+      if (new_rtx != XEXP (exp, 1))
        /* Make a copy of this expression and call recursively.  */
-       newexp = attr_rtx (code, XEXP (exp, 0), new);
+       newexp = attr_rtx (code, XEXP (exp, 0), new_rtx);
       else
        newexp = exp;
     }
@@ -1995,50 +1904,80 @@ make_alternative_compare (int mask)
    computation.  If a test condition involves an address, we leave the EQ_ATTR
    intact because addresses are only valid for the `length' attribute.
 
-   EXP is the EQ_ATTR expression and VALUE is the value of that attribute
-   for the insn corresponding to INSN_CODE and INSN_INDEX.  */
+   EXP is the EQ_ATTR expression and ATTR is the attribute to which
+   it refers.  VALUE is the value of that attribute for the insn
+   corresponding to INSN_CODE and INSN_INDEX.  */
 
 static rtx
-evaluate_eq_attr (rtx exp, rtx value, int insn_code, int insn_index)
+evaluate_eq_attr (rtx exp, struct attr_desc *attr, rtx value,
+                 int insn_code, int insn_index)
 {
   rtx orexp, andexp;
   rtx right;
   rtx newexp;
   int i;
 
-  if (GET_CODE (value) == CONST_STRING)
+  while (GET_CODE (value) == ATTR)
     {
+      struct attr_value *av = NULL;
+
+      attr = find_attr (&XSTR (value, 0), 0);
+
+      if (insn_code_values)
+        {
+          struct attr_value_list *iv;
+          for (iv = insn_code_values[insn_code]; iv; iv = iv->next)
+            if (iv->attr == attr)
+              {
+                av = iv->av;
+                break;
+              }
+        }
+      else
+        {
+          struct insn_ent *ie;
+          for (av = attr->first_value; av; av = av->next)
+            for (ie = av->first_insn; ie; ie = ie->next)
+              if (ie->def->insn_code == insn_code)
+                goto got_av;
+        }
+      if (av)
+        {
+        got_av:
+          value = av->value;
+        }
+    }
+
+  switch (GET_CODE (value))
+    {
+    case CONST_STRING:
       if (! strcmp_check (XSTR (value, 0), XSTR (exp, 1)))
        newexp = true_rtx;
       else
        newexp = false_rtx;
-    }
-  else if (GET_CODE (value) == SYMBOL_REF)
-    {
-      char *p;
-      char string[256];
-
-      if (GET_CODE (exp) != EQ_ATTR)
-       abort ();
-
-      if (strlen (XSTR (exp, 0)) + strlen (XSTR (exp, 1)) + 2 > 256)
-       abort ();
+      break;
 
-      strcpy (string, XSTR (exp, 0));
-      strcat (string, "_");
-      strcat (string, XSTR (exp, 1));
-      for (p = string; *p; p++)
-       *p = TOUPPER (*p);
+    case SYMBOL_REF:
+      {
+       const char *prefix;
+       char *string, *p;
+
+       gcc_assert (GET_CODE (exp) == EQ_ATTR);
+       prefix = attr->enum_name ? attr->enum_name : attr->name;
+       string = ACONCAT ((prefix, "_", XSTR (exp, 1), NULL));
+       for (p = string; *p; p++)
+         *p = TOUPPER (*p);
+
+       newexp = attr_rtx (EQ, value,
+                          attr_rtx (SYMBOL_REF,
+                                    DEF_ATTR_STRING (string)));
+       break;
+      }
 
-      newexp = attr_rtx (EQ, value,
-                        attr_rtx (SYMBOL_REF,
-                                  DEF_ATTR_STRING (string)));
-    }
-  else if (GET_CODE (value) == COND)
-    {
-      /* We construct an IOR of all the cases for which the requested attribute
-        value is present.  Since we start with FALSE, if it is not present,
-        FALSE will be returned.
+    case COND:
+      /* We construct an IOR of all the cases for which the
+        requested attribute value is present.  Since we start with
+        FALSE, if it is not present, FALSE will be returned.
 
         Each case is the AND of the NOT's of the previous conditions with the
         current condition; in the default case the current condition is TRUE.
@@ -2051,20 +1990,15 @@ evaluate_eq_attr (rtx exp, rtx value, int insn_code, int insn_index)
       orexp = false_rtx;
       andexp = true_rtx;
 
-      if (current_alternative_string)
-       clear_struct_flag (value);
-
       for (i = 0; i < XVECLEN (value, 0); i += 2)
        {
-         rtx this = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
-                                               insn_code, insn_index);
-
-         SIMPLIFY_ALTERNATIVE (this);
+         rtx this_cond = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
+                                                   insn_code, insn_index);
 
-         right = insert_right_side (AND, andexp, this,
+         right = insert_right_side (AND, andexp, this_cond,
                                     insn_code, insn_index);
          right = insert_right_side (AND, right,
-                                    evaluate_eq_attr (exp,
+                                    evaluate_eq_attr (exp, attr,
                                                       XVECEXP (value, 0,
                                                                i + 1),
                                                       insn_code, insn_index),
@@ -2073,20 +2007,22 @@ evaluate_eq_attr (rtx exp, rtx value, int insn_code, int insn_index)
                                     insn_code, insn_index);
 
          /* Add this condition into the AND expression.  */
-         newexp = attr_rtx (NOT, this);
+         newexp = attr_rtx (NOT, this_cond);
          andexp = insert_right_side (AND, andexp, newexp,
                                      insn_code, insn_index);
        }
 
       /* Handle the default case.  */
       right = insert_right_side (AND, andexp,
-                                evaluate_eq_attr (exp, XEXP (value, 1),
+                                evaluate_eq_attr (exp, attr, XEXP (value, 1),
                                                   insn_code, insn_index),
                                 insn_code, insn_index);
       newexp = insert_right_side (IOR, orexp, right, insn_code, insn_index);
+      break;
+
+    default:
+      gcc_unreachable ();
     }
-  else
-    abort ();
 
   /* If uses an address, must return original expression.  But set the
      ATTR_IND_SIMPLIFIED_P bit so we don't try to simplify it again.  */
@@ -2096,7 +2032,6 @@ evaluate_eq_attr (rtx exp, rtx value, int insn_code, int insn_index)
 
   if (address_used)
     {
-      /* This had `&& current_alternative_string', which seems to be wrong.  */
       if (! ATTR_IND_SIMPLIFIED_P (exp))
        return copy_rtx_unchanging (exp);
       return exp;
@@ -2184,7 +2119,7 @@ simplify_and_tree (rtx exp, rtx *pterm, int insn_code, int insn_index)
 
       if (attr_alt_subset_p (exp, *pterm))
        *pterm = true_rtx;
-       
+
       return exp;
     }
 
@@ -2405,13 +2340,14 @@ attr_alt_subset_p (rtx s1, rtx s2)
       return !(XINT (s2, 0) &~ XINT (s1, 0));
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
 /* Returns true if S1 is a subset of complement of S2.  */
 
-static bool attr_alt_subset_of_compl_p (rtx s1, rtx s2)
+static bool
+attr_alt_subset_of_compl_p (rtx s1, rtx s2)
 {
   switch ((XINT (s1, 1) << 1) | XINT (s2, 1))
     {
@@ -2428,7 +2364,7 @@ static bool attr_alt_subset_of_compl_p (rtx s1, rtx s2)
       return false;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -2454,7 +2390,7 @@ attr_alt_intersection (rtx s1, rtx s2)
       XINT (result, 0) = XINT (s1, 0) | XINT (s2, 0);
       break;
     default:
-      abort ();
+      gcc_unreachable ();
     }
   XINT (result, 1) = XINT (s1, 1) & XINT (s2, 1);
 
@@ -2483,7 +2419,7 @@ attr_alt_union (rtx s1, rtx s2)
       XINT (result, 0) = XINT (s1, 0) & XINT (s2, 0);
       break;
     default:
-      abort ();
+      gcc_unreachable ();
     }
 
   XINT (result, 1) = XINT (s1, 1) | XINT (s2, 1);
@@ -2503,14 +2439,6 @@ attr_alt_complement (rtx s)
   return result;
 }
 
-/* Tests whether a bit B belongs to the set represented by S.  */
-
-static bool
-attr_alt_bit_p (rtx s, int b)
-{
-  return XINT (s, 1) ^ ((XINT (s, 0) >> b) & 1);
-}
-
 /* Return EQ_ATTR_ALT expression representing set containing elements set
    in E.  */
 
@@ -2541,6 +2469,7 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
   struct attr_desc *attr;
   struct attr_value *av;
   struct insn_ent *ie;
+  struct attr_value_list *iv;
   int i;
   rtx newexp = exp;
   bool left_alt, right_alt;
@@ -2553,12 +2482,10 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
     {
     case AND:
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (left == false_rtx)
        return false_rtx;
       right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (right);
-      if (left == false_rtx)
+      if (right == false_rtx)
        return false_rtx;
 
       if (GET_CODE (left) == EQ_ATTR_ALT
@@ -2659,11 +2586,9 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
 
     case IOR:
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (left == true_rtx)
        return true_rtx;
       right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (right);
       if (right == true_rtx)
        return true_rtx;
 
@@ -2757,12 +2682,10 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
        {
          left = SIMPLIFY_TEST_EXP (XEXP (XEXP (exp, 0), 0),
                                    insn_code, insn_index);
-         SIMPLIFY_ALTERNATIVE (left);
          return left;
        }
 
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (GET_CODE (left) == NOT)
        return XEXP (left, 0);
 
@@ -2801,18 +2724,11 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
       break;
 
     case EQ_ATTR_ALT:
-      if (current_alternative_string)
-       return attr_alt_bit_p (exp, atoi (current_alternative_string)) ? true_rtx : false_rtx;
-
       if (!XINT (exp, 0))
        return XINT (exp, 1) ? true_rtx : false_rtx;
       break;
 
     case EQ_ATTR:
-      if (current_alternative_string && XSTR (exp, 0) == alternative_name)
-       return (XSTR (exp, 1) == current_alternative_string
-               ? true_rtx : false_rtx);
-
       if (XSTR (exp, 0) == alternative_name)
        {
          newexp = mk_attr_alt (1 << atoi (XSTR (exp, 1)));
@@ -2822,18 +2738,39 @@ simplify_test_exp (rtx exp, int insn_code, int 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.  */
-      if (XSTR (exp, 0) != alternative_name
+      if (insn_code >= 0
          && (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)
-             {
-               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;
-             }
+       {
+         rtx x;
+
+         av = NULL;
+         if (insn_code_values)
+           {
+             for (iv = insn_code_values[insn_code]; iv; iv = iv->next)
+               if (iv->attr == attr)
+                 {
+                   av = iv->av;
+                   break;
+                 }
+           }
+         else
+           {
+             for (av = attr->first_value; av; av = av->next)
+               for (ie = av->first_insn; ie; ie = ie->next)
+                 if (ie->def->insn_code == insn_code)
+                   goto got_av;
+           }
+
+         if (av)
+           {
+           got_av:
+             x = evaluate_eq_attr (exp, attr, 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:
@@ -2843,7 +2780,7 @@ simplify_test_exp (rtx exp, int insn_code, int insn_index)
   /* We have already simplified this expression.  Simplifying it again
      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.  */
+  if (insn_code != -2
       && ! ATTR_IND_SIMPLIFIED_P (newexp))
     return copy_rtx_unchanging (newexp);
 
@@ -2862,14 +2799,6 @@ optimize_attrs (void)
   struct insn_ent *ie;
   rtx newexp;
   int i;
-  struct attr_value_list
-  {
-    struct attr_value *av;
-    struct insn_ent *ie;
-    struct attr_desc *attr;
-    struct attr_value_list *next;
-  };
-  struct attr_value_list **insn_code_values;
   struct attr_value_list *ivbuf;
   struct attr_value_list *iv;
 
@@ -2880,13 +2809,12 @@ optimize_attrs (void)
     return;
 
   /* Make 2 extra elements, for "code" values -2 and -1.  */
-  insn_code_values = xcalloc ((insn_code_number + 2),
-                             sizeof (struct attr_value_list *));
+  insn_code_values = XCNEWVEC (struct attr_value_list *, insn_code_number + 2);
 
   /* Offset the table address so we can index by -2 or -1.  */
   insn_code_values += 2;
 
-  iv = ivbuf = xmalloc (num_insn_ents * sizeof (struct attr_value_list));
+  iv = ivbuf = XNEWVEC (struct attr_value_list, num_insn_ents);
 
   for (i = 0; i < MAX_ATTRS_INDEX; i++)
     for (attr = attrs[i]; attr; attr = attr->next)
@@ -2896,14 +2824,13 @@ optimize_attrs (void)
            iv->attr = attr;
            iv->av = av;
            iv->ie = ie;
-           iv->next = insn_code_values[ie->insn_code];
-           insn_code_values[ie->insn_code] = iv;
+           iv->next = insn_code_values[ie->def->insn_code];
+           insn_code_values[ie->def->insn_code] = iv;
            iv++;
          }
 
   /* Sanity check on num_insn_ents.  */
-  if (iv != ivbuf + num_insn_ents)
-    abort ();
+  gcc_assert (iv == ivbuf + num_insn_ents);
 
   /* Process one insn code at a time.  */
   for (i = -2; i < insn_code_number; i++)
@@ -2927,8 +2854,8 @@ optimize_attrs (void)
          newexp = av->value;
          while (GET_CODE (newexp) == COND)
            {
-             rtx newexp2 = simplify_cond (newexp, ie->insn_code,
-                                          ie->insn_index);
+             rtx newexp2 = simplify_cond (newexp, ie->def->insn_code,
+                                          ie->def->insn_index);
              if (newexp2 == newexp)
                break;
              newexp = newexp2;
@@ -2939,7 +2866,7 @@ optimize_attrs (void)
            {
              newexp = attr_copy_rtx (newexp);
              remove_insn_ent (av, ie);
-             av = get_attr_value (newexp, attr, ie->insn_code);
+             av = get_attr_value (newexp, attr, ie->def->insn_code);
              iv->av = av;
              insert_insn_ent (av, ie);
            }
@@ -2948,6 +2875,7 @@ optimize_attrs (void)
 
   free (ivbuf);
   free (insn_code_values - 2);
+  insn_code_values = NULL;
 }
 
 /* Clear the ATTR_CURR_SIMPLIFIED_P flag in EXP and its subexpressions.  */
@@ -3005,13 +2933,30 @@ clear_struct_flag (rtx x)
     }
 }
 
-/* Create table entries for DEFINE_ATTR.  */
+/* Add attribute value NAME to the beginning of ATTR's list.  */
+
+static void
+add_attr_value (struct attr_desc *attr, const char *name)
+{
+  struct attr_value *av;
+
+  av = oballoc (struct attr_value);
+  av->value = attr_rtx (CONST_STRING, name);
+  av->next = attr->first_value;
+  attr->first_value = av;
+  av->first_insn = NULL;
+  av->num_insns = 0;
+  av->has_asm_insn = 0;
+}
+
+/* Create table entries for DEFINE_ATTR or DEFINE_ENUM_ATTR.  */
 
 static void
 gen_attr (rtx exp, int lineno)
 {
+  struct enum_type *et;
+  struct enum_value *ev;
   struct attr_desc *attr;
-  struct attr_value *av;
   const char *name_ptr;
   char *p;
 
@@ -3020,51 +2965,45 @@ gen_attr (rtx exp, int lineno)
   attr = find_attr (&XSTR (exp, 0), 1);
   if (attr->default_val)
     {
-      message_with_line (lineno, "duplicate definition for attribute %s",
-                        attr->name);
+      error_with_line (lineno, "duplicate definition for attribute %s",
+                      attr->name);
       message_with_line (attr->lineno, "previous definition");
-      have_error = 1;
       return;
     }
   attr->lineno = lineno;
 
-  if (*XSTR (exp, 1) == '\0')
+  if (GET_CODE (exp) == DEFINE_ENUM_ATTR)
+    {
+      attr->enum_name = XSTR (exp, 1);
+      et = lookup_enum_type (XSTR (exp, 1));
+      if (!et || !et->md_p)
+       error_with_line (lineno, "No define_enum called `%s' defined",
+                        attr->name);
+      for (ev = et->values; ev; ev = ev->next)
+       add_attr_value (attr, ev->name);
+    }
+  else if (*XSTR (exp, 1) == '\0')
     attr->is_numeric = 1;
   else
     {
       name_ptr = XSTR (exp, 1);
       while ((p = next_comma_elt (&name_ptr)) != NULL)
-       {
-         av = oballoc (sizeof (struct attr_value));
-         av->value = attr_rtx (CONST_STRING, p);
-         av->next = attr->first_value;
-         attr->first_value = av;
-         av->first_insn = NULL;
-         av->num_insns = 0;
-         av->has_asm_insn = 0;
-       }
+       add_attr_value (attr, p);
     }
 
   if (GET_CODE (XEXP (exp, 2)) == CONST)
     {
       attr->is_const = 1;
       if (attr->is_numeric)
-       {
-         message_with_line (lineno,
-                            "constant attributes may not take numeric values");
-         have_error = 1;
-       }
+       error_with_line (lineno,
+                        "constant attributes may not take numeric values");
 
       /* Get rid of the CONST node.  It is allowed only at top-level.  */
       XEXP (exp, 2) = XEXP (XEXP (exp, 2), 0);
     }
 
   if (! strcmp_check (attr->name, length_str) && ! attr->is_numeric)
-    {
-      message_with_line (lineno,
-                        "`length' attribute must take numeric values");
-      have_error = 1;
-    }
+    error_with_line (lineno, "`length' attribute must take numeric values");
 
   /* Set up the default value.  */
   XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr);
@@ -3141,37 +3080,6 @@ compares_alternatives_p (rtx exp)
   return 0;
 }
 
-/* Returns nonzero is INNER is contained in EXP.  */
-
-static int
-contained_in_p (rtx inner, rtx exp)
-{
-  int i, j;
-  const char *fmt;
-
-  if (rtx_equal_p (inner, exp))
-    return 1;
-
-  for (i = 0, fmt = GET_RTX_FORMAT (GET_CODE (exp));
-       i < GET_RTX_LENGTH (GET_CODE (exp)); i++)
-    switch (*fmt++)
-      {
-      case 'e':
-      case 'u':
-       if (contained_in_p (inner, XEXP (exp, i)))
-         return 1;
-       break;
-
-      case 'E':
-       for (j = 0; j < XVECLEN (exp, i); j++)
-         if (contained_in_p (inner, XVECEXP (exp, i, j)))
-           return 1;
-       break;
-      }
-
-  return 0;
-}
-
 /* Process DEFINE_PEEPHOLE, DEFINE_INSN, and DEFINE_ASM_ATTRIBUTES.  */
 
 static void
@@ -3179,7 +3087,7 @@ gen_insn (rtx exp, int lineno)
 {
   struct insn_def *id;
 
-  id = oballoc (sizeof (struct insn_def));
+  id = oballoc (struct insn_def);
   id->next = defs;
   defs = id;
   id->def = exp;
@@ -3214,7 +3122,7 @@ gen_insn (rtx exp, int lineno)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -3229,9 +3137,9 @@ gen_delay (rtx def, int lineno)
 
   if (XVECLEN (def, 1) % 3 != 0)
     {
-      message_with_line (lineno,
-                        "number of elements in DEFINE_DELAY must be multiple of three");
-      have_error = 1;
+      error_with_line (lineno,
+                      "number of elements in DEFINE_DELAY must"
+                      " be multiple of three");
       return;
     }
 
@@ -3243,7 +3151,7 @@ gen_delay (rtx def, int lineno)
        have_annul_false = 1;
     }
 
-  delay = oballoc (sizeof (struct delay_desc));
+  delay = oballoc (struct delay_desc);
   delay->def = def;
   delay->num = ++num_delays;
   delay->next = delays;
@@ -3251,16 +3159,98 @@ gen_delay (rtx def, int lineno)
   delays = delay;
 }
 
-/* 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 nonzero in that case.
+/* Names of attributes that could be possibly cached.  */
+static const char *cached_attrs[32];
+/* Number of such attributes.  */
+static int cached_attr_count;
+/* Bitmasks of possibly cached attributes.  */
+static unsigned int attrs_seen_once, attrs_seen_more_than_once;
+static unsigned int attrs_to_cache;
+static unsigned int attrs_cached_inside, attrs_cached_after;
 
-   Set the second bit of FLAGS to make references to attribute values use
-   a cached local variable instead of calling a function.  */
+/* Finds non-const attributes that could be possibly cached.
+   When create is TRUE, fills in cached_attrs array.
+   Computes ATTRS_SEEN_ONCE and ATTRS_SEEN_MORE_THAN_ONCE
+   bitmasks.  */
 
 static void
-write_test_expr (rtx exp, int flags)
+find_attrs_to_cache (rtx exp, bool create)
+{
+  int i;
+  const char *name;
+  struct attr_desc *attr;
+
+  if (exp == NULL)
+    return;
+
+  switch (GET_CODE (exp))
+    {
+    case NOT:
+      if (GET_CODE (XEXP (exp, 0)) == EQ_ATTR)
+       find_attrs_to_cache (XEXP (exp, 0), create);
+      return;
+
+    case EQ_ATTR:
+      name = XSTR (exp, 0);
+      if (name == alternative_name)
+       return;
+      for (i = 0; i < cached_attr_count; i++)
+       if (name == cached_attrs[i])
+         {
+           if ((attrs_seen_once & (1U << i)) != 0)
+             attrs_seen_more_than_once |= (1U << i);
+           else
+             attrs_seen_once |= (1U << i);
+           return;
+         }
+      if (!create)
+       return;
+      attr = find_attr (&name, 0);
+      gcc_assert (attr);
+      if (attr->is_const)
+       return;
+      if (cached_attr_count == 32)
+       return;
+      cached_attrs[cached_attr_count] = XSTR (exp, 0);
+      attrs_seen_once |= (1U << cached_attr_count);
+      cached_attr_count++;
+      return;
+
+    case AND:
+    case IOR:
+      find_attrs_to_cache (XEXP (exp, 0), create);
+      find_attrs_to_cache (XEXP (exp, 1), create);
+      return;
+
+    case COND:
+      for (i = 0; i < XVECLEN (exp, 0); i += 2)
+       find_attrs_to_cache (XVECEXP (exp, 0, i), create);
+      return;
+
+    default:
+      return;
+    }
+}
+
+/* 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.  */
+
+/* Interpret AND/IOR as bit-wise operations instead of logical.  */
+#define FLG_BITWISE            1
+/* Set if cached attribute will be known initialized in else block after
+   this condition.  This is true for LHS of toplevel && and || and
+   even for RHS of ||, but not for RHS of &&.  */
+#define FLG_AFTER              2
+/* Set if cached attribute will be known initialized in then block after
+   this condition.  This is true for LHS of toplevel && and || and
+   even for RHS of &&, but not for RHS of ||.  */
+#define FLG_INSIDE             4
+/* Cleared when an operand of &&.  */
+#define FLG_OUTSIDE_AND                8
+
+static unsigned int
+write_test_expr (rtx exp, unsigned int attrs_cached, int flags)
 {
   int comparison_operator = 0;
   RTX_CODE code;
@@ -3282,12 +3272,30 @@ write_test_expr (rtx exp, int flags)
     case EQ: case NE:
     case GE: case GT:
     case LE: case LT:
-      comparison_operator = 1;
+      comparison_operator = FLG_BITWISE;
 
     case PLUS:   case MINUS:  case MULT:     case DIV:      case MOD:
     case AND:    case IOR:    case XOR:
     case ASHIFT: case LSHIFTRT: case ASHIFTRT:
-      write_test_expr (XEXP (exp, 0), flags | comparison_operator);
+      if ((code != AND && code != IOR) || (flags & FLG_BITWISE))
+       {
+         flags &= ~(FLG_AFTER | FLG_INSIDE | FLG_OUTSIDE_AND);
+         write_test_expr (XEXP (exp, 0), attrs_cached,
+                          flags | comparison_operator);
+       }
+      else
+       {
+         if (code == AND)
+           flags &= ~FLG_OUTSIDE_AND;
+         if (GET_CODE (XEXP (exp, 0)) == code
+             || GET_CODE (XEXP (exp, 0)) == EQ_ATTR
+             || (GET_CODE (XEXP (exp, 0)) == NOT
+                 && GET_CODE (XEXP (XEXP (exp, 0), 0)) == EQ_ATTR))
+           attrs_cached
+             = write_test_expr (XEXP (exp, 0), attrs_cached, flags);
+         else
+           write_test_expr (XEXP (exp, 0), attrs_cached, flags);
+       }
       switch (code)
        {
        case EQ:
@@ -3336,13 +3344,13 @@ write_test_expr (rtx exp, int flags)
          printf (" %% ");
          break;
        case AND:
-         if (flags & 1)
+         if (flags & FLG_BITWISE)
            printf (" & ");
          else
            printf (" && ");
          break;
        case IOR:
-         if (flags & 1)
+         if (flags & FLG_BITWISE)
            printf (" | ");
          else
            printf (" || ");
@@ -3358,18 +3366,52 @@ write_test_expr (rtx exp, int flags)
          printf (" >> ");
          break;
        default:
-         abort ();
+         gcc_unreachable ();
        }
 
-      write_test_expr (XEXP (exp, 1), flags | comparison_operator);
+      if (code == AND)
+       {
+         /* For if (something && (cached_x = get_attr_x (insn)) == X)
+            cached_x is only known to be initialized in then block.  */
+         flags &= ~FLG_AFTER;
+       }
+      else if (code == IOR)
+       {
+         if (flags & FLG_OUTSIDE_AND)
+           /* For if (something || (cached_x = get_attr_x (insn)) == X)
+              cached_x is only known to be initialized in else block
+              and else if conditions.  */
+           flags &= ~FLG_INSIDE;
+         else
+           /* For if ((something || (cached_x = get_attr_x (insn)) == X)
+                      && something_else)
+              cached_x is not know to be initialized anywhere.  */
+           flags &= ~(FLG_AFTER | FLG_INSIDE);
+       }
+      if ((code == AND || code == IOR)
+         && (GET_CODE (XEXP (exp, 1)) == code
+             || GET_CODE (XEXP (exp, 1)) == EQ_ATTR
+             || (GET_CODE (XEXP (exp, 1)) == NOT
+                 && GET_CODE (XEXP (XEXP (exp, 1), 0)) == EQ_ATTR)))
+       attrs_cached
+         = write_test_expr (XEXP (exp, 1), attrs_cached, flags);
+      else
+       write_test_expr (XEXP (exp, 1), attrs_cached,
+                        flags | comparison_operator);
       break;
 
     case NOT:
       /* Special-case (not (eq_attrq "alternative" "x")) */
-      if (! (flags & 1) && GET_CODE (XEXP (exp, 0)) == EQ_ATTR
-         && XSTR (XEXP (exp, 0), 0) == alternative_name)
+      if (! (flags & FLG_BITWISE) && GET_CODE (XEXP (exp, 0)) == EQ_ATTR)
        {
-         printf ("which_alternative != %s", XSTR (XEXP (exp, 0), 1));
+         if (XSTR (XEXP (exp, 0), 0) == alternative_name)
+           {
+             printf ("which_alternative != %s", XSTR (XEXP (exp, 0), 1));
+             break;
+           }
+
+         printf ("! ");
+         attrs_cached = write_test_expr (XEXP (exp, 0), attrs_cached, flags);
          break;
        }
 
@@ -3380,7 +3422,7 @@ write_test_expr (rtx exp, int flags)
       switch (code)
        {
        case NOT:
-         if (flags & 1)
+         if (flags & FLG_BITWISE)
            printf ("~ ");
          else
            printf ("! ");
@@ -3392,17 +3434,18 @@ write_test_expr (rtx exp, int flags)
          printf ("-");
          break;
        default:
-         abort ();
+         gcc_unreachable ();
        }
 
-      write_test_expr (XEXP (exp, 0), flags);
+      flags &= ~(FLG_AFTER | FLG_INSIDE | FLG_OUTSIDE_AND);
+      write_test_expr (XEXP (exp, 0), attrs_cached, flags);
       break;
 
     case EQ_ATTR_ALT:
        {
          int set = XINT (exp, 0), bit = 0;
 
-         if (flags & 1)
+         if (flags & FLG_BITWISE)
            fatal ("EQ_ATTR_ALT not valid inside comparison");
 
          if (!set)
@@ -3438,7 +3481,7 @@ write_test_expr (rtx exp, int flags)
            }
          else
            {
-             printf ("%s((1 << which_alternative) & 0x%x)",
+             printf ("%s((1 << which_alternative) & %#x)",
                      XINT (exp, 1) ? "!" : "", set);
            }
        }
@@ -3448,7 +3491,7 @@ write_test_expr (rtx exp, int flags)
        have been removed by optimization.   Handle "alternative"
        specially and give error if EQ_ATTR present inside a comparison.  */
     case EQ_ATTR:
-      if (flags & 1)
+      if (flags & FLG_BITWISE)
        fatal ("EQ_ATTR not valid inside comparison");
 
       if (XSTR (exp, 0) == alternative_name)
@@ -3458,20 +3501,33 @@ write_test_expr (rtx exp, int flags)
        }
 
       attr = find_attr (&XSTR (exp, 0), 0);
-      if (! attr)
-       abort ();
+      gcc_assert (attr);
 
       /* Now is the time to expand the value of a constant attribute.  */
       if (attr->is_const)
        {
-         write_test_expr (evaluate_eq_attr (exp, attr->default_val->value,
-                                            -2, -2),
-                          flags);
+         write_test_expr (evaluate_eq_attr (exp, attr,
+                                            attr->default_val->value, -2, -2),
+                          attrs_cached, 0);
        }
       else
        {
-         if (flags & 2)
-           printf ("attr_%s", attr->name);
+         int i;
+         for (i = 0; i < cached_attr_count; i++)
+           if (attr->name == cached_attrs[i])
+             break;
+         if (i < cached_attr_count && (attrs_cached & (1U << i)) != 0)
+           printf ("cached_%s", attr->name);
+         else if (i < cached_attr_count && (attrs_to_cache & (1U << i)) != 0)
+           {
+             printf ("(cached_%s = get_attr_%s (insn))",
+                     attr->name, attr->name);
+             if (flags & FLG_AFTER)
+               attrs_cached_after |= (1U << i);
+             if (flags & FLG_INSIDE)
+               attrs_cached_inside |= (1U << i);
+             attrs_cached |= (1U << i);
+           }
          else
            printf ("get_attr_%s (insn)", attr->name);
          printf (" == ");
@@ -3481,7 +3537,7 @@ write_test_expr (rtx exp, int flags)
 
     /* Comparison test of flags for define_delays.  */
     case ATTR_FLAG:
-      if (flags & 1)
+      if (flags & FLG_BITWISE)
        fatal ("ATTR_FLAG not valid inside comparison");
       printf ("(flags & ATTR_FLAG_%s) != 0", XSTR (exp, 0));
       break;
@@ -3510,7 +3566,7 @@ write_test_expr (rtx exp, int flags)
 
     /* A random C expression.  */
     case SYMBOL_REF:
-      printf ("%s", XSTR (exp, 0));
+      print_c_condition (XSTR (exp, 0));
       break;
 
     /* The address of the branch target.  */
@@ -3533,11 +3589,11 @@ write_test_expr (rtx exp, int flags)
       break;
 
     case IF_THEN_ELSE:
-      write_test_expr (XEXP (exp, 0), flags & 2);
+      write_test_expr (XEXP (exp, 0), attrs_cached, 0);
       printf (" ? ");
-      write_test_expr (XEXP (exp, 1), flags | 1);
+      write_test_expr (XEXP (exp, 1), attrs_cached, FLG_BITWISE);
       printf (" : ");
-      write_test_expr (XEXP (exp, 2), flags | 1);
+      write_test_expr (XEXP (exp, 2), attrs_cached, FLG_BITWISE);
       break;
 
     default:
@@ -3546,6 +3602,7 @@ write_test_expr (rtx exp, int flags)
     }
 
   printf (")");
+  return attrs_cached;
 }
 
 /* Given an attribute value, return the maximum CONST_STRING argument
@@ -3589,6 +3646,47 @@ max_attr_value (rtx exp, int *unknownp)
   return current_max;
 }
 
+/* Given an attribute value, return the minimum CONST_STRING argument
+   encountered.  Set *UNKNOWNP and return 0 if the value is unknown.  */
+
+static int
+min_attr_value (rtx exp, int *unknownp)
+{
+  int current_min;
+  int i, n;
+
+  switch (GET_CODE (exp))
+    {
+    case CONST_STRING:
+      current_min = atoi (XSTR (exp, 0));
+      break;
+
+    case COND:
+      current_min = min_attr_value (XEXP (exp, 1), unknownp);
+      for (i = 0; i < XVECLEN (exp, 0); i += 2)
+       {
+         n = min_attr_value (XVECEXP (exp, 0, i + 1), unknownp);
+         if (n < current_min)
+           current_min = n;
+       }
+      break;
+
+    case IF_THEN_ELSE:
+      current_min = min_attr_value (XEXP (exp, 1), unknownp);
+      n = min_attr_value (XEXP (exp, 2), unknownp);
+      if (n < current_min)
+       current_min = n;
+      break;
+
+    default:
+      *unknownp = 1;
+      current_min = INT_MAX;
+      break;
+    }
+
+  return current_min;
+}
+
 /* Given an attribute value, return the result of ORing together all
    CONST_STRING arguments encountered.  Set *UNKNOWNP and return -1
    if the numeric value is not known.  */
@@ -3709,6 +3807,7 @@ static void
 write_attr_get (struct attr_desc *attr)
 {
   struct attr_value *av, *common_av;
+  int i, j;
 
   /* Find the most used attribute value.  Handle that as the `default' of the
      switch we will generate.  */
@@ -3716,12 +3815,10 @@ write_attr_get (struct attr_desc *attr)
 
   /* Write out start of function, then all values with explicit `case' lines,
      then a `default', then the value with the most uses.  */
-  if (attr->static_p)
-    printf ("static ");
-  if (!attr->is_numeric)
+  if (attr->enum_name)
+    printf ("enum %s\n", attr->enum_name);
+  else if (!attr->is_numeric)
     printf ("enum attr_%s\n", attr->name);
-  else if (attr->unsigned_p)
-    printf ("unsigned int\n");
   else
     printf ("int\n");
 
@@ -3737,16 +3834,51 @@ write_attr_get (struct attr_desc *attr)
       printf ("{\n");
 
       for (av = attr->first_value; av; av = av->next)
-       if (av->num_insns != 0)
+       if (av->num_insns == 1)
          write_attr_set (attr, 2, av->value, "return", ";",
-                         true_rtx, av->first_insn->insn_code,
-                         av->first_insn->insn_index);
+                         true_rtx, av->first_insn->def->insn_code,
+                         av->first_insn->def->insn_index, 0);
+       else if (av->num_insns != 0)
+         write_attr_set (attr, 2, av->value, "return", ";",
+                         true_rtx, -2, 0, 0);
 
       printf ("}\n\n");
       return;
     }
 
   printf ("{\n");
+
+  /* Find attributes that are worth caching in the conditions.  */
+  cached_attr_count = 0;
+  attrs_seen_more_than_once = 0;
+  for (av = attr->first_value; av; av = av->next)
+    {
+      attrs_seen_once = 0;
+      find_attrs_to_cache (av->value, true);
+    }
+  /* Remove those that aren't worth caching from the array.  */
+  for (i = 0, j = 0; i < cached_attr_count; i++)
+    if ((attrs_seen_more_than_once & (1U << i)) != 0)
+      {
+       const char *name = cached_attrs[i];
+       struct attr_desc *cached_attr;
+       if (i != j)
+         cached_attrs[j] = name;
+       cached_attr = find_attr (&name, 0);
+       gcc_assert (cached_attr && cached_attr->is_const == 0);
+       if (cached_attr->enum_name)
+         printf ("  enum %s", cached_attr->enum_name);
+       else if (!cached_attr->is_numeric)
+         printf ("  enum attr_%s", cached_attr->name);
+       else
+         printf ("  int");
+       printf (" cached_%s ATTRIBUTE_UNUSED;\n", name);
+       j++;
+      }
+  cached_attr_count = j;
+  if (cached_attr_count)
+    printf ("\n");
+
   printf ("  switch (recog_memoized (insn))\n");
   printf ("    {\n");
 
@@ -3756,6 +3888,7 @@ write_attr_get (struct attr_desc *attr)
 
   write_attr_case (attr, common_av, 0, "return", ";", 4, true_rtx);
   printf ("    }\n}\n\n");
+  cached_attr_count = 0;
 }
 
 /* Given an AND tree of known true terms (because we are inside an `if' with
@@ -3794,7 +3927,7 @@ eliminate_known_true (rtx known_true, rtx exp, int insn_code, int insn_index)
 static void
 write_attr_set (struct attr_desc *attr, int indent, rtx value,
                const char *prefix, const char *suffix, rtx known_true,
-               int insn_code, int insn_index)
+               int insn_code, int insn_index, unsigned int attrs_cached)
 {
   if (GET_CODE (value) == COND)
     {
@@ -3806,6 +3939,15 @@ write_attr_set (struct attr_desc *attr, int indent, rtx value,
       int first_if = 1;
       int i;
 
+      if (cached_attr_count)
+       {
+         attrs_seen_once = 0;
+         attrs_seen_more_than_once = 0;
+         for (i = 0; i < XVECLEN (value, 0); i += 2)
+           find_attrs_to_cache (XVECEXP (value, 0, i), false);
+         attrs_to_cache |= attrs_seen_more_than_once;
+       }
+
       for (i = 0; i < XVECLEN (value, 0); i += 2)
        {
          rtx testexp;
@@ -3836,17 +3978,22 @@ write_attr_set (struct attr_desc *attr, int indent, rtx value,
          if (inner_true == false_rtx)
            continue;
 
+         attrs_cached_inside = attrs_cached;
+         attrs_cached_after = attrs_cached;
          write_indent (indent);
          printf ("%sif ", first_if ? "" : "else ");
          first_if = 0;
-         write_test_expr (testexp, 0);
+         write_test_expr (testexp, attrs_cached,
+                          (FLG_AFTER | FLG_INSIDE | FLG_OUTSIDE_AND));
+         attrs_cached = attrs_cached_after;
          printf ("\n");
          write_indent (indent + 2);
          printf ("{\n");
 
          write_attr_set (attr, indent + 4,
                          XVECEXP (value, 0, i + 1), prefix, suffix,
-                         inner_true, insn_code, insn_index);
+                         inner_true, insn_code, insn_index,
+                         attrs_cached_inside);
          write_indent (indent + 2);
          printf ("}\n");
          our_known_true = newexp;
@@ -3861,7 +4008,8 @@ write_attr_set (struct attr_desc *attr, int indent, rtx value,
        }
 
       write_attr_set (attr, first_if ? indent : indent + 4, default_val,
-                     prefix, suffix, our_known_true, insn_code, insn_index);
+                     prefix, suffix, our_known_true, insn_code, insn_index,
+                     attrs_cached);
 
       if (! first_if)
        {
@@ -3878,6 +4026,25 @@ write_attr_set (struct attr_desc *attr, int indent, rtx value,
     }
 }
 
+/* Write a series of case statements for every instruction in list IE.
+   INDENT is the amount of indentation to write before each case.  */
+
+static void
+write_insn_cases (struct insn_ent *ie, int indent)
+{
+  for (; ie != 0; ie = ie->next)
+    if (ie->def->insn_code != -1)
+      {
+       write_indent (indent);
+       if (GET_CODE (ie->def->def) == DEFINE_PEEPHOLE)
+         printf ("case %d:  /* define_peephole, line %d */\n",
+                 ie->def->insn_code, ie->def->lineno);
+       else
+         printf ("case %d:  /* %s */\n",
+                 ie->def->insn_code, XSTR (ie->def->def, 0));
+      }
+}
+
 /* Write out the computation for one attribute value.  */
 
 static void
@@ -3885,8 +4052,6 @@ write_attr_case (struct attr_desc *attr, struct attr_value *av,
                 int write_case_lines, const char *prefix, const char *suffix,
                 int indent, rtx known_true)
 {
-  struct insn_ent *ie;
-
   if (av->num_insns == 0)
     return;
 
@@ -3903,14 +4068,7 @@ write_attr_case (struct attr_desc *attr, struct attr_value *av,
     }
 
   if (write_case_lines)
-    {
-      for (ie = av->first_insn; ie; ie = ie->next)
-       if (ie->insn_code != -1)
-         {
-           write_indent (indent);
-           printf ("case %d:\n", ie->insn_code);
-         }
-    }
+    write_insn_cases (av->first_insn, indent);
   else
     {
       write_indent (indent);
@@ -3932,9 +4090,14 @@ write_attr_case (struct attr_desc *attr, struct attr_value *av,
       printf ("extract_insn_cached (insn);\n");
     }
 
-  write_attr_set (attr, indent + 2, av->value, prefix, suffix,
-                 known_true, av->first_insn->insn_code,
-                 av->first_insn->insn_index);
+  attrs_to_cache = 0;
+  if (av->num_insns == 1)
+    write_attr_set (attr, indent + 2, av->value, prefix, suffix,
+                   known_true, av->first_insn->def->insn_code,
+                   av->first_insn->def->insn_index, 0);
+  else
+    write_attr_set (attr, indent + 2, av->value, prefix, suffix,
+                   known_true, -2, 0, 0);
 
   if (strncmp (prefix, "return", 6))
     {
@@ -3944,53 +4107,6 @@ write_attr_case (struct attr_desc *attr, struct attr_value *av,
   printf ("\n");
 }
 
-/* Search for uses of non-const attributes and write code to cache them.  */
-
-static int
-write_expr_attr_cache (rtx p, struct attr_desc *attr)
-{
-  const char *fmt;
-  int i, ie, j, je;
-
-  if (GET_CODE (p) == EQ_ATTR)
-    {
-      if (XSTR (p, 0) != attr->name)
-       return 0;
-
-      if (!attr->is_numeric)
-       printf ("  enum attr_%s ", attr->name);
-      else if (attr->unsigned_p)
-       printf ("  unsigned int ");
-      else
-       printf ("  int ");
-
-      printf ("attr_%s = get_attr_%s (insn);\n", attr->name, attr->name);
-      return 1;
-    }
-
-  fmt = GET_RTX_FORMAT (GET_CODE (p));
-  ie = GET_RTX_LENGTH (GET_CODE (p));
-  for (i = 0; i < ie; i++)
-    {
-      switch (*fmt++)
-       {
-       case 'e':
-         if (write_expr_attr_cache (XEXP (p, i), attr))
-           return 1;
-         break;
-
-       case 'E':
-         je = XVECLEN (p, i);
-         for (j = 0; j < je; ++j)
-           if (write_expr_attr_cache (XVECEXP (p, i, j), attr))
-             return 1;
-         break;
-       }
-    }
-
-  return 0;
-}
-
 /* Utilities to write in various forms.  */
 
 static void
@@ -4003,11 +4119,11 @@ write_attr_valueq (struct attr_desc *attr, const char *s)
       printf ("%d", num);
 
       if (num > 9 || num < 0)
-       printf (" /* 0x%x */", num);
+       printf (" /* %#x */", num);
     }
   else
     {
-      write_upcase (attr->name);
+      write_upcase (attr->enum_name ? attr->enum_name : attr->name);
       printf ("_");
       write_upcase (s);
     }
@@ -4029,12 +4145,19 @@ write_attr_value (struct attr_desc *attr, rtx value)
       break;
 
     case SYMBOL_REF:
-      fputs (XSTR (value, 0), stdout);
+      print_c_condition (XSTR (value, 0));
       break;
 
     case ATTR:
       {
        struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
+       if (attr->enum_name)
+         printf ("(enum %s)", attr->enum_name);
+       else if (!attr->is_numeric)
+         printf ("(enum attr_%s)", attr->name);
+       else if (!attr2->is_numeric)
+         printf ("(int)");
+
        printf ("get_attr_%s (%s)", attr2->name,
                (attr2->is_const ? "" : "insn"));
       }
@@ -4065,7 +4188,7 @@ write_attr_value (struct attr_desc *attr, rtx value)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -4129,8 +4252,7 @@ write_eligible_delay (const char *kind)
   printf ("{\n");
   printf ("  rtx insn;\n");
   printf ("\n");
-  printf ("  if (slot >= %d)\n", max_slots);
-  printf ("    abort ();\n");
+  printf ("  gcc_assert (slot < %d);\n", max_slots);
   printf ("\n");
   /* Allow dbr_schedule to pass labels, etc.  This can happen if try_split
      converts a compound instruction into a loop.  */
@@ -4143,8 +4265,7 @@ write_eligible_delay (const char *kind)
   if (num_delays > 1)
     {
       attr = find_attr (&delay_type_str, 0);
-      if (! attr)
-       abort ();
+      gcc_assert (attr);
       common_av = find_most_used (attr);
 
       printf ("  insn = delay_insn;\n");
@@ -4160,8 +4281,7 @@ write_eligible_delay (const char *kind)
       printf ("    }\n\n");
 
       /* Ensure matched.  Otherwise, shouldn't have been called.  */
-      printf ("  if (slot < %d)\n", max_slots);
-      printf ("    abort ();\n\n");
+      printf ("  gcc_assert (slot >= %d);\n\n", max_slots);
     }
 
   /* If just one type of delay slot, write simple switch.  */
@@ -4172,8 +4292,7 @@ write_eligible_delay (const char *kind)
       printf ("    {\n");
 
       attr = find_attr (&delay_1_0_str, 0);
-      if (! attr)
-       abort ();
+      gcc_assert (attr);
       common_av = find_most_used (attr);
 
       for (av = attr->first_value; av; av = av->next)
@@ -4203,8 +4322,7 @@ write_eligible_delay (const char *kind)
            sprintf (str, "*%s_%d_%d", kind, delay->num, i / 3);
            pstr = str;
            attr = find_attr (&pstr, 0);
-           if (! attr)
-             abort ();
+           gcc_assert (attr);
            common_av = find_most_used (attr);
 
            for (av = attr->first_value; av; av = av->next)
@@ -4216,7 +4334,7 @@ write_eligible_delay (const char *kind)
          }
 
       printf ("    default:\n");
-      printf ("      abort ();\n");
+      printf ("      gcc_unreachable ();\n");
       printf ("    }\n");
     }
 
@@ -4274,11 +4392,11 @@ find_attr (const char **name_p, int create)
   if (! create)
     return NULL;
 
-  attr = oballoc (sizeof (struct attr_desc));
+  attr = oballoc (struct attr_desc);
   attr->name = DEF_ATTR_STRING (name);
+  attr->enum_name = 0;
   attr->first_value = attr->default_val = NULL;
-  attr->is_numeric = attr->negative_ok = attr->is_const = attr->is_special = 0;
-  attr->unsigned_p = attr->static_p = 0;
+  attr->is_numeric = attr->is_const = attr->is_special = 0;
   attr->next = attrs[index];
   attrs[index] = attr;
 
@@ -4289,21 +4407,17 @@ find_attr (const char **name_p, int create)
 
 /* Create internal attribute with the given default value.  */
 
-void
+static void
 make_internal_attr (const char *name, rtx value, int special)
 {
   struct attr_desc *attr;
 
   attr = find_attr (&name, 1);
-  if (attr->default_val)
-    abort ();
+  gcc_assert (!attr->default_val);
 
   attr->is_numeric = 1;
   attr->is_const = 0;
   attr->is_special = (special & ATTR_SPECIAL) != 0;
-  attr->negative_ok = (special & ATTR_NEGATIVE_OK) != 0;
-  attr->unsigned_p = (special & ATTR_UNSIGNED) != 0;
-  attr->static_p = (special & ATTR_STATIC) != 0;
   attr->default_val = get_attr_value (value, attr, -2);
 }
 
@@ -4328,15 +4442,14 @@ find_most_used (struct attr_desc *attr)
 
 /* Return (attr_value "n") */
 
-rtx
+static rtx
 make_numeric_value (int n)
 {
   static rtx int_values[20];
   rtx exp;
   char *p;
 
-  if (n < 0)
-    abort ();
+  gcc_assert (n >= 0);
 
   if (n < 20 && int_values[n])
     return int_values[n];
@@ -4368,7 +4481,6 @@ write_const_num_delay_slots (void)
 {
   struct attr_desc *attr = find_attr (&num_delay_slots_str, 0);
   struct attr_value *av;
-  struct insn_ent *ie;
 
   if (attr)
     {
@@ -4382,12 +4494,7 @@ write_const_num_delay_slots (void)
          length_used = 0;
          walk_attr_value (av->value);
          if (length_used)
-           {
-             for (ie = av->first_insn; ie; ie = ie->next)
-               if (ie->insn_code != -1)
-                 printf ("    case %d:\n", ie->insn_code);
-             printf ("      return 0;\n");
-           }
+           write_insn_cases (av->first_insn, 4);
        }
 
       printf ("    default:\n");
@@ -4395,6 +4502,358 @@ write_const_num_delay_slots (void)
       printf ("    }\n}\n\n");
     }
 }
+\f
+/* Synthetic attributes used by insn-automata.c and the scheduler.
+   These are primarily concerned with (define_insn_reservation)
+   patterns.  */
+
+struct insn_reserv
+{
+  struct insn_reserv *next;
+
+  const char *name;
+  int default_latency;
+  rtx condexp;
+
+  /* Sequence number of this insn.  */
+  int insn_num;
+
+  /* Whether a (define_bypass) construct names this insn in its
+     output list.  */
+  bool bypassed;
+};
+
+static struct insn_reserv *all_insn_reservs = 0;
+static struct insn_reserv **last_insn_reserv_p = &all_insn_reservs;
+static size_t n_insn_reservs;
+
+/* Store information from a DEFINE_INSN_RESERVATION for future
+   attribute generation.  */
+static void
+gen_insn_reserv (rtx def)
+{
+  struct insn_reserv *decl = oballoc (struct insn_reserv);
+
+  decl->name            = DEF_ATTR_STRING (XSTR (def, 0));
+  decl->default_latency = XINT (def, 1);
+  decl->condexp         = check_attr_test (XEXP (def, 2), 0, 0);
+  decl->insn_num        = n_insn_reservs;
+  decl->bypassed       = false;
+  decl->next            = 0;
+
+  *last_insn_reserv_p = decl;
+  last_insn_reserv_p  = &decl->next;
+  n_insn_reservs++;
+}
+
+/* Store information from a DEFINE_BYPASS for future attribute
+   generation.  The only thing we care about is the list of output
+   insns, which will later be used to tag reservation structures with
+   a 'bypassed' bit.  */
+
+struct bypass_list
+{
+  struct bypass_list *next;
+  const char *pattern;
+};
+
+static struct bypass_list *all_bypasses;
+static size_t n_bypasses;
+
+static void
+gen_bypass_1 (const char *s, size_t len)
+{
+  struct bypass_list *b;
+
+  if (len == 0)
+    return;
+
+  s = attr_string (s, len);
+  for (b = all_bypasses; b; b = b->next)
+    if (s == b->pattern)
+      return;  /* already got that one */
+
+  b = oballoc (struct bypass_list);
+  b->pattern = s;
+  b->next = all_bypasses;
+  all_bypasses = b;
+  n_bypasses++;
+}
+
+static void
+gen_bypass (rtx def)
+{
+  const char *p, *base;
+
+  for (p = base = XSTR (def, 1); *p; p++)
+    if (*p == ',')
+      {
+       gen_bypass_1 (base, p - base);
+       do
+         p++;
+       while (ISSPACE (*p));
+       base = p;
+      }
+  gen_bypass_1 (base, p - base);
+}
+
+/* Find and mark all of the bypassed insns.  */
+static void
+process_bypasses (void)
+{
+  struct bypass_list *b;
+  struct insn_reserv *r;
+
+  /* The reservation list is likely to be much longer than the bypass
+     list.  */
+  for (r = all_insn_reservs; r; r = r->next)
+    for (b = all_bypasses; b; b = b->next)
+      if (fnmatch (b->pattern, r->name, 0) == 0)
+       r->bypassed = true;
+}
+
+/* Check that attribute NAME is used in define_insn_reservation condition
+   EXP.  Return true if it is.  */
+static bool
+check_tune_attr (const char *name, rtx exp)
+{
+  switch (GET_CODE (exp))
+    {
+    case AND:
+      if (check_tune_attr (name, XEXP (exp, 0)))
+       return true;
+      return check_tune_attr (name, XEXP (exp, 1));
+
+    case IOR:
+      return (check_tune_attr (name, XEXP (exp, 0))
+             && check_tune_attr (name, XEXP (exp, 1)));
+
+    case EQ_ATTR:
+      return XSTR (exp, 0) == name;
+
+    default:
+      return false;
+    }
+}
+
+/* Try to find a const attribute (usually cpu or tune) that is used
+   in all define_insn_reservation conditions.  */
+static struct attr_desc *
+find_tune_attr (rtx exp)
+{
+  struct attr_desc *attr;
+
+  switch (GET_CODE (exp))
+    {
+    case AND:
+    case IOR:
+      attr = find_tune_attr (XEXP (exp, 0));
+      if (attr)
+       return attr;
+      return find_tune_attr (XEXP (exp, 1));
+
+    case EQ_ATTR:
+      if (XSTR (exp, 0) == alternative_name)
+       return NULL;
+
+      attr = find_attr (&XSTR (exp, 0), 0);
+      gcc_assert (attr);
+
+      if (attr->is_const && !attr->is_special)
+       {
+         struct insn_reserv *decl;
+
+         for (decl = all_insn_reservs; decl; decl = decl->next)
+           if (! check_tune_attr (attr->name, decl->condexp))
+             return NULL;
+         return attr;
+       }
+      return NULL;
+
+    default:
+      return NULL;
+    }
+}
+
+/* Create all of the attributes that describe automaton properties.  */
+static void
+make_automaton_attrs (void)
+{
+  int i;
+  struct insn_reserv *decl;
+  rtx code_exp, lats_exp, byps_exp;
+  struct attr_desc *tune_attr;
+
+  if (n_insn_reservs == 0)
+    return;
+
+  tune_attr = find_tune_attr (all_insn_reservs->condexp);
+  if (tune_attr != NULL)
+    {
+      rtx *condexps = XNEWVEC (rtx, n_insn_reservs * 3);
+      struct attr_value *val;
+      bool first = true;
+
+      gcc_assert (tune_attr->is_const
+                 && !tune_attr->is_special
+                 && !tune_attr->is_numeric);
+      for (val = tune_attr->first_value; val; val = val->next)
+       {
+         if (val == tune_attr->default_val)
+           continue;
+         gcc_assert (GET_CODE (val->value) == CONST_STRING);
+         printf ("static int internal_dfa_insn_code_%s (rtx);\n"
+                 "static int insn_default_latency_%s (rtx);\n",
+                 XSTR (val->value, 0), XSTR (val->value, 0));
+       }
+
+      printf ("\n");
+      printf ("int (*internal_dfa_insn_code) (rtx);\n");
+      printf ("int (*insn_default_latency) (rtx);\n");
+      printf ("\n");
+      printf ("void\n");
+      printf ("init_sched_attrs (void)\n");
+      printf ("{\n");
+
+      for (val = tune_attr->first_value; val; val = val->next)
+       {
+         int j;
+         char *name;
+         rtx test = attr_rtx (EQ_ATTR, tune_attr->name, XSTR (val->value, 0));
+
+         if (val == tune_attr->default_val)
+           continue;
+         for (decl = all_insn_reservs, i = 0;
+              decl;
+              decl = decl->next)
+           {
+             rtx ctest = test;
+             rtx condexp
+               = simplify_and_tree (decl->condexp, &ctest, -2, 0);
+             if (condexp == false_rtx)
+               continue;
+             if (condexp == true_rtx)
+               break;
+             condexps[i] = condexp;
+             condexps[i + 1] = make_numeric_value (decl->insn_num);
+             condexps[i + 2] = make_numeric_value (decl->default_latency);
+             i += 3;
+           }
+
+         code_exp = rtx_alloc (COND);
+         lats_exp = rtx_alloc (COND);
+
+         j = i / 3 * 2;
+         XVEC (code_exp, 0) = rtvec_alloc (j);
+         XVEC (lats_exp, 0) = rtvec_alloc (j);
+
+         if (decl)
+           {
+             XEXP (code_exp, 1) = make_numeric_value (decl->insn_num);
+             XEXP (lats_exp, 1) = make_numeric_value (decl->default_latency);
+           }
+         else
+           {
+             XEXP (code_exp, 1) = make_numeric_value (n_insn_reservs + 1);
+             XEXP (lats_exp, 1) = make_numeric_value (0);
+           }
+
+         while (i > 0)
+           {
+             i -= 3;
+             j -= 2;
+             XVECEXP (code_exp, 0, j) = condexps[i];
+             XVECEXP (lats_exp, 0, j) = condexps[i];
+
+             XVECEXP (code_exp, 0, j + 1) = condexps[i + 1];
+             XVECEXP (lats_exp, 0, j + 1) = condexps[i + 2];
+           }
+
+         name = XNEWVEC (char,
+                         sizeof ("*internal_dfa_insn_code_")
+                         + strlen (XSTR (val->value, 0)));
+         strcpy (name, "*internal_dfa_insn_code_");
+         strcat (name, XSTR (val->value, 0));
+         make_internal_attr (name, code_exp, ATTR_NONE);
+         strcpy (name, "*insn_default_latency_");
+         strcat (name, XSTR (val->value, 0));
+         make_internal_attr (name, lats_exp, ATTR_NONE);
+         XDELETEVEC (name);
+
+         if (first)
+           {
+             printf ("  if (");
+             first = false;
+           }
+         else
+           printf ("  else if (");
+         write_test_expr (test, 0, 0);
+         printf (")\n");
+         printf ("    {\n");
+         printf ("      internal_dfa_insn_code\n");
+         printf ("        = internal_dfa_insn_code_%s;\n",
+                 XSTR (val->value, 0));
+         printf ("      insn_default_latency\n");
+         printf ("        = insn_default_latency_%s;\n",
+                 XSTR (val->value, 0));
+         printf ("    }\n");
+       }
+
+      printf ("  else\n");
+      printf ("    gcc_unreachable ();\n");
+      printf ("}\n");
+      printf ("\n");
+
+      XDELETEVEC (condexps);
+    }
+  else
+    {
+      code_exp = rtx_alloc (COND);
+      lats_exp = rtx_alloc (COND);
+
+      XVEC (code_exp, 0) = rtvec_alloc (n_insn_reservs * 2);
+      XVEC (lats_exp, 0) = rtvec_alloc (n_insn_reservs * 2);
+
+      XEXP (code_exp, 1) = make_numeric_value (n_insn_reservs + 1);
+      XEXP (lats_exp, 1) = make_numeric_value (0);
+
+      for (decl = all_insn_reservs, i = 0;
+          decl;
+          decl = decl->next, i += 2)
+       {
+         XVECEXP (code_exp, 0, i)   = decl->condexp;
+         XVECEXP (lats_exp, 0, i)   = decl->condexp;
+
+         XVECEXP (code_exp, 0, i+1) = make_numeric_value (decl->insn_num);
+         XVECEXP (lats_exp, 0, i+1)
+           = make_numeric_value (decl->default_latency);
+       }
+      make_internal_attr ("*internal_dfa_insn_code", code_exp, ATTR_NONE);
+      make_internal_attr ("*insn_default_latency",   lats_exp, ATTR_NONE);
+    }
+
+  if (n_bypasses == 0)
+    byps_exp = make_numeric_value (0);
+  else
+    {
+      process_bypasses ();
+
+      byps_exp = rtx_alloc (COND);
+      XVEC (byps_exp, 0) = rtvec_alloc (n_bypasses * 2);
+      XEXP (byps_exp, 1) = make_numeric_value (0);
+      for (decl = all_insn_reservs, i = 0;
+          decl;
+          decl = decl->next)
+       if (decl->bypassed)
+         {
+           XVECEXP (byps_exp, 0, i)   = decl->condexp;
+           XVECEXP (byps_exp, 0, i+1) = make_numeric_value (1);
+           i += 2;
+         }
+    }
+
+  make_internal_attr ("*bypass_p",               byps_exp, ATTR_NONE);
+}
 
 int
 main (int argc, char **argv)
@@ -4407,10 +4866,7 @@ main (int argc, char **argv)
 
   progname = "genattrtab";
 
-  if (argc <= 1)
-    fatal ("no input file name");
-
-  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
+  if (!init_rtx_reader_args (argc, argv))
     return (FATAL_EXIT_CODE);
 
   obstack_init (hash_obstack);
@@ -4435,7 +4891,6 @@ from the machine description file `md'.  */\n\n");
 
   /* Read the machine description.  */
 
-  initiate_automaton_gen (argc, argv);
   while (1)
     {
       int lineno;
@@ -4453,6 +4908,7 @@ from the machine description file `md'.  */\n\n");
          break;
 
        case DEFINE_ATTR:
+       case DEFINE_ENUM_ATTR:
          gen_attr (desc, lineno);
          break;
 
@@ -4460,54 +4916,14 @@ from the machine description file `md'.  */\n\n");
          gen_delay (desc, lineno);
          break;
 
-       case DEFINE_CPU_UNIT:
-         gen_cpu_unit (desc);
-         break;
-
-       case DEFINE_QUERY_CPU_UNIT:
-         gen_query_cpu_unit (desc);
+       case DEFINE_INSN_RESERVATION:
+         gen_insn_reserv (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;
        }
@@ -4532,41 +4948,38 @@ from the machine description file `md'.  */\n\n");
   if (num_delays)
     expand_delays ();
 
-  /* Build DFA, output some functions and expand DFA information
-     to new attributes.  */
-  if (num_dfa_decls)
-    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 \"insn-attr.h\"\n");
   printf ("#include \"tm_p.h\"\n");
   printf ("#include \"insn-config.h\"\n");
   printf ("#include \"recog.h\"\n");
   printf ("#include \"regs.h\"\n");
-  printf ("#include \"real.h\"\n");
   printf ("#include \"output.h\"\n");
-  printf ("#include \"insn-attr.h\"\n");
-  printf ("#include \"toplev.h\"\n");
+  printf ("#include \"diagnostic-core.h\"\n");
   printf ("#include \"flags.h\"\n");
   printf ("#include \"function.h\"\n");
   printf ("\n");
   printf ("#define operands recog_data.operand\n\n");
 
   /* Make `insn_alternatives'.  */
-  insn_alternatives = oballoc (insn_code_number * sizeof (int));
+  insn_alternatives = oballocvec (int, insn_code_number);
   for (id = defs; id; id = id->next)
     if (id->insn_code >= 0)
       insn_alternatives[id->insn_code] = (1 << id->num_alternatives) - 1;
 
   /* Make `insn_n_alternatives'.  */
-  insn_n_alternatives = oballoc (insn_code_number * sizeof (int));
+  insn_n_alternatives = oballocvec (int, insn_code_number);
   for (id = defs; id; id = id->next)
     if (id->insn_code >= 0)
       insn_n_alternatives[id->insn_code] = id->num_alternatives;
 
+  /* Construct extra attributes for automata.  */
+  make_automaton_attrs ();
+
   /* Prepare to write out attribute subroutines by checking everything stored
      away and building the attribute cases.  */
 
@@ -4597,18 +5010,7 @@ from the machine description file `md'.  */\n\n");
     for (attr = attrs[i]; attr; attr = attr->next)
       {
        if (! attr->is_special && ! attr->is_const)
-         {
-           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_attr_get (attr);
       }
 
   /* Write out delay eligibility information, if DEFINE_DELAY present.
@@ -4623,11 +5025,6 @@ from the machine description file `md'.  */\n\n");
        write_eligible_delay ("annul_false");
     }
 
-  /* Output code for pipeline hazards recognition based on DFA
-     (deterministic finite-state automata).  */
-  if (num_dfa_decls)
-    write_automata ();
-
   /* Write out constant delay slot info.  */
   write_const_num_delay_slots ();
 
@@ -4636,10 +5033,3 @@ from the machine description file `md'.  */\n\n");
   fflush (stdout);
   return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
 }
-
-/* Define this so we can link with print-rtl.o to get debug_rtx function.  */
-const char *
-get_insn_name (int code ATTRIBUTE_UNUSED)
-{
-  return NULL;
-}