OSDN Git Service

* java-tree.h (push_labeled_block, pop_labeled_block): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / read-rtl.c
index b4b1051..15fa503 100644 (file)
@@ -1,13 +1,13 @@
 /* RTL reader for GCC.
    Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005
+   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 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 +16,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, 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"
 
@@ -145,6 +144,7 @@ static int find_macro (struct macro_group *, const char *, FILE *);
 static struct mapping *read_mapping (struct macro_group *, htab_t, FILE *);
 static void check_code_macro (struct mapping *, FILE *);
 static rtx read_rtx_1 (FILE *, struct map_value **);
+static rtx read_rtx_variadic (FILE *, struct map_value **, rtx);
 
 /* The mode and code macro structures.  */
 static struct macro_group modes, codes;
@@ -436,7 +436,7 @@ apply_macro_to_rtx (rtx original, struct mapping *macro, int value,
   /* Create a shallow copy of ORIGINAL.  */
   bellwether_code = BELLWETHER_CODE (GET_CODE (original));
   x = rtx_alloc (bellwether_code);
-  memcpy (x, original, RTX_SIZE (bellwether_code));
+  memcpy (x, original, RTX_CODE_SIZE (bellwether_code));
 
   /* Change the mode or code itself.  */
   group = macro->group;
@@ -885,7 +885,7 @@ read_name (char *str, FILE *infile)
   p = str;
   while (1)
     {
-      if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r')
+      if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r' || c == EOF)
        break;
       if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
          || c == '(' || c == '[')
@@ -1696,7 +1696,49 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
 
   c = read_skip_spaces (infile);
   if (c != ')')
-    fatal_expected_char (infile, ')', c);
+    {
+      /* Syntactic sugar for AND and IOR, allowing Lisp-like
+        arbitrary number of arguments for them.  */
+      if (c == '(' && (GET_CODE (return_rtx) == AND
+                      || GET_CODE (return_rtx) == IOR))
+       return read_rtx_variadic (infile, mode_maps, return_rtx);
+      else
+       fatal_expected_char (infile, ')', c);
+    }
 
   return return_rtx;
 }
+
+/* Mutually recursive subroutine of read_rtx which reads
+   (thing x1 x2 x3 ...) and produces RTL as if
+   (thing x1 (thing x2 (thing x3 ...)))  had been written.
+   When called, FORM is (thing x1 x2), and the file position
+   is just past the leading parenthesis of x3.  Only works
+   for THINGs which are dyadic expressions, e.g. AND, IOR.  */
+static rtx
+read_rtx_variadic (FILE *infile, struct map_value **mode_maps, rtx form)
+{
+  char c = '(';
+  rtx p = form, q;
+
+  do
+    {
+      ungetc (c, infile);
+
+      q = rtx_alloc (GET_CODE (p));
+      PUT_MODE (q, GET_MODE (p));
+
+      XEXP (q, 0) = XEXP (p, 1);
+      XEXP (q, 1) = read_rtx_1 (infile, mode_maps);
+      
+      XEXP (p, 1) = q;
+      p = q;
+      c = read_skip_spaces (infile);
+    }
+  while (c == '(');
+
+  if (c != ')')
+    fatal_expected_char (infile, ')', c);
+
+  return form;
+}