OSDN Git Service

(do_include): Diagnose #import and #include_next if pedantic and if
[pf3gnuchains/gcc-fork.git] / gcc / genextract.c
index fb58aaf..f222de1 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate code from machine description to extract operands from insn as rtl.
-   Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1991, 1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -15,11 +15,12 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 #include <stdio.h>
-#include "config.h"
+#include "hconfig.h"
 #include "rtl.h"
 #include "obstack.h"
 #include "insn-config.h"
@@ -31,6 +32,10 @@ struct obstack *rtl_obstack = &obstack;
 #define obstack_chunk_free free
 
 extern void free ();
+extern rtx read_rtx ();
+
+/* Names for patterns.  Need to allow linking with print-rtl.  */
+char **insn_name_ptr;
 
 /* This structure contains all the information needed to describe one
    set of extractions methods.  Each method may be used by more than 
@@ -135,7 +140,7 @@ gen_insn (insn)
   link = (struct code_ptr *) xmalloc (sizeof (struct code_ptr));
   link->insn_code = insn_code_number;
 
-  /* See if we find something that already had this extraction method. */
+  /* See if we find something that already had this extraction method.  */
 
   for (p = extractions; p; p = p->next)
     {
@@ -215,12 +220,28 @@ walk_rtx (x, path)
       break;
 
     case MATCH_DUP:
-    case MATCH_OP_DUP:
+    case MATCH_PAR_DUP:
       duplocs[dup_count] = copystr (path);
       dupnums[dup_count] = XINT (x, 0);
       dup_count++;
       break;
 
+    case MATCH_OP_DUP:
+      duplocs[dup_count] = copystr (path);
+      dupnums[dup_count] = XINT (x, 0);
+      dup_count++;
+      
+      newpath = (char *) alloca (depth + 2);
+      strcpy (newpath, path);
+      newpath[depth + 1] = 0;
+      
+      for (i = XVECLEN (x, 1) - 1; i >= 0; i--)
+        {
+         newpath[depth] = '0' + i;
+         walk_rtx (XVECEXP (x, 1, i), newpath);
+        }
+      return;
+      
     case MATCH_OPERATOR:
       oplocs[XINT (x, 0)] = copystr (path);
       op_count = MAX (op_count, XINT (x, 0) + 1);
@@ -274,7 +295,7 @@ walk_rtx (x, path)
          int j;
          for (j = XVECLEN (x, i) - 1; j >= 0; j--)
            {
-             newpath[depth] = 'a' + i;
+             newpath[depth] = 'a' + j;
              walk_rtx (XVECEXP (x, i, j), newpath);
            }
        }
@@ -305,7 +326,7 @@ print_path (path)
        abort ();
     }
   
-  printf ("insn");
+  printf ("pat");
 
   for (i = 0; i < len; i++)
     {
@@ -390,7 +411,6 @@ main (argc, argv)
 {
   rtx desc;
   FILE *infile;
-  extern rtx read_rtx ();
   register int c, i;
   struct extraction *p;
   struct code_ptr *link;
@@ -428,17 +448,15 @@ from the machine description file `md'.  */\n\n");
   printf ("extern rtx *recog_operand_loc[];\n");
   printf ("extern rtx *recog_dup_loc[];\n");
   printf ("extern char recog_dup_num[];\n");
-  printf ("extern\n#ifdef __GNUC__\nvolatile\n#endif\n");
-  printf ("void fatal_insn_not_found ();\n\n");
 
   printf ("void\ninsn_extract (insn)\n");
   printf ("     rtx insn;\n");
   printf ("{\n");
   printf ("  register rtx *ro = recog_operand;\n");
   printf ("  register rtx **ro_loc = recog_operand_loc;\n");
-  printf ("  int insn_code = INSN_CODE (insn);\n");
-  printf ("  insn = PATTERN (insn);\n");
-  printf ("  switch (insn_code)\n");
+  printf ("  rtx pat = PATTERN (insn);\n");
+  printf ("  int i;\n\n");
+  printf ("  switch (INSN_CODE (insn))\n");
   printf ("    {\n");
   printf ("    case -1:\n");
   printf ("      fatal_insn_not_found (insn);\n\n");
@@ -485,11 +503,8 @@ from the machine description file `md'.  */\n\n");
       /* The vector in the insn says how many operands it has.
         And all it contains are operands.  In fact, the vector was
         created just for the sake of this function.  */
-      printf ("#if __GNUC__ > 1 && !defined (bcopy)\n");
-      printf ("#define bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)\n");
-      printf ("#endif\n");
-      printf ("      bcopy (&XVECEXP (insn, 0, 0), ro,\n");
-      printf ("             sizeof (rtx) * XVECLEN (insn, 0));\n");
+      printf ("      for (i = XVECLEN (pat, 0); i >= 0; i--)\n");
+      printf ("          ro[i] = XVECEXP (pat, 0, i);\n");
       printf ("      break;\n\n");
     }
 
@@ -504,7 +519,7 @@ from the machine description file `md'.  */\n\n");
          if (p->oplocs[i] == 0)
            {
              printf ("      ro[%d] = const0_rtx;\n", i);
-             printf ("      ro_loc[%d] = &junk;\n", i, i);
+             printf ("      ro_loc[%d] = &junk;\n", i);
            }
          else
            {