OSDN Git Service

PR target/21723
[pf3gnuchains/gcc-fork.git] / gcc / genattrtab.c
index dc8ff6e..c284f86 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
+   1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GCC.
@@ -17,8 +17,8 @@ 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.  */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
 
 /* This program handles insn attributes and the DEFINE_DELAY and
    DEFINE_INSN_RESERVATION definitions.
@@ -90,14 +90,11 @@ 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)             \
@@ -184,15 +181,11 @@ struct attr_desc
   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
@@ -336,6 +329,7 @@ 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_insn_cases   (struct insn_ent *, 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 *);
@@ -734,7 +728,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));
 
@@ -966,7 +959,7 @@ check_attr_value (rtx exp, struct attr_desc *attr)
          break;
        }
 
-      if (INTVAL (exp) < 0 && ! attr->negative_ok)
+      if (INTVAL (exp) < 0)
        {
          message_with_line (attr->lineno,
                             "negative numeric value specified for attribute %s",
@@ -983,8 +976,6 @@ 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))
              {
@@ -1087,8 +1078,7 @@ check_attr_value (rtx exp, struct attr_desc *attr)
            have_error = 1;
          }
        else if (attr
-                && (attr->is_numeric != attr2->is_numeric
-                    || (! attr->negative_ok && attr2->negative_ok)))
+                && attr->is_numeric != attr2->is_numeric)
          {
            message_with_line (attr->lineno,
                "numeric attribute mismatch calling `%s' from `%s'",
@@ -3505,7 +3495,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.  */
@@ -3715,8 +3705,6 @@ write_attr_get (struct attr_desc *attr)
     printf ("static ");
   if (!attr->is_numeric)
     printf ("enum attr_%s\n", attr->name);
-  else if (attr->unsigned_p)
-    printf ("unsigned int\n");
   else
     printf ("int\n");
 
@@ -3873,6 +3861,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
@@ -3880,8 +3887,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;
 
@@ -3898,15 +3903,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->def->insn_code != -1)
-         {
-           write_indent (indent);
-           printf ("case %d:  /* %s */\n",
-                   ie->def->insn_code, XSTR (ie->def->def, 0));
-         }
-    }
+    write_insn_cases (av->first_insn, indent);
   else
     {
       write_indent (indent);
@@ -3955,8 +3952,6 @@ write_expr_attr_cache (rtx p, struct attr_desc *attr)
 
       if (!attr->is_numeric)
        printf ("  enum attr_%s ", attr->name);
-      else if (attr->unsigned_p)
-       printf ("  unsigned int ");
       else
        printf ("  int ");
 
@@ -4025,7 +4020,7 @@ 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:
@@ -4268,8 +4263,8 @@ find_attr (const char **name_p, int create)
   attr = oballoc (sizeof (struct attr_desc));
   attr->name = DEF_ATTR_STRING (name);
   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->static_p = 0;
   attr->next = attrs[index];
   attrs[index] = attr;
 
@@ -4291,8 +4286,6 @@ make_internal_attr (const char *name, rtx value, int special)
   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);
 }
@@ -4357,7 +4350,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)
     {
@@ -4371,13 +4363,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->def->insn_code != -1)
-                 printf ("    case %d:  /* %s */\n",
-                         ie->def->insn_code, XSTR (ie->def->def, 0));
-             printf ("      return 0;\n");
-           }
+           write_insn_cases (av->first_insn, 4);
        }
 
       printf ("    default:\n");