2015-09-03 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / genemit.c
bloba2c474dacd6101996d11df35e7c5af41800b69f9
1 /* Generate code from machine description to emit insns as rtl.
2 Copyright (C) 1987-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
21 #include "bconfig.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "rtl.h"
26 #include "errors.h"
27 #include "read-md.h"
28 #include "gensupport.h"
31 /* Data structure for recording the patterns of insns that have CLOBBERs.
32 We use this to output a function that adds these CLOBBERs to a
33 previously-allocated PARALLEL expression. */
35 struct clobber_pat
37 struct clobber_ent *insns;
38 rtx pattern;
39 int first_clobber;
40 struct clobber_pat *next;
41 int has_hard_reg;
42 } *clobber_list;
44 /* Records one insn that uses the clobber list. */
46 struct clobber_ent
48 int code_number; /* Counts only insns. */
49 struct clobber_ent *next;
52 static void output_peephole2_scratches (rtx);
55 static void
56 print_code (RTX_CODE code)
58 const char *p1;
59 for (p1 = GET_RTX_NAME (code); *p1; p1++)
60 putchar (TOUPPER (*p1));
63 static void
64 gen_rtx_scratch (rtx x, enum rtx_code subroutine_type)
66 if (subroutine_type == DEFINE_PEEPHOLE2)
68 printf ("operand%d", XINT (x, 0));
70 else
72 printf ("gen_rtx_SCRATCH (%smode)", GET_MODE_NAME (GET_MODE (x)));
76 /* Print a C expression to construct an RTX just like X,
77 substituting any operand references appearing within. */
79 static void
80 gen_exp (rtx x, enum rtx_code subroutine_type, char *used)
82 RTX_CODE code;
83 int i;
84 int len;
85 const char *fmt;
86 const char *sep = "";
88 if (x == 0)
90 printf ("NULL_RTX");
91 return;
94 code = GET_CODE (x);
96 switch (code)
98 case MATCH_OPERAND:
99 case MATCH_DUP:
100 if (used)
102 if (used[XINT (x, 0)])
104 printf ("copy_rtx (operand%d)", XINT (x, 0));
105 return;
107 used[XINT (x, 0)] = 1;
109 printf ("operand%d", XINT (x, 0));
110 return;
112 case MATCH_OP_DUP:
113 printf ("gen_rtx_fmt_");
114 for (i = 0; i < XVECLEN (x, 1); i++)
115 printf ("e");
116 printf (" (GET_CODE (operand%d), ", XINT (x, 0));
117 if (GET_MODE (x) == VOIDmode)
118 printf ("GET_MODE (operand%d)", XINT (x, 0));
119 else
120 printf ("%smode", GET_MODE_NAME (GET_MODE (x)));
121 for (i = 0; i < XVECLEN (x, 1); i++)
123 printf (",\n\t\t");
124 gen_exp (XVECEXP (x, 1, i), subroutine_type, used);
126 printf (")");
127 return;
129 case MATCH_OPERATOR:
130 printf ("gen_rtx_fmt_");
131 for (i = 0; i < XVECLEN (x, 2); i++)
132 printf ("e");
133 printf (" (GET_CODE (operand%d)", XINT (x, 0));
134 printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
135 for (i = 0; i < XVECLEN (x, 2); i++)
137 printf (",\n\t\t");
138 gen_exp (XVECEXP (x, 2, i), subroutine_type, used);
140 printf (")");
141 return;
143 case MATCH_PARALLEL:
144 case MATCH_PAR_DUP:
145 printf ("operand%d", XINT (x, 0));
146 return;
148 case MATCH_SCRATCH:
149 gen_rtx_scratch (x, subroutine_type);
150 return;
152 case PC:
153 printf ("pc_rtx");
154 return;
155 case RETURN:
156 printf ("ret_rtx");
157 return;
158 case SIMPLE_RETURN:
159 printf ("simple_return_rtx");
160 return;
161 case CLOBBER:
162 if (REG_P (XEXP (x, 0)))
164 printf ("gen_hard_reg_clobber (%smode, %i)", GET_MODE_NAME (GET_MODE (XEXP (x, 0))),
165 REGNO (XEXP (x, 0)));
166 return;
168 break;
170 case CC0:
171 printf ("cc0_rtx");
172 return;
174 case CONST_INT:
175 if (INTVAL (x) == 0)
176 printf ("const0_rtx");
177 else if (INTVAL (x) == 1)
178 printf ("const1_rtx");
179 else if (INTVAL (x) == -1)
180 printf ("constm1_rtx");
181 else if (-MAX_SAVED_CONST_INT <= INTVAL (x)
182 && INTVAL (x) <= MAX_SAVED_CONST_INT)
183 printf ("const_int_rtx[MAX_SAVED_CONST_INT + (%d)]",
184 (int) INTVAL (x));
185 else if (INTVAL (x) == STORE_FLAG_VALUE)
186 printf ("const_true_rtx");
187 else
189 printf ("GEN_INT (");
190 printf (HOST_WIDE_INT_PRINT_DEC_C, INTVAL (x));
191 printf (")");
193 return;
195 case CONST_DOUBLE:
196 case CONST_FIXED:
197 case CONST_WIDE_INT:
198 /* These shouldn't be written in MD files. Instead, the appropriate
199 routines in varasm.c should be called. */
200 gcc_unreachable ();
202 default:
203 break;
206 printf ("gen_rtx_");
207 print_code (code);
208 printf (" (");
209 if (!always_void_p (code))
211 printf ("%smode", GET_MODE_NAME (GET_MODE (x)));
212 sep = ",\n\t";
215 fmt = GET_RTX_FORMAT (code);
216 len = GET_RTX_LENGTH (code);
217 for (i = 0; i < len; i++)
219 if (fmt[i] == '0')
220 break;
221 fputs (sep, stdout);
222 switch (fmt[i])
224 case 'e': case 'u':
225 gen_exp (XEXP (x, i), subroutine_type, used);
226 break;
228 case 'i':
229 printf ("%u", XINT (x, i));
230 break;
232 case 'r':
233 printf ("%u", REGNO (x));
234 break;
236 case 's':
237 printf ("\"%s\"", XSTR (x, i));
238 break;
240 case 'E':
242 int j;
243 printf ("gen_rtvec (%d", XVECLEN (x, i));
244 for (j = 0; j < XVECLEN (x, i); j++)
246 printf (",\n\t\t");
247 gen_exp (XVECEXP (x, i, j), subroutine_type, used);
249 printf (")");
250 break;
253 default:
254 gcc_unreachable ();
256 sep = ",\n\t";
258 printf (")");
261 /* Output code to emit the instruction patterns in VEC, with each element
262 becoming a separate instruction. USED is as for gen_exp. */
264 static void
265 gen_emit_seq (rtvec vec, char *used)
267 for (int i = 0, len = GET_NUM_ELEM (vec); i < len; ++i)
269 bool last_p = (i == len - 1);
270 rtx next = RTVEC_ELT (vec, i);
271 if (const char *name = get_emit_function (next))
273 printf (" %s (", name);
274 gen_exp (next, DEFINE_EXPAND, used);
275 printf (");\n");
276 if (!last_p && needs_barrier_p (next))
277 printf (" emit_barrier ();");
279 else
281 printf (" emit (");
282 gen_exp (next, DEFINE_EXPAND, used);
283 printf (", %s);\n", last_p ? "false" : "true");
288 /* Generate the `gen_...' function for a DEFINE_INSN. */
290 static void
291 gen_insn (md_rtx_info *info)
293 struct pattern_stats stats;
294 int i;
296 /* See if the pattern for this insn ends with a group of CLOBBERs of (hard)
297 registers or MATCH_SCRATCHes. If so, store away the information for
298 later. */
300 rtx insn = info->def;
301 if (XVEC (insn, 1))
303 int has_hard_reg = 0;
305 for (i = XVECLEN (insn, 1) - 1; i > 0; i--)
307 if (GET_CODE (XVECEXP (insn, 1, i)) != CLOBBER)
308 break;
310 if (REG_P (XEXP (XVECEXP (insn, 1, i), 0)))
311 has_hard_reg = 1;
312 else if (GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != MATCH_SCRATCH)
313 break;
316 if (i != XVECLEN (insn, 1) - 1)
318 struct clobber_pat *p;
319 struct clobber_ent *link = XNEW (struct clobber_ent);
320 int j;
322 link->code_number = info->index;
324 /* See if any previous CLOBBER_LIST entry is the same as this
325 one. */
327 for (p = clobber_list; p; p = p->next)
329 if (p->first_clobber != i + 1
330 || XVECLEN (p->pattern, 1) != XVECLEN (insn, 1))
331 continue;
333 for (j = i + 1; j < XVECLEN (insn, 1); j++)
335 rtx old_rtx = XEXP (XVECEXP (p->pattern, 1, j), 0);
336 rtx new_rtx = XEXP (XVECEXP (insn, 1, j), 0);
338 /* OLD and NEW_INSN are the same if both are to be a SCRATCH
339 of the same mode,
340 or if both are registers of the same mode and number. */
341 if (! (GET_MODE (old_rtx) == GET_MODE (new_rtx)
342 && ((GET_CODE (old_rtx) == MATCH_SCRATCH
343 && GET_CODE (new_rtx) == MATCH_SCRATCH)
344 || (REG_P (old_rtx) && REG_P (new_rtx)
345 && REGNO (old_rtx) == REGNO (new_rtx)))))
346 break;
349 if (j == XVECLEN (insn, 1))
350 break;
353 if (p == 0)
355 p = XNEW (struct clobber_pat);
357 p->insns = 0;
358 p->pattern = insn;
359 p->first_clobber = i + 1;
360 p->next = clobber_list;
361 p->has_hard_reg = has_hard_reg;
362 clobber_list = p;
365 link->next = p->insns;
366 p->insns = link;
370 /* Don't mention instructions whose names are the null string
371 or begin with '*'. They are in the machine description just
372 to be recognized. */
373 if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*')
374 return;
376 printf ("/* %s:%d */\n", info->loc.filename, info->loc.lineno);
378 /* Find out how many operands this function has. */
379 get_pattern_stats (&stats, XVEC (insn, 1));
380 if (stats.max_dup_opno > stats.max_opno)
381 fatal_at (info->loc, "match_dup operand number has no match_operand");
383 /* Output the function name and argument declarations. */
384 printf ("rtx\ngen_%s (", XSTR (insn, 0));
385 if (stats.num_generator_args)
386 for (i = 0; i < stats.num_generator_args; i++)
387 if (i)
388 printf (",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
389 else
390 printf ("rtx operand%d ATTRIBUTE_UNUSED", i);
391 else
392 printf ("void");
393 printf (")\n");
394 printf ("{\n");
396 /* Output code to construct and return the rtl for the instruction body. */
398 rtx pattern = add_implicit_parallel (XVEC (insn, 1));
399 /* ??? This is the traditional behavior, but seems suspect. */
400 char *used = (XVECLEN (insn, 1) == 1
401 ? NULL
402 : XCNEWVEC (char, stats.num_generator_args));
403 printf (" return ");
404 gen_exp (pattern, DEFINE_INSN, used);
405 printf (";\n}\n\n");
406 XDELETEVEC (used);
409 /* Generate the `gen_...' function for a DEFINE_EXPAND. */
411 static void
412 gen_expand (md_rtx_info *info)
414 struct pattern_stats stats;
415 int i;
416 char *used;
418 rtx expand = info->def;
419 if (strlen (XSTR (expand, 0)) == 0)
420 fatal_at (info->loc, "define_expand lacks a name");
421 if (XVEC (expand, 1) == 0)
422 fatal_at (info->loc, "define_expand for %s lacks a pattern",
423 XSTR (expand, 0));
425 /* Find out how many operands this function has. */
426 get_pattern_stats (&stats, XVEC (expand, 1));
428 /* Output the function name and argument declarations. */
429 printf ("rtx\ngen_%s (", XSTR (expand, 0));
430 if (stats.num_generator_args)
431 for (i = 0; i < stats.num_generator_args; i++)
432 if (i)
433 printf (",\n\trtx operand%d", i);
434 else
435 printf ("rtx operand%d", i);
436 else
437 printf ("void");
438 printf (")\n");
439 printf ("{\n");
441 /* If we don't have any C code to write, only one insn is being written,
442 and no MATCH_DUPs are present, we can just return the desired insn
443 like we do for a DEFINE_INSN. This saves memory. */
444 if ((XSTR (expand, 3) == 0 || *XSTR (expand, 3) == '\0')
445 && stats.max_opno >= stats.max_dup_opno
446 && XVECLEN (expand, 1) == 1)
448 printf (" return ");
449 gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL);
450 printf (";\n}\n\n");
451 return;
454 /* For each operand referred to only with MATCH_DUPs,
455 make a local variable. */
456 for (i = stats.num_generator_args; i <= stats.max_dup_opno; i++)
457 printf (" rtx operand%d;\n", i);
458 for (; i <= stats.max_scratch_opno; i++)
459 printf (" rtx operand%d ATTRIBUTE_UNUSED;\n", i);
460 printf (" rtx_insn *_val = 0;\n");
461 printf (" start_sequence ();\n");
463 /* The fourth operand of DEFINE_EXPAND is some code to be executed
464 before the actual construction.
465 This code expects to refer to `operands'
466 just as the output-code in a DEFINE_INSN does,
467 but here `operands' is an automatic array.
468 So copy the operand values there before executing it. */
469 if (XSTR (expand, 3) && *XSTR (expand, 3))
471 printf (" {\n");
472 if (stats.num_operand_vars > 0)
473 printf (" rtx operands[%d];\n", stats.num_operand_vars);
475 /* Output code to copy the arguments into `operands'. */
476 for (i = 0; i < stats.num_generator_args; i++)
477 printf (" operands[%d] = operand%d;\n", i, i);
479 /* Output the special code to be executed before the sequence
480 is generated. */
481 print_md_ptr_loc (XSTR (expand, 3));
482 printf ("%s\n", XSTR (expand, 3));
484 /* Output code to copy the arguments back out of `operands'
485 (unless we aren't going to use them at all). */
486 if (XVEC (expand, 1) != 0)
488 for (i = 0; i < stats.num_operand_vars; i++)
490 printf (" operand%d = operands[%d];\n", i, i);
491 printf (" (void) operand%d;\n", i);
494 printf (" }\n");
497 used = XCNEWVEC (char, stats.num_operand_vars);
498 gen_emit_seq (XVEC (expand, 1), used);
499 XDELETEVEC (used);
501 /* Call `get_insns' to extract the list of all the
502 insns emitted within this gen_... function. */
504 printf (" _val = get_insns ();\n");
505 printf (" end_sequence ();\n");
506 printf (" return _val;\n}\n\n");
509 /* Like gen_expand, but generates insns resulting from splitting SPLIT. */
511 static void
512 gen_split (md_rtx_info *info)
514 struct pattern_stats stats;
515 int i;
516 rtx split = info->def;
517 const char *const name =
518 ((GET_CODE (split) == DEFINE_PEEPHOLE2) ? "peephole2" : "split");
519 const char *unused;
520 char *used;
522 if (XVEC (split, 0) == 0)
523 fatal_at (info->loc, "%s lacks a pattern",
524 GET_RTX_NAME (GET_CODE (split)));
525 else if (XVEC (split, 2) == 0)
526 fatal_at (info->loc, "%s lacks a replacement pattern",
527 GET_RTX_NAME (GET_CODE (split)));
529 /* Find out how many operands this function has. */
531 get_pattern_stats (&stats, XVEC (split, 2));
532 unused = (stats.num_operand_vars == 0 ? " ATTRIBUTE_UNUSED" : "");
533 used = XCNEWVEC (char, stats.num_operand_vars);
535 /* Output the prototype, function name and argument declarations. */
536 if (GET_CODE (split) == DEFINE_PEEPHOLE2)
538 printf ("extern rtx_insn *gen_%s_%d (rtx_insn *, rtx *);\n",
539 name, info->index);
540 printf ("rtx_insn *\ngen_%s_%d (rtx_insn *curr_insn ATTRIBUTE_UNUSED,"
541 " rtx *operands%s)\n",
542 name, info->index, unused);
544 else
546 printf ("extern rtx_insn *gen_split_%d (rtx_insn *, rtx *);\n",
547 info->index);
548 printf ("rtx_insn *\ngen_split_%d "
549 "(rtx_insn *curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n",
550 info->index, unused);
552 printf ("{\n");
554 /* Declare all local variables. */
555 for (i = 0; i < stats.num_operand_vars; i++)
556 printf (" rtx operand%d;\n", i);
557 printf (" rtx_insn *_val = NULL;\n");
559 if (GET_CODE (split) == DEFINE_PEEPHOLE2)
560 output_peephole2_scratches (split);
562 printf (" if (dump_file)\n");
563 printf (" fprintf (dump_file, \"Splitting with gen_%s_%d\\n\");\n",
564 name, info->index);
566 printf (" start_sequence ();\n");
568 /* The fourth operand of DEFINE_SPLIT is some code to be executed
569 before the actual construction. */
571 if (XSTR (split, 3))
573 print_md_ptr_loc (XSTR (split, 3));
574 printf ("%s\n", XSTR (split, 3));
577 /* Output code to copy the arguments back out of `operands' */
578 for (i = 0; i < stats.num_operand_vars; i++)
580 printf (" operand%d = operands[%d];\n", i, i);
581 printf (" (void) operand%d;\n", i);
584 gen_emit_seq (XVEC (split, 2), used);
586 /* Call `get_insns' to make a list of all the
587 insns emitted within this gen_... function. */
589 printf (" _val = get_insns ();\n");
590 printf (" end_sequence ();\n");
591 printf (" return _val;\n}\n\n");
593 free (used);
596 /* Write a function, `add_clobbers', that is given a PARALLEL of sufficient
597 size for the insn and an INSN_CODE, and inserts the required CLOBBERs at
598 the end of the vector. */
600 static void
601 output_add_clobbers (void)
603 struct clobber_pat *clobber;
604 struct clobber_ent *ent;
605 int i;
607 printf ("\n\nvoid\nadd_clobbers (rtx pattern ATTRIBUTE_UNUSED, int insn_code_number)\n");
608 printf ("{\n");
609 printf (" switch (insn_code_number)\n");
610 printf (" {\n");
612 for (clobber = clobber_list; clobber; clobber = clobber->next)
614 for (ent = clobber->insns; ent; ent = ent->next)
615 printf (" case %d:\n", ent->code_number);
617 for (i = clobber->first_clobber; i < XVECLEN (clobber->pattern, 1); i++)
619 printf (" XVECEXP (pattern, 0, %d) = ", i);
620 gen_exp (XVECEXP (clobber->pattern, 1, i),
621 GET_CODE (clobber->pattern), NULL);
622 printf (";\n");
625 printf (" break;\n\n");
628 printf (" default:\n");
629 printf (" gcc_unreachable ();\n");
630 printf (" }\n");
631 printf ("}\n");
634 /* Write a function, `added_clobbers_hard_reg_p' that is given an insn_code
635 number that will have clobbers added (as indicated by `recog') and returns
636 1 if those include a clobber of a hard reg or 0 if all of them just clobber
637 SCRATCH. */
639 static void
640 output_added_clobbers_hard_reg_p (void)
642 struct clobber_pat *clobber;
643 struct clobber_ent *ent;
644 int clobber_p, used;
646 printf ("\n\nint\nadded_clobbers_hard_reg_p (int insn_code_number)\n");
647 printf ("{\n");
648 printf (" switch (insn_code_number)\n");
649 printf (" {\n");
651 for (clobber_p = 0; clobber_p <= 1; clobber_p++)
653 used = 0;
654 for (clobber = clobber_list; clobber; clobber = clobber->next)
655 if (clobber->has_hard_reg == clobber_p)
656 for (ent = clobber->insns; ent; ent = ent->next)
658 printf (" case %d:\n", ent->code_number);
659 used++;
662 if (used)
663 printf (" return %d;\n\n", clobber_p);
666 printf (" default:\n");
667 printf (" gcc_unreachable ();\n");
668 printf (" }\n");
669 printf ("}\n");
672 /* Generate code to invoke find_free_register () as needed for the
673 scratch registers used by the peephole2 pattern in SPLIT. */
675 static void
676 output_peephole2_scratches (rtx split)
678 int i;
679 int insn_nr = 0;
680 bool first = true;
682 for (i = 0; i < XVECLEN (split, 0); i++)
684 rtx elt = XVECEXP (split, 0, i);
685 if (GET_CODE (elt) == MATCH_SCRATCH)
687 int last_insn_nr = insn_nr;
688 int cur_insn_nr = insn_nr;
689 int j;
690 for (j = i + 1; j < XVECLEN (split, 0); j++)
691 if (GET_CODE (XVECEXP (split, 0, j)) == MATCH_DUP)
693 if (XINT (XVECEXP (split, 0, j), 0) == XINT (elt, 0))
694 last_insn_nr = cur_insn_nr;
696 else if (GET_CODE (XVECEXP (split, 0, j)) != MATCH_SCRATCH)
697 cur_insn_nr++;
699 if (first)
701 printf (" HARD_REG_SET _regs_allocated;\n");
702 printf (" CLEAR_HARD_REG_SET (_regs_allocated);\n");
703 first = false;
706 printf (" if ((operands[%d] = peep2_find_free_register (%d, %d, \"%s\", %smode, &_regs_allocated)) == NULL_RTX)\n\
707 return NULL;\n",
708 XINT (elt, 0),
709 insn_nr, last_insn_nr,
710 XSTR (elt, 1),
711 GET_MODE_NAME (GET_MODE (elt)));
714 else if (GET_CODE (elt) != MATCH_DUP)
715 insn_nr++;
720 main (int argc, char **argv)
722 progname = "genemit";
724 if (!init_rtx_reader_args (argc, argv))
725 return (FATAL_EXIT_CODE);
727 /* Assign sequential codes to all entries in the machine description
728 in parallel with the tables in insn-output.c. */
730 printf ("/* Generated automatically by the program `genemit'\n\
731 from the machine description file `md'. */\n\n");
733 printf ("#include \"config.h\"\n");
734 printf ("#include \"system.h\"\n");
735 printf ("#include \"coretypes.h\"\n");
736 printf ("#include \"backend.h\"\n");
737 printf ("#include \"predict.h\"\n");
738 printf ("#include \"tree.h\"\n");
739 printf ("#include \"rtl.h\"\n");
740 printf ("#include \"alias.h\"\n");
741 printf ("#include \"varasm.h\"\n");
742 printf ("#include \"stor-layout.h\"\n");
743 printf ("#include \"calls.h\"\n");
744 printf ("#include \"tm_p.h\"\n");
745 printf ("#include \"flags.h\"\n");
746 printf ("#include \"insn-config.h\"\n");
747 printf ("#include \"expmed.h\"\n");
748 printf ("#include \"dojump.h\"\n");
749 printf ("#include \"explow.h\"\n");
750 printf ("#include \"emit-rtl.h\"\n");
751 printf ("#include \"stmt.h\"\n");
752 printf ("#include \"expr.h\"\n");
753 printf ("#include \"insn-codes.h\"\n");
754 printf ("#include \"optabs.h\"\n");
755 printf ("#include \"dfp.h\"\n");
756 printf ("#include \"output.h\"\n");
757 printf ("#include \"recog.h\"\n");
758 printf ("#include \"df.h\"\n");
759 printf ("#include \"resource.h\"\n");
760 printf ("#include \"reload.h\"\n");
761 printf ("#include \"diagnostic-core.h\"\n");
762 printf ("#include \"regs.h\"\n");
763 printf ("#include \"tm-constrs.h\"\n");
764 printf ("#include \"ggc.h\"\n");
765 printf ("#include \"dumpfile.h\"\n");
766 printf ("#include \"target.h\"\n\n");
767 printf ("#define FAIL return (end_sequence (), _val)\n");
768 printf ("#define DONE return (_val = get_insns (), end_sequence (), _val)\n\n");
770 /* Read the machine description. */
772 md_rtx_info info;
773 while (read_md_rtx (&info))
774 switch (GET_CODE (info.def))
776 case DEFINE_INSN:
777 gen_insn (&info);
778 break;
780 case DEFINE_EXPAND:
781 printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
782 gen_expand (&info);
783 break;
785 case DEFINE_SPLIT:
786 printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
787 gen_split (&info);
788 break;
790 case DEFINE_PEEPHOLE2:
791 printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
792 gen_split (&info);
793 break;
795 default:
796 break;
799 /* Write out the routines to add CLOBBERs to a pattern and say whether they
800 clobber a hard reg. */
801 output_add_clobbers ();
802 output_added_clobbers_hard_reg_p ();
804 fflush (stdout);
805 return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);