/* Generate code from to output assembler insns as recognized from rtl.
- Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
This file is part of GNU CC.
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. */
/* This program reads the machine description for the compiler target machine
It would not make an case in output_insn_hairy because the template
given in the entry is a constant (it does not start with `*'). */
\f
-#include <stdio.h>
-#include "config.h"
+#include "hconfig.h"
+#include "system.h"
#include "rtl.h"
#include "obstack.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-extern void free ();
-
-char *xmalloc ();
+char *xmalloc PROTO((unsigned));
static void fatal ();
-void fancy_abort ();
+void fancy_abort PROTO((void));
static void error ();
static void mybcopy ();
static void mybzero ();
-static int n_occurrences ();
+static int n_occurrences PROTO((int, char *));
+
+/* Define this so we can link with print-rtl.o to get debug_rtx function. */
+char **insn_name_ptr = 0;
/* insns in the machine description are assigned sequential code numbers
that are used by insn-recog.c (produced by genrecog) to communicate
for this machine description. */
int have_constraints;
+
+/* Nonzero if some error has occurred. We will make all errors fatal, but
+ might as well continue until we see all of them. */
+
+static int have_error;
+\f
+static void output_prologue PROTO((void));
+static void output_epilogue PROTO((void));
+static void scan_operands PROTO((rtx, int, int));
+static void process_template PROTO((struct data *, char *));
+static void validate_insn_alternatives PROTO((struct data *));
+static void gen_insn PROTO((rtx));
+static void gen_peephole PROTO((rtx));
+static void gen_expand PROTO((rtx));
+static void gen_split PROTO((rtx));
+static int n_occurrences PROTO((int, char *));
\f
static void
output_prologue ()
{
-
printf ("/* Generated automatically by the program `genoutput'\n\
from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
+ printf ("#include \"system.h\"\n");
+ printf ("#include \"flags.h\"\n");
printf ("#include \"rtl.h\"\n");
printf ("#include \"regs.h\"\n");
printf ("#include \"hard-reg-set.h\"\n");
printf ("#include \"insn-codes.h\"\n\n");
printf ("#include \"recog.h\"\n\n");
- printf ("#include <stdio.h>\n");
printf ("#include \"output.h\"\n");
}
printf ("\nrtx (*const insn_gen_function[]) () =\n {\n");
for (d = insn_data; d; d = d->next)
{
- if (d->name)
+ if (d->name && d->name[0] != '*')
printf (" gen_%s,\n", d->name);
else
printf (" 0,\n");
int offset = 0;
int next;
char * last_name = 0;
- char * next_name;
+ char * next_name = 0;
register struct data *n;
- for (n = insn_data, next = 0; n; n = n->next, next++)
+ for (n = insn_data, next = 1; n; n = n->next, next++)
if (n->name)
{
next_name = n->name;
case MATCH_DUP:
case MATCH_OP_DUP:
+ case MATCH_PAR_DUP:
++num_dups;
return;
case STRICT_LOW_PART:
scan_operands (XEXP (part, 0), 0, 1);
return;
+
+ default:
+ break;
}
format_ptr = GET_RTX_FORMAT (GET_CODE (part));
switch (*format_ptr++)
{
case 'e':
+ case 'u':
scan_operands (XEXP (part, i), 0, 0);
break;
case 'E':
printf ("\nstatic char *\n");
printf ("output_%d (operands, insn)\n", d->code_number);
- printf (" rtx *operands;\n");
- printf (" rtx insn;\n");
+ printf (" rtx *operands ATTRIBUTE_UNUSED;\n");
+ printf (" rtx insn ATTRIBUTE_UNUSED;\n");
printf ("{\n");
/* If the assembler code template starts with a @ it is a newline-separated
printf (" \"");
while (*cp != '\n' && *cp != '\0')
- putchar (*cp++);
+ {
+ putchar (*cp);
+ cp++;
+ }
printf ("\",\n");
i++;
VAX-11 "C" on VMS. It is the equivalent of:
printf ("%s\n", &template[1])); */
cp = &template[1];
- while (*cp) putchar (*cp++);
+ while (*cp)
+ {
+ putchar (*cp);
+ cp++;
+ }
putchar ('\n');
}
mybzero (d->strict_low, sizeof strict_low);
d->n_dups = 0;
+ d->n_alternatives = 0;
d->template = 0;
d->outfun = 0;
}
fprintf (stderr, "genoutput: ");
fprintf (stderr, s, a1, a2);
fprintf (stderr, "\n");
+
+ have_error = 1;
}
\f
int
{
rtx desc;
FILE *infile;
- extern rtx read_rtx ();
register int c;
obstack_init (rtl_obstack);
output_epilogue ();
fflush (stdout);
- exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+ exit (ferror (stdout) != 0 || have_error
+ ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+
/* NOTREACHED */
return 0;
}
static int
n_occurrences (c, s)
- char c;
+ int c;
char *s;
{
int n = 0;