Import final gcc2 snapshot (990109)
[official-gcc.git] / gcc / genemit.c
blobe57a30e9c63149706a3f4c6db564964435835744
1 /* Generate code from machine description to emit insns as rtl.
2 Copyright (C) 1987, 88, 91, 94, 95, 97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include "hconfig.h"
23 #include "system.h"
24 #include "rtl.h"
25 #include "obstack.h"
27 static struct obstack obstack;
28 struct obstack *rtl_obstack = &obstack;
30 #define obstack_chunk_alloc xmalloc
31 #define obstack_chunk_free free
33 extern rtx read_rtx ();
35 char *xmalloc ();
37 #ifdef HAVE_VPRINTF
38 void fatal PVPROTO((char *, ...));
39 #else
40 /* We must not provide any prototype here, even if ANSI C. */
41 void fatal PROTO(());
42 #endif
44 void fancy_abort ();
46 static int max_opno;
47 static int max_dup_opno;
48 static int register_constraints;
49 static int insn_code_number;
50 static int insn_index_number;
52 /* Data structure for recording the patterns of insns that have CLOBBERs.
53 We use this to output a function that adds these CLOBBERs to a
54 previously-allocated PARALLEL expression. */
56 struct clobber_pat
58 struct clobber_ent *insns;
59 rtx pattern;
60 int first_clobber;
61 struct clobber_pat *next;
62 } *clobber_list;
64 /* Records one insn that uses the clobber list. */
66 struct clobber_ent
68 int code_number; /* Counts only insns. */
69 struct clobber_ent *next;
72 static void
73 max_operand_1 (x)
74 rtx x;
76 register RTX_CODE code;
77 register int i;
78 register int len;
79 register char *fmt;
81 if (x == 0)
82 return;
84 code = GET_CODE (x);
86 if (code == MATCH_OPERAND && XSTR (x, 2) != 0 && *XSTR (x, 2) != '\0')
87 register_constraints = 1;
88 if (code == MATCH_SCRATCH && XSTR (x, 1) != 0 && *XSTR (x, 1) != '\0')
89 register_constraints = 1;
90 if (code == MATCH_OPERAND || code == MATCH_OPERATOR
91 || code == MATCH_PARALLEL)
92 max_opno = MAX (max_opno, XINT (x, 0));
93 if (code == MATCH_DUP || code == MATCH_OP_DUP || code == MATCH_PAR_DUP)
94 max_dup_opno = MAX (max_dup_opno, XINT (x, 0));
96 fmt = GET_RTX_FORMAT (code);
97 len = GET_RTX_LENGTH (code);
98 for (i = 0; i < len; i++)
100 if (fmt[i] == 'e' || fmt[i] == 'u')
101 max_operand_1 (XEXP (x, i));
102 else if (fmt[i] == 'E')
104 int j;
105 for (j = 0; j < XVECLEN (x, i); j++)
106 max_operand_1 (XVECEXP (x, i, j));
111 static int
112 max_operand_vec (insn, arg)
113 rtx insn;
114 int arg;
116 register int len = XVECLEN (insn, arg);
117 register int i;
119 max_opno = -1;
120 max_dup_opno = -1;
122 for (i = 0; i < len; i++)
123 max_operand_1 (XVECEXP (insn, arg, i));
125 return max_opno + 1;
128 static void
129 print_code (code)
130 RTX_CODE code;
132 register char *p1;
133 for (p1 = GET_RTX_NAME (code); *p1; p1++)
135 if (*p1 >= 'a' && *p1 <= 'z')
136 putchar (*p1 + 'A' - 'a');
137 else
138 putchar (*p1);
142 /* Print a C expression to construct an RTX just like X,
143 substituting any operand references appearing within. */
145 static void
146 gen_exp (x)
147 rtx x;
149 register RTX_CODE code;
150 register int i;
151 register int len;
152 register char *fmt;
154 if (x == 0)
156 printf ("NULL_RTX");
157 return;
160 code = GET_CODE (x);
162 switch (code)
164 case MATCH_OPERAND:
165 case MATCH_DUP:
166 printf ("operand%d", XINT (x, 0));
167 return;
169 case MATCH_OP_DUP:
170 printf ("gen_rtx (GET_CODE (operand%d), GET_MODE (operand%d)",
171 XINT (x, 0), XINT (x, 0));
172 for (i = 0; i < XVECLEN (x, 1); i++)
174 printf (",\n\t\t");
175 gen_exp (XVECEXP (x, 1, i));
177 printf (")");
178 return;
180 case MATCH_OPERATOR:
181 printf ("gen_rtx (GET_CODE (operand%d)", XINT (x, 0));
182 printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
183 for (i = 0; i < XVECLEN (x, 2); i++)
185 printf (",\n\t\t");
186 gen_exp (XVECEXP (x, 2, i));
188 printf (")");
189 return;
191 case MATCH_PARALLEL:
192 case MATCH_PAR_DUP:
193 printf ("operand%d", XINT (x, 0));
194 return;
196 case MATCH_SCRATCH:
197 printf ("gen_rtx_SCRATCH (%smode)", GET_MODE_NAME (GET_MODE (x)));
198 return;
200 case ADDRESS:
201 fatal ("ADDRESS expression code used in named instruction pattern");
203 case PC:
204 printf ("pc_rtx");
205 return;
207 case CC0:
208 printf ("cc0_rtx");
209 return;
211 case CONST_INT:
212 if (INTVAL (x) == 0)
213 printf ("const0_rtx");
214 else if (INTVAL (x) == 1)
215 printf ("const1_rtx");
216 else if (INTVAL (x) == -1)
217 printf ("constm1_rtx");
218 else if (INTVAL (x) == STORE_FLAG_VALUE)
219 printf ("const_true_rtx");
220 else
221 printf (
222 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
223 "GEN_INT (%d)",
224 #else
225 "GEN_INT (%ld)",
226 #endif
227 INTVAL (x));
228 return;
230 case CONST_DOUBLE:
231 /* These shouldn't be written in MD files. Instead, the appropriate
232 routines in varasm.c should be called. */
233 abort ();
236 printf ("gen_rtx_");
237 print_code (code);
238 printf (" (%smode", GET_MODE_NAME (GET_MODE (x)));
240 fmt = GET_RTX_FORMAT (code);
241 len = GET_RTX_LENGTH (code);
242 for (i = 0; i < len; i++)
244 if (fmt[i] == '0')
245 break;
246 printf (",\n\t");
247 if (fmt[i] == 'e' || fmt[i] == 'u')
248 gen_exp (XEXP (x, i));
249 else if (fmt[i] == 'i')
250 printf ("%u", XINT (x, i));
251 else if (fmt[i] == 's')
252 printf ("\"%s\"", XSTR (x, i));
253 else if (fmt[i] == 'E')
255 int j;
256 printf ("gen_rtvec (%d", XVECLEN (x, i));
257 for (j = 0; j < XVECLEN (x, i); j++)
259 printf (",\n\t\t");
260 gen_exp (XVECEXP (x, i, j));
262 printf (")");
264 else
265 abort ();
267 printf (")");
270 /* Generate the `gen_...' function for a DEFINE_INSN. */
272 static void
273 gen_insn (insn)
274 rtx insn;
276 int operands;
277 register int i;
279 /* See if the pattern for this insn ends with a group of CLOBBERs of (hard)
280 registers or MATCH_SCRATCHes. If so, store away the information for
281 later. */
283 if (XVEC (insn, 1))
285 for (i = XVECLEN (insn, 1) - 1; i > 0; i--)
286 if (GET_CODE (XVECEXP (insn, 1, i)) != CLOBBER
287 || (GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != REG
288 && GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != MATCH_SCRATCH))
289 break;
291 if (i != XVECLEN (insn, 1) - 1)
293 register struct clobber_pat *p;
294 register struct clobber_ent *link
295 = (struct clobber_ent *) xmalloc (sizeof (struct clobber_ent));
296 register int j;
298 link->code_number = insn_code_number;
300 /* See if any previous CLOBBER_LIST entry is the same as this
301 one. */
303 for (p = clobber_list; p; p = p->next)
305 if (p->first_clobber != i + 1
306 || XVECLEN (p->pattern, 1) != XVECLEN (insn, 1))
307 continue;
309 for (j = i + 1; j < XVECLEN (insn, 1); j++)
311 rtx old = XEXP (XVECEXP (p->pattern, 1, j), 0);
312 rtx new = XEXP (XVECEXP (insn, 1, j), 0);
314 /* OLD and NEW are the same if both are to be a SCRATCH
315 of the same mode,
316 or if both are registers of the same mode and number. */
317 if (! (GET_MODE (old) == GET_MODE (new)
318 && ((GET_CODE (old) == MATCH_SCRATCH
319 && GET_CODE (new) == MATCH_SCRATCH)
320 || (GET_CODE (old) == REG && GET_CODE (new) == REG
321 && REGNO (old) == REGNO (new)))))
322 break;
325 if (j == XVECLEN (insn, 1))
326 break;
329 if (p == 0)
331 p = (struct clobber_pat *) xmalloc (sizeof (struct clobber_pat));
333 p->insns = 0;
334 p->pattern = insn;
335 p->first_clobber = i + 1;
336 p->next = clobber_list;
337 clobber_list = p;
340 link->next = p->insns;
341 p->insns = link;
345 /* Don't mention instructions whose names are the null string
346 or begin with '*'. They are in the machine description just
347 to be recognized. */
348 if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*')
349 return;
351 /* Find out how many operands this function has,
352 and also whether any of them have register constraints. */
353 register_constraints = 0;
354 operands = max_operand_vec (insn, 1);
355 if (max_dup_opno >= operands)
356 fatal ("match_dup operand number has no match_operand");
358 /* Output the function name and argument declarations. */
359 printf ("rtx\ngen_%s (", XSTR (insn, 0));
360 for (i = 0; i < operands; i++)
361 printf (i ? ", operand%d" : "operand%d", i);
362 printf (")\n");
363 for (i = 0; i < operands; i++)
364 printf (" rtx operand%d;\n", i);
365 printf ("{\n");
367 /* Output code to construct and return the rtl for the instruction body */
369 if (XVECLEN (insn, 1) == 1)
371 printf (" return ");
372 gen_exp (XVECEXP (insn, 1, 0));
373 printf (";\n}\n\n");
375 else
377 printf (" return gen_rtx_PARALLEL (VOIDmode, gen_rtvec (%d",
378 XVECLEN (insn, 1));
380 for (i = 0; i < XVECLEN (insn, 1); i++)
382 printf (",\n\t\t");
383 gen_exp (XVECEXP (insn, 1, i));
385 printf ("));\n}\n\n");
389 /* Generate the `gen_...' function for a DEFINE_EXPAND. */
391 static void
392 gen_expand (expand)
393 rtx expand;
395 int operands;
396 register int i;
398 if (strlen (XSTR (expand, 0)) == 0)
399 fatal ("define_expand lacks a name");
400 if (XVEC (expand, 1) == 0)
401 fatal ("define_expand for %s lacks a pattern", XSTR (expand, 0));
403 /* Find out how many operands this function has,
404 and also whether any of them have register constraints. */
405 register_constraints = 0;
407 operands = max_operand_vec (expand, 1);
409 /* Output the function name and argument declarations. */
410 printf ("rtx\ngen_%s (", XSTR (expand, 0));
411 for (i = 0; i < operands; i++)
412 printf (i ? ", operand%d" : "operand%d", i);
413 printf (")\n");
414 for (i = 0; i < operands; i++)
415 printf (" rtx operand%d;\n", i);
416 printf ("{\n");
418 /* If we don't have any C code to write, only one insn is being written,
419 and no MATCH_DUPs are present, we can just return the desired insn
420 like we do for a DEFINE_INSN. This saves memory. */
421 if ((XSTR (expand, 3) == 0 || *XSTR (expand, 3) == '\0')
422 && operands > max_dup_opno
423 && XVECLEN (expand, 1) == 1)
425 printf (" return ");
426 gen_exp (XVECEXP (expand, 1, 0));
427 printf (";\n}\n\n");
428 return;
431 /* For each operand referred to only with MATCH_DUPs,
432 make a local variable. */
433 for (i = operands; i <= max_dup_opno; i++)
434 printf (" rtx operand%d;\n", i);
435 if (operands > 0 || max_dup_opno >= 0)
436 printf (" rtx operands[%d];\n", MAX (operands, max_dup_opno + 1));
437 printf (" rtx _val = 0;\n");
438 printf (" start_sequence ();\n");
440 /* The fourth operand of DEFINE_EXPAND is some code to be executed
441 before the actual construction.
442 This code expects to refer to `operands'
443 just as the output-code in a DEFINE_INSN does,
444 but here `operands' is an automatic array.
445 So copy the operand values there before executing it. */
446 if (XSTR (expand, 3) && *XSTR (expand, 3))
448 /* Output code to copy the arguments into `operands'. */
449 for (i = 0; i < operands; i++)
450 printf (" operands[%d] = operand%d;\n", i, i);
452 /* Output the special code to be executed before the sequence
453 is generated. */
454 printf ("%s\n", XSTR (expand, 3));
456 /* Output code to copy the arguments back out of `operands'
457 (unless we aren't going to use them at all). */
458 if (XVEC (expand, 1) != 0)
460 for (i = 0; i < operands; i++)
461 printf (" operand%d = operands[%d];\n", i, i);
462 for (; i <= max_dup_opno; i++)
463 printf (" operand%d = operands[%d];\n", i, i);
467 /* Output code to construct the rtl for the instruction bodies.
468 Use emit_insn to add them to the sequence being accumulated.
469 But don't do this if the user's code has set `no_more' nonzero. */
471 for (i = 0; i < XVECLEN (expand, 1); i++)
473 rtx next = XVECEXP (expand, 1, i);
474 if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC)
475 || (GET_CODE (next) == PARALLEL
476 && GET_CODE (XVECEXP (next, 0, 0)) == SET
477 && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC)
478 || GET_CODE (next) == RETURN)
479 printf (" emit_jump_insn (");
480 else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL)
481 || GET_CODE (next) == CALL
482 || (GET_CODE (next) == PARALLEL
483 && GET_CODE (XVECEXP (next, 0, 0)) == SET
484 && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL)
485 || (GET_CODE (next) == PARALLEL
486 && GET_CODE (XVECEXP (next, 0, 0)) == CALL))
487 printf (" emit_call_insn (");
488 else if (GET_CODE (next) == CODE_LABEL)
489 printf (" emit_label (");
490 else if (GET_CODE (next) == MATCH_OPERAND
491 || GET_CODE (next) == MATCH_OPERATOR
492 || GET_CODE (next) == MATCH_PARALLEL
493 || GET_CODE (next) == MATCH_OP_DUP
494 || GET_CODE (next) == MATCH_DUP
495 || GET_CODE (next) == PARALLEL)
496 printf (" emit (");
497 else
498 printf (" emit_insn (");
499 gen_exp (next);
500 printf (");\n");
501 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
502 && GET_CODE (SET_SRC (next)) == LABEL_REF)
503 printf (" emit_barrier ();");
506 /* Call `gen_sequence' to make a SEQUENCE out of all the
507 insns emitted within this gen_... function. */
509 printf (" _done:\n");
510 printf (" _val = gen_sequence ();\n");
511 printf (" _fail:\n");
512 printf (" end_sequence ();\n");
513 printf (" return _val;\n}\n\n");
516 /* Like gen_expand, but generates a SEQUENCE. */
518 static void
519 gen_split (split)
520 rtx split;
522 register int i;
523 int operands;
525 if (XVEC (split, 0) == 0)
526 fatal ("define_split (definition %d) lacks a pattern", insn_index_number);
527 else if (XVEC (split, 2) == 0)
528 fatal ("define_split (definition %d) lacks a replacement pattern",
529 insn_index_number);
531 /* Find out how many operands this function has. */
533 max_operand_vec (split, 2);
534 operands = MAX (max_opno, max_dup_opno) + 1;
536 /* Output the function name and argument declarations. */
537 printf ("rtx\ngen_split_%d (operands)\n rtx *operands;\n",
538 insn_code_number);
539 printf ("{\n");
541 /* Declare all local variables. */
542 for (i = 0; i < operands; i++)
543 printf (" rtx operand%d;\n", i);
544 printf (" rtx _val = 0;\n");
545 printf (" start_sequence ();\n");
547 /* The fourth operand of DEFINE_SPLIT is some code to be executed
548 before the actual construction. */
550 if (XSTR (split, 3))
551 printf ("%s\n", XSTR (split, 3));
553 /* Output code to copy the arguments back out of `operands' */
554 for (i = 0; i < operands; i++)
555 printf (" operand%d = operands[%d];\n", i, i);
557 /* Output code to construct the rtl for the instruction bodies.
558 Use emit_insn to add them to the sequence being accumulated.
559 But don't do this if the user's code has set `no_more' nonzero. */
561 for (i = 0; i < XVECLEN (split, 2); i++)
563 rtx next = XVECEXP (split, 2, i);
564 if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC)
565 || (GET_CODE (next) == PARALLEL
566 && GET_CODE (XVECEXP (next, 0, 0)) == SET
567 && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC)
568 || GET_CODE (next) == RETURN)
569 printf (" emit_jump_insn (");
570 else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL)
571 || GET_CODE (next) == CALL
572 || (GET_CODE (next) == PARALLEL
573 && GET_CODE (XVECEXP (next, 0, 0)) == SET
574 && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL)
575 || (GET_CODE (next) == PARALLEL
576 && GET_CODE (XVECEXP (next, 0, 0)) == CALL))
577 printf (" emit_call_insn (");
578 else if (GET_CODE (next) == CODE_LABEL)
579 printf (" emit_label (");
580 else if (GET_CODE (next) == MATCH_OPERAND
581 || GET_CODE (next) == MATCH_OPERATOR
582 || GET_CODE (next) == MATCH_PARALLEL
583 || GET_CODE (next) == MATCH_OP_DUP
584 || GET_CODE (next) == MATCH_DUP
585 || GET_CODE (next) == PARALLEL)
586 printf (" emit (");
587 else
588 printf (" emit_insn (");
589 gen_exp (next);
590 printf (");\n");
591 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
592 && GET_CODE (SET_SRC (next)) == LABEL_REF)
593 printf (" emit_barrier ();");
596 /* Call `gen_sequence' to make a SEQUENCE out of all the
597 insns emitted within this gen_... function. */
599 printf (" _done:\n");
600 printf (" _val = gen_sequence ();\n");
601 printf (" _fail:\n");
602 printf (" end_sequence ();\n");
603 printf (" return _val;\n}\n\n");
606 /* Write a function, `add_clobbers', that is given a PARALLEL of sufficient
607 size for the insn and an INSN_CODE, and inserts the required CLOBBERs at
608 the end of the vector. */
610 static void
611 output_add_clobbers ()
613 struct clobber_pat *clobber;
614 struct clobber_ent *ent;
615 int i;
617 printf ("\n\nvoid\nadd_clobbers (pattern, insn_code_number)\n");
618 printf (" rtx pattern;\n int insn_code_number;\n");
619 printf ("{\n");
620 printf (" int i;\n\n");
621 printf (" switch (insn_code_number)\n");
622 printf (" {\n");
624 for (clobber = clobber_list; clobber; clobber = clobber->next)
626 for (ent = clobber->insns; ent; ent = ent->next)
627 printf (" case %d:\n", ent->code_number);
629 for (i = clobber->first_clobber; i < XVECLEN (clobber->pattern, 1); i++)
631 printf (" XVECEXP (pattern, 0, %d) = ", i);
632 gen_exp (XVECEXP (clobber->pattern, 1, i));
633 printf (";\n");
636 printf (" break;\n\n");
639 printf (" default:\n");
640 printf (" abort ();\n");
641 printf (" }\n");
642 printf ("}\n");
645 /* Write a function, init_mov_optab, that is called to set up entries
646 in mov_optab for EXTRA_CC_MODES. */
648 static void
649 output_init_mov_optab ()
651 #ifdef EXTRA_CC_NAMES
652 static char *cc_names[] = { EXTRA_CC_NAMES };
653 char *p;
654 int i;
656 printf ("\nvoid\ninit_mov_optab ()\n{\n");
658 for (i = 0; i < sizeof cc_names / sizeof cc_names[0]; i++)
660 printf ("#ifdef HAVE_mov");
661 for (p = cc_names[i]; *p; p++)
662 printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
663 printf ("\n");
664 printf (" if (HAVE_mov");
665 for (p = cc_names[i]; *p; p++)
666 printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
667 printf (")\n");
668 printf (" mov_optab->handlers[(int) %smode].insn_code = CODE_FOR_mov",
669 cc_names[i]);
670 for (p = cc_names[i]; *p; p++)
671 printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
672 printf (";\n#endif\n");
675 printf ("}\n");
676 #endif
679 char *
680 xmalloc (size)
681 unsigned size;
683 register char *val = (char *) malloc (size);
685 if (val == 0)
686 fatal ("virtual memory exhausted");
688 return val;
691 char *
692 xrealloc (ptr, size)
693 char *ptr;
694 unsigned size;
696 char *result = (char *) realloc (ptr, size);
697 if (!result)
698 fatal ("virtual memory exhausted");
699 return result;
702 #ifdef HAVE_VPRINTF
703 void
704 fatal VPROTO((char *s, ...))
706 #ifndef ANSI_PROTOTYPES
707 char *s;
708 #endif
709 va_list ap;
711 VA_START (ap, s);
713 #ifndef ANSI_PROTOTYPES
714 s = va_arg (ap, char *);
715 #endif
717 fprintf (stderr, "genemit: ");
718 vfprintf (stderr, s, ap);
719 va_end (ap);
720 fprintf (stderr, "\n");
721 exit (FATAL_EXIT_CODE);
723 #else /* not HAVE_VPRINTF */
725 void
726 fatal (s, a1, a2)
727 char *s;
729 fprintf (stderr, "genemit: ");
730 fprintf (stderr, s, a1, a2);
731 fprintf (stderr, "\n");
732 exit (FATAL_EXIT_CODE);
734 #endif /* not HAVE_VPRINTF */
736 /* More 'friendly' abort that prints the line and file.
737 config.h can #define abort fancy_abort if you like that sort of thing. */
739 void
740 fancy_abort ()
742 fatal ("Internal gcc abort.");
746 main (argc, argv)
747 int argc;
748 char **argv;
750 rtx desc;
751 FILE *infile;
752 register int c;
754 obstack_init (rtl_obstack);
756 if (argc <= 1)
757 fatal ("No input file name.");
759 infile = fopen (argv[1], "r");
760 if (infile == 0)
762 perror (argv[1]);
763 exit (FATAL_EXIT_CODE);
766 init_rtl ();
768 /* Assign sequential codes to all entries in the machine description
769 in parallel with the tables in insn-output.c. */
771 insn_code_number = 0;
772 insn_index_number = 0;
774 printf ("/* Generated automatically by the program `genemit'\n\
775 from the machine description file `md'. */\n\n");
777 printf ("#include \"config.h\"\n");
778 printf ("#include \"system.h\"\n");
779 printf ("#include \"rtl.h\"\n");
780 printf ("#include \"expr.h\"\n");
781 printf ("#include \"real.h\"\n");
782 printf ("#include \"flags.h\"\n");
783 printf ("#include \"output.h\"\n");
784 printf ("#include \"insn-config.h\"\n\n");
785 printf ("#include \"insn-flags.h\"\n\n");
786 printf ("#include \"insn-codes.h\"\n\n");
787 printf ("#include \"reload.h\"\n");
788 printf ("extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS];\n\n");
789 printf ("extern rtx recog_operand[];\n");
790 printf ("#define operands emit_operand\n\n");
791 printf ("#define FAIL goto _fail\n\n");
792 printf ("#define DONE goto _done\n\n");
794 /* Read the machine description. */
796 while (1)
798 c = read_skip_spaces (infile);
799 if (c == EOF)
800 break;
801 ungetc (c, infile);
803 desc = read_rtx (infile);
804 if (GET_CODE (desc) == DEFINE_INSN)
806 gen_insn (desc);
807 ++insn_code_number;
809 if (GET_CODE (desc) == DEFINE_EXPAND)
811 gen_expand (desc);
812 ++insn_code_number;
814 if (GET_CODE (desc) == DEFINE_SPLIT)
816 gen_split (desc);
817 ++insn_code_number;
819 if (GET_CODE (desc) == DEFINE_PEEPHOLE)
821 ++insn_code_number;
823 ++insn_index_number;
826 /* Write out the routine to add CLOBBERs to a pattern. */
827 output_add_clobbers ();
829 /* Write the routine to initialize mov_optab for the EXTRA_CC_MODES. */
830 output_init_mov_optab ();
832 fflush (stdout);
833 exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
834 /* NOTREACHED */
835 return 0;