|
|
1.1 root 1: /* Generate code from machine description to emit insns as rtl.
2: Copyright (C) 1987, 1988, 1991 Free Software Foundation, Inc.
3:
4: This file is part of GNU CC.
5:
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.
10:
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.
15:
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
19:
20:
21: #include <stdio.h>
22: #include "config.h"
23: #include "rtl.h"
24: #include "obstack.h"
25:
26: static struct obstack obstack;
27: struct obstack *rtl_obstack = &obstack;
28:
29: #define obstack_chunk_alloc xmalloc
30: #define obstack_chunk_free free
31:
32: extern void free ();
1.1.1.2 ! root 33: extern rtx read_rtx ();
1.1 root 34:
35: char *xmalloc ();
36: static void fatal ();
37: void fancy_abort ();
38:
39: static int max_opno;
40: static int max_dup_opno;
41: static int register_constraints;
42: static int insn_code_number;
43: static int insn_index_number;
44:
45: /* Data structure for recording the patterns of insns that have CLOBBERs.
46: We use this to output a function that adds these CLOBBERs to a
47: previously-allocated PARALLEL expression. */
48:
49: struct clobber_pat
50: {
1.1.1.2 ! root 51: struct clobber_ent *insns;
1.1 root 52: rtx pattern;
53: int first_clobber;
54: struct clobber_pat *next;
55: } *clobber_list;
56:
1.1.1.2 ! root 57: /* Records one insn that uses the clobber list. */
! 58:
! 59: struct clobber_ent
! 60: {
! 61: int code_number; /* Counts only insns. */
! 62: struct clobber_ent *next;
! 63: };
! 64:
1.1 root 65: static void
66: max_operand_1 (x)
67: rtx x;
68: {
69: register RTX_CODE code;
70: register int i;
71: register int len;
72: register char *fmt;
73:
74: if (x == 0)
75: return;
76:
77: code = GET_CODE (x);
78:
79: if (code == MATCH_OPERAND && XSTR (x, 2) != 0 && *XSTR (x, 2) != '\0')
80: register_constraints = 1;
81: if (code == MATCH_SCRATCH && XSTR (x, 1) != 0 && *XSTR (x, 1) != '\0')
82: register_constraints = 1;
83: if (code == MATCH_OPERAND || code == MATCH_OPERATOR
84: || code == MATCH_PARALLEL)
85: max_opno = MAX (max_opno, XINT (x, 0));
86: if (code == MATCH_DUP || code == MATCH_OP_DUP)
87: max_dup_opno = MAX (max_dup_opno, XINT (x, 0));
88:
89: fmt = GET_RTX_FORMAT (code);
90: len = GET_RTX_LENGTH (code);
91: for (i = 0; i < len; i++)
92: {
93: if (fmt[i] == 'e' || fmt[i] == 'u')
94: max_operand_1 (XEXP (x, i));
95: else if (fmt[i] == 'E')
96: {
97: int j;
98: for (j = 0; j < XVECLEN (x, i); j++)
99: max_operand_1 (XVECEXP (x, i, j));
100: }
101: }
102: }
103:
104: static int
105: max_operand_vec (insn, arg)
106: rtx insn;
107: int arg;
108: {
109: register int len = XVECLEN (insn, arg);
110: register int i;
111:
112: max_opno = -1;
113: max_dup_opno = -1;
114:
115: for (i = 0; i < len; i++)
116: max_operand_1 (XVECEXP (insn, arg, i));
117:
118: return max_opno + 1;
119: }
120:
121: static void
122: print_code (code)
123: RTX_CODE code;
124: {
125: register char *p1;
126: for (p1 = GET_RTX_NAME (code); *p1; p1++)
127: {
128: if (*p1 >= 'a' && *p1 <= 'z')
129: putchar (*p1 + 'A' - 'a');
130: else
131: putchar (*p1);
132: }
133: }
134:
135: /* Print a C expression to construct an RTX just like X,
136: substituting any operand references appearing within. */
137:
138: static void
139: gen_exp (x)
140: rtx x;
141: {
142: register RTX_CODE code;
143: register int i;
144: register int len;
145: register char *fmt;
146:
147: if (x == 0)
148: {
149: printf ("0");
150: return;
151: }
152:
153: code = GET_CODE (x);
154:
155: switch (code)
156: {
157: case MATCH_OPERAND:
158: case MATCH_DUP:
159: printf ("operand%d", XINT (x, 0));
160: return;
161:
162: case MATCH_OP_DUP:
163: printf ("gen_rtx (GET_CODE (operand%d), GET_MODE (operand%d)",
164: XINT (x, 0), XINT (x, 0));
165: for (i = 0; i < XVECLEN (x, 1); i++)
166: {
167: printf (",\n\t\t");
168: gen_exp (XVECEXP (x, 1, i));
169: }
170: printf (")");
171: return;
172:
173: case MATCH_OPERATOR:
174: printf ("gen_rtx (GET_CODE (operand%d)", XINT (x, 0));
175: printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
176: for (i = 0; i < XVECLEN (x, 2); i++)
177: {
178: printf (",\n\t\t");
179: gen_exp (XVECEXP (x, 2, i));
180: }
181: printf (")");
182: return;
183:
184: case MATCH_PARALLEL:
185: printf ("operand%d", XINT (x, 0));
186: return;
187:
188: case MATCH_SCRATCH:
189: printf ("gen_rtx (SCRATCH, %smode, 0)", GET_MODE_NAME (GET_MODE (x)));
190: return;
191:
192: case ADDRESS:
193: fatal ("ADDRESS expression code used in named instruction pattern");
194:
195: case PC:
196: printf ("pc_rtx");
197: return;
198:
199: case CC0:
200: printf ("cc0_rtx");
201: return;
202:
203: case CONST_INT:
204: if (INTVAL (x) == 0)
205: {
206: printf ("const0_rtx");
207: return;
208: }
209: if (INTVAL (x) == 1)
210: {
211: printf ("const1_rtx");
212: return;
213: }
214: if (INTVAL (x) == -1)
215: {
216: printf ("constm1_rtx");
217: return;
218: }
219: if (INTVAL (x) == STORE_FLAG_VALUE)
220: {
221: printf ("const_true_rtx");
222: return;
223: }
224: }
225:
226: printf ("gen_rtx (");
227: print_code (code);
228: printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
229:
230: fmt = GET_RTX_FORMAT (code);
231: len = GET_RTX_LENGTH (code);
232: for (i = 0; i < len; i++)
233: {
234: if (fmt[i] == '0')
235: break;
236: printf (", ");
237: if (fmt[i] == 'e' || fmt[i] == 'u')
238: gen_exp (XEXP (x, i));
239: else if (fmt[i] == 'i')
240: printf ("%u", (unsigned) XINT (x, i));
241: else if (fmt[i] == 's')
242: printf ("\"%s\"", XSTR (x, i));
243: else if (fmt[i] == 'E')
244: {
245: int j;
246: printf ("gen_rtvec (%d", XVECLEN (x, i));
247: for (j = 0; j < XVECLEN (x, i); j++)
248: {
249: printf (",\n\t\t");
250: gen_exp (XVECEXP (x, i, j));
251: }
252: printf (")");
253: }
254: else
255: abort ();
256: }
257: printf (")");
258: }
259:
260: /* Generate the `gen_...' function for a DEFINE_INSN. */
261:
262: static void
263: gen_insn (insn)
264: rtx insn;
265: {
266: int operands;
267: register int i;
268:
269: /* See if the pattern for this insn ends with a group of CLOBBERs of (hard)
270: registers or MATCH_SCRATCHes. If so, store away the information for
271: later. */
272:
273: if (XVEC (insn, 1))
274: {
275: for (i = XVECLEN (insn, 1) - 1; i > 0; i--)
276: if (GET_CODE (XVECEXP (insn, 1, i)) != CLOBBER
277: || (GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != REG
278: && GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != MATCH_SCRATCH))
279: break;
280:
281: if (i != XVECLEN (insn, 1) - 1)
282: {
1.1.1.2 ! root 283: register struct clobber_pat *p;
! 284: register struct clobber_ent *link
! 285: = (struct clobber_ent *) xmalloc (sizeof (struct clobber_ent));
! 286: register int j;
! 287:
! 288: link->code_number = insn_code_number;
! 289:
! 290: /* See if any previous CLOBBER_LIST entry is the same as this
! 291: one. */
! 292:
! 293: for (p = clobber_list; p; p = p->next)
! 294: {
! 295: if (p->first_clobber != i + 1
! 296: || XVECLEN (p->pattern, 1) != XVECLEN (insn, 1))
! 297: continue;
! 298:
! 299: for (j = i + 1; j < XVECLEN (insn, 1); j++)
! 300: {
! 301: rtx old = XEXP (XVECEXP (p->pattern, 1, j), 0);
! 302: rtx new = XEXP (XVECEXP (insn, 1, j), 0);
! 303:
! 304: /* OLD and NEW are the same if both are to be a SCRATCH
! 305: of the same mode,
! 306: or if both are registers of the same mode and number. */
! 307: if (! (GET_MODE (old) == GET_MODE (new)
! 308: && ((GET_CODE (old) == MATCH_SCRATCH
! 309: && GET_CODE (new) == MATCH_SCRATCH)
! 310: || (GET_CODE (old) == REG && GET_CODE (new) == REG
! 311: && REGNO (old) == REGNO (new)))))
! 312: break;
! 313: }
! 314:
! 315: if (j == XVECLEN (insn, 1))
! 316: break;
! 317: }
! 318:
! 319: if (p == 0)
! 320: {
! 321: p = (struct clobber_pat *) xmalloc (sizeof (struct clobber_pat));
1.1 root 322:
1.1.1.2 ! root 323: p->insns = 0;
! 324: p->pattern = insn;
! 325: p->first_clobber = i + 1;
! 326: p->next = clobber_list;
! 327: clobber_list = p;
! 328: }
! 329:
! 330: link->next = p->insns;
! 331: p->insns = link;
1.1 root 332: }
333: }
334:
335: /* Don't mention instructions whose names are the null string.
336: They are in the machine description just to be recognized. */
337: if (strlen (XSTR (insn, 0)) == 0)
338: return;
339:
340: /* Find out how many operands this function has,
341: and also whether any of them have register constraints. */
342: register_constraints = 0;
343: operands = max_operand_vec (insn, 1);
344: if (max_dup_opno >= operands)
345: fatal ("match_dup operand number has no match_operand");
346:
347: /* Output the function name and argument declarations. */
348: printf ("rtx\ngen_%s (", XSTR (insn, 0));
349: for (i = 0; i < operands; i++)
350: printf (i ? ", operand%d" : "operand%d", i);
351: printf (")\n");
352: for (i = 0; i < operands; i++)
353: printf (" rtx operand%d;\n", i);
354: printf ("{\n");
355:
356: /* Output code to construct and return the rtl for the instruction body */
357:
358: if (XVECLEN (insn, 1) == 1)
359: {
360: printf (" return ");
361: gen_exp (XVECEXP (insn, 1, 0));
362: printf (";\n}\n\n");
363: }
364: else
365: {
366: printf (" return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (%d", XVECLEN (insn, 1));
367: for (i = 0; i < XVECLEN (insn, 1); i++)
368: {
369: printf (",\n\t\t");
370: gen_exp (XVECEXP (insn, 1, i));
371: }
372: printf ("));\n}\n\n");
373: }
374: }
375:
376: /* Generate the `gen_...' function for a DEFINE_EXPAND. */
377:
378: static void
379: gen_expand (expand)
380: rtx expand;
381: {
382: int operands;
383: register int i;
384:
385: if (strlen (XSTR (expand, 0)) == 0)
386: fatal ("define_expand lacks a name");
387: if (XVEC (expand, 1) == 0)
388: fatal ("define_expand for %s lacks a pattern", XSTR (expand, 0));
389:
390: /* Find out how many operands this function has,
391: and also whether any of them have register constraints. */
392: register_constraints = 0;
393:
394: operands = max_operand_vec (expand, 1);
395:
396: /* Output the function name and argument declarations. */
397: printf ("rtx\ngen_%s (", XSTR (expand, 0));
398: for (i = 0; i < operands; i++)
399: printf (i ? ", operand%d" : "operand%d", i);
400: printf (")\n");
401: for (i = 0; i < operands; i++)
402: printf (" rtx operand%d;\n", i);
403: printf ("{\n");
404:
405: /* If we don't have any C code to write, only one insn is being written,
406: and no MATCH_DUPs are present, we can just return the desired insn
407: like we do for a DEFINE_INSN. This saves memory. */
408: if ((XSTR (expand, 3) == 0 || *XSTR (expand, 3) == '\0')
409: && operands > max_dup_opno
410: && XVECLEN (expand, 1) == 1)
411: {
412: printf (" return ");
413: gen_exp (XVECEXP (expand, 1, 0));
414: printf (";\n}\n\n");
415: return;
416: }
417:
418: /* For each operand referred to only with MATCH_DUPs,
419: make a local variable. */
420: for (i = operands; i <= max_dup_opno; i++)
421: printf (" rtx operand%d;\n", i);
422: if (operands > 0 || max_dup_opno >= 0)
423: printf (" rtx operands[%d];\n", MAX (operands, max_dup_opno + 1));
424: printf (" rtx _val = 0;\n");
425: printf (" start_sequence ();\n");
426:
427: /* The fourth operand of DEFINE_EXPAND is some code to be executed
428: before the actual construction.
429: This code expects to refer to `operands'
430: just as the output-code in a DEFINE_INSN does,
431: but here `operands' is an automatic array.
432: So copy the operand values there before executing it. */
433: if (XSTR (expand, 3) && *XSTR (expand, 3))
434: {
435: /* Output code to copy the arguments into `operands'. */
436: for (i = 0; i < operands; i++)
437: printf (" operands[%d] = operand%d;\n", i, i);
438:
439: /* Output the special code to be executed before the sequence
440: is generated. */
441: printf ("%s\n", XSTR (expand, 3));
442:
443: /* Output code to copy the arguments back out of `operands'
444: (unless we aren't going to use them at all). */
445: if (XVEC (expand, 1) != 0)
446: {
447: for (i = 0; i < operands; i++)
448: printf (" operand%d = operands[%d];\n", i, i);
449: for (; i <= max_dup_opno; i++)
450: printf (" operand%d = operands[%d];\n", i, i);
451: }
452: }
453:
454: /* Output code to construct the rtl for the instruction bodies.
455: Use emit_insn to add them to the sequence being accumulated.
456: But don't do this if the user's code has set `no_more' nonzero. */
457:
458: for (i = 0; i < XVECLEN (expand, 1); i++)
459: {
460: rtx next = XVECEXP (expand, 1, i);
461: if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC)
462: || (GET_CODE (next) == PARALLEL
463: && GET_CODE (XVECEXP (next, 0, 0)) == SET
464: && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC)
465: || GET_CODE (next) == RETURN)
466: printf (" emit_jump_insn (");
467: else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL)
468: || GET_CODE (next) == CALL
469: || (GET_CODE (next) == PARALLEL
470: && GET_CODE (XVECEXP (next, 0, 0)) == SET
471: && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL)
472: || (GET_CODE (next) == PARALLEL
473: && GET_CODE (XVECEXP (next, 0, 0)) == CALL))
474: printf (" emit_call_insn (");
475: else if (GET_CODE (next) == CODE_LABEL)
476: printf (" emit_label (");
477: else if (GET_CODE (next) == MATCH_OPERAND
478: || GET_CODE (next) == MATCH_OPERATOR
479: || GET_CODE (next) == MATCH_PARALLEL
480: || GET_CODE (next) == MATCH_OP_DUP
481: || GET_CODE (next) == MATCH_DUP
482: || GET_CODE (next) == PARALLEL)
483: printf (" emit (");
484: else
485: printf (" emit_insn (");
486: gen_exp (next);
487: printf (");\n");
488: if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
489: && GET_CODE (SET_SRC (next)) == LABEL_REF)
490: printf (" emit_barrier ();");
491: }
492:
493: /* Call `gen_sequence' to make a SEQUENCE out of all the
494: insns emitted within this gen_... function. */
495:
496: printf (" _done:\n");
497: printf (" _val = gen_sequence ();\n");
498: printf (" _fail:\n");
499: printf (" end_sequence ();\n");
500: printf (" return _val;\n}\n\n");
501: }
502:
503: /* Like gen_expand, but generates a SEQUENCE. */
504: static void
505: gen_split (split)
506: rtx split;
507: {
508: register int i;
509: int operands;
510:
511: if (XVEC (split, 0) == 0)
512: fatal ("define_split (definition %d) lacks a pattern", insn_index_number);
513: else if (XVEC (split, 2) == 0)
514: fatal ("define_split (definition %d) lacks a replacement pattern",
515: insn_index_number);
516:
517: /* Find out how many operands this function has. */
518:
519: max_operand_vec (split, 2);
520: operands = MAX (max_opno, max_dup_opno) + 1;
521:
522: /* Output the function name and argument declarations. */
523: printf ("rtx\ngen_split_%d (operands)\n rtx *operands;\n",
524: insn_code_number);
525: printf ("{\n");
526:
527: /* Declare all local variables. */
528: for (i = 0; i < operands; i++)
529: printf (" rtx operand%d;\n", i);
530: printf (" rtx _val;\n");
531: printf (" start_sequence ();\n");
532:
533: /* The fourth operand of DEFINE_SPLIT is some code to be executed
534: before the actual construction. */
535:
536: if (XSTR (split, 3))
537: printf ("%s\n", XSTR (split, 3));
538:
539: /* Output code to copy the arguments back out of `operands' */
540: for (i = 0; i < operands; i++)
541: printf (" operand%d = operands[%d];\n", i, i);
542:
543: /* Output code to construct the rtl for the instruction bodies.
544: Use emit_insn to add them to the sequence being accumulated.
545: But don't do this if the user's code has set `no_more' nonzero. */
546:
547: for (i = 0; i < XVECLEN (split, 2); i++)
548: {
549: rtx next = XVECEXP (split, 2, i);
550: if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC)
551: || (GET_CODE (next) == PARALLEL
552: && GET_CODE (XVECEXP (next, 0, 0)) == SET
553: && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC)
554: || GET_CODE (next) == RETURN)
555: printf (" emit_jump_insn (");
556: else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL)
557: || GET_CODE (next) == CALL
558: || (GET_CODE (next) == PARALLEL
559: && GET_CODE (XVECEXP (next, 0, 0)) == SET
560: && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL)
561: || (GET_CODE (next) == PARALLEL
562: && GET_CODE (XVECEXP (next, 0, 0)) == CALL))
563: printf (" emit_call_insn (");
564: else if (GET_CODE (next) == CODE_LABEL)
565: printf (" emit_label (");
566: else if (GET_CODE (next) == MATCH_OPERAND
567: || GET_CODE (next) == MATCH_OPERATOR
568: || GET_CODE (next) == MATCH_PARALLEL
569: || GET_CODE (next) == MATCH_OP_DUP
570: || GET_CODE (next) == MATCH_DUP
571: || GET_CODE (next) == PARALLEL)
572: printf (" emit (");
573: else
574: printf (" emit_insn (");
575: gen_exp (next);
576: printf (");\n");
577: if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
578: && GET_CODE (SET_SRC (next)) == LABEL_REF)
579: printf (" emit_barrier ();");
580: }
581:
582: /* Call `gen_sequence' to make a SEQUENCE out of all the
583: insns emitted within this gen_... function. */
584:
585: printf (" _done:\n");
586: printf (" _val = gen_sequence ();\n");
587: printf (" _fail:\n");
588: printf (" end_sequence ();\n");
589: printf (" return _val;\n}\n\n");
590: }
591:
592: /* Write a function, `add_clobbers', that is given a PARALLEL of sufficient
593: size for the insn and an INSN_CODE, and inserts the required CLOBBERs at
594: the end of the vector. */
595:
596: static void
597: output_add_clobbers ()
598: {
599: struct clobber_pat *clobber;
1.1.1.2 ! root 600: struct clobber_ent *ent;
1.1 root 601: int i;
602:
603: printf ("\n\nvoid\nadd_clobbers (pattern, insn_code_number)\n");
604: printf (" rtx pattern;\n int insn_code_number;\n");
605: printf ("{\n");
606: printf (" int i;\n\n");
607: printf (" switch (insn_code_number)\n");
608: printf (" {\n");
609:
610: for (clobber = clobber_list; clobber; clobber = clobber->next)
611: {
1.1.1.2 ! root 612: for (ent = clobber->insns; ent; ent = ent->next)
! 613: printf (" case %d:\n", ent->code_number);
1.1 root 614:
615: for (i = clobber->first_clobber; i < XVECLEN (clobber->pattern, 1); i++)
616: {
617: printf (" XVECEXP (pattern, 0, %d) = ", i);
618: gen_exp (XVECEXP (clobber->pattern, 1, i));
619: printf (";\n");
620: }
621:
1.1.1.2 ! root 622: printf (" break;\n\n");
1.1 root 623: }
624:
625: printf (" default:\n");
626: printf (" abort ();\n");
627: printf (" }\n");
628: printf ("}\n");
629: }
630:
631: /* Write a function, init_mov_optab, that is called to set up entries
632: in mov_optab for EXTRA_CC_MODES. */
633:
634: static void
635: output_init_mov_optab ()
636: {
637: #ifdef EXTRA_CC_NAMES
638: static char *cc_names[] = { EXTRA_CC_NAMES };
639: char *p;
640: int i;
641:
642: printf ("\nvoid\ninit_mov_optab ()\n{\n");
643:
644: for (i = 0; i < sizeof cc_names / sizeof cc_names[0]; i++)
645: {
646: printf ("#ifdef HAVE_mov");
647: for (p = cc_names[i]; *p; p++)
648: printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
649: printf ("\n");
650: printf (" if (HAVE_mov");
651: for (p = cc_names[i]; *p; p++)
652: printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
653: printf (")\n");
654: printf (" mov_optab->handlers[(int) %smode].insn_code = CODE_FOR_mov",
655: cc_names[i]);
656: for (p = cc_names[i]; *p; p++)
657: printf ("%c", *p >= 'A' && *p <= 'Z' ? *p - 'A' + 'a' : *p);
658: printf (";\n#endif\n");
659: }
660:
661: printf ("}\n");
662: #endif
663: }
664:
665: char *
666: xmalloc (size)
667: unsigned size;
668: {
669: register char *val = (char *) malloc (size);
670:
671: if (val == 0)
672: fatal ("virtual memory exhausted");
673:
674: return val;
675: }
676:
677: char *
678: xrealloc (ptr, size)
679: char *ptr;
680: unsigned size;
681: {
682: char *result = (char *) realloc (ptr, size);
683: if (!result)
684: fatal ("virtual memory exhausted");
685: return result;
686: }
687:
688: static void
689: fatal (s, a1, a2)
690: char *s;
691: {
692: fprintf (stderr, "genemit: ");
693: fprintf (stderr, s, a1, a2);
694: fprintf (stderr, "\n");
695: exit (FATAL_EXIT_CODE);
696: }
697:
698: /* More 'friendly' abort that prints the line and file.
699: config.h can #define abort fancy_abort if you like that sort of thing. */
700:
701: void
702: fancy_abort ()
703: {
704: fatal ("Internal gcc abort.");
705: }
706:
707: int
708: main (argc, argv)
709: int argc;
710: char **argv;
711: {
712: rtx desc;
713: FILE *infile;
714: register int c;
715:
716: obstack_init (rtl_obstack);
717:
718: if (argc <= 1)
719: fatal ("No input file name.");
720:
721: infile = fopen (argv[1], "r");
722: if (infile == 0)
723: {
724: perror (argv[1]);
725: exit (FATAL_EXIT_CODE);
726: }
727:
728: init_rtl ();
729:
730: /* Assign sequential codes to all entries in the machine description
731: in parallel with the tables in insn-output.c. */
732:
733: insn_code_number = 0;
734: insn_index_number = 0;
735:
736: printf ("/* Generated automatically by the program `genemit'\n\
737: from the machine description file `md'. */\n\n");
738:
739: printf ("#include \"config.h\"\n");
740: printf ("#include \"rtl.h\"\n");
741: printf ("#include \"expr.h\"\n");
742: printf ("#include \"real.h\"\n");
743: printf ("#include \"output.h\"\n");
744: printf ("#include \"insn-config.h\"\n\n");
745: printf ("#include \"insn-flags.h\"\n\n");
746: printf ("#include \"insn-codes.h\"\n\n");
747: printf ("extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS];\n\n");
748: printf ("extern rtx recog_operand[];\n");
749: printf ("#define operands emit_operand\n\n");
750: printf ("#define FAIL goto _fail\n\n");
751: printf ("#define DONE goto _done\n\n");
752:
753: /* Read the machine description. */
754:
755: while (1)
756: {
757: c = read_skip_spaces (infile);
758: if (c == EOF)
759: break;
760: ungetc (c, infile);
761:
762: desc = read_rtx (infile);
763: if (GET_CODE (desc) == DEFINE_INSN)
764: {
765: gen_insn (desc);
766: ++insn_code_number;
767: }
768: if (GET_CODE (desc) == DEFINE_EXPAND)
769: {
770: gen_expand (desc);
771: ++insn_code_number;
772: }
773: if (GET_CODE (desc) == DEFINE_SPLIT)
774: {
775: gen_split (desc);
776: ++insn_code_number;
777: }
778: if (GET_CODE (desc) == DEFINE_PEEPHOLE)
779: {
780: ++insn_code_number;
781: }
782: ++insn_index_number;
783: }
784:
785: /* Write out the routine to add CLOBBERs to a pattern. */
786: output_add_clobbers ();
787:
788: /* Write the routine to initialize mov_optab for the EXTRA_CC_MODES. */
789: output_init_mov_optab ();
790:
791: fflush (stdout);
792: exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
793: /* NOTREACHED */
794: return 0;
795: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.