summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/genextract.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-08-26 09:30:50 +0000
committerobrien <obrien@FreeBSD.org>1999-08-26 09:30:50 +0000
commit0bedf4fb30066e5e1d4342a1d3914dae7d37cba7 (patch)
tree68d8110b41afd0ebbf39167b1a4918eea667a7c5 /contrib/gcc/genextract.c
parentd4db5fb866b7ad5216abd5047774a3973b9901a9 (diff)
downloadFreeBSD-src-0bedf4fb30066e5e1d4342a1d3914dae7d37cba7.zip
FreeBSD-src-0bedf4fb30066e5e1d4342a1d3914dae7d37cba7.tar.gz
Virgin import of gcc from EGCS 1.1.2
Diffstat (limited to 'contrib/gcc/genextract.c')
-rw-r--r--contrib/gcc/genextract.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/contrib/gcc/genextract.c b/contrib/gcc/genextract.c
index 3861bd5..c06a74c 100644
--- a/contrib/gcc/genextract.c
+++ b/contrib/gcc/genextract.c
@@ -1,5 +1,5 @@
/* Generate code from machine description to extract operands from insn as rtl.
- Copyright (C) 1987, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1987, 91, 92, 93, 97, 1998 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -19,8 +19,13 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
#include "rtl.h"
#include "obstack.h"
#include "insn-config.h"
@@ -31,9 +36,6 @@ 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;
@@ -98,14 +100,15 @@ 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;
+static char *copystr PROTO ((char *));
static void mybzero ();
-void fancy_abort ();
+void fancy_abort PROTO ((void));
static void
gen_insn (insn)
@@ -140,7 +143,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)
{
@@ -196,7 +199,6 @@ walk_rtx (x, path)
register int i;
register int len;
register char *fmt;
- register struct code_ptr *link;
int depth = strlen (path);
char *newpath;
@@ -275,6 +277,9 @@ walk_rtx (x, path)
case ADDRESS:
walk_rtx (XEXP (x, 0), path);
return;
+
+ default:
+ break;
}
newpath = (char *) alloca (depth + 2);
@@ -313,6 +318,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. */
@@ -362,11 +375,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);
}
@@ -438,11 +462,12 @@ main (argc, argv)
from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
+ printf ("#include \"system.h\"\n");
printf ("#include \"rtl.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 ("static rtx junk ATTRIBUTE_UNUSED;\n");
printf ("extern rtx recog_operand[];\n");
printf ("extern rtx *recog_operand_loc[];\n");
@@ -455,6 +480,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 ATTRIBUTE_UNUSED;\n\n");
printf (" switch (INSN_CODE (insn))\n");
printf (" {\n");
printf (" case -1:\n");
@@ -502,11 +528,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 (pat, 0, 0), ro,\n");
- printf (" sizeof (rtx) * XVECLEN (pat, 0));\n");
+ printf (" for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)\n");
+ printf (" ro[i] = XVECEXP (pat, 0, i);\n");
printf (" break;\n\n");
}
OpenPOWER on IntegriCloud