|
|
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: {
1.1.1.19! root 1141: /* Don't write out static consts, unless we used them.
! 1142: (This used to write them out only if the address was
! 1143: taken, but that was wrong; if the variable was simply
! 1144: referred to, it still needs to exist or else it will
! 1145: be undefined in the linker.) */
1.1.1.16 root 1146: if (! TREE_READONLY (decl)
1.1.1.19! root 1147: || TREE_USED (decl)
1.1.1.16 root 1148: || TREE_PUBLIC (decl)
1149: || TREE_ADDRESSABLE (decl))
1150: rest_of_decl_compilation (decl, 0, 1, 1);
1151: /* Otherwise maybe mention them just for the debugger. */
1152: #ifdef DBX_DEBUGGING_INFO
1153: else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
1154: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1155: #endif
1156: #ifdef SDB_DEBUGGING_INFO
1157: else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
1158: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
1159: #endif
1160: }
1.1.1.2 root 1161: if (TREE_CODE (decl) == FUNCTION_DECL
1162: && ! TREE_ASM_WRITTEN (decl)
1163: && DECL_INITIAL (decl) != 0
1.1.1.16 root 1164: && TREE_ADDRESSABLE (decl)
1165: && ! TREE_EXTERNAL (decl))
1.1.1.2 root 1166: output_inline_function (decl);
1.1.1.15 root 1167:
1168: /* Warn about any function declared static but not defined. */
1.1.1.13 root 1169: if (warn_unused
1170: && TREE_CODE (decl) == FUNCTION_DECL
1171: && DECL_INITIAL (decl) == 0
1172: && TREE_EXTERNAL (decl)
1173: && ! TREE_PUBLIC (decl))
1174: warning_with_decl (decl, "`%s' declared but never defined");
1.1.1.15 root 1175: /* Warn about statics fns or vars defined but not used,
1176: but not about inline functions
1177: since unused inline statics is normal practice. */
1178: if (warn_unused
1179: && (TREE_CODE (decl) == FUNCTION_DECL
1180: || TREE_CODE (decl) == VAR_DECL)
1181: && ! TREE_EXTERNAL (decl)
1182: && ! TREE_PUBLIC (decl)
1183: && ! TREE_USED (decl)
1.1.1.17 root 1184: && ! TREE_INLINE (decl)
1185: /* The TREE_USED bit for file-scope decls
1186: is kept in the identifier, to handle multiple
1187: external decls in different scopes. */
1188: && ! TREE_USED (DECL_NAME (decl)))
1.1.1.15 root 1189: warning_with_decl (decl, "`%s' defined but not used");
1.1.1.2 root 1190: }
1191: }
1192:
1.1 root 1193: /* Do dbx symbols */
1.1.1.4 root 1194: #ifdef DBX_DEBUGGING_INFO
1195: if (write_symbols == DBX_DEBUG)
1.1 root 1196: TIMEVAR (symout_time,
1197: {
1198: dbxout_tags (gettags ());
1199: dbxout_types (get_permanent_types ());
1200: });
1.1.1.4 root 1201: #endif
1202:
1203: #ifdef SDB_DEBUGGING_INFO
1204: if (write_symbols == SDB_DEBUG)
1205: TIMEVAR (symout_time,
1206: {
1207: sdbout_tags (gettags ());
1208: sdbout_types (get_permanent_types ());
1209: });
1210: #endif
1.1 root 1211:
1212: /* Do gdb symbols */
1.1.1.4 root 1213: if (write_symbols == GDB_DEBUG)
1.1 root 1214: TIMEVAR (symout_time,
1215: {
1216: struct stat statbuf;
1217: fstat (fileno (finput), &statbuf);
1218: symout_types (get_permanent_types ());
1219: symout_top_blocks (globals, gettags ());
1220: symout_finish (name, statbuf.st_ctime);
1221: });
1222:
1.1.1.14 root 1223: /* Output some stuff at end of file if nec. */
1224:
1225: end_final (main_input_filename);
1226:
1.1.1.16 root 1227: #ifdef ASM_FILE_END
1228: ASM_FILE_END (asm_out_file);
1229: #endif
1230:
1.1.1.2 root 1231: /* Close the dump files. */
1.1 root 1232:
1233: if (rtl_dump)
1234: fclose (rtl_dump_file);
1235:
1236: if (jump_opt_dump)
1237: fclose (jump_opt_dump_file);
1238:
1239: if (cse_dump)
1240: fclose (cse_dump_file);
1241:
1242: if (loop_dump)
1243: fclose (loop_dump_file);
1244:
1245: if (flow_dump)
1246: fclose (flow_dump_file);
1247:
1248: if (combine_dump)
1249: {
1250: dump_combine_total_stats (combine_dump_file);
1251: fclose (combine_dump_file);
1252: }
1253:
1254: if (local_reg_dump)
1255: fclose (local_reg_dump_file);
1256:
1257: if (global_reg_dump)
1258: fclose (global_reg_dump_file);
1259:
1.1.1.2 root 1260: if (jump2_opt_dump)
1261: fclose (jump2_opt_dump_file);
1262:
1.1.1.16 root 1263: if (dbr_sched_dump)
1264: fclose (dbr_sched_dump_file);
1265:
1266: /* Close non-debugging input and output files. Take special care to note
1267: whether fclose returns an error, since the pages might still be on the
1268: buffer chain while the file is open. */
1.1.1.2 root 1269:
1270: fclose (finput);
1.1.1.16 root 1271: if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
1.1.1.2 root 1272: fatal_io_error (asm_file_name);
1273:
1.1 root 1274: /* Print the times. */
1275:
1276: if (! quiet_flag)
1277: {
1.1.1.2 root 1278: fprintf (stderr,"\n");
1.1 root 1279: print_time ("parse", parse_time);
1.1.1.2 root 1280: print_time ("integration", integration_time);
1.1 root 1281: print_time ("jump", jump_time);
1282: print_time ("cse", cse_time);
1283: print_time ("loop", loop_time);
1284: print_time ("flow", flow_time);
1285: print_time ("combine", combine_time);
1286: print_time ("local-alloc", local_alloc_time);
1287: print_time ("global-alloc", global_alloc_time);
1.1.1.16 root 1288: print_time ("dbranch", dbr_sched_time);
1.1 root 1289: print_time ("final", final_time);
1290: print_time ("varconst", varconst_time);
1291: print_time ("symout", symout_time);
1292: print_time ("dump", dump_time);
1293: }
1294: }
1295:
1.1.1.2 root 1296: /* This is called from finish_decl (within yyparse)
1297: for each declaration of a function or variable.
1298: This does nothing for automatic variables.
1299: Otherwise, it sets up the RTL and outputs any assembler code
1300: (label definition, storage allocation and initialization).
1301:
1302: DECL is the declaration. If ASMSPEC is nonzero, it specifies
1303: the assembler symbol name to be used. TOP_LEVEL is nonzero
1304: if this declaration is not within a function. */
1305:
1306: void
1307: rest_of_decl_compilation (decl, asmspec, top_level, at_end)
1308: tree decl;
1.1.1.16 root 1309: char *asmspec;
1.1.1.2 root 1310: int top_level;
1311: int at_end;
1312: {
1313: /* Declarations of variables, and of functions defined elsewhere. */
1314:
1315: if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
1316: TIMEVAR (varconst_time,
1317: {
1.1.1.12 root 1318: make_decl_rtl (decl, asmspec, top_level);
1319: /* Don't output anything
1320: when a tentative file-scope definition is seen.
1321: But at end of compilation, do output code for them. */
1322: if (! (! at_end && top_level
1323: && (DECL_INITIAL (decl) == 0
1324: || DECL_INITIAL (decl) == error_mark_node)))
1325: assemble_variable (decl, top_level, write_symbols, at_end);
1.1.1.2 root 1326: });
1.1.1.16 root 1327: else if (TREE_REGDECL (decl) && asmspec != 0)
1328: {
1329: if (decode_reg_name (asmspec) >= 0)
1330: {
1331: DECL_RTL (decl) = 0;
1332: make_decl_rtl (decl, asmspec, top_level);
1333: }
1334: else
1335: error ("invalid register name `%s' for register variable", asmspec);
1336: }
1.1.1.4 root 1337: #ifdef DBX_DEBUGGING_INFO
1338: else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
1.1.1.3 root 1339: TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
1.1.1.4 root 1340: #endif
1341: #ifdef SDB_DEBUGGING_INFO
1.1.1.18 root 1342: else if (write_symbols == SDB_DEBUG && top_level
1343: && TREE_CODE (decl) == TYPE_DECL)
1.1.1.4 root 1344: TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
1345: #endif
1.1.1.2 root 1346:
1347: if (top_level)
1348: {
1.1.1.4 root 1349: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1350: {
1351: TIMEVAR (symout_time,
1352: {
1353: /* The initizations make types when they contain
1354: string constants. The types are on the temporary
1355: obstack, so output them now before they go away. */
1356: symout_types (get_temporary_types ());
1357: });
1358: }
1359: else
1360: /* Clean out the temporary type list, since the types will go away. */
1361: get_temporary_types ();
1362: }
1363: }
1364:
1.1 root 1365: /* This is called from finish_function (within yyparse)
1.1.1.2 root 1366: after each top-level definition is parsed.
1.1 root 1367: It is supposed to compile that function or variable
1368: and output the assembler code for it.
1369: After we return, the tree storage is freed. */
1370:
1371: void
1.1.1.2 root 1372: rest_of_compilation (decl)
1.1 root 1373: tree decl;
1374: {
1375: register rtx insns;
1376: int start_time = gettime ();
1377: int tem;
1378:
1.1.1.2 root 1379: /* If we are reconsidering an inline function
1380: at the end of compilation, skip the stuff for making it inline. */
1.1 root 1381:
1.1.1.2 root 1382: if (DECL_SAVED_INSNS (decl) == 0)
1.1 root 1383: {
1384:
1.1.1.2 root 1385: /* If requested, consider whether to make this function inline. */
1386: if (flag_inline_functions || TREE_INLINE (decl))
1387: {
1388: TIMEVAR (integration_time,
1389: {
1390: int specd = TREE_INLINE (decl);
1391: char *lose = function_cannot_inline_p (decl);
1392: if (lose != 0 && specd)
1393: warning_with_decl (decl, lose);
1394: if (lose == 0)
1395: save_for_inline (decl);
1396: else
1397: TREE_INLINE (decl) = 0;
1398: });
1399: }
1.1 root 1400:
1.1.1.2 root 1401: insns = get_insns ();
1.1 root 1402:
1403: /* Dump the rtl code if we are dumping rtl. */
1404:
1405: if (rtl_dump)
1406: TIMEVAR (dump_time,
1407: {
1408: fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1409: IDENTIFIER_POINTER (DECL_NAME (decl)));
1.1.1.2 root 1410: if (DECL_SAVED_INSNS (decl))
1411: fprintf (rtl_dump_file, ";; (integrable)\n\n");
1.1 root 1412: print_rtl (rtl_dump_file, insns);
1413: fflush (rtl_dump_file);
1414: });
1415:
1.1.1.2 root 1416: /* If function is inline, and we don't yet know whether to
1417: compile it by itself, defer decision till end of compilation.
1418: finish_compilation will call rest_of_compilation again
1419: for those functions that need to be output. */
1420:
1.1.1.16 root 1421: if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
1422: && ! flag_keep_inline_functions)
1423: || TREE_EXTERNAL (decl))
1424: && TREE_INLINE (decl))
1.1 root 1425: goto exit_rest_of_compilation;
1.1.1.2 root 1426: }
1.1 root 1427:
1.1.1.16 root 1428: if (rtl_dump_and_exit || flag_syntax_only)
1429: {
1430: get_temporary_types ();
1431: goto exit_rest_of_compilation;
1432: }
1.1 root 1433:
1.1.1.2 root 1434: TREE_ASM_WRITTEN (decl) = 1;
1.1 root 1435:
1.1.1.2 root 1436: insns = get_insns ();
1.1 root 1437:
1.1.1.2 root 1438: /* Copy any shared structure that should not be shared. */
1.1 root 1439:
1.1.1.2 root 1440: unshare_all_rtl (insns);
1.1 root 1441:
1.1.1.2 root 1442: /* See if we have allocated stack slots that are not directly addressable.
1443: If so, scan all the insns and create explicit address computation
1444: for all references to such slots. */
1445: /* fixup_stack_slots (); */
1.1 root 1446:
1.1.1.2 root 1447: /* Do jump optimization the first time, if -opt.
1448: Also do it if -W, but in that case it doesn't change the rtl code,
1449: it only computes whether control can drop off the end of the function. */
1.1 root 1450:
1.1.1.13 root 1451: if (optimize || extra_warnings || warn_return_type
1452: /* If function is `volatile', we should warn if it tries to return. */
1453: || TREE_THIS_VOLATILE (decl))
1.1.1.2 root 1454: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1.1 root 1455:
1.1.1.2 root 1456: /* Dump rtl code after jump, if we are doing that. */
1.1 root 1457:
1.1.1.2 root 1458: if (jump_opt_dump)
1459: TIMEVAR (dump_time,
1460: {
1461: fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
1462: IDENTIFIER_POINTER (DECL_NAME (decl)));
1463: print_rtl (jump_opt_dump_file, insns);
1464: fflush (jump_opt_dump_file);
1465: });
1.1 root 1466:
1.1.1.2 root 1467: /* Perform common subexpression elimination.
1468: Nonzero value from `cse_main' means that jumps were simplified
1469: and some code may now be unreachable, so do
1470: jump optimization again. */
1.1 root 1471:
1.1.1.2 root 1472: if (optimize)
1473: {
1474: TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
1.1 root 1475:
1.1.1.2 root 1476: TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
1.1 root 1477:
1.1.1.2 root 1478: if (tem)
1479: TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
1480: }
1.1 root 1481:
1.1.1.2 root 1482: /* Dump rtl code after cse, if we are doing that. */
1.1 root 1483:
1.1.1.2 root 1484: if (cse_dump)
1485: TIMEVAR (dump_time,
1486: {
1487: fprintf (cse_dump_file, "\n;; Function %s\n\n",
1488: IDENTIFIER_POINTER (DECL_NAME (decl)));
1489: print_rtl (cse_dump_file, insns);
1490: fflush (cse_dump_file);
1491: });
1.1 root 1492:
1.1.1.2 root 1493: if (loop_dump)
1494: TIMEVAR (dump_time,
1495: {
1496: fprintf (loop_dump_file, "\n;; Function %s\n\n",
1497: IDENTIFIER_POINTER (DECL_NAME (decl)));
1498: });
1.1 root 1499:
1.1.1.2 root 1500: /* Move constant computations out of loops. */
1.1 root 1501:
1.1.1.2 root 1502: if (optimize)
1503: {
1504: TIMEVAR (loop_time,
1505: {
1506: reg_scan (insns, max_reg_num (), 1);
1.1.1.9 root 1507: loop_optimize (insns, loop_dump ? loop_dump_file : 0);
1.1.1.2 root 1508: });
1509: }
1.1 root 1510:
1.1.1.2 root 1511: /* Dump rtl code after loop opt, if we are doing that. */
1.1 root 1512:
1.1.1.2 root 1513: if (loop_dump)
1514: TIMEVAR (dump_time,
1515: {
1516: print_rtl (loop_dump_file, insns);
1517: fflush (loop_dump_file);
1518: });
1.1 root 1519:
1.1.1.2 root 1520: /* Now we choose between stupid (pcc-like) register allocation
1521: (if we got the -noreg switch and not -opt)
1522: and smart register allocation. */
1.1 root 1523:
1.1.1.2 root 1524: if (optimize) /* Stupid allocation probably won't work */
1525: obey_regdecls = 0; /* if optimizations being done. */
1.1 root 1526:
1.1.1.2 root 1527: regclass_init ();
1.1 root 1528:
1.1.1.2 root 1529: /* Print function header into flow dump now
1530: because doing the flow analysis makes some of the dump. */
1.1 root 1531:
1.1.1.2 root 1532: if (flow_dump)
1533: TIMEVAR (dump_time,
1534: {
1535: fprintf (flow_dump_file, "\n;; Function %s\n\n",
1536: IDENTIFIER_POINTER (DECL_NAME (decl)));
1537: });
1538:
1539: if (obey_regdecls)
1540: {
1541: TIMEVAR (flow_time,
1542: {
1543: regclass (insns, max_reg_num ());
1544: stupid_life_analysis (insns, max_reg_num (),
1545: flow_dump_file);
1546: });
1547: }
1548: else
1549: {
1550: /* Do control and data flow analysis,
1551: and write some of the results to dump file. */
1.1 root 1552:
1.1.1.2 root 1553: TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
1554: flow_dump_file));
1555: if (extra_warnings)
1556: uninitialized_vars_warning (DECL_INITIAL (decl));
1557: }
1.1 root 1558:
1.1.1.2 root 1559: /* Dump rtl after flow analysis. */
1.1 root 1560:
1.1.1.2 root 1561: if (flow_dump)
1562: TIMEVAR (dump_time,
1563: {
1564: print_rtl (flow_dump_file, insns);
1565: fflush (flow_dump_file);
1566: });
1.1 root 1567:
1.1.1.2 root 1568: /* If -opt, try combining insns through substitution. */
1.1 root 1569:
1.1.1.2 root 1570: if (optimize)
1571: TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
1.1 root 1572:
1.1.1.2 root 1573: /* Dump rtl code after insn combination. */
1.1 root 1574:
1.1.1.2 root 1575: if (combine_dump)
1576: TIMEVAR (dump_time,
1577: {
1578: fprintf (combine_dump_file, "\n;; Function %s\n\n",
1579: IDENTIFIER_POINTER (DECL_NAME (decl)));
1580: dump_combine_stats (combine_dump_file);
1581: print_rtl (combine_dump_file, insns);
1582: fflush (combine_dump_file);
1583: });
1.1 root 1584:
1.1.1.2 root 1585: /* Unless we did stupid register allocation,
1586: allocate pseudo-regs that are used only within 1 basic block. */
1.1 root 1587:
1.1.1.2 root 1588: if (!obey_regdecls)
1589: TIMEVAR (local_alloc_time,
1590: {
1591: regclass (insns, max_reg_num ());
1592: local_alloc ();
1593: });
1.1 root 1594:
1.1.1.2 root 1595: /* Dump rtl code after allocating regs within basic blocks. */
1.1 root 1596:
1.1.1.2 root 1597: if (local_reg_dump)
1598: TIMEVAR (dump_time,
1599: {
1600: fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
1601: IDENTIFIER_POINTER (DECL_NAME (decl)));
1602: dump_flow_info (local_reg_dump_file);
1603: dump_local_alloc (local_reg_dump_file);
1604: print_rtl (local_reg_dump_file, insns);
1605: fflush (local_reg_dump_file);
1606: });
1.1 root 1607:
1.1.1.2 root 1608: if (global_reg_dump)
1609: TIMEVAR (dump_time,
1610: fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
1611: IDENTIFIER_POINTER (DECL_NAME (decl))));
1612:
1613: /* Unless we did stupid register allocation,
1614: allocate remaining pseudo-regs, then do the reload pass
1615: fixing up any insns that are invalid. */
1616:
1617: TIMEVAR (global_alloc_time,
1618: {
1619: if (!obey_regdecls)
1620: global_alloc (global_reg_dump ? global_reg_dump_file : 0);
1621: else
1622: reload (insns, 0,
1623: global_reg_dump ? global_reg_dump_file : 0);
1624: });
1625:
1626: if (global_reg_dump)
1627: TIMEVAR (dump_time,
1628: {
1629: dump_global_regs (global_reg_dump_file);
1630: print_rtl (global_reg_dump_file, insns);
1631: fflush (global_reg_dump_file);
1632: });
1.1 root 1633:
1.1.1.12 root 1634: rtx_equal_function_value_matters = 1;
1.1.1.11 root 1635: reload_completed = 1;
1636:
1.1.1.2 root 1637: /* One more attempt to remove jumps to .+1
1638: left by dead-store-elimination.
1639: Also do cross-jumping this time
1640: and delete no-op move insns. */
1.1 root 1641:
1.1.1.2 root 1642: if (optimize)
1643: {
1644: TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
1645: }
1.1 root 1646:
1.1.1.2 root 1647: /* Dump rtl code after jump, if we are doing that. */
1648:
1649: if (jump2_opt_dump)
1650: TIMEVAR (dump_time,
1651: {
1652: fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
1653: IDENTIFIER_POINTER (DECL_NAME (decl)));
1654: print_rtl (jump2_opt_dump_file, insns);
1655: fflush (jump2_opt_dump_file);
1656: });
1657:
1.1.1.16 root 1658: /* If a scheduling pass for delayed branches is to be done,
1659: call the scheduling code. */
1660:
1661: #ifdef HAVE_DELAYED_BRANCH
1662: if (optimize && flag_delayed_branch)
1663: {
1664: TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
1665: if (dbr_sched_dump)
1666: {
1667: TIMEVAR (dump_time,
1668: {
1669: fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
1670: IDENTIFIER_POINTER (DECL_NAME (decl)));
1671: print_rtl (dbr_sched_dump_file, insns);
1672: fflush (dbr_sched_dump_file);
1673: });
1674: }
1675: }
1676: #endif
1677:
1.1.1.2 root 1678: /* Now turn the rtl into assembler code. */
1679:
1680: TIMEVAR (final_time,
1681: {
1682: assemble_function (decl);
1683: final_start_function (insns, asm_out_file,
1684: write_symbols, optimize);
1685: final (insns, asm_out_file,
1.1.1.9 root 1686: write_symbols, optimize, 0);
1.1.1.2 root 1687: final_end_function (insns, asm_out_file,
1688: write_symbols, optimize);
1689: fflush (asm_out_file);
1690: });
1.1 root 1691:
1.1.1.2 root 1692: /* Write GDB symbols if requested */
1.1 root 1693:
1.1.1.4 root 1694: if (write_symbols == GDB_DEBUG)
1.1.1.2 root 1695: {
1696: TIMEVAR (symout_time,
1697: {
1698: symout_types (get_permanent_types ());
1699: symout_types (get_temporary_types ());
1700:
1701: DECL_BLOCK_SYMTAB_ADDRESS (decl)
1702: = symout_function (DECL_INITIAL (decl),
1703: DECL_ARGUMENTS (decl), 0);
1.1.1.6 root 1704: symout_function_end ();
1.1.1.2 root 1705: });
1.1 root 1706: }
1.1.1.2 root 1707: else
1708: get_temporary_types ();
1709:
1710: /* Write DBX symbols if requested */
1711:
1.1.1.4 root 1712: #ifdef DBX_DEBUGGING_INFO
1713: if (write_symbols == DBX_DEBUG)
1.1.1.2 root 1714: TIMEVAR (symout_time, dbxout_function (decl));
1.1.1.4 root 1715: #endif
1.1 root 1716:
1717: exit_rest_of_compilation:
1718:
1.1.1.12 root 1719: rtx_equal_function_value_matters = 0;
1.1.1.11 root 1720: reload_completed = 0;
1721:
1.1.1.8 root 1722: /* Clear out the real_constant_chain before some of the rtx's
1723: it runs through become garbage. */
1724:
1725: clear_const_double_mem ();
1726:
1.1 root 1727: /* The parsing time is all the time spent in yyparse
1728: *except* what is spent in this function. */
1729:
1730: parse_time -= gettime () - start_time;
1731: }
1732:
1733: /* Entry point of cc1. Decode command args, then call compile_file.
1.1.1.2 root 1734: Exit code is 35 if can't open files, 34 if fatal error,
1735: 33 if had nonfatal errors, else success. */
1.1 root 1736:
1737: int
1738: main (argc, argv, envp)
1739: int argc;
1740: char **argv;
1741: char **envp;
1742: {
1743: register int i;
1.1.1.2 root 1744: char *filename = 0;
1745: int print_mem_flag = 0;
1.1.1.16 root 1746: char *p;
1747:
1748: /* save in case md file wants to emit args as a comment. */
1749: save_argc = argc;
1750: save_argv = argv;
1751:
1752: p = argv[0] + strlen (argv[0]);
1753: while (p != argv[0] && p[-1] != '/') --p;
1754: progname = p;
1.1.1.2 root 1755:
1756: #ifdef RLIMIT_STACK
1757: /* Get rid of any avoidable limit on stack size. */
1758: {
1759: struct rlimit rlim;
1760:
1761: /* Set the stack limit huge so that alloca does not fail. */
1762: getrlimit (RLIMIT_STACK, &rlim);
1763: rlim.rlim_cur = rlim.rlim_max;
1764: setrlimit (RLIMIT_STACK, &rlim);
1765: }
1766: #endif /* RLIMIT_STACK */
1767:
1.1.1.10 root 1768: signal (SIGFPE, float_signal);
1769:
1.1.1.13 root 1770: signal (SIGPIPE, pipe_closed);
1771:
1.1.1.2 root 1772: /* Initialize whether `char' is signed. */
1773: flag_signed_char = DEFAULT_SIGNED_CHAR;
1.1.1.16 root 1774: #ifdef DEFAULT_SHORT_ENUMS
1775: /* Initialize how much space enums occupy, by default. */
1776: flag_short_enums = DEFAULT_SHORT_ENUMS;
1777: #endif
1.1.1.2 root 1778:
1.1.1.4 root 1779: /* This is zeroed by -O. */
1780: obey_regdecls = 1;
1781:
1782: /* Initialize register usage now so switches may override. */
1.1.1.2 root 1783: init_reg_sets ();
1.1 root 1784:
1785: target_flags = 0;
1786: set_target_switch ("");
1787:
1788: for (i = 1; i < argc; i++)
1.1.1.13 root 1789: if (argv[i][0] == '-' && argv[i][1] != 0)
1.1 root 1790: {
1791: register char *str = argv[i] + 1;
1792: if (str[0] == 'Y')
1793: str++;
1794:
1795: if (str[0] == 'm')
1796: set_target_switch (&str[1]);
1797: else if (!strcmp (str, "dumpbase"))
1798: {
1799: dump_base_name = argv[++i];
1800: }
1801: else if (str[0] == 'd')
1802: {
1803: register char *p = &str[1];
1804: while (*p)
1805: switch (*p++)
1806: {
1807: case 'c':
1808: combine_dump = 1;
1809: break;
1.1.1.16 root 1810: case 'd':
1811: dbr_sched_dump = 1;
1812: break;
1.1 root 1813: case 'f':
1814: flow_dump = 1;
1815: break;
1816: case 'g':
1817: global_reg_dump = 1;
1818: break;
1819: case 'j':
1820: jump_opt_dump = 1;
1821: break;
1.1.1.2 root 1822: case 'J':
1823: jump2_opt_dump = 1;
1824: break;
1.1 root 1825: case 'l':
1826: local_reg_dump = 1;
1827: break;
1828: case 'L':
1829: loop_dump = 1;
1830: break;
1.1.1.2 root 1831: case 'm':
1832: print_mem_flag = 1;
1833: break;
1.1 root 1834: case 'r':
1835: rtl_dump = 1;
1836: break;
1837: case 's':
1838: cse_dump = 1;
1839: break;
1840: case 'y':
1841: yydebug = 1;
1842: break;
1843: }
1844: }
1.1.1.2 root 1845: else if (str[0] == 'f')
1846: {
1.1.1.12 root 1847: int j;
1.1.1.2 root 1848: register char *p = &str[1];
1.1.1.12 root 1849: int found = 0;
1850:
1851: /* Some kind of -f option.
1852: P's value is the option sans `-f'.
1853: Search for it in the table of options. */
1854:
1855: for (j = 0;
1856: !found && j < sizeof (f_options) / sizeof (f_options[0]);
1857: j++)
1858: {
1859: if (!strcmp (p, f_options[j].string))
1860: {
1861: *f_options[j].variable = f_options[j].on_value;
1862: /* A goto here would be cleaner,
1863: but breaks the vax pcc. */
1864: found = 1;
1865: }
1.1.1.13 root 1866: if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
1.1.1.12 root 1867: && ! strcmp (p+3, f_options[j].string))
1868: {
1869: *f_options[j].variable = ! f_options[j].on_value;
1870: found = 1;
1871: }
1872: }
1873:
1874: if (found)
1875: ;
1.1.1.2 root 1876: else if (!strncmp (p, "fixed-", 6))
1877: fix_register (&p[6], 1, 1);
1878: else if (!strncmp (p, "call-used-", 10))
1879: fix_register (&p[10], 0, 1);
1880: else if (!strncmp (p, "call-saved-", 11))
1881: fix_register (&p[11], 0, 0);
1.1.1.7 root 1882: else if (! lang_decode_option (argv[i]))
1.1.1.16 root 1883: error ("Invalid option `%s'", argv[i]);
1.1.1.2 root 1884: }
1.1 root 1885: else if (!strcmp (str, "noreg"))
1.1.1.4 root 1886: ;
1.1.1.2 root 1887: else if (!strcmp (str, "opt"))
1.1.1.4 root 1888: optimize = 1, obey_regdecls = 0;
1889: else if (!strcmp (str, "O"))
1890: optimize = 1, obey_regdecls = 0;
1.1.1.2 root 1891: else if (!strcmp (str, "pedantic"))
1892: pedantic = 1;
1.1.1.7 root 1893: else if (lang_decode_option (argv[i]))
1894: ;
1.1.1.2 root 1895: else if (!strcmp (str, "quiet"))
1896: quiet_flag = 1;
1897: else if (!strcmp (str, "version"))
1898: {
1.1.1.7 root 1899: extern char *version_string, *language_string;
1.1.1.12 root 1900: fprintf (stderr, "%s version %s", language_string, version_string);
1.1.1.2 root 1901: #ifdef TARGET_VERSION
1902: TARGET_VERSION;
1903: #endif
1904: #ifdef __GNUC__
1905: #ifndef __VERSION__
1906: #define __VERSION__ "[unknown]"
1907: #endif
1.1.1.12 root 1908: fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
1.1.1.2 root 1909: #else
1.1.1.12 root 1910: fprintf (stderr, " compiled by CC.\n");
1.1.1.2 root 1911: #endif
1.1.1.16 root 1912: print_target_switch_defaults ();
1.1.1.2 root 1913: }
1.1 root 1914: else if (!strcmp (str, "w"))
1915: inhibit_warnings = 1;
1.1.1.2 root 1916: else if (!strcmp (str, "W"))
1917: extra_warnings = 1;
1.1.1.9 root 1918: else if (!strcmp (str, "Wunused"))
1919: warn_unused = 1;
1.1.1.15 root 1920: else if (!strcmp (str, "Wshadow"))
1921: warn_shadow = 1;
1922: else if (!strcmp (str, "Wswitch"))
1923: warn_switch = 1;
1924: else if (!strncmp (str, "Wid-clash-", 10))
1925: {
1926: char *endp = str + 10;
1927:
1928: while (*endp)
1929: {
1930: if (*endp >= '0' && *endp <= '9')
1931: endp++;
1932: else
1933: error ("Invalid option `%s'", argv[i]);
1934: }
1935: warn_id_clash = 1;
1936: id_clash_len = atoi (str + 10);
1937: }
1.1.1.2 root 1938: else if (!strcmp (str, "p"))
1939: profile_flag = 1;
1.1.1.14 root 1940: else if (!strcmp (str, "a"))
1941: {
1942: #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
1943: warning ("`-a' option (basic block profile) not supported");
1944: #else
1945: profile_block_flag = 1;
1946: #endif
1947: }
1.1.1.4 root 1948: else if (!strcmp (str, "gg"))
1949: write_symbols = GDB_DEBUG;
1950: #ifdef DBX_DEBUGGING_INFO
1.1.1.16 root 1951: else if (!strcmp (str, "g0"))
1.1.1.4 root 1952: write_symbols = DBX_DEBUG;
1.1.1.16 root 1953: else if (!strcmp (str, "G0"))
1.1.1.4 root 1954: write_symbols = DBX_DEBUG;
1.1.1.16 root 1955: else if (!strcmp (str, "g"))
1956: {
1957: write_symbols = DBX_DEBUG;
1958: use_gdb_dbx_extensions = 1;
1959: }
1960: else if (!strcmp (str, "G"))
1961: {
1962: write_symbols = DBX_DEBUG;
1963: use_gdb_dbx_extensions = 1;
1964: }
1.1.1.4 root 1965: #endif
1966: #ifdef SDB_DEBUGGING_INFO
1967: else if (!strcmp (str, "g"))
1968: write_symbols = SDB_DEBUG;
1969: else if (!strcmp (str, "G"))
1970: write_symbols = SDB_DEBUG;
1.1.1.16 root 1971: else if (!strcmp (str, "g0"))
1972: write_symbols = SDB_DEBUG;
1973: else if (!strcmp (str, "G0"))
1974: write_symbols = SDB_DEBUG;
1.1.1.4 root 1975: #endif
1.1 root 1976: else if (!strcmp (str, "symout"))
1977: {
1.1.1.4 root 1978: if (write_symbols == NO_DEBUG)
1979: write_symbols = GDB_DEBUG;
1.1 root 1980: sym_file_name = argv[++i];
1981: }
1982: else if (!strcmp (str, "o"))
1983: {
1984: asm_file_name = argv[++i];
1985: }
1986: else
1.1.1.7 root 1987: error ("Invalid option `%s'", argv[i]);
1.1 root 1988: }
1989: else
1990: filename = argv[i];
1991:
1.1.1.2 root 1992: #ifdef OVERRIDE_OPTIONS
1993: /* Some machines may reject certain combinations of options. */
1994: OVERRIDE_OPTIONS;
1995: #endif
1996:
1.1.1.4 root 1997: /* Now that register usage is specified, convert it to HARD_REG_SETs. */
1998: init_reg_sets_1 ();
1999:
1.1 root 2000: compile_file (filename);
2001:
1.1.1.2 root 2002: #ifndef USG
2003: #ifndef VMS
2004: if (print_mem_flag)
2005: {
2006: extern char **environ;
1.1.1.16 root 2007: char *lim = (char *) sbrk (0);
2008:
1.1.1.2 root 2009: fprintf (stderr, "Data size %d.\n",
2010: (int) lim - (int) &environ);
2011: fflush (stderr);
2012:
2013: system ("ps v");
2014: }
2015: #endif /* not VMS */
2016: #endif /* not USG */
2017:
1.1 root 2018: if (errorcount)
1.1.1.2 root 2019: exit (FATAL_EXIT_CODE);
1.1.1.7 root 2020: if (sorrycount)
2021: exit (FATAL_EXIT_CODE);
1.1.1.2 root 2022: exit (SUCCESS_EXIT_CODE);
2023: return 34;
1.1 root 2024: }
2025:
2026: /* Decode -m switches. */
2027:
2028: /* Here is a table, controlled by the tm-...h file, listing each -m switch
2029: and which bits in `target_switches' it should set or clear.
2030: If VALUE is positive, it is bits to set.
2031: If VALUE is negative, -VALUE is bits to clear.
2032: (The sign bit is not used so there is no confusion.) */
2033:
2034: struct {char *name; int value;} target_switches []
2035: = TARGET_SWITCHES;
2036:
2037: /* Decode the switch -mNAME. */
2038:
1.1.1.2 root 2039: void
1.1 root 2040: set_target_switch (name)
2041: char *name;
2042: {
1.1.1.2 root 2043: register int j;
1.1 root 2044: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
2045: if (!strcmp (target_switches[j].name, name))
2046: {
2047: if (target_switches[j].value < 0)
2048: target_flags &= ~-target_switches[j].value;
2049: else
2050: target_flags |= target_switches[j].value;
1.1.1.7 root 2051: return;
1.1 root 2052: }
1.1.1.7 root 2053: error ("Invalid option `%s'", name);
1.1 root 2054: }
1.1.1.16 root 2055:
2056: /* Print default target switches for -version. */
2057:
2058: void
2059: print_target_switch_defaults ()
2060: {
2061: register int j;
2062: register int mask = TARGET_DEFAULT;
2063: fprintf (stderr, "default target switches:");
2064: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
2065: if (target_switches[j].name[0] != '\0'
2066: && target_switches[j].value > 0
2067: && (target_switches[j].value & mask) == target_switches[j].value)
2068:
2069: fprintf (stderr, " -m%s", target_switches[j].name);
2070:
2071: fprintf (stderr, "\n");
2072: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.