|
|
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: {
1.1.1.5 ! root 948: assemble_variable (decl, asmspec, top_level,
! 949: write_symbols, at_end);
1.1.1.2 root 950: });
1.1.1.4 root 951: #ifdef DBX_DEBUGGING_INFO
952: else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3 root 953: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4 root 954: #endif
955: #ifdef SDB_DEBUGGING_INFO
956: else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
957: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
958: #endif
1.1.1.2 root 959:
960: if (top_level)
961: {
1.1.1.4 root 962: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 963: {
964: TIMEVAR (symout_time,
965: {
966: /* The initizations make types when they contain
967: string constants. The types are on the temporary
968: obstack, so output them now before they go away. */
969: symout_types (get_temporary_types ());
970: });
971: }
972: else
973: /* Clean out the temporary type list, since the types will go away. */
974: get_temporary_types ();
975: }
976: }
977:
1.1 root 978: /* This is called from finish_function (within yyparse)
1.1.1.2 root 979: after each top-level definition is parsed.
1.1 root 980: It is supposed to compile that function or variable
981: and output the assembler code for it.
982: After we return, the tree storage is freed. */
983:
984: void
1.1.1.2 root 985: rest_of_compilation (decl)
1.1 root 986: tree decl;
987: {
988: register rtx insns;
989: int start_time = gettime ();
990: int tem;
991:
1.1.1.2 root 992: /* If we are reconsidering an inline function
993: at the end of compilation, skip the stuff for making it inline. */
1.1 root 994:
1.1.1.2 root 995: if (DECL_SAVED_INSNS (decl) == 0)
1.1 root 996: {
997:
1.1.1.2 root 998: /* If requested, consider whether to make this function inline. */
999: if (flag_inline_functions || TREE_INLINE (decl))
1000: {
1001: TIMEVAR (integration_time,
1002: {
1003: int specd = TREE_INLINE (decl);
1004: char *lose = function_cannot_inline_p (decl);
1005: if (lose != 0 && specd)
1006: warning_with_decl (decl, lose);
1007: if (lose == 0)
1008: save_for_inline (decl);
1009: else
1010: TREE_INLINE (decl) = 0;
1011: });
1012: }
1.1 root 1013:
1.1.1.2 root 1014: insns = get_insns ();
1.1 root 1015:
1016: /* Dump the rtl code if we are dumping rtl. */
1017:
1018: if (rtl_dump)
1019: TIMEVAR (dump_time,
1020: {
1021: fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1022: IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2 root 1023: if (DECL_SAVED_INSNS (decl))
1024: fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1 root 1025: print_rtl (rtl_dump_file, insns);
1026: fflush (rtl_dump_file);
1027: });
1028:
1.1.1.2 root 1029: /* If function is inline, and we don't yet know whether to
1030: compile it by itself, defer decision till end of compilation.
1031: finish_compilation will call rest_of_compilation again
1032: for those functions that need to be output. */
1033:
1034: if (TREE_PUBLIC (decl) == 0
1035: && TREE_INLINE (decl)
1036: && ! flag_keep_inline_functions)
1.1 root 1037: goto exit_rest_of_compilation;
1.1.1.2 root 1038: }
1.1 root 1039:
1.1.1.2 root 1040: if (rtl_dump_and_exit)
1041: goto exit_rest_of_compilation;
1.1 root 1042:
1.1.1.2 root 1043: TREE_ASM_WRITTEN (decl) = 1;
1.1 root 1044:
1.1.1.2 root 1045: insns = get_insns ();
1.1 root 1046:
1.1.1.2 root 1047: /* Copy any shared structure that should not be shared. */
1.1 root 1048:
1.1.1.2 root 1049: unshare_all_rtl (insns);
1.1 root 1050:
1.1.1.2 root 1051: /* See if we have allocated stack slots that are not directly addressable.
1052: If so, scan all the insns and create explicit address computation
1053: for all references to such slots. */
1054: /* fixup_stack_slots (); */
1.1 root 1055:
1.1.1.2 root 1056: /* Do jump optimization the first time, if -opt.
1057: Also do it if -W, but in that case it doesn't change the rtl code,
1058: it only computes whether control can drop off the end of the function. */
1.1 root 1059:
1.1.1.2 root 1060: if (optimize || extra_warnings || warn_return_type)
1061: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1 root 1062:
1.1.1.2 root 1063: /* Dump rtl code after jump, if we are doing that. */
1.1 root 1064:
1.1.1.2 root 1065: if (jump_opt_dump)
1066: TIMEVAR (dump_time,
1067: {
1068: fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
1069: IDENTIFIER_POINTER (DECL_NAME (decl)));
1070: print_rtl (jump_opt_dump_file, insns);
1071: fflush (jump_opt_dump_file);
1072: });
1.1 root 1073:
1.1.1.2 root 1074: /* Perform common subexpression elimination.
1075: Nonzero value from `cse_main' means that jumps were simplified
1076: and some code may now be unreachable, so do
1077: jump optimization again. */
1.1 root 1078:
1.1.1.2 root 1079: if (optimize)
1080: {
1081: TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1 root 1082:
1.1.1.2 root 1083: TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1 root 1084:
1.1.1.2 root 1085: if (tem)
1086: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1087: }
1.1 root 1088:
1.1.1.2 root 1089: /* Dump rtl code after cse, if we are doing that. */
1.1 root 1090:
1.1.1.2 root 1091: if (cse_dump)
1092: TIMEVAR (dump_time,
1093: {
1094: fprintf (cse_dump_file, "\n;; Function %s\n\n",
1095: IDENTIFIER_POINTER (DECL_NAME (decl)));
1096: print_rtl (cse_dump_file, insns);
1097: fflush (cse_dump_file);
1098: });
1.1 root 1099:
1.1.1.2 root 1100: if (loop_dump)
1101: TIMEVAR (dump_time,
1102: {
1103: fprintf (loop_dump_file, "\n;; Function %s\n\n",
1104: IDENTIFIER_POINTER (DECL_NAME (decl)));
1105: });
1.1 root 1106:
1.1.1.2 root 1107: /* Move constant computations out of loops. */
1.1 root 1108:
1.1.1.2 root 1109: if (optimize)
1110: {
1111: TIMEVAR (loop_time,
1112: {
1113: reg_scan (insns, max_reg_num (), 1);
1114: loop_optimize (insns, max_reg_num (),
1115: loop_dump ? loop_dump_file : 0);
1116: });
1117: }
1.1 root 1118:
1.1.1.2 root 1119: /* Dump rtl code after loop opt, if we are doing that. */
1.1 root 1120:
1.1.1.2 root 1121: if (loop_dump)
1122: TIMEVAR (dump_time,
1123: {
1124: print_rtl (loop_dump_file, insns);
1125: fflush (loop_dump_file);
1126: });
1.1 root 1127:
1.1.1.2 root 1128: /* Now we choose between stupid (pcc-like) register allocation
1129: (if we got the -noreg switch and not -opt)
1130: and smart register allocation. */
1.1 root 1131:
1.1.1.2 root 1132: if (optimize) /* Stupid allocation probably won't work */
1133: obey_regdecls = 0; /* if optimizations being done. */
1.1 root 1134:
1.1.1.2 root 1135: regclass_init ();
1.1 root 1136:
1.1.1.2 root 1137: /* Print function header into flow dump now
1138: because doing the flow analysis makes some of the dump. */
1.1 root 1139:
1.1.1.2 root 1140: if (flow_dump)
1141: TIMEVAR (dump_time,
1142: {
1143: fprintf (flow_dump_file, "\n;; Function %s\n\n",
1144: IDENTIFIER_POINTER (DECL_NAME (decl)));
1145: });
1146:
1147: if (obey_regdecls)
1148: {
1149: TIMEVAR (flow_time,
1150: {
1151: regclass (insns, max_reg_num ());
1152: stupid_life_analysis (insns, max_reg_num (),
1153: flow_dump_file);
1154: });
1155: }
1156: else
1157: {
1158: /* Do control and data flow analysis,
1159: and write some of the results to dump file. */
1.1 root 1160:
1.1.1.2 root 1161: TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
1162: flow_dump_file));
1163: if (extra_warnings)
1164: uninitialized_vars_warning (DECL_INITIAL (decl));
1165: }
1.1 root 1166:
1.1.1.2 root 1167: /* Dump rtl after flow analysis. */
1.1 root 1168:
1.1.1.2 root 1169: if (flow_dump)
1170: TIMEVAR (dump_time,
1171: {
1172: print_rtl (flow_dump_file, insns);
1173: fflush (flow_dump_file);
1174: });
1.1 root 1175:
1.1.1.2 root 1176: /* If -opt, try combining insns through substitution. */
1.1 root 1177:
1.1.1.2 root 1178: if (optimize)
1179: TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1 root 1180:
1.1.1.2 root 1181: /* Dump rtl code after insn combination. */
1.1 root 1182:
1.1.1.2 root 1183: if (combine_dump)
1184: TIMEVAR (dump_time,
1185: {
1186: fprintf (combine_dump_file, "\n;; Function %s\n\n",
1187: IDENTIFIER_POINTER (DECL_NAME (decl)));
1188: dump_combine_stats (combine_dump_file);
1189: print_rtl (combine_dump_file, insns);
1190: fflush (combine_dump_file);
1191: });
1.1 root 1192:
1.1.1.2 root 1193: /* Unless we did stupid register allocation,
1194: allocate pseudo-regs that are used only within 1 basic block. */
1.1 root 1195:
1.1.1.2 root 1196: if (!obey_regdecls)
1197: TIMEVAR (local_alloc_time,
1198: {
1199: regclass (insns, max_reg_num ());
1200: local_alloc ();
1201: });
1.1 root 1202:
1.1.1.2 root 1203: /* Dump rtl code after allocating regs within basic blocks. */
1.1 root 1204:
1.1.1.2 root 1205: if (local_reg_dump)
1206: TIMEVAR (dump_time,
1207: {
1208: fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
1209: IDENTIFIER_POINTER (DECL_NAME (decl)));
1210: dump_flow_info (local_reg_dump_file);
1211: dump_local_alloc (local_reg_dump_file);
1212: print_rtl (local_reg_dump_file, insns);
1213: fflush (local_reg_dump_file);
1214: });
1.1 root 1215:
1.1.1.2 root 1216: if (global_reg_dump)
1217: TIMEVAR (dump_time,
1218: fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
1219: IDENTIFIER_POINTER (DECL_NAME (decl))));
1220:
1221: /* Unless we did stupid register allocation,
1222: allocate remaining pseudo-regs, then do the reload pass
1223: fixing up any insns that are invalid. */
1224:
1225: TIMEVAR (global_alloc_time,
1226: {
1227: if (!obey_regdecls)
1228: global_alloc (global_reg_dump ? global_reg_dump_file : 0);
1229: else
1230: reload (insns, 0,
1231: global_reg_dump ? global_reg_dump_file : 0);
1232: });
1233:
1234: if (global_reg_dump)
1235: TIMEVAR (dump_time,
1236: {
1237: dump_global_regs (global_reg_dump_file);
1238: print_rtl (global_reg_dump_file, insns);
1239: fflush (global_reg_dump_file);
1240: });
1.1 root 1241:
1.1.1.2 root 1242: /* One more attempt to remove jumps to .+1
1243: left by dead-store-elimination.
1244: Also do cross-jumping this time
1245: and delete no-op move insns. */
1.1 root 1246:
1.1.1.2 root 1247: if (optimize)
1248: {
1249: TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
1250: }
1.1 root 1251:
1.1.1.2 root 1252: /* Dump rtl code after jump, if we are doing that. */
1253:
1254: if (jump2_opt_dump)
1255: TIMEVAR (dump_time,
1256: {
1257: fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
1258: IDENTIFIER_POINTER (DECL_NAME (decl)));
1259: print_rtl (jump2_opt_dump_file, insns);
1260: fflush (jump2_opt_dump_file);
1261: });
1262:
1263: /* Now turn the rtl into assembler code. */
1264:
1265: TIMEVAR (final_time,
1266: {
1267: assemble_function (decl);
1268: final_start_function (insns, asm_out_file,
1269: write_symbols, optimize);
1270: final (insns, asm_out_file,
1271: write_symbols, optimize);
1272: final_end_function (insns, asm_out_file,
1273: write_symbols, optimize);
1274: fflush (asm_out_file);
1275: });
1.1 root 1276:
1.1.1.2 root 1277: /* Write GDB symbols if requested */
1.1 root 1278:
1.1.1.4 root 1279: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1280: {
1281: TIMEVAR (symout_time,
1282: {
1283: symout_types (get_permanent_types ());
1284: symout_types (get_temporary_types ());
1285:
1286: DECL_BLOCK_SYMTAB_ADDRESS (decl)
1287: = symout_function (DECL_INITIAL (decl),
1288: DECL_ARGUMENTS (decl), 0);
1289: });
1.1 root 1290: }
1.1.1.2 root 1291: else
1292: get_temporary_types ();
1293:
1294: /* Write DBX symbols if requested */
1295:
1.1.1.4 root 1296: #ifdef DBX_DEBUGGING_INFO
1297: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 1298: TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4 root 1299: #endif
1.1 root 1300:
1301: exit_rest_of_compilation:
1302:
1303: /* The parsing time is all the time spent in yyparse
1304: *except* what is spent in this function. */
1305:
1306: parse_time -= gettime () - start_time;
1307: }
1308:
1309: /* Entry point of cc1. Decode command args, then call compile_file.
1.1.1.2 root 1310: Exit code is 35 if can't open files, 34 if fatal error,
1311: 33 if had nonfatal errors, else success. */
1.1 root 1312:
1313: int
1314: main (argc, argv, envp)
1315: int argc;
1316: char **argv;
1317: char **envp;
1318: {
1319: register int i;
1.1.1.2 root 1320: char *filename = 0;
1321: int print_mem_flag = 0;
1322:
1323: #ifdef RLIMIT_STACK
1324: /* Get rid of any avoidable limit on stack size. */
1325: {
1326: struct rlimit rlim;
1327:
1328: /* Set the stack limit huge so that alloca does not fail. */
1329: getrlimit (RLIMIT_STACK, &rlim);
1330: rlim.rlim_cur = rlim.rlim_max;
1331: setrlimit (RLIMIT_STACK, &rlim);
1332: }
1333: #endif /* RLIMIT_STACK */
1334:
1335: /* Initialize whether `char' is signed. */
1336: flag_signed_char = DEFAULT_SIGNED_CHAR;
1337:
1.1.1.4 root 1338: /* This is zeroed by -O. */
1339: obey_regdecls = 1;
1340:
1341: /* Initialize register usage now so switches may override. */
1.1.1.2 root 1342: init_reg_sets ();
1.1 root 1343:
1344: target_flags = 0;
1345: set_target_switch ("");
1346:
1347: for (i = 1; i < argc; i++)
1348: if (argv[i][0] == '-')
1349: {
1350: register char *str = argv[i] + 1;
1351: if (str[0] == 'Y')
1352: str++;
1353:
1354: if (str[0] == 'm')
1355: set_target_switch (&str[1]);
1356: else if (!strcmp (str, "dumpbase"))
1357: {
1358: dump_base_name = argv[++i];
1359: }
1360: else if (str[0] == 'd')
1361: {
1362: register char *p = &str[1];
1363: while (*p)
1364: switch (*p++)
1365: {
1366: case 'c':
1367: combine_dump = 1;
1368: break;
1369: case 'f':
1370: flow_dump = 1;
1371: break;
1372: case 'g':
1373: global_reg_dump = 1;
1374: break;
1375: case 'j':
1376: jump_opt_dump = 1;
1377: break;
1.1.1.2 root 1378: case 'J':
1379: jump2_opt_dump = 1;
1380: break;
1.1 root 1381: case 'l':
1382: local_reg_dump = 1;
1383: break;
1384: case 'L':
1385: loop_dump = 1;
1386: break;
1.1.1.2 root 1387: case 'm':
1388: print_mem_flag = 1;
1389: break;
1.1 root 1390: case 'r':
1391: rtl_dump = 1;
1392: break;
1393: case 's':
1394: cse_dump = 1;
1395: break;
1396: case 'y':
1397: yydebug = 1;
1398: break;
1399: }
1400: }
1.1.1.2 root 1401: else if (str[0] == 'f')
1402: {
1403: register char *p = &str[1];
1404: if (!strcmp (p, "float-store"))
1405: flag_float_store = 1;
1406: else if (!strcmp (p, "traditional"))
1.1.1.4 root 1407: flag_traditional = 1, dollars_in_ident = 1;
1.1.1.2 root 1408: else if (!strcmp (p, "volatile"))
1409: flag_volatile = 1;
1410: else if (!strcmp (p, "defer-pop"))
1411: flag_defer_pop = 1;
1412: else if (!strcmp (p, "no-defer-pop"))
1413: flag_defer_pop = 0;
1414: else if (!strcmp (p, "omit-frame-pointer"))
1415: flag_omit_frame_pointer = 1;
1416: else if (!strcmp (p, "no-omit-frame-pointer"))
1417: flag_omit_frame_pointer = 0;
1418: else if (!strcmp (p, "no-peephole"))
1419: flag_no_peephole = 1;
1420: else if (!strcmp (p, "signed-char"))
1421: flag_signed_char = 1;
1422: else if (!strcmp (p, "unsigned-char"))
1423: flag_signed_char = 0;
1424: else if (!strcmp (p, "force-mem"))
1425: flag_force_mem = 1;
1426: else if (!strcmp (p, "force-addr"))
1427: flag_force_addr = 1;
1428: else if (!strcmp (p, "combine-regs"))
1429: flag_combine_regs = 1;
1430: else if (!strcmp (p, "writable-strings"))
1431: flag_writable_strings = 1;
1432: else if (!strcmp (p, "no-function-cse"))
1433: flag_no_function_cse = 1;
1434: else if (!strcmp (p, "cond-mismatch"))
1435: flag_cond_mismatch = 1;
1436: else if (!strcmp (p, "no-asm"))
1437: flag_no_asm = 1;
1438: else if (!strncmp (p, "fixed-", 6))
1439: fix_register (&p[6], 1, 1);
1440: else if (!strncmp (p, "call-used-", 10))
1441: fix_register (&p[10], 0, 1);
1442: else if (!strncmp (p, "call-saved-", 11))
1443: fix_register (&p[11], 0, 0);
1444: else if (!strcmp (p, "inline-functions"))
1445: flag_inline_functions = 1;
1446: else if (!strcmp (p, "keep-inline-functions"))
1447: flag_keep_inline_functions = 1;
1448: else
1449: error ("Invalid option, `%s'", argv[i]);
1450: }
1.1 root 1451: else if (!strcmp (str, "noreg"))
1.1.1.4 root 1452: ;
1.1.1.2 root 1453: else if (!strcmp (str, "opt"))
1.1.1.4 root 1454: optimize = 1, obey_regdecls = 0;
1455: else if (!strcmp (str, "O"))
1456: optimize = 1, obey_regdecls = 0;
1.1.1.2 root 1457: else if (!strcmp (str, "pedantic"))
1458: pedantic = 1;
1459: else if (!strcmp (str, "traditional"))
1.1.1.4 root 1460: flag_traditional = 1, dollars_in_ident = 1;
1.1.1.2 root 1461: else if (!strcmp (str, "ansi"))
1.1.1.4 root 1462: flag_no_asm = 1, dollars_in_ident = 0;
1.1.1.2 root 1463: else if (!strcmp (str, "quiet"))
1464: quiet_flag = 1;
1465: else if (!strcmp (str, "version"))
1466: {
1467: extern char *version_string;
1468: printf ("GNU C version %s", version_string);
1469: #ifdef TARGET_VERSION
1470: TARGET_VERSION;
1471: #endif
1472: #ifdef __GNUC__
1473: #ifndef __VERSION__
1474: #define __VERSION__ "[unknown]"
1475: #endif
1476: printf (" compiled by GNU C version %s.\n", __VERSION__);
1477: #else
1478: printf (" compiled by CC.\n");
1479: #endif
1480: }
1.1 root 1481: else if (!strcmp (str, "w"))
1482: inhibit_warnings = 1;
1.1.1.2 root 1483: else if (!strcmp (str, "W"))
1484: extra_warnings = 1;
1485: else if (!strcmp (str, "Wimplicit"))
1486: warn_implicit = 1;
1487: else if (!strcmp (str, "Wreturn-type"))
1488: warn_return_type = 1;
1.1.1.3 root 1489: else if (!strcmp (str, "Wcomment"))
1490: ; /* cpp handles this one. */
1.1.1.4 root 1491: else if (!strcmp (str, "Wtrigraphs"))
1492: ; /* cpp handles this one. */
1.1.1.3 root 1493: else if (!strcmp (str, "Wall"))
1494: {
1495: extra_warnings = 1;
1496: warn_implicit = 1;
1497: warn_return_type = 1;
1498: }
1.1.1.2 root 1499: else if (!strcmp (str, "p"))
1500: profile_flag = 1;
1.1.1.4 root 1501: else if (!strcmp (str, "gg"))
1502: write_symbols = GDB_DEBUG;
1503: #ifdef DBX_DEBUGGING_INFO
1.1 root 1504: else if (!strcmp (str, "g"))
1.1.1.4 root 1505: write_symbols = DBX_DEBUG;
1.1 root 1506: else if (!strcmp (str, "G"))
1.1.1.4 root 1507: write_symbols = DBX_DEBUG;
1508: #endif
1509: #ifdef SDB_DEBUGGING_INFO
1510: else if (!strcmp (str, "g"))
1511: write_symbols = SDB_DEBUG;
1512: else if (!strcmp (str, "G"))
1513: write_symbols = SDB_DEBUG;
1514: #endif
1.1 root 1515: else if (!strcmp (str, "symout"))
1516: {
1.1.1.4 root 1517: if (write_symbols == NO_DEBUG)
1518: write_symbols = GDB_DEBUG;
1.1 root 1519: sym_file_name = argv[++i];
1520: }
1521: else if (!strcmp (str, "o"))
1522: {
1523: asm_file_name = argv[++i];
1524: }
1525: else
1.1.1.2 root 1526: error ("Invalid switch, %s.", argv[i]);
1.1 root 1527: }
1528: else
1529: filename = argv[i];
1530:
1531: if (filename == 0)
1532: fatal ("no input file specified");
1533:
1534: if (dump_base_name == 0)
1535: dump_base_name = filename;
1.1.1.2 root 1536:
1537: #ifdef OVERRIDE_OPTIONS
1538: /* Some machines may reject certain combinations of options. */
1539: OVERRIDE_OPTIONS;
1540: #endif
1541:
1.1.1.4 root 1542: /* Now that register usage is specified, convert it to HARD_REG_SETs. */
1543: init_reg_sets_1 ();
1544:
1.1 root 1545: compile_file (filename);
1546:
1.1.1.2 root 1547: #ifndef USG
1548: #ifndef VMS
1549: if (print_mem_flag)
1550: {
1551: extern char **environ;
1552: caddr_t lim = (caddr_t) sbrk (0);
1553:
1554: fprintf (stderr, "Data size %d.\n",
1555: (int) lim - (int) &environ);
1556: fflush (stderr);
1557:
1558: system ("ps v");
1559: }
1560: #endif /* not VMS */
1561: #endif /* not USG */
1562:
1.1 root 1563: if (errorcount)
1.1.1.2 root 1564: exit (FATAL_EXIT_CODE);
1565: exit (SUCCESS_EXIT_CODE);
1566: return 34;
1.1 root 1567: }
1568:
1569: /* Decode -m switches. */
1570:
1571: /* Here is a table, controlled by the tm-...h file, listing each -m switch
1572: and which bits in `target_switches' it should set or clear.
1573: If VALUE is positive, it is bits to set.
1574: If VALUE is negative, -VALUE is bits to clear.
1575: (The sign bit is not used so there is no confusion.) */
1576:
1577: struct {char *name; int value;} target_switches []
1578: = TARGET_SWITCHES;
1579:
1580: /* Decode the switch -mNAME. */
1581:
1.1.1.2 root 1582: void
1.1 root 1583: set_target_switch (name)
1584: char *name;
1585: {
1.1.1.2 root 1586: register int j;
1.1 root 1587: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
1588: if (!strcmp (target_switches[j].name, name))
1589: {
1590: if (target_switches[j].value < 0)
1591: target_flags &= ~-target_switches[j].value;
1592: else
1593: target_flags |= target_switches[j].value;
1594: break;
1595: }
1596: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.