OSDN Git Service

* init.c (expand_vec_init): Fix off-by-one error.
[pf3gnuchains/gcc-fork.git] / gcc / genextract.c
index 6ebdfff..a1e48ed 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate code from machine description to extract operands from insn as rtl.
-   Copyright (C) 1987, 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1987, 91, 92, 93, 97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -19,25 +19,18 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 
-#include <stdio.h>
 #include "hconfig.h"
+#include "system.h"
 #include "rtl.h"
 #include "obstack.h"
 #include "insn-config.h"
 
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
 static struct obstack obstack;
 struct obstack *rtl_obstack = &obstack;
 
 #define obstack_chunk_alloc xmalloc
 #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;
 
@@ -102,14 +95,16 @@ static int dupnums[MAX_DUP_OPERANDS];
 
 static struct code_ptr *peepholes;
 
-static void walk_rtx ();
-static void print_path ();
-char *xmalloc ();
-char *xrealloc ();
-static void fatal ();
-static char *copystr ();
+static void gen_insn PROTO ((rtx));
+static void walk_rtx PROTO ((rtx, char *));
+static void print_path PROTO ((char *));
+char *xmalloc PROTO ((unsigned));
+char *xrealloc PROTO ((char *, unsigned));
+static void fatal PVPROTO ((char *, ...))
+  ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+static char *copystr PROTO ((char *));
 static void mybzero ();
-void fancy_abort ();
+void fancy_abort PROTO ((void)) ATTRIBUTE_NORETURN;
 \f
 static void
 gen_insn (insn)
@@ -319,6 +314,14 @@ print_path (path)
   register int len = strlen (path);
   register int i;
 
+  if (len == 0)
+    {
+      /* Don't emit "pat", since we may try to take the address of it,
+        which isn't what is intended.  */
+      printf("PATTERN (insn)");
+      return;
+    }
+
   /* We first write out the operations (XEXP or XVECEXP) in reverse
      order, then write "insn", then the indices in forward order.  */
 
@@ -368,11 +371,22 @@ xrealloc (ptr, size)
 }
 
 static void
-fatal (s, a1, a2)
-     char *s;
+fatal VPROTO ((char *format, ...))
 {
+#ifndef __STDC__
+  char *format;
+#endif
+  va_list ap;
+
+  VA_START (ap, format);
+
+#ifndef __STDC__
+  format = va_arg (ap, char *);
+#endif
+
   fprintf (stderr, "genextract: ");
-  fprintf (stderr, s, a1, a2);
+  vfprintf (stderr, format, ap);
+  va_end (ap);
   fprintf (stderr, "\n");
   exit (FATAL_EXIT_CODE);
 }
@@ -444,17 +458,15 @@ main (argc, argv)
 from the machine description file `md'.  */\n\n");
 
   printf ("#include \"config.h\"\n");
-  printf ("#include <stdio.h>\n");
-  printf ("#include \"rtl.h\"\n\n");
+  printf ("#include \"system.h\"\n");
+  printf ("#include \"rtl.h\"\n");
+  printf ("#include \"insn-config.h\"\n");
+  printf ("#include \"recog.h\"\n");
+  printf ("#include \"toplev.h\"\n\n");
 
   /* This variable exists only so it can be the "location"
      of any missing operand whose numbers are skipped by a given pattern.  */
-  printf ("static rtx junk;\n");
-
-  printf ("extern rtx recog_operand[];\n");
-  printf ("extern rtx *recog_operand_loc[];\n");
-  printf ("extern rtx *recog_dup_loc[];\n");
-  printf ("extern char recog_dup_num[];\n");
+  printf ("static rtx junk ATTRIBUTE_UNUSED;\n");
 
   printf ("void\ninsn_extract (insn)\n");
   printf ("     rtx insn;\n");
@@ -462,7 +474,7 @@ from the machine description file `md'.  */\n\n");
   printf ("  register rtx *ro = recog_operand;\n");
   printf ("  register rtx **ro_loc = recog_operand_loc;\n");
   printf ("  rtx pat = PATTERN (insn);\n");
-  printf ("  int i;\n\n");
+  printf ("  int i ATTRIBUTE_UNUSED;\n\n");
   printf ("  switch (INSN_CODE (insn))\n");
   printf ("    {\n");
   printf ("    case -1:\n");