|
|
1.1 root 1: /* Top level of GNU C compiler
1.1.1.14 root 2: Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
1.1.1.14 root 6: GNU CC is free software; you can redistribute it and/or modify
7: it under the terms of the GNU General Public License as published by
8: the Free Software Foundation; either version 1, or (at your option)
9: any later version.
10:
1.1 root 11: GNU CC is distributed in the hope that it will be useful,
1.1.1.14 root 12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with GNU CC; see the file COPYING. If not, write to
18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
1.1 root 19:
20:
21: /* This is the top level of cc1.
22: It parses command args, opens files, invokes the various passes
23: in the proper order, and counts the time used by each.
24: Error messages and low-level interface to malloc also handled here. */
25:
26: #include "config.h"
1.1.1.18! root 27: #include <sys/types.h>
1.1 root 28: #include <stdio.h>
29: #include <signal.h>
1.1.1.10 root 30: #include <setjmp.h>
1.1.1.2 root 31:
1.1.1.4 root 32: #include <sys/stat.h>
33:
1.1.1.2 root 34: #ifdef USG
1.1.1.16 root 35: #undef FLOAT
1.1.1.2 root 36: #include <sys/param.h>
1.1.1.16 root 37: /* This is for hpux. It is a real screw. They should change hpux. */
38: #undef FLOAT
1.1.1.2 root 39: #include <sys/times.h>
40: #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
1.1.1.17 root 41: #undef FFS /* Some systems define this in param.h. */
1.1.1.2 root 42: #else
43: #ifndef VMS
1.1 root 44: #include <sys/time.h>
45: #include <sys/resource.h>
1.1.1.2 root 46: #endif
47: #endif
48:
1.1.1.16 root 49: #include "input.h"
1.1 root 50: #include "tree.h"
51: #include "c-tree.h"
52: #include "rtl.h"
1.1.1.2 root 53: #include "flags.h"
1.1 root 54:
55: extern int yydebug;
56:
57: extern FILE *finput;
58:
1.1.1.11 root 59: extern int reload_completed;
1.1.1.12 root 60: extern int rtx_equal_function_value_matters;
1.1.1.11 root 61:
1.1 root 62: extern void init_lex ();
63: extern void init_decl_processing ();
64: extern void init_tree ();
65: extern void init_rtl ();
66: extern void init_optabs ();
1.1.1.2 root 67: extern void init_reg_sets ();
1.1 root 68: extern void dump_flow_info ();
69: extern void dump_local_alloc ();
70:
1.1.1.2 root 71: void rest_of_decl_compilation ();
72: void error ();
73: void error_with_file_and_line ();
1.1.1.16 root 74: void fancy_abort ();
1.1.1.2 root 75: void set_target_switch ();
1.1.1.16 root 76: void print_target_switch_defaults ();
1.1.1.2 root 77:
1.1 root 78: /* Bit flags that specify the machine subtype we are compiling for.
79: Bits are tested using macros TARGET_... defined in the tm-...h file
80: and set by `-m...' switches. */
81:
82: int target_flags;
83:
1.1.1.2 root 84: /* Name of current original source file (what was input to cpp).
85: This comes from each #-command in the actual input. */
1.1 root 86:
1.1.1.2 root 87: char *input_filename;
88:
89: /* Name of top-level original source file (what was input to cpp).
1.1.1.8 root 90: This comes from the #-command at the beginning of the actual input.
91: If there isn't any there, then this is the cc1 input file name. */
1.1.1.2 root 92:
93: char *main_input_filename;
1.1 root 94:
95: /* Current line number in real source file. */
96:
1.1.1.16 root 97: int lineno;
98:
99: /* Stack of currently pending input files. */
100:
101: struct file_stack *input_file_stack;
102:
103: /* Incremented on each change to input_file_stack. */
104: int input_file_stack_tick;
1.1 root 105:
106: /* FUNCTION_DECL for function now being parsed or compiled. */
107:
108: extern tree current_function_decl;
109:
110: /* Name to use as base of names for dump output files. */
111:
112: char *dump_base_name;
113:
114: /* Flags saying which kinds of debugging dump have been requested. */
115:
116: int rtl_dump = 0;
117: int rtl_dump_and_exit = 0;
118: int jump_opt_dump = 0;
119: int cse_dump = 0;
120: int loop_dump = 0;
121: int flow_dump = 0;
122: int combine_dump = 0;
123: int local_reg_dump = 0;
124: int global_reg_dump = 0;
1.1.1.2 root 125: int jump2_opt_dump = 0;
1.1.1.16 root 126: int dbr_sched_dump = 0;
1.1 root 127:
128: /* 1 => write gdb debugging output (using symout.c). -g
1.1.1.6 root 129: 2 => write dbx debugging output (using dbxout.c). -G
130: 3 => write sdb debugging output (using sdbout.c). -g. */
1.1 root 131:
1.1.1.4 root 132: enum debugger write_symbols = NO_DEBUG;
1.1 root 133:
1.1.1.6 root 134: /* Nonzero means can use our own extensions to DBX format.
135: Relevant only with write_symbols == DBX_DEBUG. */
136:
137: int use_gdb_dbx_extensions;
138:
1.1 root 139: /* Nonzero means do optimizations. -opt. */
140:
141: int optimize = 0;
142:
1.1.1.16 root 143: /* Nonzero means `char' should be signed. */
144:
145: int flag_signed_char;
146:
147: /* Nonzero means give an enum type only as many bytes as it needs. */
148:
149: int flag_short_enums;
150:
1.1.1.14 root 151: /* Nonzero for -fcaller-saves: allocate values in regs that need to
152: be saved across function calls, if that produces overall better code.
153: Optional now, so people can test it. */
154:
155: #ifdef DEFAULT_CALLER_SAVES
156: int flag_caller_saves = 1;
157: #else
158: int flag_caller_saves = 0;
159: #endif
160:
161: /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
162:
163: int flag_pcc_struct_return = 0;
164:
1.1.1.2 root 165: /* Nonzero for -fforce-mem: load memory value into a register
1.1 root 166: before arithmetic on it. This makes better cse but slower compilation. */
167:
1.1.1.2 root 168: int flag_force_mem = 0;
1.1 root 169:
1.1.1.2 root 170: /* Nonzero for -fforce-addr: load memory address into a register before
1.1 root 171: reference to memory. This makes better cse but slower compilation. */
172:
1.1.1.2 root 173: int flag_force_addr = 0;
174:
175: /* Nonzero for -fdefer-pop: don't pop args after each function call;
176: instead save them up to pop many calls' args with one insns. */
177:
178: int flag_defer_pop = 1;
179:
180: /* Nonzero for -ffloat-store: don't allocate floats and doubles
181: in extended-precision registers. */
182:
183: int flag_float_store = 0;
184:
185: /* Nonzero for -fcombine-regs:
186: allow instruction combiner to combine an insn
187: that just copies one reg to another. */
188:
189: int flag_combine_regs = 0;
190:
1.1.1.9 root 191: /* Nonzero enables strength-reduction in loop.c. */
192:
193: int flag_strength_reduce = 0;
194:
1.1.1.2 root 195: /* Nonzero for -fwritable-strings:
196: store string constants in data segment and don't uniquize them. */
197:
198: int flag_writable_strings = 0;
199:
200: /* Nonzero means don't put addresses of constant functions in registers.
201: Used for compiling the Unix kernel, where strange substitutions are
202: done on the assembly output. */
203:
204: int flag_no_function_cse = 0;
205:
206: /* Nonzero for -fomit-frame-pointer:
207: don't make a frame pointer in simple functions that don't require one. */
208:
209: int flag_omit_frame_pointer = 0;
210:
211: /* Nonzero to inhibit use of define_optimization peephole opts. */
212:
213: int flag_no_peephole = 0;
214:
215: /* Nonzero means all references through pointers are volatile. */
216:
217: int flag_volatile;
1.1 root 218:
1.1.1.16 root 219: /* Nonzero means just do syntax checking; don't output anything. */
220:
221: int flag_syntax_only = 0;
222:
1.1 root 223: /* Nonzero means do stupid register allocation. -noreg.
1.1.1.2 root 224: This and `optimize' are controlled by different switches in cc1,
1.1 root 225: but normally cc controls them both with the -O switch. */
226:
227: int obey_regdecls = 0;
228:
229: /* Don't print functions as they are compiled and don't print
230: times taken by the various passes. -quiet. */
231:
232: int quiet_flag = 0;
233:
234: /* Don't print warning messages. -w. */
235:
236: int inhibit_warnings = 0;
237:
1.1.1.2 root 238: /* Do print extra warnings (such as for uninitialized variables). -W. */
239:
240: int extra_warnings = 0;
241:
1.1.1.9 root 242: /* Nonzero to warn about unused local variables. */
243:
244: int warn_unused;
245:
1.1.1.15 root 246: /* Nonzero means warn about all declarations which shadow others. */
247:
248: int warn_shadow;
249:
250: /* Warn if a switch on an enum fails to have a case for every enum value. */
251:
252: int warn_switch;
253:
254: /* Nonzero means warn about any identifiers that match in the first N
255: characters. The value N is in `id_clash_len'. */
256:
257: int warn_id_clash;
258: int id_clash_len;
259:
1.1 root 260: /* Number of error messages and warning messages so far. */
261:
262: int errorcount = 0;
263: int warningcount = 0;
1.1.1.7 root 264: int sorrycount = 0;
1.1 root 265:
1.1.1.16 root 266: /* Name of program invoked, sans directories. */
267:
268: char *progname;
269:
1.1.1.2 root 270: /* Nonzero if generating code to do profiling. */
271:
272: int profile_flag = 0;
273:
1.1.1.14 root 274: /* Nonzero if generating code to do profiling on a line-by-line basis. */
275:
276: int profile_block_flag;
277:
1.1 root 278: /* Nonzero for -pedantic switch: warn about anything
1.1.1.7 root 279: that standard spec forbids. */
1.1 root 280:
281: int pedantic = 0;
282:
1.1.1.2 root 283: /* Nonzero for -finline-functions: ok to inline functions that look like
284: good inline candidates. */
285:
286: int flag_inline_functions;
287:
288: /* Nonzero for -fkeep-inline-functions: even if we make a function
289: go inline everywhere, keep its defintion around for debugging
290: purposes. */
291:
292: int flag_keep_inline_functions;
293:
1.1.1.12 root 294: /* Nonzero means make the text shared if supported. */
295:
296: int flag_shared_data;
297:
1.1.1.16 root 298: /* Nonzero means schedule into delayed branch slots if supported. */
299:
300: int flag_delayed_branch;
301:
302: /* Copy of arguments to main. */
303: int save_argc;
304: char **save_argv;
305:
1.1 root 306: /* Name for output file of assembly code, specified with -o. */
307:
308: char *asm_file_name;
309:
310: /* Name for output file of GDB symbol segment, specified with -symout. */
311:
312: char *sym_file_name;
313:
1.1.1.12 root 314: /* Table of language-independent -f options.
315: STRING is the option name. VARIABLE is the address of the variable.
316: ON_VALUE is the value to store in VARIABLE
317: if `-fSTRING' is seen as an option.
318: (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
319:
320: struct { char *string; int *variable; int on_value;} f_options[] =
321: {
322: {"float-store", &flag_float_store, 1},
323: {"volatile", &flag_volatile, 1},
324: {"defer-pop", &flag_defer_pop, 1},
325: {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
326: {"strength-reduce", &flag_strength_reduce, 1},
327: {"writable-strings", &flag_writable_strings, 1},
328: {"peephole", &flag_no_peephole, 0},
329: {"force-mem", &flag_force_mem, 1},
330: {"force-addr", &flag_force_addr, 1},
331: {"combine-regs", &flag_combine_regs, 1},
332: {"function-cse", &flag_no_function_cse, 0},
333: {"inline-functions", &flag_inline_functions, 1},
334: {"keep-inline-functions", &flag_keep_inline_functions, 1},
335: {"syntax-only", &flag_syntax_only, 1},
1.1.1.14 root 336: {"shared-data", &flag_shared_data, 1},
337: {"caller-saves", &flag_caller_saves, 1},
1.1.1.16 root 338: {"pcc-struct-return", &flag_pcc_struct_return, 1},
339: {"delayed-branch", &flag_delayed_branch, 1}
1.1.1.12 root 340: };
341:
1.1 root 342: /* Output files for assembler code (real compiler output)
343: and debugging dumps. */
344:
345: FILE *asm_out_file;
346: FILE *rtl_dump_file;
347: FILE *jump_opt_dump_file;
348: FILE *cse_dump_file;
349: FILE *loop_dump_file;
350: FILE *flow_dump_file;
351: FILE *combine_dump_file;
352: FILE *local_reg_dump_file;
353: FILE *global_reg_dump_file;
1.1.1.2 root 354: FILE *jump2_opt_dump_file;
1.1.1.16 root 355: FILE *dbr_sched_dump_file;
1.1 root 356:
357: /* Time accumulators, to count the total time spent in various passes. */
358:
359: int parse_time;
360: int varconst_time;
1.1.1.2 root 361: int integration_time;
1.1 root 362: int jump_time;
363: int cse_time;
364: int loop_time;
365: int flow_time;
366: int combine_time;
367: int local_alloc_time;
368: int global_alloc_time;
1.1.1.16 root 369: int dbr_sched_time;
1.1 root 370: int final_time;
371: int symout_time;
372: int dump_time;
373:
374: /* Return time used so far, in microseconds. */
375:
1.1.1.2 root 376: int
1.1 root 377: gettime ()
378: {
1.1.1.2 root 379: #ifdef USG
380: struct tms tms;
381: #else
382: #ifndef VMS
1.1 root 383: struct rusage rusage;
1.1.1.2 root 384: #else /* VMS */
385: struct
386: {
387: int proc_user_time;
388: int proc_system_time;
389: int child_user_time;
390: int child_system_time;
391: } vms_times;
392: #endif
393: #endif
394:
1.1 root 395: if (quiet_flag)
396: return 0;
1.1.1.2 root 397:
398: #ifdef USG
399: times (&tms);
400: return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
401: #else
402: #ifndef VMS
1.1 root 403: getrusage (0, &rusage);
404: return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
405: + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1.1.1.2 root 406: #else /* VMS */
407: times (&vms_times);
408: return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
409: #endif
410: #endif
1.1 root 411: }
412:
413: #define TIMEVAR(VAR, BODY) \
1.1.1.3 root 414: do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
1.1 root 415:
1.1.1.2 root 416: void
1.1 root 417: print_time (str, total)
418: char *str;
419: int total;
420: {
1.1.1.2 root 421: fprintf (stderr,
422: "time in %s: %d.%06d\n",
423: str, total / 1000000, total % 1000000);
1.1 root 424: }
425:
426: /* Count an error or warning. Return 1 if the message should be printed. */
427:
428: int
429: count_error (warningp)
430: int warningp;
431: {
432: if (warningp && inhibit_warnings)
433: return 0;
434:
435: if (warningp)
436: warningcount++;
437: else
438: errorcount++;
439:
440: return 1;
441: }
442:
443: /* Print a fatal error message. NAME is the text.
444: Also include a system error message based on `errno'. */
445:
1.1.1.2 root 446: void
1.1 root 447: pfatal_with_name (name)
1.1.1.2 root 448: char *name;
1.1 root 449: {
1.1.1.16 root 450: fprintf (stderr, "%s: ", progname);
1.1 root 451: perror (name);
452: exit (35);
453: }
454:
455: void
1.1.1.2 root 456: fatal_io_error (name)
457: char *name;
458: {
1.1.1.16 root 459: fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1.1.1.2 root 460: exit (35);
461: }
462:
463: void
1.1.1.7 root 464: fatal (s, v)
1.1 root 465: char *s;
1.1.1.16 root 466: int v;
1.1 root 467: {
1.1.1.7 root 468: error (s, v);
1.1 root 469: exit (34);
470: }
1.1.1.16 root 471:
472: /* Called from insn-extract to give a better error message when we
473: don't have an insn to match what we are looking for, rather
474: than just calling abort(). */
475:
476: void
477: fatal_insn_not_found (insn)
478: rtx insn;
479: {
480: error ("The following insn was not recognizable:", 0);
481: debug_rtx (insn);
482: abort ();
483: }
1.1.1.8 root 484:
485: static int need_error_newline;
486:
487: /* Function of last error message;
488: more generally, function such that if next error message is in it
489: then we don't have to mention the function name. */
490: static tree last_error_function = NULL;
1.1 root 491:
1.1.1.16 root 492: /* Used to detect when input_file_stack has changed since last described. */
493: static int last_error_tick;
494:
1.1 root 495: /* Called when the start of a function definition is parsed,
496: this function prints on stderr the name of the function. */
497:
498: void
499: announce_function (decl)
500: tree decl;
501: {
502: if (! quiet_flag)
503: {
1.1.1.16 root 504: fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
1.1 root 505: fflush (stderr);
1.1.1.9 root 506: need_error_newline = 1;
507: last_error_function = current_function_decl;
1.1 root 508: }
509: }
1.1.1.8 root 510:
1.1.1.2 root 511: /* Prints out, if necessary, the name of the current function
512: which caused an error. Called from all error and warning functions. */
513:
1.1.1.16 root 514: void
1.1.1.9 root 515: report_error_function (file)
516: char *file;
1.1.1.2 root 517: {
1.1.1.16 root 518: struct file_stack *p;
519:
1.1.1.8 root 520: if (need_error_newline)
521: {
522: fprintf (stderr, "\n");
523: need_error_newline = 0;
524: }
1.1.1.2 root 525:
526: if (last_error_function != current_function_decl)
527: {
1.1.1.9 root 528: if (file)
529: fprintf (stderr, "%s: ", file);
530:
1.1.1.2 root 531: if (current_function_decl == NULL)
1.1.1.8 root 532: fprintf (stderr, "At top level:\n");
1.1.1.16 root 533: else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
534: fprintf (stderr, "In method %s:\n",
535: DECL_PRINT_NAME (current_function_decl));
1.1.1.2 root 536: else
1.1.1.8 root 537: fprintf (stderr, "In function %s:\n",
1.1.1.16 root 538: DECL_PRINT_NAME (current_function_decl));
1.1.1.8 root 539:
1.1.1.2 root 540: last_error_function = current_function_decl;
541: }
1.1.1.16 root 542: if (input_file_stack && input_file_stack->next != 0
543: && input_file_stack_tick != last_error_tick)
544: {
545: fprintf (stderr, "In file included");
546: for (p = input_file_stack->next; p; p = p->next)
547: {
548: fprintf (stderr, " from %s:%d", p->name, p->line);
549: if (p->next)
550: fprintf (stderr, ",");
551: }
552: fprintf (stderr, ":\n");
553: last_error_tick = input_file_stack_tick;
554: }
1.1.1.2 root 555: }
1.1 root 556:
557: /* Report an error at the current line number.
558: S and V are a string and an arg for `printf'. */
559:
560: void
1.1.1.7 root 561: error (s, v, v2)
1.1 root 562: char *s;
563: int v; /* @@also used as pointer */
1.1.1.7 root 564: int v2; /* @@also used as pointer */
1.1 root 565: {
1.1.1.7 root 566: error_with_file_and_line (input_filename, lineno, s, v, v2);
1.1 root 567: }
568:
1.1.1.2 root 569: /* Report an error at line LINE of file FILE.
1.1 root 570: S and V are a string and an arg for `printf'. */
571:
1.1.1.2 root 572: void
1.1.1.7 root 573: error_with_file_and_line (file, line, s, v, v2)
1.1.1.2 root 574: char *file;
1.1 root 575: int line;
576: char *s;
577: int v;
1.1.1.7 root 578: int v2;
1.1 root 579: {
580: count_error (0);
581:
1.1.1.9 root 582: report_error_function (file);
1.1.1.2 root 583:
584: if (file)
585: fprintf (stderr, "%s:%d: ", file, line);
586: else
1.1.1.16 root 587: fprintf (stderr, "%s: ", progname);
1.1.1.7 root 588: fprintf (stderr, s, v, v2);
1.1 root 589: fprintf (stderr, "\n");
590: }
591:
1.1.1.2 root 592: /* Report an error at the declaration DECL.
1.1.1.12 root 593: S and V are a string and an arg which uses %s to substitute the declaration name. */
1.1 root 594:
595: void
1.1.1.12 root 596: error_with_decl (decl, s, v)
1.1.1.2 root 597: tree decl;
1.1 root 598: char *s;
1.1.1.12 root 599: int v;
1.1 root 600: {
1.1.1.2 root 601: count_error (0);
602:
1.1.1.9 root 603: report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2 root 604:
605: fprintf (stderr, "%s:%d: ",
606: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
607:
1.1.1.16 root 608: if (DECL_PRINT_NAME (decl))
609: fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
610: else if (DECL_NAME (decl))
1.1.1.12 root 611: fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
1.1.1.2 root 612: else
1.1.1.12 root 613: fprintf (stderr, s, "((anonymous))", v);
1.1.1.2 root 614: fprintf (stderr, "\n");
1.1 root 615: }
616:
1.1.1.11 root 617: /* Report an error at the line number of the insn INSN.
618: S and V are a string and an arg for `printf'.
619: This is used only when INSN is an `asm' with operands,
1.1.1.15 root 620: and each ASM_OPERANDS records its own source file and line. */
1.1.1.11 root 621:
622: void
623: error_for_asm (insn, s, v, v2)
624: rtx insn;
625: char *s;
626: int v; /* @@also used as pointer */
627: int v2; /* @@also used as pointer */
628: {
1.1.1.12 root 629: rtx temp;
630: char *filename;
631: int line;
1.1.1.15 root 632: rtx body = PATTERN (insn);
633: rtx asmop;
1.1.1.12 root 634:
1.1.1.15 root 635: /* Find the (or one of the) ASM_OPERANDS in the insn. */
636: if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
637: asmop = SET_SRC (body);
638: else if (GET_CODE (body) == ASM_OPERANDS)
639: asmop = body;
640: else if (GET_CODE (body) == PARALLEL
641: && GET_CODE (XVECEXP (body, 0, 0)) == SET)
642: asmop = SET_SRC (XVECEXP (body, 0, 0));
643: else if (GET_CODE (body) == PARALLEL
644: && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
645: asmop = XVECEXP (body, 0, 0);
646:
647: filename = ASM_OPERANDS_SOURCE_FILE (asmop);
648: line = ASM_OPERANDS_SOURCE_LINE (asmop);
1.1.1.16 root 649:
1.1.1.12 root 650: error_with_file_and_line (filename, line, s, v, v2);
1.1.1.11 root 651: }
652:
1.1 root 653: /* Report a warning at line LINE.
654: S and V are a string and an arg for `printf'. */
655:
1.1.1.2 root 656: void
1.1.1.11 root 657: warning_with_file_and_line (file, line, s, v, v2)
658: char *file;
1.1 root 659: int line;
660: char *s;
661: int v;
1.1.1.7 root 662: int v2;
1.1 root 663: {
664: if (count_error (1) == 0)
665: return;
666:
1.1.1.11 root 667: report_error_function (file);
1.1.1.2 root 668:
1.1.1.11 root 669: if (file)
670: fprintf (stderr, "%s:%d: ", file, line);
1.1.1.2 root 671: else
1.1.1.16 root 672: fprintf (stderr, "%s: ", progname);
1.1 root 673:
674: fprintf (stderr, "warning: ");
1.1.1.7 root 675: fprintf (stderr, s, v, v2);
1.1 root 676: fprintf (stderr, "\n");
677: }
1.1.1.2 root 678:
679: /* Report a warning at the current line number.
680: S and V are a string and an arg for `printf'. */
681:
682: void
1.1.1.7 root 683: warning (s, v, v2)
1.1.1.2 root 684: char *s;
685: int v; /* @@also used as pointer */
1.1.1.7 root 686: int v2;
1.1.1.2 root 687: {
1.1.1.11 root 688: warning_with_file_and_line (input_filename, lineno, s, v, v2);
1.1.1.2 root 689: }
690:
691: /* Report a warning at the declaration DECL.
1.1.1.16 root 692: S is string which uses %s to substitute the declaration name.
693: V is a second parameter that S can refer to. */
1.1.1.2 root 694:
695: void
1.1.1.12 root 696: warning_with_decl (decl, s, v)
1.1.1.2 root 697: tree decl;
698: char *s;
1.1.1.12 root 699: int v;
1.1.1.2 root 700: {
701: if (count_error (1) == 0)
702: return;
703:
1.1.1.9 root 704: report_error_function (DECL_SOURCE_FILE (decl));
1.1.1.2 root 705:
706: fprintf (stderr, "%s:%d: ",
707: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
708:
709: fprintf (stderr, "warning: ");
1.1.1.16 root 710: if (DECL_PRINT_NAME (decl))
711: fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
712: else if (DECL_NAME (decl))
1.1.1.12 root 713: fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
1.1.1.2 root 714: else
1.1.1.12 root 715: fprintf (stderr, s, "((anonymous))", v);
1.1.1.2 root 716: fprintf (stderr, "\n");
717: }
1.1.1.7 root 718:
719: /* Apologize for not implementing some feature.
720: S, V, and V2 are a string and args for `printf'. */
721:
722: void
723: sorry (s, v, v2)
724: char *s;
725: int v, v2;
726: {
727: sorrycount++;
728: if (input_filename)
729: fprintf (stderr, "%s:%d: ", input_filename, lineno);
730: else
1.1.1.16 root 731: fprintf (stderr, "%s: ", progname);
1.1.1.7 root 732:
733: fprintf (stderr, "sorry, not implemented: ");
734: fprintf (stderr, s, v, v2);
735: fprintf (stderr, "\n");
736: }
737:
738: /* Apologize for not implementing some feature, then quit.
739: S, V, and V2 are a string and args for `printf'. */
740:
741: void
742: really_sorry (s, v, v2)
743: char *s;
744: int v, v2;
745: {
746: if (input_filename)
747: fprintf (stderr, "%s:%d: ", input_filename, lineno);
748: else
749: fprintf (stderr, "c++: ");
750:
751: fprintf (stderr, "sorry, not implemented: ");
752: fprintf (stderr, s, v, v2);
753: fatal (" (fatal)\n");
754: }
1.1 root 755:
1.1.1.16 root 756: /* More 'friendly' abort that prints the line and file.
757: config.h can #define abort fancy_abort if you like that sort of thing. */
758:
759: void
760: fancy_abort ()
761: {
762: fatal ("Internal gcc abort.");
763: }
764:
1.1 root 765: /* When `malloc.c' is compiled with `rcheck' defined,
766: it calls this function to report clobberage. */
767:
1.1.1.2 root 768: void
1.1 root 769: botch (s)
770: {
771: abort ();
772: }
773:
774: /* Same as `malloc' but report error if no memory available. */
775:
1.1.1.2 root 776: int
1.1 root 777: xmalloc (size)
778: unsigned size;
779: {
780: register int value = (int) malloc (size);
781: if (value == 0)
782: fatal ("Virtual memory exhausted.");
783: return value;
784: }
785:
786: /* Same as `realloc' but report error if no memory available. */
787:
788: int
789: xrealloc (ptr, size)
790: char *ptr;
791: int size;
792: {
793: int result = realloc (ptr, size);
794: if (!result)
1.1.1.2 root 795: fatal ("Virtual memory exhausted.");
1.1 root 796: return result;
797: }
798:
799: /* Return the logarithm of X, base 2, considering X unsigned,
800: if X is a power of 2. Otherwise, returns -1. */
801:
802: int
803: exact_log2 (x)
804: register unsigned int x;
805: {
806: register int log = 0;
807: for (log = 0; log < HOST_BITS_PER_INT; log++)
808: if (x == (1 << log))
809: return log;
810: return -1;
811: }
812:
813: /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
814: If X is 0, return -1. */
815:
816: int
817: floor_log2 (x)
818: register unsigned int x;
819: {
820: register int log = 0;
821: for (log = 0; log < HOST_BITS_PER_INT; log++)
822: if ((x & ((-1) << log)) == 0)
823: return log - 1;
824: return HOST_BITS_PER_INT - 1;
825: }
1.1.1.10 root 826:
827: int float_handled;
828: jmp_buf float_handler;
829:
830: /* Specify where to longjmp to when a floating arithmetic error happens.
831: If HANDLER is 0, it means don't handle the errors any more. */
832:
833: void
834: set_float_handler (handler)
835: jmp_buf handler;
836: {
837: float_handled = (handler != 0);
838: if (handler)
839: bcopy (handler, float_handler, sizeof (float_handler));
840: }
841:
842: /* Signals actually come here. */
843:
844: static void
845: float_signal ()
846: {
847: if (float_handled == 0)
848: abort ();
849: float_handled = 0;
850: longjmp (float_handler, 1);
851: }
1.1.1.13 root 852:
853: /* Handler for SIGPIPE. */
854:
855: static void
856: pipe_closed ()
857: {
858: fatal ("output pipe has been closed");
859: }
1.1 root 860:
861: /* Compile an entire file of output from cpp, named NAME.
862: Write a file of assembly output and various debugging dumps. */
863:
864: static void
865: compile_file (name)
866: char *name;
867: {
868: tree globals;
869: int start_time;
1.1.1.9 root 870: int dump_base_name_length;
871:
872: int name_specified = name != 0;
873:
874: if (dump_base_name == 0)
875: dump_base_name = name ? name : "gccdump";
876: dump_base_name_length = strlen (dump_base_name);
1.1 root 877:
878: parse_time = 0;
879: varconst_time = 0;
1.1.1.2 root 880: integration_time = 0;
1.1 root 881: jump_time = 0;
882: cse_time = 0;
883: loop_time = 0;
884: flow_time = 0;
885: combine_time = 0;
886: local_alloc_time = 0;
887: global_alloc_time = 0;
1.1.1.16 root 888: dbr_sched_time = 0;
1.1 root 889: final_time = 0;
890: symout_time = 0;
1.1.1.2 root 891: dump_time = 0;
1.1 root 892:
893: /* Open input file. */
894:
1.1.1.9 root 895: if (name == 0 || !strcmp (name, "-"))
896: {
897: finput = stdin;
898: name = "stdin";
899: }
900: else
901: finput = fopen (name, "r");
1.1 root 902: if (finput == 0)
903: pfatal_with_name (name);
904:
905: /* Initialize data in various passes. */
906:
907: init_tree ();
908: init_lex ();
909: init_rtl ();
1.1.1.2 root 910: init_emit_once ();
1.1 root 911: init_decl_processing ();
912: init_optabs ();
913:
914: /* If rtl dump desired, open the output file. */
915: if (rtl_dump)
916: {
917: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
918: strcpy (dumpname, dump_base_name);
919: strcat (dumpname, ".rtl");
920: rtl_dump_file = fopen (dumpname, "w");
921: if (rtl_dump_file == 0)
922: pfatal_with_name (dumpname);
923: }
924:
925: /* If jump_opt dump desired, open the output file. */
926: if (jump_opt_dump)
927: {
928: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
929: strcpy (dumpname, dump_base_name);
930: strcat (dumpname, ".jump");
931: jump_opt_dump_file = fopen (dumpname, "w");
932: if (jump_opt_dump_file == 0)
933: pfatal_with_name (dumpname);
934: }
935:
936: /* If cse dump desired, open the output file. */
937: if (cse_dump)
938: {
939: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
940: strcpy (dumpname, dump_base_name);
941: strcat (dumpname, ".cse");
942: cse_dump_file = fopen (dumpname, "w");
943: if (cse_dump_file == 0)
944: pfatal_with_name (dumpname);
945: }
946:
947: /* If loop dump desired, open the output file. */
948: if (loop_dump)
949: {
950: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
951: strcpy (dumpname, dump_base_name);
952: strcat (dumpname, ".loop");
953: loop_dump_file = fopen (dumpname, "w");
954: if (loop_dump_file == 0)
955: pfatal_with_name (dumpname);
956: }
957:
958: /* If flow dump desired, open the output file. */
959: if (flow_dump)
960: {
961: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
962: strcpy (dumpname, dump_base_name);
963: strcat (dumpname, ".flow");
964: flow_dump_file = fopen (dumpname, "w");
965: if (flow_dump_file == 0)
966: pfatal_with_name (dumpname);
967: }
968:
969: /* If combine dump desired, open the output file. */
970: if (combine_dump)
971: {
972: register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
973: strcpy (dumpname, dump_base_name);
974: strcat (dumpname, ".combine");
975: combine_dump_file = fopen (dumpname, "w");
976: if (combine_dump_file == 0)
977: pfatal_with_name (dumpname);
978: }
979:
980: /* If local_reg dump desired, open the output file. */
981: if (local_reg_dump)
982: {
983: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
984: strcpy (dumpname, dump_base_name);
985: strcat (dumpname, ".lreg");
986: local_reg_dump_file = fopen (dumpname, "w");
987: if (local_reg_dump_file == 0)
988: pfatal_with_name (dumpname);
989: }
990:
991: /* If global_reg dump desired, open the output file. */
992: if (global_reg_dump)
993: {
994: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
995: strcpy (dumpname, dump_base_name);
996: strcat (dumpname, ".greg");
997: global_reg_dump_file = fopen (dumpname, "w");
998: if (global_reg_dump_file == 0)
999: pfatal_with_name (dumpname);
1000: }
1001:
1.1.1.2 root 1002: /* If jump2_opt dump desired, open the output file. */
1003: if (jump2_opt_dump)
1004: {
1005: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1006: strcpy (dumpname, dump_base_name);
1007: strcat (dumpname, ".jump2");
1008: jump2_opt_dump_file = fopen (dumpname, "w");
1009: if (jump2_opt_dump_file == 0)
1010: pfatal_with_name (dumpname);
1011: }
1012:
1.1.1.16 root 1013: /* If dbr_sched dump desired, open the output file. */
1014: if (dbr_sched_dump)
1015: {
1016: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
1017: strcpy (dumpname, dump_base_name);
1018: strcat (dumpname, ".dbr");
1019: dbr_sched_dump_file = fopen (dumpname, "w");
1020: if (dbr_sched_dump_file == 0)
1021: pfatal_with_name (dumpname);
1022: }
1023:
1.1 root 1024: /* Open assembler code output file. */
1.1.1.16 root 1025:
1.1.1.9 root 1026: if (! name_specified && asm_file_name == 0)
1027: asm_out_file = stdout;
1028: else
1029: {
1030: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1031: int len = strlen (dump_base_name);
1032: strcpy (dumpname, dump_base_name);
1033: if (len > 2 && ! strcmp (".c", dumpname + len - 2))
1034: dumpname[len - 2] = 0;
1035: else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
1036: dumpname[len - 2] = 0;
1037: else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
1038: dumpname[len - 3] = 0;
1039: strcat (dumpname, ".s");
1040: if (asm_file_name == 0)
1041: {
1042: asm_file_name = (char *) malloc (strlen (dumpname) + 1);
1043: strcpy (asm_file_name, dumpname);
1044: }
1045: if (!strcmp (asm_file_name, "-"))
1046: asm_out_file = stdout;
1047: else
1048: asm_out_file = fopen (asm_file_name, "w");
1049: if (asm_out_file == 0)
1050: pfatal_with_name (asm_file_name);
1051: }
1.1 root 1052:
1053: input_filename = name;
1054:
1055: /* the beginning of the file is a new line; check for # */
1056: /* With luck, we discover the real source file's name from that
1057: and put it in input_filename. */
1.1.1.4 root 1058: ungetc (check_newline (), finput);
1059:
1.1.1.8 root 1060: /* If the input doesn't start with a #line, use the input name
1061: as the official input file name. */
1062: if (main_input_filename == 0)
1063: main_input_filename = name;
1064:
1.1.1.16 root 1065: /* Put an entry on the input file stack for the main input file. */
1066: input_file_stack
1067: = (struct file_stack *) xmalloc (sizeof (struct file_stack));
1068: input_file_stack->next = 0;
1069: input_file_stack->name = input_filename;
1070:
1.1.1.4 root 1071: ASM_FILE_START (asm_out_file);
1.1 root 1072:
1.1.1.12 root 1073: /* Output something to inform GDB that this compilation was by GCC. */
1074: #ifndef ASM_IDENTIFY_GCC
1075: fprintf (asm_out_file, "gcc_compiled.:\n");
1076: #else
1077: ASM_IDENTIFY_GCC (asm_out_file);
1078: #endif
1079:
1.1 root 1080: /* If GDB symbol table desired, open the GDB symbol output file. */
1.1.1.4 root 1081: if (write_symbols == GDB_DEBUG)
1.1 root 1082: {
1083: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
1.1.1.2 root 1084: int len = strlen (dump_base_name);
1.1 root 1085: strcpy (dumpname, dump_base_name);
1.1.1.2 root 1086: if (len > 2 && ! strcmp (".c", dumpname + len - 2))
1087: dumpname[len - 2] = 0;
1.1.1.7 root 1088: else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
1089: dumpname[len - 2] = 0;
1.1.1.2 root 1090: else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
1091: dumpname[len - 3] = 0;
1.1 root 1092: strcat (dumpname, ".sym");
1093: if (sym_file_name == 0)
1094: sym_file_name = dumpname;
1.1.1.4 root 1095: symout_init (sym_file_name, asm_out_file, main_input_filename);
1.1 root 1096: }
1097:
1098: /* If dbx symbol table desired, initialize writing it
1099: and output the predefined types. */
1.1.1.4 root 1100: #ifdef DBX_DEBUGGING_INFO
1101: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 1102: dbxout_init (asm_out_file, main_input_filename);
1.1.1.4 root 1103: #endif
1104: #ifdef SDB_DEBUGGING_INFO
1105: if (write_symbols == SDB_DEBUG)
1106: sdbout_init (asm_out_file, main_input_filename);
1107: #endif
1.1 root 1108:
1109: /* Initialize yet another pass. */
1110:
1.1.1.2 root 1111: init_final (main_input_filename);
1.1 root 1112:
1113: start_time = gettime ();
1114:
1115: /* Call the parser, which parses the entire file
1116: (calling rest_of_compilation for each function). */
1117:
1118: yyparse ();
1119:
1120: /* Compilation is now finished except for writing
1121: what's left of the symbol table output. */
1122:
1123: parse_time += gettime () - start_time;
1124:
1.1.1.16 root 1125: parse_time -= integration_time;
1.1.1.2 root 1126: parse_time -= varconst_time;
1127:
1.1 root 1128: globals = getdecls ();
1129:
1.1.1.2 root 1130: /* Really define vars that have had only a tentative definition.
1131: Really output inline functions that must actually be callable
1132: and have not been output so far. */
1133:
1134: {
1135: tree decl;
1136: for (decl = globals; decl; decl = TREE_CHAIN (decl))
1137: {
1138: if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1139: && ! TREE_ASM_WRITTEN (decl))
1.1.1.16 root 1140: {
1141: /* Don't write out static consts, unless we needed
1142: to take their address for some reason. */
1143: if (! TREE_READONLY (decl)
1144: || TREE_PUBLIC (decl)
1145: || TREE_ADDRESSABLE (decl))
1146: rest_of_decl_compilation (decl, 0, 1, 1);
1147: /* Otherwise maybe mention them just for the debugger. */
1148: #ifdef DBX_DEBUGGING_INFO
1149: else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
1150: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1151: #endif
1152: #ifdef SDB_DEBUGGING_INFO
1153: else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
1154: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
1155: #endif
1156: }
1.1.1.2 root 1157: if (TREE_CODE (decl) == FUNCTION_DECL
1158: && ! TREE_ASM_WRITTEN (decl)
1159: && DECL_INITIAL (decl) != 0
1.1.1.16 root 1160: && TREE_ADDRESSABLE (decl)
1161: && ! TREE_EXTERNAL (decl))
1.1.1.2 root 1162: output_inline_function (decl);
1.1.1.15 root 1163:
1164: /* Warn about any function declared static but not defined. */
1.1.1.13 root 1165: if (warn_unused
1166: && TREE_CODE (decl) == FUNCTION_DECL
1167: && DECL_INITIAL (decl) == 0
1168: && TREE_EXTERNAL (decl)
1169: && ! TREE_PUBLIC (decl))
1170: warning_with_decl (decl, "`%s' declared but never defined");
1.1.1.15 root 1171: /* Warn about statics fns or vars defined but not used,
1172: but not about inline functions
1173: since unused inline statics is normal practice. */
1174: if (warn_unused
1175: && (TREE_CODE (decl) == FUNCTION_DECL
1176: || TREE_CODE (decl) == VAR_DECL)
1177: && ! TREE_EXTERNAL (decl)
1178: && ! TREE_PUBLIC (decl)
1179: && ! TREE_USED (decl)
1.1.1.17 root 1180: && ! TREE_INLINE (decl)
1181: /* The TREE_USED bit for file-scope decls
1182: is kept in the identifier, to handle multiple
1183: external decls in different scopes. */
1184: && ! TREE_USED (DECL_NAME (decl)))
1.1.1.15 root 1185: warning_with_decl (decl, "`%s' defined but not used");
1.1.1.2 root 1186: }
1187: }
1188:
1.1 root 1189: /* Do dbx symbols */
1.1.1.4 root 1190: #ifdef DBX_DEBUGGING_INFO
1191: if (write_symbols == DBX_DEBUG)
1.1 root 1192: TIMEVAR (symout_time,
1193: {
1194: dbxout_tags (gettags ());
1195: dbxout_types (get_permanent_types ());
1196: });
1.1.1.4 root 1197: #endif
1198:
1199: #ifdef SDB_DEBUGGING_INFO
1200: if (write_symbols == SDB_DEBUG)
1201: TIMEVAR (symout_time,
1202: {
1203: sdbout_tags (gettags ());
1204: sdbout_types (get_permanent_types ());
1205: });
1206: #endif
1.1 root 1207:
1208: /* Do gdb symbols */
1.1.1.4 root 1209: if (write_symbols == GDB_DEBUG)
1.1 root 1210: TIMEVAR (symout_time,
1211: {
1212: struct stat statbuf;
1213: fstat (fileno (finput), &statbuf);
1214: symout_types (get_permanent_types ());
1215: symout_top_blocks (globals, gettags ());
1216: symout_finish (name, statbuf.st_ctime);
1217: });
1218:
1.1.1.14 root 1219: /* Output some stuff at end of file if nec. */
1220:
1221: end_final (main_input_filename);
1222:
1.1.1.16 root 1223: #ifdef ASM_FILE_END
1224: ASM_FILE_END (asm_out_file);
1225: #endif
1226:
1.1.1.2 root 1227: /* Close the dump files. */
1.1 root 1228:
1229: if (rtl_dump)
1230: fclose (rtl_dump_file);
1231:
1232: if (jump_opt_dump)
1233: fclose (jump_opt_dump_file);
1234:
1235: if (cse_dump)
1236: fclose (cse_dump_file);
1237:
1238: if (loop_dump)
1239: fclose (loop_dump_file);
1240:
1241: if (flow_dump)
1242: fclose (flow_dump_file);
1243:
1244: if (combine_dump)
1245: {
1246: dump_combine_total_stats (combine_dump_file);
1247: fclose (combine_dump_file);
1248: }
1249:
1250: if (local_reg_dump)
1251: fclose (local_reg_dump_file);
1252:
1253: if (global_reg_dump)
1254: fclose (global_reg_dump_file);
1255:
1.1.1.2 root 1256: if (jump2_opt_dump)
1257: fclose (jump2_opt_dump_file);
1258:
1.1.1.16 root 1259: if (dbr_sched_dump)
1260: fclose (dbr_sched_dump_file);
1261:
1262: /* Close non-debugging input and output files. Take special care to note
1263: whether fclose returns an error, since the pages might still be on the
1264: buffer chain while the file is open. */
1.1.1.2 root 1265:
1266: fclose (finput);
1.1.1.16 root 1267: if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1.1.1.2 root 1268: fatal_io_error (asm_file_name);
1269:
1.1 root 1270: /* Print the times. */
1271:
1272: if (! quiet_flag)
1273: {
1.1.1.2 root 1274: fprintf (stderr,"\n");
1.1 root 1275: print_time ("parse", parse_time);
1.1.1.2 root 1276: print_time ("integration", integration_time);
1.1 root 1277: print_time ("jump", jump_time);
1278: print_time ("cse", cse_time);
1279: print_time ("loop", loop_time);
1280: print_time ("flow", flow_time);
1281: print_time ("combine", combine_time);
1282: print_time ("local-alloc", local_alloc_time);
1283: print_time ("global-alloc", global_alloc_time);
1.1.1.16 root 1284: print_time ("dbranch", dbr_sched_time);
1.1 root 1285: print_time ("final", final_time);
1286: print_time ("varconst", varconst_time);
1287: print_time ("symout", symout_time);
1288: print_time ("dump", dump_time);
1289: }
1290: }
1291:
1.1.1.2 root 1292: /* This is called from finish_decl (within yyparse)
1293: for each declaration of a function or variable.
1294: This does nothing for automatic variables.
1295: Otherwise, it sets up the RTL and outputs any assembler code
1296: (label definition, storage allocation and initialization).
1297:
1298: DECL is the declaration. If ASMSPEC is nonzero, it specifies
1299: the assembler symbol name to be used. TOP_LEVEL is nonzero
1300: if this declaration is not within a function. */
1301:
1302: void
1303: rest_of_decl_compilation (decl, asmspec, top_level, at_end)
1304: tree decl;
1.1.1.16 root 1305: char *asmspec;
1.1.1.2 root 1306: int top_level;
1307: int at_end;
1308: {
1309: /* Declarations of variables, and of functions defined elsewhere. */
1310:
1311: if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
1312: TIMEVAR (varconst_time,
1313: {
1.1.1.12 root 1314: make_decl_rtl (decl, asmspec, top_level);
1315: /* Don't output anything
1316: when a tentative file-scope definition is seen.
1317: But at end of compilation, do output code for them. */
1318: if (! (! at_end && top_level
1319: && (DECL_INITIAL (decl) == 0
1320: || DECL_INITIAL (decl) == error_mark_node)))
1321: assemble_variable (decl, top_level, write_symbols, at_end);
1.1.1.2 root 1322: });
1.1.1.16 root 1323: else if (TREE_REGDECL (decl) && asmspec != 0)
1324: {
1325: if (decode_reg_name (asmspec) >= 0)
1326: {
1327: DECL_RTL (decl) = 0;
1328: make_decl_rtl (decl, asmspec, top_level);
1329: }
1330: else
1331: error ("invalid register name `%s' for register variable", asmspec);
1332: }
1.1.1.4 root 1333: #ifdef DBX_DEBUGGING_INFO
1334: else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3 root 1335: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4 root 1336: #endif
1337: #ifdef SDB_DEBUGGING_INFO
1.1.1.18! root 1338: else if (write_symbols == SDB_DEBUG && top_level
! 1339: && TREE_CODE (decl) == TYPE_DECL)
1.1.1.4 root 1340: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
1341: #endif
1.1.1.2 root 1342:
1343: if (top_level)
1344: {
1.1.1.4 root 1345: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1346: {
1347: TIMEVAR (symout_time,
1348: {
1349: /* The initizations make types when they contain
1350: string constants. The types are on the temporary
1351: obstack, so output them now before they go away. */
1352: symout_types (get_temporary_types ());
1353: });
1354: }
1355: else
1356: /* Clean out the temporary type list, since the types will go away. */
1357: get_temporary_types ();
1358: }
1359: }
1360:
1.1 root 1361: /* This is called from finish_function (within yyparse)
1.1.1.2 root 1362: after each top-level definition is parsed.
1.1 root 1363: It is supposed to compile that function or variable
1364: and output the assembler code for it.
1365: After we return, the tree storage is freed. */
1366:
1367: void
1.1.1.2 root 1368: rest_of_compilation (decl)
1.1 root 1369: tree decl;
1370: {
1371: register rtx insns;
1372: int start_time = gettime ();
1373: int tem;
1374:
1.1.1.2 root 1375: /* If we are reconsidering an inline function
1376: at the end of compilation, skip the stuff for making it inline. */
1.1 root 1377:
1.1.1.2 root 1378: if (DECL_SAVED_INSNS (decl) == 0)
1.1 root 1379: {
1380:
1.1.1.2 root 1381: /* If requested, consider whether to make this function inline. */
1382: if (flag_inline_functions || TREE_INLINE (decl))
1383: {
1384: TIMEVAR (integration_time,
1385: {
1386: int specd = TREE_INLINE (decl);
1387: char *lose = function_cannot_inline_p (decl);
1388: if (lose != 0 && specd)
1389: warning_with_decl (decl, lose);
1390: if (lose == 0)
1391: save_for_inline (decl);
1392: else
1393: TREE_INLINE (decl) = 0;
1394: });
1395: }
1.1 root 1396:
1.1.1.2 root 1397: insns = get_insns ();
1.1 root 1398:
1399: /* Dump the rtl code if we are dumping rtl. */
1400:
1401: if (rtl_dump)
1402: TIMEVAR (dump_time,
1403: {
1404: fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1405: IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2 root 1406: if (DECL_SAVED_INSNS (decl))
1407: fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1 root 1408: print_rtl (rtl_dump_file, insns);
1409: fflush (rtl_dump_file);
1410: });
1411:
1.1.1.2 root 1412: /* If function is inline, and we don't yet know whether to
1413: compile it by itself, defer decision till end of compilation.
1414: finish_compilation will call rest_of_compilation again
1415: for those functions that need to be output. */
1416:
1.1.1.16 root 1417: if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
1418: && ! flag_keep_inline_functions)
1419: || TREE_EXTERNAL (decl))
1420: && TREE_INLINE (decl))
1.1 root 1421: goto exit_rest_of_compilation;
1.1.1.2 root 1422: }
1.1 root 1423:
1.1.1.16 root 1424: if (rtl_dump_and_exit || flag_syntax_only)
1425: {
1426: get_temporary_types ();
1427: goto exit_rest_of_compilation;
1428: }
1.1 root 1429:
1.1.1.2 root 1430: TREE_ASM_WRITTEN (decl) = 1;
1.1 root 1431:
1.1.1.2 root 1432: insns = get_insns ();
1.1 root 1433:
1.1.1.2 root 1434: /* Copy any shared structure that should not be shared. */
1.1 root 1435:
1.1.1.2 root 1436: unshare_all_rtl (insns);
1.1 root 1437:
1.1.1.2 root 1438: /* See if we have allocated stack slots that are not directly addressable.
1439: If so, scan all the insns and create explicit address computation
1440: for all references to such slots. */
1441: /* fixup_stack_slots (); */
1.1 root 1442:
1.1.1.2 root 1443: /* Do jump optimization the first time, if -opt.
1444: Also do it if -W, but in that case it doesn't change the rtl code,
1445: it only computes whether control can drop off the end of the function. */
1.1 root 1446:
1.1.1.13 root 1447: if (optimize || extra_warnings || warn_return_type
1448: /* If function is `volatile', we should warn if it tries to return. */
1449: || TREE_THIS_VOLATILE (decl))
1.1.1.2 root 1450: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1 root 1451:
1.1.1.2 root 1452: /* Dump rtl code after jump, if we are doing that. */
1.1 root 1453:
1.1.1.2 root 1454: if (jump_opt_dump)
1455: TIMEVAR (dump_time,
1456: {
1457: fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
1458: IDENTIFIER_POINTER (DECL_NAME (decl)));
1459: print_rtl (jump_opt_dump_file, insns);
1460: fflush (jump_opt_dump_file);
1461: });
1.1 root 1462:
1.1.1.2 root 1463: /* Perform common subexpression elimination.
1464: Nonzero value from `cse_main' means that jumps were simplified
1465: and some code may now be unreachable, so do
1466: jump optimization again. */
1.1 root 1467:
1.1.1.2 root 1468: if (optimize)
1469: {
1470: TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1 root 1471:
1.1.1.2 root 1472: TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1 root 1473:
1.1.1.2 root 1474: if (tem)
1475: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1476: }
1.1 root 1477:
1.1.1.2 root 1478: /* Dump rtl code after cse, if we are doing that. */
1.1 root 1479:
1.1.1.2 root 1480: if (cse_dump)
1481: TIMEVAR (dump_time,
1482: {
1483: fprintf (cse_dump_file, "\n;; Function %s\n\n",
1484: IDENTIFIER_POINTER (DECL_NAME (decl)));
1485: print_rtl (cse_dump_file, insns);
1486: fflush (cse_dump_file);
1487: });
1.1 root 1488:
1.1.1.2 root 1489: if (loop_dump)
1490: TIMEVAR (dump_time,
1491: {
1492: fprintf (loop_dump_file, "\n;; Function %s\n\n",
1493: IDENTIFIER_POINTER (DECL_NAME (decl)));
1494: });
1.1 root 1495:
1.1.1.2 root 1496: /* Move constant computations out of loops. */
1.1 root 1497:
1.1.1.2 root 1498: if (optimize)
1499: {
1500: TIMEVAR (loop_time,
1501: {
1502: reg_scan (insns, max_reg_num (), 1);
1.1.1.9 root 1503: loop_optimize (insns, loop_dump ? loop_dump_file : 0);
1.1.1.2 root 1504: });
1505: }
1.1 root 1506:
1.1.1.2 root 1507: /* Dump rtl code after loop opt, if we are doing that. */
1.1 root 1508:
1.1.1.2 root 1509: if (loop_dump)
1510: TIMEVAR (dump_time,
1511: {
1512: print_rtl (loop_dump_file, insns);
1513: fflush (loop_dump_file);
1514: });
1.1 root 1515:
1.1.1.2 root 1516: /* Now we choose between stupid (pcc-like) register allocation
1517: (if we got the -noreg switch and not -opt)
1518: and smart register allocation. */
1.1 root 1519:
1.1.1.2 root 1520: if (optimize) /* Stupid allocation probably won't work */
1521: obey_regdecls = 0; /* if optimizations being done. */
1.1 root 1522:
1.1.1.2 root 1523: regclass_init ();
1.1 root 1524:
1.1.1.2 root 1525: /* Print function header into flow dump now
1526: because doing the flow analysis makes some of the dump. */
1.1 root 1527:
1.1.1.2 root 1528: if (flow_dump)
1529: TIMEVAR (dump_time,
1530: {
1531: fprintf (flow_dump_file, "\n;; Function %s\n\n",
1532: IDENTIFIER_POINTER (DECL_NAME (decl)));
1533: });
1534:
1535: if (obey_regdecls)
1536: {
1537: TIMEVAR (flow_time,
1538: {
1539: regclass (insns, max_reg_num ());
1540: stupid_life_analysis (insns, max_reg_num (),
1541: flow_dump_file);
1542: });
1543: }
1544: else
1545: {
1546: /* Do control and data flow analysis,
1547: and write some of the results to dump file. */
1.1 root 1548:
1.1.1.2 root 1549: TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
1550: flow_dump_file));
1551: if (extra_warnings)
1552: uninitialized_vars_warning (DECL_INITIAL (decl));
1553: }
1.1 root 1554:
1.1.1.2 root 1555: /* Dump rtl after flow analysis. */
1.1 root 1556:
1.1.1.2 root 1557: if (flow_dump)
1558: TIMEVAR (dump_time,
1559: {
1560: print_rtl (flow_dump_file, insns);
1561: fflush (flow_dump_file);
1562: });
1.1 root 1563:
1.1.1.2 root 1564: /* If -opt, try combining insns through substitution. */
1.1 root 1565:
1.1.1.2 root 1566: if (optimize)
1567: TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1 root 1568:
1.1.1.2 root 1569: /* Dump rtl code after insn combination. */
1.1 root 1570:
1.1.1.2 root 1571: if (combine_dump)
1572: TIMEVAR (dump_time,
1573: {
1574: fprintf (combine_dump_file, "\n;; Function %s\n\n",
1575: IDENTIFIER_POINTER (DECL_NAME (decl)));
1576: dump_combine_stats (combine_dump_file);
1577: print_rtl (combine_dump_file, insns);
1578: fflush (combine_dump_file);
1579: });
1.1 root 1580:
1.1.1.2 root 1581: /* Unless we did stupid register allocation,
1582: allocate pseudo-regs that are used only within 1 basic block. */
1.1 root 1583:
1.1.1.2 root 1584: if (!obey_regdecls)
1585: TIMEVAR (local_alloc_time,
1586: {
1587: regclass (insns, max_reg_num ());
1588: local_alloc ();
1589: });
1.1 root 1590:
1.1.1.2 root 1591: /* Dump rtl code after allocating regs within basic blocks. */
1.1 root 1592:
1.1.1.2 root 1593: if (local_reg_dump)
1594: TIMEVAR (dump_time,
1595: {
1596: fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
1597: IDENTIFIER_POINTER (DECL_NAME (decl)));
1598: dump_flow_info (local_reg_dump_file);
1599: dump_local_alloc (local_reg_dump_file);
1600: print_rtl (local_reg_dump_file, insns);
1601: fflush (local_reg_dump_file);
1602: });
1.1 root 1603:
1.1.1.2 root 1604: if (global_reg_dump)
1605: TIMEVAR (dump_time,
1606: fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
1607: IDENTIFIER_POINTER (DECL_NAME (decl))));
1608:
1609: /* Unless we did stupid register allocation,
1610: allocate remaining pseudo-regs, then do the reload pass
1611: fixing up any insns that are invalid. */
1612:
1613: TIMEVAR (global_alloc_time,
1614: {
1615: if (!obey_regdecls)
1616: global_alloc (global_reg_dump ? global_reg_dump_file : 0);
1617: else
1618: reload (insns, 0,
1619: global_reg_dump ? global_reg_dump_file : 0);
1620: });
1621:
1622: if (global_reg_dump)
1623: TIMEVAR (dump_time,
1624: {
1625: dump_global_regs (global_reg_dump_file);
1626: print_rtl (global_reg_dump_file, insns);
1627: fflush (global_reg_dump_file);
1628: });
1.1 root 1629:
1.1.1.12 root 1630: rtx_equal_function_value_matters = 1;
1.1.1.11 root 1631: reload_completed = 1;
1632:
1.1.1.2 root 1633: /* One more attempt to remove jumps to .+1
1634: left by dead-store-elimination.
1635: Also do cross-jumping this time
1636: and delete no-op move insns. */
1.1 root 1637:
1.1.1.2 root 1638: if (optimize)
1639: {
1640: TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
1641: }
1.1 root 1642:
1.1.1.2 root 1643: /* Dump rtl code after jump, if we are doing that. */
1644:
1645: if (jump2_opt_dump)
1646: TIMEVAR (dump_time,
1647: {
1648: fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
1649: IDENTIFIER_POINTER (DECL_NAME (decl)));
1650: print_rtl (jump2_opt_dump_file, insns);
1651: fflush (jump2_opt_dump_file);
1652: });
1653:
1.1.1.16 root 1654: /* If a scheduling pass for delayed branches is to be done,
1655: call the scheduling code. */
1656:
1657: #ifdef HAVE_DELAYED_BRANCH
1658: if (optimize && flag_delayed_branch)
1659: {
1660: TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
1661: if (dbr_sched_dump)
1662: {
1663: TIMEVAR (dump_time,
1664: {
1665: fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
1666: IDENTIFIER_POINTER (DECL_NAME (decl)));
1667: print_rtl (dbr_sched_dump_file, insns);
1668: fflush (dbr_sched_dump_file);
1669: });
1670: }
1671: }
1672: #endif
1673:
1.1.1.2 root 1674: /* Now turn the rtl into assembler code. */
1675:
1676: TIMEVAR (final_time,
1677: {
1678: assemble_function (decl);
1679: final_start_function (insns, asm_out_file,
1680: write_symbols, optimize);
1681: final (insns, asm_out_file,
1.1.1.9 root 1682: write_symbols, optimize, 0);
1.1.1.2 root 1683: final_end_function (insns, asm_out_file,
1684: write_symbols, optimize);
1685: fflush (asm_out_file);
1686: });
1.1 root 1687:
1.1.1.2 root 1688: /* Write GDB symbols if requested */
1.1 root 1689:
1.1.1.4 root 1690: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1691: {
1692: TIMEVAR (symout_time,
1693: {
1694: symout_types (get_permanent_types ());
1695: symout_types (get_temporary_types ());
1696:
1697: DECL_BLOCK_SYMTAB_ADDRESS (decl)
1698: = symout_function (DECL_INITIAL (decl),
1699: DECL_ARGUMENTS (decl), 0);
1.1.1.6 root 1700: symout_function_end ();
1.1.1.2 root 1701: });
1.1 root 1702: }
1.1.1.2 root 1703: else
1704: get_temporary_types ();
1705:
1706: /* Write DBX symbols if requested */
1707:
1.1.1.4 root 1708: #ifdef DBX_DEBUGGING_INFO
1709: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 1710: TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4 root 1711: #endif
1.1 root 1712:
1713: exit_rest_of_compilation:
1714:
1.1.1.12 root 1715: rtx_equal_function_value_matters = 0;
1.1.1.11 root 1716: reload_completed = 0;
1717:
1.1.1.8 root 1718: /* Clear out the real_constant_chain before some of the rtx's
1719: it runs through become garbage. */
1720:
1721: clear_const_double_mem ();
1722:
1.1 root 1723: /* The parsing time is all the time spent in yyparse
1724: *except* what is spent in this function. */
1725:
1726: parse_time -= gettime () - start_time;
1727: }
1728:
1729: /* Entry point of cc1. Decode command args, then call compile_file.
1.1.1.2 root 1730: Exit code is 35 if can't open files, 34 if fatal error,
1731: 33 if had nonfatal errors, else success. */
1.1 root 1732:
1733: int
1734: main (argc, argv, envp)
1735: int argc;
1736: char **argv;
1737: char **envp;
1738: {
1739: register int i;
1.1.1.2 root 1740: char *filename = 0;
1741: int print_mem_flag = 0;
1.1.1.16 root 1742: char *p;
1743:
1744: /* save in case md file wants to emit args as a comment. */
1745: save_argc = argc;
1746: save_argv = argv;
1747:
1748: p = argv[0] + strlen (argv[0]);
1749: while (p != argv[0] && p[-1] != '/') --p;
1750: progname = p;
1.1.1.2 root 1751:
1752: #ifdef RLIMIT_STACK
1753: /* Get rid of any avoidable limit on stack size. */
1754: {
1755: struct rlimit rlim;
1756:
1757: /* Set the stack limit huge so that alloca does not fail. */
1758: getrlimit (RLIMIT_STACK, &rlim);
1759: rlim.rlim_cur = rlim.rlim_max;
1760: setrlimit (RLIMIT_STACK, &rlim);
1761: }
1762: #endif /* RLIMIT_STACK */
1763:
1.1.1.10 root 1764: signal (SIGFPE, float_signal);
1765:
1.1.1.13 root 1766: signal (SIGPIPE, pipe_closed);
1767:
1.1.1.2 root 1768: /* Initialize whether `char' is signed. */
1769: flag_signed_char = DEFAULT_SIGNED_CHAR;
1.1.1.16 root 1770: #ifdef DEFAULT_SHORT_ENUMS
1771: /* Initialize how much space enums occupy, by default. */
1772: flag_short_enums = DEFAULT_SHORT_ENUMS;
1773: #endif
1.1.1.2 root 1774:
1.1.1.4 root 1775: /* This is zeroed by -O. */
1776: obey_regdecls = 1;
1777:
1778: /* Initialize register usage now so switches may override. */
1.1.1.2 root 1779: init_reg_sets ();
1.1 root 1780:
1781: target_flags = 0;
1782: set_target_switch ("");
1783:
1784: for (i = 1; i < argc; i++)
1.1.1.13 root 1785: if (argv[i][0] == '-' && argv[i][1] != 0)
1.1 root 1786: {
1787: register char *str = argv[i] + 1;
1788: if (str[0] == 'Y')
1789: str++;
1790:
1791: if (str[0] == 'm')
1792: set_target_switch (&str[1]);
1793: else if (!strcmp (str, "dumpbase"))
1794: {
1795: dump_base_name = argv[++i];
1796: }
1797: else if (str[0] == 'd')
1798: {
1799: register char *p = &str[1];
1800: while (*p)
1801: switch (*p++)
1802: {
1803: case 'c':
1804: combine_dump = 1;
1805: break;
1.1.1.16 root 1806: case 'd':
1807: dbr_sched_dump = 1;
1808: break;
1.1 root 1809: case 'f':
1810: flow_dump = 1;
1811: break;
1812: case 'g':
1813: global_reg_dump = 1;
1814: break;
1815: case 'j':
1816: jump_opt_dump = 1;
1817: break;
1.1.1.2 root 1818: case 'J':
1819: jump2_opt_dump = 1;
1820: break;
1.1 root 1821: case 'l':
1822: local_reg_dump = 1;
1823: break;
1824: case 'L':
1825: loop_dump = 1;
1826: break;
1.1.1.2 root 1827: case 'm':
1828: print_mem_flag = 1;
1829: break;
1.1 root 1830: case 'r':
1831: rtl_dump = 1;
1832: break;
1833: case 's':
1834: cse_dump = 1;
1835: break;
1836: case 'y':
1837: yydebug = 1;
1838: break;
1839: }
1840: }
1.1.1.2 root 1841: else if (str[0] == 'f')
1842: {
1.1.1.12 root 1843: int j;
1.1.1.2 root 1844: register char *p = &str[1];
1.1.1.12 root 1845: int found = 0;
1846:
1847: /* Some kind of -f option.
1848: P's value is the option sans `-f'.
1849: Search for it in the table of options. */
1850:
1851: for (j = 0;
1852: !found && j < sizeof (f_options) / sizeof (f_options[0]);
1853: j++)
1854: {
1855: if (!strcmp (p, f_options[j].string))
1856: {
1857: *f_options[j].variable = f_options[j].on_value;
1858: /* A goto here would be cleaner,
1859: but breaks the vax pcc. */
1860: found = 1;
1861: }
1.1.1.13 root 1862: if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
1.1.1.12 root 1863: && ! strcmp (p+3, f_options[j].string))
1864: {
1865: *f_options[j].variable = ! f_options[j].on_value;
1866: found = 1;
1867: }
1868: }
1869:
1870: if (found)
1871: ;
1.1.1.2 root 1872: else if (!strncmp (p, "fixed-", 6))
1873: fix_register (&p[6], 1, 1);
1874: else if (!strncmp (p, "call-used-", 10))
1875: fix_register (&p[10], 0, 1);
1876: else if (!strncmp (p, "call-saved-", 11))
1877: fix_register (&p[11], 0, 0);
1.1.1.7 root 1878: else if (! lang_decode_option (argv[i]))
1.1.1.16 root 1879: error ("Invalid option `%s'", argv[i]);
1.1.1.2 root 1880: }
1.1 root 1881: else if (!strcmp (str, "noreg"))
1.1.1.4 root 1882: ;
1.1.1.2 root 1883: else if (!strcmp (str, "opt"))
1.1.1.4 root 1884: optimize = 1, obey_regdecls = 0;
1885: else if (!strcmp (str, "O"))
1886: optimize = 1, obey_regdecls = 0;
1.1.1.2 root 1887: else if (!strcmp (str, "pedantic"))
1888: pedantic = 1;
1.1.1.7 root 1889: else if (lang_decode_option (argv[i]))
1890: ;
1.1.1.2 root 1891: else if (!strcmp (str, "quiet"))
1892: quiet_flag = 1;
1893: else if (!strcmp (str, "version"))
1894: {
1.1.1.7 root 1895: extern char *version_string, *language_string;
1.1.1.12 root 1896: fprintf (stderr, "%s version %s", language_string, version_string);
1.1.1.2 root 1897: #ifdef TARGET_VERSION
1898: TARGET_VERSION;
1899: #endif
1900: #ifdef __GNUC__
1901: #ifndef __VERSION__
1902: #define __VERSION__ "[unknown]"
1903: #endif
1.1.1.12 root 1904: fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
1.1.1.2 root 1905: #else
1.1.1.12 root 1906: fprintf (stderr, " compiled by CC.\n");
1.1.1.2 root 1907: #endif
1.1.1.16 root 1908: print_target_switch_defaults ();
1.1.1.2 root 1909: }
1.1 root 1910: else if (!strcmp (str, "w"))
1911: inhibit_warnings = 1;
1.1.1.2 root 1912: else if (!strcmp (str, "W"))
1913: extra_warnings = 1;
1.1.1.9 root 1914: else if (!strcmp (str, "Wunused"))
1915: warn_unused = 1;
1.1.1.15 root 1916: else if (!strcmp (str, "Wshadow"))
1917: warn_shadow = 1;
1918: else if (!strcmp (str, "Wswitch"))
1919: warn_switch = 1;
1920: else if (!strncmp (str, "Wid-clash-", 10))
1921: {
1922: char *endp = str + 10;
1923:
1924: while (*endp)
1925: {
1926: if (*endp >= '0' && *endp <= '9')
1927: endp++;
1928: else
1929: error ("Invalid option `%s'", argv[i]);
1930: }
1931: warn_id_clash = 1;
1932: id_clash_len = atoi (str + 10);
1933: }
1.1.1.2 root 1934: else if (!strcmp (str, "p"))
1935: profile_flag = 1;
1.1.1.14 root 1936: else if (!strcmp (str, "a"))
1937: {
1938: #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
1939: warning ("`-a' option (basic block profile) not supported");
1940: #else
1941: profile_block_flag = 1;
1942: #endif
1943: }
1.1.1.4 root 1944: else if (!strcmp (str, "gg"))
1945: write_symbols = GDB_DEBUG;
1946: #ifdef DBX_DEBUGGING_INFO
1.1.1.16 root 1947: else if (!strcmp (str, "g0"))
1.1.1.4 root 1948: write_symbols = DBX_DEBUG;
1.1.1.16 root 1949: else if (!strcmp (str, "G0"))
1.1.1.4 root 1950: write_symbols = DBX_DEBUG;
1.1.1.16 root 1951: else if (!strcmp (str, "g"))
1952: {
1953: write_symbols = DBX_DEBUG;
1954: use_gdb_dbx_extensions = 1;
1955: }
1956: else if (!strcmp (str, "G"))
1957: {
1958: write_symbols = DBX_DEBUG;
1959: use_gdb_dbx_extensions = 1;
1960: }
1.1.1.4 root 1961: #endif
1962: #ifdef SDB_DEBUGGING_INFO
1963: else if (!strcmp (str, "g"))
1964: write_symbols = SDB_DEBUG;
1965: else if (!strcmp (str, "G"))
1966: write_symbols = SDB_DEBUG;
1.1.1.16 root 1967: else if (!strcmp (str, "g0"))
1968: write_symbols = SDB_DEBUG;
1969: else if (!strcmp (str, "G0"))
1970: write_symbols = SDB_DEBUG;
1.1.1.4 root 1971: #endif
1.1 root 1972: else if (!strcmp (str, "symout"))
1973: {
1.1.1.4 root 1974: if (write_symbols == NO_DEBUG)
1975: write_symbols = GDB_DEBUG;
1.1 root 1976: sym_file_name = argv[++i];
1977: }
1978: else if (!strcmp (str, "o"))
1979: {
1980: asm_file_name = argv[++i];
1981: }
1982: else
1.1.1.7 root 1983: error ("Invalid option `%s'", argv[i]);
1.1 root 1984: }
1985: else
1986: filename = argv[i];
1987:
1.1.1.2 root 1988: #ifdef OVERRIDE_OPTIONS
1989: /* Some machines may reject certain combinations of options. */
1990: OVERRIDE_OPTIONS;
1991: #endif
1992:
1.1.1.4 root 1993: /* Now that register usage is specified, convert it to HARD_REG_SETs. */
1994: init_reg_sets_1 ();
1995:
1.1 root 1996: compile_file (filename);
1997:
1.1.1.2 root 1998: #ifndef USG
1999: #ifndef VMS
2000: if (print_mem_flag)
2001: {
2002: extern char **environ;
1.1.1.16 root 2003: char *lim = (char *) sbrk (0);
2004:
1.1.1.2 root 2005: fprintf (stderr, "Data size %d.\n",
2006: (int) lim - (int) &environ);
2007: fflush (stderr);
2008:
2009: system ("ps v");
2010: }
2011: #endif /* not VMS */
2012: #endif /* not USG */
2013:
1.1 root 2014: if (errorcount)
1.1.1.2 root 2015: exit (FATAL_EXIT_CODE);
1.1.1.7 root 2016: if (sorrycount)
2017: exit (FATAL_EXIT_CODE);
1.1.1.2 root 2018: exit (SUCCESS_EXIT_CODE);
2019: return 34;
1.1 root 2020: }
2021:
2022: /* Decode -m switches. */
2023:
2024: /* Here is a table, controlled by the tm-...h file, listing each -m switch
2025: and which bits in `target_switches' it should set or clear.
2026: If VALUE is positive, it is bits to set.
2027: If VALUE is negative, -VALUE is bits to clear.
2028: (The sign bit is not used so there is no confusion.) */
2029:
2030: struct {char *name; int value;} target_switches []
2031: = TARGET_SWITCHES;
2032:
2033: /* Decode the switch -mNAME. */
2034:
1.1.1.2 root 2035: void
1.1 root 2036: set_target_switch (name)
2037: char *name;
2038: {
1.1.1.2 root 2039: register int j;
1.1 root 2040: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
2041: if (!strcmp (target_switches[j].name, name))
2042: {
2043: if (target_switches[j].value < 0)
2044: target_flags &= ~-target_switches[j].value;
2045: else
2046: target_flags |= target_switches[j].value;
1.1.1.7 root 2047: return;
1.1 root 2048: }
1.1.1.7 root 2049: error ("Invalid option `%s'", name);
1.1 root 2050: }
1.1.1.16 root 2051:
2052: /* Print default target switches for -version. */
2053:
2054: void
2055: print_target_switch_defaults ()
2056: {
2057: register int j;
2058: register int mask = TARGET_DEFAULT;
2059: fprintf (stderr, "default target switches:");
2060: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
2061: if (target_switches[j].name[0] != '\0'
2062: && target_switches[j].value > 0
2063: && (target_switches[j].value & mask) == target_switches[j].value)
2064:
2065: fprintf (stderr, " -m%s", target_switches[j].name);
2066:
2067: fprintf (stderr, "\n");
2068: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.