OSDN Git Service

PR bootstrap/35216
[pf3gnuchains/gcc-fork.git] / gcc / genpreds.c
index 535c9dd..bc20b16 100644 (file)
@@ -2,13 +2,14 @@
    - prototype declarations for operand predicates (tm-preds.h)
    - function definitions of operand predicates, if defined new-style
      (insn-preds.c)
    - prototype declarations for operand predicates (tm-preds.h)
    - function definitions of operand predicates, if defined new-style
      (insn-preds.c)
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007
+   Free Software Foundation, Inc.
 
 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
 
 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)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -17,9 +18,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 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, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "bconfig.h"
 #include "system.h"
 
 #include "bconfig.h"
 #include "system.h"
@@ -1000,26 +1000,44 @@ write_lookup_constraint (void)
        "}\n");
 }
 
        "}\n");
 }
 
-/* Write out the function which computes constraint name lengths from
-   their enumerators. */
+/* Write out a function which looks at a string and determines what
+   the constraint name length is.  */
 static void
 write_insn_constraint_len (void)
 {
 static void
 write_insn_constraint_len (void)
 {
-  struct constraint_data *c;
-
-  if (constraint_max_namelen == 1)
-    return;
+  unsigned int i;
 
 
-  puts ("size_t\n"
-       "insn_constraint_len (enum constraint_num c)\n"
+  puts ("static inline size_t\n"
+       "insn_constraint_len (char fc, const char *str ATTRIBUTE_UNUSED)\n"
        "{\n"
        "{\n"
-       "  switch (c)\n"
+       "  switch (fc)\n"
        "    {");
 
        "    {");
 
-  FOR_ALL_CONSTRAINTS (c)
-    if (c->namelen > 1)
-      printf ("    case CONSTRAINT_%s: return %lu;\n", c->c_name,
-             (unsigned long int) c->namelen);
+  for (i = 0; i < ARRAY_SIZE(constraints_by_letter_table); i++)
+    {
+      struct constraint_data *c = constraints_by_letter_table[i];
+
+      if (!c
+         || c->namelen == 1)
+       continue;
+
+      /* Constraints with multiple characters should have the same
+        length.  */
+      {
+       struct constraint_data *c2 = c->next_this_letter;
+       size_t len = c->namelen;
+       while (c2)
+         {
+           if (c2->namelen != len)
+             error ("Multi-letter constraints with first letter '%c' "
+                    "should have same length", i);
+           c2 = c2->next_this_letter;
+         }
+      }
+
+      printf ("    case '%c': return %lu;\n",
+             i, (unsigned long int) c->namelen);
+    }
 
   puts ("    default: break;\n"
        "    }\n"
 
   puts ("    default: break;\n"
        "    }\n"
@@ -1247,9 +1265,11 @@ write_tm_preds_h (void)
            "extern bool constraint_satisfied_p (rtx, enum constraint_num);\n");
 
       if (constraint_max_namelen > 1)
            "extern bool constraint_satisfied_p (rtx, enum constraint_num);\n");
 
       if (constraint_max_namelen > 1)
-       puts ("extern size_t insn_constraint_len (enum constraint_num);\n"
-             "#define CONSTRAINT_LEN(c_,s_) "
-             "insn_constraint_len (lookup_constraint (s_))\n");
+        {
+         write_insn_constraint_len ();
+         puts ("#define CONSTRAINT_LEN(c_,s_) "
+               "insn_constraint_len (c_,s_)\n");
+       }
       else
        puts ("#define CONSTRAINT_LEN(c_,s_) 1\n");
       if (have_register_constraints)
       else
        puts ("#define CONSTRAINT_LEN(c_,s_) 1\n");
       if (have_register_constraints)
@@ -1336,12 +1356,10 @@ write_insn_preds_c (void)
   if (constraint_max_namelen > 0)
     {
       write_lookup_constraint ();
   if (constraint_max_namelen > 0)
     {
       write_lookup_constraint ();
-      write_regclass_for_constraint ();
+      if (have_register_constraints)
+       write_regclass_for_constraint ();
       write_constraint_satisfied_p ();
       
       write_constraint_satisfied_p ();
       
-      if (constraint_max_namelen > 1)
-       write_insn_constraint_len ();
-
       if (have_const_int_constraints)
        write_insn_const_int_ok_for_constraint ();
 
       if (have_const_int_constraints)
        write_insn_const_int_ok_for_constraint ();