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