|
|
1.1 root 1: /* Top level of GNU C compiler
1.1.1.2 root 2: Copyright (C) 1987, 1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
6: GNU CC is distributed in the hope that it will be useful,
7: but WITHOUT ANY WARRANTY. No author or distributor
8: accepts responsibility to anyone for the consequences of using it
9: or for whether it serves any particular purpose or works at all,
10: unless he says so in writing. Refer to the GNU CC General Public
11: License for full details.
12:
13: Everyone is granted permission to copy, modify and redistribute
14: GNU CC, but only under the conditions described in the
15: GNU CC General Public License. A copy of this license is
16: supposed to have been given to you along with GNU CC so you
17: can know your rights and responsibilities. It should be in a
18: file named COPYING. Among other things, the copyright notice
19: and this notice must be preserved on all copies. */
20:
21:
22: /* This is the top level of cc1.
23: It parses command args, opens files, invokes the various passes
24: in the proper order, and counts the time used by each.
25: Error messages and low-level interface to malloc also handled here. */
26:
27: #include "config.h"
28: #include <stdio.h>
29: #include <signal.h>
1.1.1.2 root 30:
1.1.1.4 ! root 31: #include <sys/types.h>
! 32: #include <sys/stat.h>
! 33:
1.1.1.2 root 34: #ifdef USG
35: #include <sys/param.h>
36: #include <sys/times.h>
37: #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
38: #else
39: #ifndef VMS
1.1 root 40: #include <sys/time.h>
41: #include <sys/resource.h>
1.1.1.2 root 42: #endif
43: #endif
44:
1.1 root 45: #include "tree.h"
46: #include "c-tree.h"
47: #include "rtl.h"
1.1.1.2 root 48: #include "flags.h"
1.1 root 49:
50: extern int yydebug;
51:
52: extern FILE *finput;
53:
54: extern void init_lex ();
55: extern void init_decl_processing ();
56: extern void init_tree ();
57: extern void init_rtl ();
58: extern void init_optabs ();
1.1.1.2 root 59: extern void init_reg_sets ();
1.1 root 60: extern void dump_flow_info ();
61: extern void dump_local_alloc ();
62:
1.1.1.2 root 63: void rest_of_decl_compilation ();
64: void error ();
65: void error_with_file_and_line ();
66: void set_target_switch ();
67:
1.1 root 68: /* Bit flags that specify the machine subtype we are compiling for.
69: Bits are tested using macros TARGET_... defined in the tm-...h file
70: and set by `-m...' switches. */
71:
72: int target_flags;
73:
1.1.1.2 root 74: /* Name of current original source file (what was input to cpp).
75: This comes from each #-command in the actual input. */
1.1 root 76:
1.1.1.2 root 77: char *input_filename;
78:
79: /* Name of top-level original source file (what was input to cpp).
80: This comes from the first #-command in the actual input. */
81:
82: char *main_input_filename;
1.1 root 83:
84: /* Current line number in real source file. */
85:
86: extern int lineno;
87:
88: /* FUNCTION_DECL for function now being parsed or compiled. */
89:
90: extern tree current_function_decl;
91:
92: /* Name to use as base of names for dump output files. */
93:
94: char *dump_base_name;
95:
96: /* Flags saying which kinds of debugging dump have been requested. */
97:
98: int rtl_dump = 0;
99: int rtl_dump_and_exit = 0;
100: int jump_opt_dump = 0;
101: int cse_dump = 0;
102: int loop_dump = 0;
103: int flow_dump = 0;
104: int combine_dump = 0;
105: int local_reg_dump = 0;
106: int global_reg_dump = 0;
1.1.1.2 root 107: int jump2_opt_dump = 0;
1.1 root 108:
109: /* 1 => write gdb debugging output (using symout.c). -g
110: 2 => write dbx debugging output (using dbxout.c). -G */
111:
1.1.1.4 ! root 112: enum debugger write_symbols = NO_DEBUG;
1.1 root 113:
114: /* Nonzero means do optimizations. -opt. */
115:
116: int optimize = 0;
117:
1.1.1.2 root 118: /* Nonzero for -fforce-mem: load memory value into a register
1.1 root 119: before arithmetic on it. This makes better cse but slower compilation. */
120:
1.1.1.2 root 121: int flag_force_mem = 0;
1.1 root 122:
1.1.1.2 root 123: /* Nonzero for -fforce-addr: load memory address into a register before
1.1 root 124: reference to memory. This makes better cse but slower compilation. */
125:
1.1.1.2 root 126: int flag_force_addr = 0;
127:
128: /* Nonzero for -fdefer-pop: don't pop args after each function call;
129: instead save them up to pop many calls' args with one insns. */
130:
131: int flag_defer_pop = 1;
132:
133: /* Nonzero for -ffloat-store: don't allocate floats and doubles
134: in extended-precision registers. */
135:
136: int flag_float_store = 0;
137:
138: /* Nonzero for -fcombine-regs:
139: allow instruction combiner to combine an insn
140: that just copies one reg to another. */
141:
142: int flag_combine_regs = 0;
143:
144: /* Nonzero for -fwritable-strings:
145: store string constants in data segment and don't uniquize them. */
146:
147: int flag_writable_strings = 0;
148:
149: /* Nonzero means don't put addresses of constant functions in registers.
150: Used for compiling the Unix kernel, where strange substitutions are
151: done on the assembly output. */
152:
153: int flag_no_function_cse = 0;
154:
155: /* Nonzero for -fomit-frame-pointer:
156: don't make a frame pointer in simple functions that don't require one. */
157:
158: int flag_omit_frame_pointer = 0;
159:
160: /* Nonzero to inhibit use of define_optimization peephole opts. */
161:
162: int flag_no_peephole = 0;
163:
164: /* Nonzero means `char' should be signed. */
165:
166: int flag_signed_char;
167:
168: /* Nonzero means allow type mismatches in conditional expressions;
169: just make their values `void'. */
170:
171: int flag_cond_mismatch;
172:
173: /* Nonzero means don't recognize the keyword `asm'. */
174:
175: int flag_no_asm;
176:
177: /* Nonzero means warn about implicit declarations. */
178:
179: int warn_implicit;
180:
181: /* Nonzero means warn about function definitions that default the return type
182: or that use a null return and have a return-type other than void. */
183:
184: int warn_return_type;
185:
186: /* Nonzero means do some things the same way PCC does. */
187:
188: int flag_traditional;
189:
190: /* Nonzero means all references through pointers are volatile. */
191:
192: int flag_volatile;
1.1 root 193:
194: /* Nonzero means do stupid register allocation. -noreg.
1.1.1.2 root 195: This and `optimize' are controlled by different switches in cc1,
1.1 root 196: but normally cc controls them both with the -O switch. */
197:
198: int obey_regdecls = 0;
199:
200: /* Don't print functions as they are compiled and don't print
201: times taken by the various passes. -quiet. */
202:
203: int quiet_flag = 0;
204:
205: /* Don't print warning messages. -w. */
206:
207: int inhibit_warnings = 0;
208:
1.1.1.2 root 209: /* Do print extra warnings (such as for uninitialized variables). -W. */
210:
211: int extra_warnings = 0;
212:
1.1 root 213: /* Number of error messages and warning messages so far. */
214:
215: int errorcount = 0;
216: int warningcount = 0;
217:
1.1.1.2 root 218: /* Nonzero if generating code to do profiling. */
219:
220: int profile_flag = 0;
221:
1.1 root 222: /* Nonzero for -pedantic switch: warn about anything
223: that standard C forbids. */
224:
225: int pedantic = 0;
226:
1.1.1.4 ! root 227: /* Nonzero means `$' can be in an identifier.
! 228: See cccp.c for reasons why this breaks some obscure ANSI C programs. */
! 229:
! 230: #ifndef DOLLARS_IN_IDENTIFIERS
! 231: #define DOLLARS_IN_IDENTIFIERS 0
! 232: #endif
! 233: int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
! 234:
1.1.1.2 root 235: /* Nonzero for -finline-functions: ok to inline functions that look like
236: good inline candidates. */
237:
238: int flag_inline_functions;
239:
240: /* Nonzero for -fkeep-inline-functions: even if we make a function
241: go inline everywhere, keep its defintion around for debugging
242: purposes. */
243:
244: int flag_keep_inline_functions;
245:
1.1 root 246: /* Name for output file of assembly code, specified with -o. */
247:
248: char *asm_file_name;
249:
250: /* Name for output file of GDB symbol segment, specified with -symout. */
251:
252: char *sym_file_name;
253:
254: /* Output files for assembler code (real compiler output)
255: and debugging dumps. */
256:
257: FILE *asm_out_file;
258: FILE *rtl_dump_file;
259: FILE *jump_opt_dump_file;
260: FILE *cse_dump_file;
261: FILE *loop_dump_file;
262: FILE *flow_dump_file;
263: FILE *combine_dump_file;
264: FILE *local_reg_dump_file;
265: FILE *global_reg_dump_file;
1.1.1.2 root 266: FILE *jump2_opt_dump_file;
1.1 root 267:
268: /* Time accumulators, to count the total time spent in various passes. */
269:
270: int parse_time;
271: int varconst_time;
1.1.1.2 root 272: int integration_time;
1.1 root 273: int jump_time;
274: int cse_time;
275: int loop_time;
276: int flow_time;
277: int combine_time;
278: int local_alloc_time;
279: int global_alloc_time;
280: int final_time;
281: int symout_time;
282: int dump_time;
283:
284: /* Return time used so far, in microseconds. */
285:
1.1.1.2 root 286: int
1.1 root 287: gettime ()
288: {
1.1.1.2 root 289: #ifdef USG
290: struct tms tms;
291: #else
292: #ifndef VMS
1.1 root 293: struct rusage rusage;
1.1.1.2 root 294: #else /* VMS */
295: struct
296: {
297: int proc_user_time;
298: int proc_system_time;
299: int child_user_time;
300: int child_system_time;
301: } vms_times;
302: #endif
303: #endif
304:
1.1 root 305: if (quiet_flag)
306: return 0;
1.1.1.2 root 307:
308: #ifdef USG
309: times (&tms);
310: return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
311: #else
312: #ifndef VMS
1.1 root 313: getrusage (0, &rusage);
314: return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
315: + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1.1.1.2 root 316: #else /* VMS */
317: times (&vms_times);
318: return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
319: #endif
320: #endif
1.1 root 321: }
322:
323: #define TIMEVAR(VAR, BODY) \
1.1.1.3 root 324: do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
1.1 root 325:
1.1.1.2 root 326: void
1.1 root 327: print_time (str, total)
328: char *str;
329: int total;
330: {
1.1.1.2 root 331: fprintf (stderr,
332: "time in %s: %d.%06d\n",
333: str, total / 1000000, total % 1000000);
1.1 root 334: }
335:
336: /* Count an error or warning. Return 1 if the message should be printed. */
337:
338: int
339: count_error (warningp)
340: int warningp;
341: {
342: if (warningp && inhibit_warnings)
343: return 0;
344:
345: if (warningp)
346: warningcount++;
347: else
348: errorcount++;
349:
350: return 1;
351: }
352:
353: /* Print a fatal error message. NAME is the text.
354: Also include a system error message based on `errno'. */
355:
1.1.1.2 root 356: void
1.1 root 357: pfatal_with_name (name)
1.1.1.2 root 358: char *name;
1.1 root 359: {
360: fprintf (stderr, "cc1: ");
361: perror (name);
362: exit (35);
363: }
364:
365: void
1.1.1.2 root 366: fatal_io_error (name)
367: char *name;
368: {
369: fprintf (stderr, "cc1:%s: I/O error\n", name);
370: exit (35);
371: }
372:
373: void
1.1 root 374: fatal (s)
375: char *s;
376: {
1.1.1.2 root 377: error (s, 0);
1.1 root 378: exit (34);
379: }
380:
381: /* Called when the start of a function definition is parsed,
382: this function prints on stderr the name of the function. */
383:
384: void
385: announce_function (decl)
386: tree decl;
387: {
388: if (! quiet_flag)
389: {
390: fprintf (stderr, " %s", IDENTIFIER_POINTER (DECL_NAME (decl)));
391: fflush (stderr);
392: }
393: }
394:
1.1.1.2 root 395: /* Prints out, if necessary, the name of the current function
396: which caused an error. Called from all error and warning functions. */
397:
398: void
399: report_error_function()
400: {
401: static tree last_error_function = NULL;
402:
403: if (last_error_function != current_function_decl)
404: {
405: if (current_function_decl == NULL)
406: {
407: if (!quiet_flag)
408: fprintf (stderr, "\n");
409: fprintf (stderr, "At top level:\n");
410: }
411: else
412: {
413: if (!quiet_flag)
414: /* We already know this info. Don't print it twice.
415: But make sure we are at the beginning of a line. */
416: fprintf (stderr, "\n");
417: else
418: fprintf (stderr, "In function %s:\n",
419: IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
420: }
421: last_error_function = current_function_decl;
422: }
423: }
1.1 root 424:
425: /* Report an error at the current line number.
426: S and V are a string and an arg for `printf'. */
427:
428: void
1.1.1.2 root 429: error (s, v)
1.1 root 430: char *s;
431: int v; /* @@also used as pointer */
432: {
1.1.1.2 root 433: error_with_file_and_line (input_filename, lineno, s, v);
1.1 root 434: }
435:
1.1.1.2 root 436: /* Report an error at line LINE of file FILE.
1.1 root 437: S and V are a string and an arg for `printf'. */
438:
1.1.1.2 root 439: void
440: error_with_file_and_line (file, line, s, v)
441: char *file;
1.1 root 442: int line;
443: char *s;
444: int v;
445: {
446: count_error (0);
447:
1.1.1.2 root 448: report_error_function ();
449:
450: if (file)
451: fprintf (stderr, "%s:%d: ", file, line);
452: else
453: fprintf (stderr, "cc1: ");
1.1 root 454: fprintf (stderr, s, v);
455: fprintf (stderr, "\n");
456: }
457:
1.1.1.2 root 458: /* Report an error at the declaration DECL.
459: S is string which uses %s to substitute the declaration name. */
1.1 root 460:
461: void
1.1.1.2 root 462: error_with_decl (decl, s)
463: tree decl;
1.1 root 464: char *s;
465: {
1.1.1.2 root 466: count_error (0);
467:
468: report_error_function ();
469:
470: fprintf (stderr, "%s:%d: ",
471: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
472:
473: if (DECL_NAME (decl))
474: fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
475: else
476: fprintf (stderr, s, "((anonymous))");
477: fprintf (stderr, "\n");
1.1 root 478: }
479:
480: /* Report a warning at line LINE.
481: S and V are a string and an arg for `printf'. */
482:
1.1.1.2 root 483: void
1.1 root 484: warning_with_line (line, s, v)
485: int line;
486: char *s;
487: int v;
488: {
489: if (count_error (1) == 0)
490: return;
491:
1.1.1.2 root 492: report_error_function ();
493:
494: if (input_filename)
495: fprintf (stderr, "%s:%d: ", input_filename, line);
496: else
497: fprintf (stderr, "cc1: ");
1.1 root 498:
499: fprintf (stderr, "warning: ");
500: fprintf (stderr, s, v);
501: fprintf (stderr, "\n");
502: }
1.1.1.2 root 503:
504: /* Report a warning at the current line number.
505: S and V are a string and an arg for `printf'. */
506:
507: void
508: warning (s, v)
509: char *s;
510: int v; /* @@also used as pointer */
511: {
512: warning_with_line (lineno, s, v);
513: }
514:
515: /* Report a warning at the declaration DECL.
516: S is string which uses %s to substitute the declaration name. */
517:
518: void
519: warning_with_decl (decl, s)
520: tree decl;
521: char *s;
522: {
523: if (count_error (1) == 0)
524: return;
525:
526: report_error_function ();
527:
528: fprintf (stderr, "%s:%d: ",
529: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
530:
531: fprintf (stderr, "warning: ");
532: if (DECL_NAME (decl))
533: fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
534: else
535: fprintf (stderr, s, "((anonymous))");
536: fprintf (stderr, "\n");
537: }
1.1 root 538:
539: /* When `malloc.c' is compiled with `rcheck' defined,
540: it calls this function to report clobberage. */
541:
1.1.1.2 root 542: void
1.1 root 543: botch (s)
544: {
545: abort ();
546: }
547:
548: /* Same as `malloc' but report error if no memory available. */
549:
1.1.1.2 root 550: int
1.1 root 551: xmalloc (size)
552: unsigned size;
553: {
554: register int value = (int) malloc (size);
555: if (value == 0)
556: fatal ("Virtual memory exhausted.");
557: return value;
558: }
559:
560: /* Same as `realloc' but report error if no memory available. */
561:
562: int
563: xrealloc (ptr, size)
564: char *ptr;
565: int size;
566: {
567: int result = realloc (ptr, size);
568: if (!result)
1.1.1.2 root 569: fatal ("Virtual memory exhausted.");
1.1 root 570: return result;
571: }
572:
573: /* Return the logarithm of X, base 2, considering X unsigned,
574: if X is a power of 2. Otherwise, returns -1. */
575:
576: int
577: exact_log2 (x)
578: register unsigned int x;
579: {
580: register int log = 0;
581: for (log = 0; log < HOST_BITS_PER_INT; log++)
582: if (x == (1 << log))
583: return log;
584: return -1;
585: }
586:
587: /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
588: If X is 0, return -1. */
589:
590: int
591: floor_log2 (x)
592: register unsigned int x;
593: {
594: register int log = 0;
595: for (log = 0; log < HOST_BITS_PER_INT; log++)
596: if ((x & ((-1) << log)) == 0)
597: return log - 1;
598: return HOST_BITS_PER_INT - 1;
599: }
600:
601: /* Compile an entire file of output from cpp, named NAME.
602: Write a file of assembly output and various debugging dumps. */
603:
604: static void
605: compile_file (name)
606: char *name;
607: {
608: tree globals;
609: int start_time;
610: int dump_base_name_length = strlen (dump_base_name);
611:
612: parse_time = 0;
613: varconst_time = 0;
1.1.1.2 root 614: integration_time = 0;
1.1 root 615: jump_time = 0;
616: cse_time = 0;
617: loop_time = 0;
618: flow_time = 0;
619: combine_time = 0;
620: local_alloc_time = 0;
621: global_alloc_time = 0;
622: final_time = 0;
623: symout_time = 0;
1.1.1.2 root 624: dump_time = 0;
1.1 root 625:
626: /* Open input file. */
627:
628: finput = fopen (name, "r");
629: if (finput == 0)
630: pfatal_with_name (name);
631:
632: /* Initialize data in various passes. */
633:
634: init_tree ();
635: init_lex ();
636: init_rtl ();
1.1.1.2 root 637: init_emit_once ();
1.1 root 638: init_decl_processing ();
639: init_optabs ();
640:
641: /* If rtl dump desired, open the output file. */
642: if (rtl_dump)
643: {
644: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
645: strcpy (dumpname, dump_base_name);
646: strcat (dumpname, ".rtl");
647: rtl_dump_file = fopen (dumpname, "w");
648: if (rtl_dump_file == 0)
649: pfatal_with_name (dumpname);
650: }
651:
652: /* If jump_opt dump desired, open the output file. */
653: if (jump_opt_dump)
654: {
655: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
656: strcpy (dumpname, dump_base_name);
657: strcat (dumpname, ".jump");
658: jump_opt_dump_file = fopen (dumpname, "w");
659: if (jump_opt_dump_file == 0)
660: pfatal_with_name (dumpname);
661: }
662:
663: /* If cse dump desired, open the output file. */
664: if (cse_dump)
665: {
666: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
667: strcpy (dumpname, dump_base_name);
668: strcat (dumpname, ".cse");
669: cse_dump_file = fopen (dumpname, "w");
670: if (cse_dump_file == 0)
671: pfatal_with_name (dumpname);
672: }
673:
674: /* If loop dump desired, open the output file. */
675: if (loop_dump)
676: {
677: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
678: strcpy (dumpname, dump_base_name);
679: strcat (dumpname, ".loop");
680: loop_dump_file = fopen (dumpname, "w");
681: if (loop_dump_file == 0)
682: pfatal_with_name (dumpname);
683: }
684:
685: /* If flow dump desired, open the output file. */
686: if (flow_dump)
687: {
688: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
689: strcpy (dumpname, dump_base_name);
690: strcat (dumpname, ".flow");
691: flow_dump_file = fopen (dumpname, "w");
692: if (flow_dump_file == 0)
693: pfatal_with_name (dumpname);
694: }
695:
696: /* If combine dump desired, open the output file. */
697: if (combine_dump)
698: {
699: register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
700: strcpy (dumpname, dump_base_name);
701: strcat (dumpname, ".combine");
702: combine_dump_file = fopen (dumpname, "w");
703: if (combine_dump_file == 0)
704: pfatal_with_name (dumpname);
705: }
706:
707: /* If local_reg dump desired, open the output file. */
708: if (local_reg_dump)
709: {
710: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
711: strcpy (dumpname, dump_base_name);
712: strcat (dumpname, ".lreg");
713: local_reg_dump_file = fopen (dumpname, "w");
714: if (local_reg_dump_file == 0)
715: pfatal_with_name (dumpname);
716: }
717:
718: /* If global_reg dump desired, open the output file. */
719: if (global_reg_dump)
720: {
721: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
722: strcpy (dumpname, dump_base_name);
723: strcat (dumpname, ".greg");
724: global_reg_dump_file = fopen (dumpname, "w");
725: if (global_reg_dump_file == 0)
726: pfatal_with_name (dumpname);
727: }
728:
1.1.1.2 root 729: /* If jump2_opt dump desired, open the output file. */
730: if (jump2_opt_dump)
731: {
732: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
733: strcpy (dumpname, dump_base_name);
734: strcat (dumpname, ".jump2");
735: jump2_opt_dump_file = fopen (dumpname, "w");
736: if (jump2_opt_dump_file == 0)
737: pfatal_with_name (dumpname);
738: }
739:
1.1 root 740: /* Open assembler code output file. */
741:
742: {
743: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1.1.1.2 root 744: int len = strlen (dump_base_name);
1.1 root 745: strcpy (dumpname, dump_base_name);
1.1.1.2 root 746: if (len > 2 && ! strcmp (".c", dumpname + len - 2))
747: dumpname[len - 2] = 0;
748: else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
749: dumpname[len - 3] = 0;
1.1 root 750: strcat (dumpname, ".s");
1.1.1.2 root 751: if (asm_file_name == 0)
752: {
753: asm_file_name = (char *) malloc (strlen (dumpname) + 1);
754: strcpy (asm_file_name, dumpname);
755: }
756: asm_out_file = fopen (asm_file_name, "w");
1.1 root 757: if (asm_out_file == 0)
758: pfatal_with_name (asm_file_name ? asm_file_name : dumpname);
759: }
760:
761: input_filename = name;
762:
763: /* the beginning of the file is a new line; check for # */
764: /* With luck, we discover the real source file's name from that
765: and put it in input_filename. */
1.1.1.4 ! root 766: ungetc (check_newline (), finput);
! 767:
! 768: ASM_FILE_START (asm_out_file);
1.1 root 769:
770: /* If GDB symbol table desired, open the GDB symbol output file. */
1.1.1.4 ! root 771: if (write_symbols == GDB_DEBUG)
1.1 root 772: {
773: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1.1.1.2 root 774: int len = strlen (dump_base_name);
1.1 root 775: strcpy (dumpname, dump_base_name);
1.1.1.2 root 776: if (len > 2 && ! strcmp (".c", dumpname + len - 2))
777: dumpname[len - 2] = 0;
778: else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
779: dumpname[len - 3] = 0;
1.1 root 780: strcat (dumpname, ".sym");
781: if (sym_file_name == 0)
782: sym_file_name = dumpname;
1.1.1.4 ! root 783: symout_init (sym_file_name, asm_out_file, main_input_filename);
1.1 root 784: }
785:
786: /* If dbx symbol table desired, initialize writing it
787: and output the predefined types. */
1.1.1.4 ! root 788: #ifdef DBX_DEBUGGING_INFO
! 789: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 790: dbxout_init (asm_out_file, main_input_filename);
1.1.1.4 ! root 791: #endif
! 792: #ifdef SDB_DEBUGGING_INFO
! 793: if (write_symbols == SDB_DEBUG)
! 794: sdbout_init (asm_out_file, main_input_filename);
! 795: #endif
1.1 root 796:
797: /* Initialize yet another pass. */
798:
1.1.1.2 root 799: init_final (main_input_filename);
1.1 root 800:
801: start_time = gettime ();
802:
803: /* Call the parser, which parses the entire file
804: (calling rest_of_compilation for each function). */
805:
806: yyparse ();
807:
808: /* Compilation is now finished except for writing
809: what's left of the symbol table output. */
810:
811: parse_time += gettime () - start_time;
812:
1.1.1.2 root 813: parse_time -= varconst_time;
814:
1.1 root 815: globals = getdecls ();
816:
1.1.1.2 root 817: /* Really define vars that have had only a tentative definition.
818: Really output inline functions that must actually be callable
819: and have not been output so far. */
820:
821: {
822: tree decl;
823: for (decl = globals; decl; decl = TREE_CHAIN (decl))
824: {
825: if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
826: && ! TREE_ASM_WRITTEN (decl))
827: rest_of_decl_compilation (decl, 0, 1, 1);
828: if (TREE_CODE (decl) == FUNCTION_DECL
829: && ! TREE_ASM_WRITTEN (decl)
830: && DECL_INITIAL (decl) != 0
831: && TREE_ADDRESSABLE (decl))
832: output_inline_function (decl);
833: }
834: }
835:
1.1 root 836: /* Do dbx symbols */
1.1.1.4 ! root 837: #ifdef DBX_DEBUGGING_INFO
! 838: if (write_symbols == DBX_DEBUG)
1.1 root 839: TIMEVAR (symout_time,
840: {
841: dbxout_tags (gettags ());
842: dbxout_types (get_permanent_types ());
843: });
1.1.1.4 ! root 844: #endif
! 845:
! 846: #ifdef SDB_DEBUGGING_INFO
! 847: if (write_symbols == SDB_DEBUG)
! 848: TIMEVAR (symout_time,
! 849: {
! 850: sdbout_tags (gettags ());
! 851: sdbout_types (get_permanent_types ());
! 852: });
! 853: #endif
1.1 root 854:
855: /* Do gdb symbols */
1.1.1.4 ! root 856: if (write_symbols == GDB_DEBUG)
1.1 root 857: TIMEVAR (symout_time,
858: {
859: struct stat statbuf;
860: fstat (fileno (finput), &statbuf);
861: symout_types (get_permanent_types ());
862: symout_top_blocks (globals, gettags ());
863: symout_finish (name, statbuf.st_ctime);
864: });
865:
1.1.1.2 root 866: /* Close the dump files. */
1.1 root 867:
868: if (rtl_dump)
869: fclose (rtl_dump_file);
870:
871: if (jump_opt_dump)
872: fclose (jump_opt_dump_file);
873:
874: if (cse_dump)
875: fclose (cse_dump_file);
876:
877: if (loop_dump)
878: fclose (loop_dump_file);
879:
880: if (flow_dump)
881: fclose (flow_dump_file);
882:
883: if (combine_dump)
884: {
885: dump_combine_total_stats (combine_dump_file);
886: fclose (combine_dump_file);
887: }
888:
889: if (local_reg_dump)
890: fclose (local_reg_dump_file);
891:
892: if (global_reg_dump)
893: fclose (global_reg_dump_file);
894:
1.1.1.2 root 895: if (jump2_opt_dump)
896: fclose (jump2_opt_dump_file);
897:
898: /* Close non-debugging input and output files. */
899:
900: fclose (finput);
901: if (ferror (asm_out_file) != 0)
902: fatal_io_error (asm_file_name);
903: fclose (asm_out_file);
904:
1.1 root 905: /* Print the times. */
906:
907: if (! quiet_flag)
908: {
1.1.1.2 root 909: fprintf (stderr,"\n");
1.1 root 910: print_time ("parse", parse_time);
1.1.1.2 root 911: print_time ("integration", integration_time);
1.1 root 912: print_time ("jump", jump_time);
913: print_time ("cse", cse_time);
914: print_time ("loop", loop_time);
915: print_time ("flow", flow_time);
916: print_time ("combine", combine_time);
917: print_time ("local-alloc", local_alloc_time);
918: print_time ("global-alloc", global_alloc_time);
919: print_time ("final", final_time);
920: print_time ("varconst", varconst_time);
921: print_time ("symout", symout_time);
922: print_time ("dump", dump_time);
923: }
924: }
925:
1.1.1.2 root 926: /* This is called from finish_decl (within yyparse)
927: for each declaration of a function or variable.
928: This does nothing for automatic variables.
929: Otherwise, it sets up the RTL and outputs any assembler code
930: (label definition, storage allocation and initialization).
931:
932: DECL is the declaration. If ASMSPEC is nonzero, it specifies
933: the assembler symbol name to be used. TOP_LEVEL is nonzero
934: if this declaration is not within a function. */
935:
936: void
937: rest_of_decl_compilation (decl, asmspec, top_level, at_end)
938: tree decl;
939: tree asmspec;
940: int top_level;
941: int at_end;
942: {
943: /* Declarations of variables, and of functions defined elsewhere. */
944:
945: if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
946: TIMEVAR (varconst_time,
947: {
948: assemble_variable (decl, asmspec, top_level, write_symbols, at_end);
949: });
1.1.1.4 ! root 950: #ifdef DBX_DEBUGGING_INFO
! 951: else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3 root 952: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4 ! root 953: #endif
! 954: #ifdef SDB_DEBUGGING_INFO
! 955: else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
! 956: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
! 957: #endif
1.1.1.2 root 958:
959: if (top_level)
960: {
1.1.1.4 ! root 961: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 962: {
963: TIMEVAR (symout_time,
964: {
965: /* The initizations make types when they contain
966: string constants. The types are on the temporary
967: obstack, so output them now before they go away. */
968: symout_types (get_temporary_types ());
969: });
970: }
971: else
972: /* Clean out the temporary type list, since the types will go away. */
973: get_temporary_types ();
974: }
975: }
976:
1.1 root 977: /* This is called from finish_function (within yyparse)
1.1.1.2 root 978: after each top-level definition is parsed.
1.1 root 979: It is supposed to compile that function or variable
980: and output the assembler code for it.
981: After we return, the tree storage is freed. */
982:
983: void
1.1.1.2 root 984: rest_of_compilation (decl)
1.1 root 985: tree decl;
986: {
987: register rtx insns;
988: int start_time = gettime ();
989: int tem;
990:
1.1.1.2 root 991: /* If we are reconsidering an inline function
992: at the end of compilation, skip the stuff for making it inline. */
1.1 root 993:
1.1.1.2 root 994: if (DECL_SAVED_INSNS (decl) == 0)
1.1 root 995: {
996:
1.1.1.2 root 997: /* If requested, consider whether to make this function inline. */
998: if (flag_inline_functions || TREE_INLINE (decl))
999: {
1000: TIMEVAR (integration_time,
1001: {
1002: int specd = TREE_INLINE (decl);
1003: char *lose = function_cannot_inline_p (decl);
1004: if (lose != 0 && specd)
1005: warning_with_decl (decl, lose);
1006: if (lose == 0)
1007: save_for_inline (decl);
1008: else
1009: TREE_INLINE (decl) = 0;
1010: });
1011: }
1.1 root 1012:
1.1.1.2 root 1013: insns = get_insns ();
1.1 root 1014:
1015: /* Dump the rtl code if we are dumping rtl. */
1016:
1017: if (rtl_dump)
1018: TIMEVAR (dump_time,
1019: {
1020: fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1021: IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2 root 1022: if (DECL_SAVED_INSNS (decl))
1023: fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1 root 1024: print_rtl (rtl_dump_file, insns);
1025: fflush (rtl_dump_file);
1026: });
1027:
1.1.1.2 root 1028: /* If function is inline, and we don't yet know whether to
1029: compile it by itself, defer decision till end of compilation.
1030: finish_compilation will call rest_of_compilation again
1031: for those functions that need to be output. */
1032:
1033: if (TREE_PUBLIC (decl) == 0
1034: && TREE_INLINE (decl)
1035: && ! flag_keep_inline_functions)
1.1 root 1036: goto exit_rest_of_compilation;
1.1.1.2 root 1037: }
1.1 root 1038:
1.1.1.2 root 1039: if (rtl_dump_and_exit)
1040: goto exit_rest_of_compilation;
1.1 root 1041:
1.1.1.2 root 1042: TREE_ASM_WRITTEN (decl) = 1;
1.1 root 1043:
1.1.1.2 root 1044: insns = get_insns ();
1.1 root 1045:
1.1.1.2 root 1046: /* Copy any shared structure that should not be shared. */
1.1 root 1047:
1.1.1.2 root 1048: unshare_all_rtl (insns);
1.1 root 1049:
1.1.1.2 root 1050: /* See if we have allocated stack slots that are not directly addressable.
1051: If so, scan all the insns and create explicit address computation
1052: for all references to such slots. */
1053: /* fixup_stack_slots (); */
1.1 root 1054:
1.1.1.2 root 1055: /* Do jump optimization the first time, if -opt.
1056: Also do it if -W, but in that case it doesn't change the rtl code,
1057: it only computes whether control can drop off the end of the function. */
1.1 root 1058:
1.1.1.2 root 1059: if (optimize || extra_warnings || warn_return_type)
1060: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1 root 1061:
1.1.1.2 root 1062: /* Dump rtl code after jump, if we are doing that. */
1.1 root 1063:
1.1.1.2 root 1064: if (jump_opt_dump)
1065: TIMEVAR (dump_time,
1066: {
1067: fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
1068: IDENTIFIER_POINTER (DECL_NAME (decl)));
1069: print_rtl (jump_opt_dump_file, insns);
1070: fflush (jump_opt_dump_file);
1071: });
1.1 root 1072:
1.1.1.2 root 1073: /* Perform common subexpression elimination.
1074: Nonzero value from `cse_main' means that jumps were simplified
1075: and some code may now be unreachable, so do
1076: jump optimization again. */
1.1 root 1077:
1.1.1.2 root 1078: if (optimize)
1079: {
1080: TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1 root 1081:
1.1.1.2 root 1082: TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1 root 1083:
1.1.1.2 root 1084: if (tem)
1085: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1086: }
1.1 root 1087:
1.1.1.2 root 1088: /* Dump rtl code after cse, if we are doing that. */
1.1 root 1089:
1.1.1.2 root 1090: if (cse_dump)
1091: TIMEVAR (dump_time,
1092: {
1093: fprintf (cse_dump_file, "\n;; Function %s\n\n",
1094: IDENTIFIER_POINTER (DECL_NAME (decl)));
1095: print_rtl (cse_dump_file, insns);
1096: fflush (cse_dump_file);
1097: });
1.1 root 1098:
1.1.1.2 root 1099: if (loop_dump)
1100: TIMEVAR (dump_time,
1101: {
1102: fprintf (loop_dump_file, "\n;; Function %s\n\n",
1103: IDENTIFIER_POINTER (DECL_NAME (decl)));
1104: });
1.1 root 1105:
1.1.1.2 root 1106: /* Move constant computations out of loops. */
1.1 root 1107:
1.1.1.2 root 1108: if (optimize)
1109: {
1110: TIMEVAR (loop_time,
1111: {
1112: reg_scan (insns, max_reg_num (), 1);
1113: loop_optimize (insns, max_reg_num (),
1114: loop_dump ? loop_dump_file : 0);
1115: });
1116: }
1.1 root 1117:
1.1.1.2 root 1118: /* Dump rtl code after loop opt, if we are doing that. */
1.1 root 1119:
1.1.1.2 root 1120: if (loop_dump)
1121: TIMEVAR (dump_time,
1122: {
1123: print_rtl (loop_dump_file, insns);
1124: fflush (loop_dump_file);
1125: });
1.1 root 1126:
1.1.1.2 root 1127: /* Now we choose between stupid (pcc-like) register allocation
1128: (if we got the -noreg switch and not -opt)
1129: and smart register allocation. */
1.1 root 1130:
1.1.1.2 root 1131: if (optimize) /* Stupid allocation probably won't work */
1132: obey_regdecls = 0; /* if optimizations being done. */
1.1 root 1133:
1.1.1.2 root 1134: regclass_init ();
1.1 root 1135:
1.1.1.2 root 1136: /* Print function header into flow dump now
1137: because doing the flow analysis makes some of the dump. */
1.1 root 1138:
1.1.1.2 root 1139: if (flow_dump)
1140: TIMEVAR (dump_time,
1141: {
1142: fprintf (flow_dump_file, "\n;; Function %s\n\n",
1143: IDENTIFIER_POINTER (DECL_NAME (decl)));
1144: });
1145:
1146: if (obey_regdecls)
1147: {
1148: TIMEVAR (flow_time,
1149: {
1150: regclass (insns, max_reg_num ());
1151: stupid_life_analysis (insns, max_reg_num (),
1152: flow_dump_file);
1153: });
1154: }
1155: else
1156: {
1157: /* Do control and data flow analysis,
1158: and write some of the results to dump file. */
1.1 root 1159:
1.1.1.2 root 1160: TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
1161: flow_dump_file));
1162: if (extra_warnings)
1163: uninitialized_vars_warning (DECL_INITIAL (decl));
1164: }
1.1 root 1165:
1.1.1.2 root 1166: /* Dump rtl after flow analysis. */
1.1 root 1167:
1.1.1.2 root 1168: if (flow_dump)
1169: TIMEVAR (dump_time,
1170: {
1171: print_rtl (flow_dump_file, insns);
1172: fflush (flow_dump_file);
1173: });
1.1 root 1174:
1.1.1.2 root 1175: /* If -opt, try combining insns through substitution. */
1.1 root 1176:
1.1.1.2 root 1177: if (optimize)
1178: TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1 root 1179:
1.1.1.2 root 1180: /* Dump rtl code after insn combination. */
1.1 root 1181:
1.1.1.2 root 1182: if (combine_dump)
1183: TIMEVAR (dump_time,
1184: {
1185: fprintf (combine_dump_file, "\n;; Function %s\n\n",
1186: IDENTIFIER_POINTER (DECL_NAME (decl)));
1187: dump_combine_stats (combine_dump_file);
1188: print_rtl (combine_dump_file, insns);
1189: fflush (combine_dump_file);
1190: });
1.1 root 1191:
1.1.1.2 root 1192: /* Unless we did stupid register allocation,
1193: allocate pseudo-regs that are used only within 1 basic block. */
1.1 root 1194:
1.1.1.2 root 1195: if (!obey_regdecls)
1196: TIMEVAR (local_alloc_time,
1197: {
1198: regclass (insns, max_reg_num ());
1199: local_alloc ();
1200: });
1.1 root 1201:
1.1.1.2 root 1202: /* Dump rtl code after allocating regs within basic blocks. */
1.1 root 1203:
1.1.1.2 root 1204: if (local_reg_dump)
1205: TIMEVAR (dump_time,
1206: {
1207: fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
1208: IDENTIFIER_POINTER (DECL_NAME (decl)));
1209: dump_flow_info (local_reg_dump_file);
1210: dump_local_alloc (local_reg_dump_file);
1211: print_rtl (local_reg_dump_file, insns);
1212: fflush (local_reg_dump_file);
1213: });
1.1 root 1214:
1.1.1.2 root 1215: if (global_reg_dump)
1216: TIMEVAR (dump_time,
1217: fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
1218: IDENTIFIER_POINTER (DECL_NAME (decl))));
1219:
1220: /* Unless we did stupid register allocation,
1221: allocate remaining pseudo-regs, then do the reload pass
1222: fixing up any insns that are invalid. */
1223:
1224: TIMEVAR (global_alloc_time,
1225: {
1226: if (!obey_regdecls)
1227: global_alloc (global_reg_dump ? global_reg_dump_file : 0);
1228: else
1229: reload (insns, 0,
1230: global_reg_dump ? global_reg_dump_file : 0);
1231: });
1232:
1233: if (global_reg_dump)
1234: TIMEVAR (dump_time,
1235: {
1236: dump_global_regs (global_reg_dump_file);
1237: print_rtl (global_reg_dump_file, insns);
1238: fflush (global_reg_dump_file);
1239: });
1.1 root 1240:
1.1.1.2 root 1241: /* One more attempt to remove jumps to .+1
1242: left by dead-store-elimination.
1243: Also do cross-jumping this time
1244: and delete no-op move insns. */
1.1 root 1245:
1.1.1.2 root 1246: if (optimize)
1247: {
1248: TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
1249: }
1.1 root 1250:
1.1.1.2 root 1251: /* Dump rtl code after jump, if we are doing that. */
1252:
1253: if (jump2_opt_dump)
1254: TIMEVAR (dump_time,
1255: {
1256: fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
1257: IDENTIFIER_POINTER (DECL_NAME (decl)));
1258: print_rtl (jump2_opt_dump_file, insns);
1259: fflush (jump2_opt_dump_file);
1260: });
1261:
1262: /* Now turn the rtl into assembler code. */
1263:
1264: TIMEVAR (final_time,
1265: {
1266: assemble_function (decl);
1267: final_start_function (insns, asm_out_file,
1268: write_symbols, optimize);
1269: final (insns, asm_out_file,
1270: write_symbols, optimize);
1271: final_end_function (insns, asm_out_file,
1272: write_symbols, optimize);
1273: fflush (asm_out_file);
1274: });
1.1 root 1275:
1.1.1.2 root 1276: /* Write GDB symbols if requested */
1.1 root 1277:
1.1.1.4 ! root 1278: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1279: {
1280: TIMEVAR (symout_time,
1281: {
1282: symout_types (get_permanent_types ());
1283: symout_types (get_temporary_types ());
1284:
1285: DECL_BLOCK_SYMTAB_ADDRESS (decl)
1286: = symout_function (DECL_INITIAL (decl),
1287: DECL_ARGUMENTS (decl), 0);
1288: });
1.1 root 1289: }
1.1.1.2 root 1290: else
1291: get_temporary_types ();
1292:
1293: /* Write DBX symbols if requested */
1294:
1.1.1.4 ! root 1295: #ifdef DBX_DEBUGGING_INFO
! 1296: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 1297: TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4 ! root 1298: #endif
1.1 root 1299:
1300: exit_rest_of_compilation:
1301:
1302: /* The parsing time is all the time spent in yyparse
1303: *except* what is spent in this function. */
1304:
1305: parse_time -= gettime () - start_time;
1306: }
1307:
1308: /* Entry point of cc1. Decode command args, then call compile_file.
1.1.1.2 root 1309: Exit code is 35 if can't open files, 34 if fatal error,
1310: 33 if had nonfatal errors, else success. */
1.1 root 1311:
1312: int
1313: main (argc, argv, envp)
1314: int argc;
1315: char **argv;
1316: char **envp;
1317: {
1318: register int i;
1.1.1.2 root 1319: char *filename = 0;
1320: int print_mem_flag = 0;
1321:
1322: #ifdef RLIMIT_STACK
1323: /* Get rid of any avoidable limit on stack size. */
1324: {
1325: struct rlimit rlim;
1326:
1327: /* Set the stack limit huge so that alloca does not fail. */
1328: getrlimit (RLIMIT_STACK, &rlim);
1329: rlim.rlim_cur = rlim.rlim_max;
1330: setrlimit (RLIMIT_STACK, &rlim);
1331: }
1332: #endif /* RLIMIT_STACK */
1333:
1334: /* Initialize whether `char' is signed. */
1335: flag_signed_char = DEFAULT_SIGNED_CHAR;
1336:
1.1.1.4 ! root 1337: /* This is zeroed by -O. */
! 1338: obey_regdecls = 1;
! 1339:
! 1340: /* Initialize register usage now so switches may override. */
1.1.1.2 root 1341: init_reg_sets ();
1.1 root 1342:
1343: target_flags = 0;
1344: set_target_switch ("");
1345:
1346: for (i = 1; i < argc; i++)
1347: if (argv[i][0] == '-')
1348: {
1349: register char *str = argv[i] + 1;
1350: if (str[0] == 'Y')
1351: str++;
1352:
1353: if (str[0] == 'm')
1354: set_target_switch (&str[1]);
1355: else if (!strcmp (str, "dumpbase"))
1356: {
1357: dump_base_name = argv[++i];
1358: }
1359: else if (str[0] == 'd')
1360: {
1361: register char *p = &str[1];
1362: while (*p)
1363: switch (*p++)
1364: {
1365: case 'c':
1366: combine_dump = 1;
1367: break;
1368: case 'f':
1369: flow_dump = 1;
1370: break;
1371: case 'g':
1372: global_reg_dump = 1;
1373: break;
1374: case 'j':
1375: jump_opt_dump = 1;
1376: break;
1.1.1.2 root 1377: case 'J':
1378: jump2_opt_dump = 1;
1379: break;
1.1 root 1380: case 'l':
1381: local_reg_dump = 1;
1382: break;
1383: case 'L':
1384: loop_dump = 1;
1385: break;
1.1.1.2 root 1386: case 'm':
1387: print_mem_flag = 1;
1388: break;
1.1 root 1389: case 'r':
1390: rtl_dump = 1;
1391: break;
1392: case 's':
1393: cse_dump = 1;
1394: break;
1395: case 'y':
1396: yydebug = 1;
1397: break;
1398: }
1399: }
1.1.1.2 root 1400: else if (str[0] == 'f')
1401: {
1402: register char *p = &str[1];
1403: if (!strcmp (p, "float-store"))
1404: flag_float_store = 1;
1405: else if (!strcmp (p, "traditional"))
1.1.1.4 ! root 1406: flag_traditional = 1, dollars_in_ident = 1;
1.1.1.2 root 1407: else if (!strcmp (p, "volatile"))
1408: flag_volatile = 1;
1409: else if (!strcmp (p, "defer-pop"))
1410: flag_defer_pop = 1;
1411: else if (!strcmp (p, "no-defer-pop"))
1412: flag_defer_pop = 0;
1413: else if (!strcmp (p, "omit-frame-pointer"))
1414: flag_omit_frame_pointer = 1;
1415: else if (!strcmp (p, "no-omit-frame-pointer"))
1416: flag_omit_frame_pointer = 0;
1417: else if (!strcmp (p, "no-peephole"))
1418: flag_no_peephole = 1;
1419: else if (!strcmp (p, "signed-char"))
1420: flag_signed_char = 1;
1421: else if (!strcmp (p, "unsigned-char"))
1422: flag_signed_char = 0;
1423: else if (!strcmp (p, "force-mem"))
1424: flag_force_mem = 1;
1425: else if (!strcmp (p, "force-addr"))
1426: flag_force_addr = 1;
1427: else if (!strcmp (p, "combine-regs"))
1428: flag_combine_regs = 1;
1429: else if (!strcmp (p, "writable-strings"))
1430: flag_writable_strings = 1;
1431: else if (!strcmp (p, "no-function-cse"))
1432: flag_no_function_cse = 1;
1433: else if (!strcmp (p, "cond-mismatch"))
1434: flag_cond_mismatch = 1;
1435: else if (!strcmp (p, "no-asm"))
1436: flag_no_asm = 1;
1437: else if (!strncmp (p, "fixed-", 6))
1438: fix_register (&p[6], 1, 1);
1439: else if (!strncmp (p, "call-used-", 10))
1440: fix_register (&p[10], 0, 1);
1441: else if (!strncmp (p, "call-saved-", 11))
1442: fix_register (&p[11], 0, 0);
1443: else if (!strcmp (p, "inline-functions"))
1444: flag_inline_functions = 1;
1445: else if (!strcmp (p, "keep-inline-functions"))
1446: flag_keep_inline_functions = 1;
1447: else
1448: error ("Invalid option, `%s'", argv[i]);
1449: }
1.1 root 1450: else if (!strcmp (str, "noreg"))
1.1.1.4 ! root 1451: ;
1.1.1.2 root 1452: else if (!strcmp (str, "opt"))
1.1.1.4 ! root 1453: optimize = 1, obey_regdecls = 0;
! 1454: else if (!strcmp (str, "O"))
! 1455: optimize = 1, obey_regdecls = 0;
1.1.1.2 root 1456: else if (!strcmp (str, "pedantic"))
1457: pedantic = 1;
1458: else if (!strcmp (str, "traditional"))
1.1.1.4 ! root 1459: flag_traditional = 1, dollars_in_ident = 1;
1.1.1.2 root 1460: else if (!strcmp (str, "ansi"))
1.1.1.4 ! root 1461: flag_no_asm = 1, dollars_in_ident = 0;
1.1.1.2 root 1462: else if (!strcmp (str, "quiet"))
1463: quiet_flag = 1;
1464: else if (!strcmp (str, "version"))
1465: {
1466: extern char *version_string;
1467: printf ("GNU C version %s", version_string);
1468: #ifdef TARGET_VERSION
1469: TARGET_VERSION;
1470: #endif
1471: #ifdef __GNUC__
1472: #ifndef __VERSION__
1473: #define __VERSION__ "[unknown]"
1474: #endif
1475: printf (" compiled by GNU C version %s.\n", __VERSION__);
1476: #else
1477: printf (" compiled by CC.\n");
1478: #endif
1479: }
1.1 root 1480: else if (!strcmp (str, "w"))
1481: inhibit_warnings = 1;
1.1.1.2 root 1482: else if (!strcmp (str, "W"))
1483: extra_warnings = 1;
1484: else if (!strcmp (str, "Wimplicit"))
1485: warn_implicit = 1;
1486: else if (!strcmp (str, "Wreturn-type"))
1487: warn_return_type = 1;
1.1.1.3 root 1488: else if (!strcmp (str, "Wcomment"))
1489: ; /* cpp handles this one. */
1.1.1.4 ! root 1490: else if (!strcmp (str, "Wtrigraphs"))
! 1491: ; /* cpp handles this one. */
1.1.1.3 root 1492: else if (!strcmp (str, "Wall"))
1493: {
1494: extra_warnings = 1;
1495: warn_implicit = 1;
1496: warn_return_type = 1;
1497: }
1.1.1.2 root 1498: else if (!strcmp (str, "p"))
1499: profile_flag = 1;
1.1.1.4 ! root 1500: else if (!strcmp (str, "gg"))
! 1501: write_symbols = GDB_DEBUG;
! 1502: #ifdef DBX_DEBUGGING_INFO
1.1 root 1503: else if (!strcmp (str, "g"))
1.1.1.4 ! root 1504: write_symbols = DBX_DEBUG;
1.1 root 1505: else if (!strcmp (str, "G"))
1.1.1.4 ! root 1506: write_symbols = DBX_DEBUG;
! 1507: #endif
! 1508: #ifdef SDB_DEBUGGING_INFO
! 1509: else if (!strcmp (str, "g"))
! 1510: write_symbols = SDB_DEBUG;
! 1511: else if (!strcmp (str, "G"))
! 1512: write_symbols = SDB_DEBUG;
! 1513: #endif
1.1 root 1514: else if (!strcmp (str, "symout"))
1515: {
1.1.1.4 ! root 1516: if (write_symbols == NO_DEBUG)
! 1517: write_symbols = GDB_DEBUG;
1.1 root 1518: sym_file_name = argv[++i];
1519: }
1520: else if (!strcmp (str, "o"))
1521: {
1522: asm_file_name = argv[++i];
1523: }
1524: else
1.1.1.2 root 1525: error ("Invalid switch, %s.", argv[i]);
1.1 root 1526: }
1527: else
1528: filename = argv[i];
1529:
1530: if (filename == 0)
1531: fatal ("no input file specified");
1532:
1533: if (dump_base_name == 0)
1534: dump_base_name = filename;
1.1.1.2 root 1535:
1536: #ifdef OVERRIDE_OPTIONS
1537: /* Some machines may reject certain combinations of options. */
1538: OVERRIDE_OPTIONS;
1539: #endif
1540:
1.1.1.4 ! root 1541: /* Now that register usage is specified, convert it to HARD_REG_SETs. */
! 1542: init_reg_sets_1 ();
! 1543:
1.1 root 1544: compile_file (filename);
1545:
1.1.1.2 root 1546: #ifndef USG
1547: #ifndef VMS
1548: if (print_mem_flag)
1549: {
1550: extern char **environ;
1551: caddr_t lim = (caddr_t) sbrk (0);
1552:
1553: fprintf (stderr, "Data size %d.\n",
1554: (int) lim - (int) &environ);
1555: fflush (stderr);
1556:
1557: system ("ps v");
1558: }
1559: #endif /* not VMS */
1560: #endif /* not USG */
1561:
1.1 root 1562: if (errorcount)
1.1.1.2 root 1563: exit (FATAL_EXIT_CODE);
1564: exit (SUCCESS_EXIT_CODE);
1565: return 34;
1.1 root 1566: }
1567:
1568: /* Decode -m switches. */
1569:
1570: /* Here is a table, controlled by the tm-...h file, listing each -m switch
1571: and which bits in `target_switches' it should set or clear.
1572: If VALUE is positive, it is bits to set.
1573: If VALUE is negative, -VALUE is bits to clear.
1574: (The sign bit is not used so there is no confusion.) */
1575:
1576: struct {char *name; int value;} target_switches []
1577: = TARGET_SWITCHES;
1578:
1579: /* Decode the switch -mNAME. */
1580:
1.1.1.2 root 1581: void
1.1 root 1582: set_target_switch (name)
1583: char *name;
1584: {
1.1.1.2 root 1585: register int j;
1.1 root 1586: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
1587: if (!strcmp (target_switches[j].name, name))
1588: {
1589: if (target_switches[j].value < 0)
1590: target_flags &= ~-target_switches[j].value;
1591: else
1592: target_flags |= target_switches[j].value;
1593: break;
1594: }
1595: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.