]>
Commit | Line | Data |
---|---|---|
4291d9c8 RS |
1 | /* Top level of GNU C compiler |
2 | Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GNU CC. | |
5 | ||
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 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
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. */ | |
19 | ||
20 | ||
21 | /* This is the top level of cc1/c++. | |
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 <sys/types.h> | |
28 | #include <stdio.h> | |
29 | #include <signal.h> | |
30 | #include <setjmp.h> | |
31 | ||
32 | #include <sys/stat.h> | |
33 | ||
34 | #ifdef USG | |
35 | #undef FLOAT | |
36 | #include <sys/param.h> | |
37 | /* This is for hpux. It is a real screw. They should change hpux. */ | |
38 | #undef FLOAT | |
39 | #include <sys/times.h> | |
40 | #include <time.h> /* Correct for hpux at least. Is it good on other USG? */ | |
41 | #undef FFS /* Some systems define this in param.h. */ | |
42 | #else | |
43 | #ifndef VMS | |
44 | #include <sys/time.h> | |
45 | #include <sys/resource.h> | |
46 | #endif | |
47 | #endif | |
48 | ||
49 | #include "input.h" | |
50 | #include "tree.h" | |
51 | /* #include "c-tree.h" */ | |
52 | #include "rtl.h" | |
53 | #include "flags.h" | |
54 | #include "insn-attr.h" | |
f246a305 RS |
55 | |
56 | #ifdef XCOFF_DEBUGGING_INFO | |
57 | #include "xcoffout.h" | |
58 | #endif | |
4291d9c8 RS |
59 | \f |
60 | #ifdef VMS | |
61 | /* The extra parameters substantially improve the I/O performance. */ | |
62 | static FILE * | |
63 | VMS_fopen (fname, type) | |
64 | char * fname; | |
65 | char * type; | |
66 | { | |
67 | if (strcmp (type, "w") == 0) | |
68 | return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil"); | |
69 | return fopen (fname, type, "mbc=16"); | |
70 | } | |
71 | #define fopen VMS_fopen | |
72 | #endif | |
73 | ||
74 | #ifndef DEFAULT_GDB_EXTENSIONS | |
75 | #define DEFAULT_GDB_EXTENSIONS 1 | |
76 | #endif | |
77 | ||
78 | extern int rtx_equal_function_value_matters; | |
79 | ||
80 | extern char **environ; | |
81 | extern char *version_string, *language_string; | |
82 | ||
83 | extern void init_lex (); | |
84 | extern void init_decl_processing (); | |
85 | extern void init_obstacks (); | |
86 | extern void init_tree_codes (); | |
87 | extern void init_rtl (); | |
88 | extern void init_optabs (); | |
89 | extern void init_stmt (); | |
90 | extern void init_reg_sets (); | |
91 | extern void dump_flow_info (); | |
92 | extern void dump_sched_info (); | |
93 | extern void dump_local_alloc (); | |
94 | ||
95 | void rest_of_decl_compilation (); | |
96 | void error (); | |
97 | void error_with_file_and_line (); | |
98 | void fancy_abort (); | |
99 | #ifndef abort | |
100 | void abort (); | |
101 | #endif | |
102 | void set_target_switch (); | |
103 | static void print_switch_values (); | |
104 | static char *decl_name (); | |
105 | ||
106 | /* Name of program invoked, sans directories. */ | |
107 | ||
108 | char *progname; | |
109 | ||
110 | /* Copy of arguments to main. */ | |
111 | int save_argc; | |
112 | char **save_argv; | |
113 | \f | |
114 | /* Name of current original source file (what was input to cpp). | |
115 | This comes from each #-command in the actual input. */ | |
116 | ||
117 | char *input_filename; | |
118 | ||
119 | /* Name of top-level original source file (what was input to cpp). | |
120 | This comes from the #-command at the beginning of the actual input. | |
121 | If there isn't any there, then this is the cc1 input file name. */ | |
122 | ||
123 | char *main_input_filename; | |
124 | ||
125 | /* Stream for reading from the input file. */ | |
126 | ||
127 | FILE *finput; | |
128 | ||
129 | /* Current line number in real source file. */ | |
130 | ||
131 | int lineno; | |
132 | ||
133 | /* Stack of currently pending input files. */ | |
134 | ||
135 | struct file_stack *input_file_stack; | |
136 | ||
137 | /* Incremented on each change to input_file_stack. */ | |
138 | int input_file_stack_tick; | |
139 | ||
140 | /* FUNCTION_DECL for function now being parsed or compiled. */ | |
141 | ||
142 | extern tree current_function_decl; | |
143 | ||
144 | /* Name to use as base of names for dump output files. */ | |
145 | ||
146 | char *dump_base_name; | |
147 | ||
148 | /* Bit flags that specify the machine subtype we are compiling for. | |
149 | Bits are tested using macros TARGET_... defined in the tm.h file | |
150 | and set by `-m...' switches. Must be defined in rtlanal.c. */ | |
151 | ||
152 | extern int target_flags; | |
153 | ||
154 | /* Flags saying which kinds of debugging dump have been requested. */ | |
155 | ||
156 | int rtl_dump = 0; | |
157 | int rtl_dump_and_exit = 0; | |
158 | int jump_opt_dump = 0; | |
159 | int cse_dump = 0; | |
160 | int loop_dump = 0; | |
161 | int cse2_dump = 0; | |
162 | int flow_dump = 0; | |
163 | int combine_dump = 0; | |
164 | int sched_dump = 0; | |
165 | int local_reg_dump = 0; | |
166 | int global_reg_dump = 0; | |
167 | int sched2_dump = 0; | |
168 | int jump2_opt_dump = 0; | |
169 | int dbr_sched_dump = 0; | |
170 | int flag_print_asm_name = 0; | |
171 | int stack_reg_dump = 0; | |
172 | ||
173 | /* Name for output file of assembly code, specified with -o. */ | |
174 | ||
175 | char *asm_file_name; | |
176 | ||
177 | /* Value of the -G xx switch, and whether it was passed or not. */ | |
178 | int g_switch_value; | |
179 | int g_switch_set; | |
180 | ||
181 | /* Type(s) of debugging information we are producing (if any). | |
182 | See flags.h for the definitions of the different possible | |
183 | types of debugging information. */ | |
184 | enum debug_info_type write_symbols = NO_DEBUG; | |
185 | ||
186 | /* Level of debugging information we are producing. See flags.h | |
187 | for the definitions of the different possible levels. */ | |
188 | enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; | |
189 | ||
f246a305 | 190 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
4291d9c8 | 191 | /* Nonzero means can use our own extensions to DBX format. |
f246a305 | 192 | Relevant only when write_symbols == DBX_DEBUG or XCOFF_DEBUG. */ |
4291d9c8 RS |
193 | int use_gdb_dbx_extensions = 0; |
194 | #endif | |
195 | ||
196 | /* Nonzero means do optimizations. -O. | |
197 | Particular numeric values stand for particular amounts of optimization; | |
198 | thus, -O2 stores 2 here. However, the optimizations beyond the basic | |
199 | ones are not controlled directly by this variable. Instead, they are | |
200 | controlled by individual `flag_...' variables that are defaulted | |
201 | based on this variable. */ | |
202 | ||
203 | int optimize = 0; | |
204 | ||
205 | /* Number of error messages and warning messages so far. */ | |
206 | ||
207 | int errorcount = 0; | |
208 | int warningcount = 0; | |
209 | int sorrycount = 0; | |
210 | ||
211 | /* Pointer to function to compute the name to use to print a declaration. */ | |
212 | ||
213 | char *(*decl_printable_name) (); | |
214 | ||
215 | /* Pointer to function to compute rtl for a language-specific tree code. */ | |
216 | ||
217 | struct rtx_def *(*lang_expand_expr) (); | |
218 | ||
219 | /* Nonzero if generating code to do profiling. */ | |
220 | ||
221 | int profile_flag = 0; | |
222 | ||
223 | /* Nonzero if generating code to do profiling on a line-by-line basis. */ | |
224 | ||
225 | int profile_block_flag; | |
226 | ||
227 | /* Nonzero for -pedantic switch: warn about anything | |
228 | that standard spec forbids. */ | |
229 | ||
230 | int pedantic = 0; | |
231 | ||
232 | /* Temporarily suppress certain warnings. | |
233 | This is set while reading code from a system header file. */ | |
234 | ||
235 | int in_system_header = 0; | |
236 | ||
237 | /* Nonzero means do stupid register allocation. | |
238 | Currently, this is 1 if `optimize' is 0. */ | |
239 | ||
240 | int obey_regdecls = 0; | |
241 | ||
242 | /* Don't print functions as they are compiled and don't print | |
243 | times taken by the various passes. -quiet. */ | |
244 | ||
245 | int quiet_flag = 0; | |
246 | \f | |
247 | /* -f flags. */ | |
248 | ||
249 | /* Nonzero means `char' should be signed. */ | |
250 | ||
251 | int flag_signed_char; | |
252 | ||
253 | /* Nonzero means give an enum type only as many bytes as it needs. */ | |
254 | ||
255 | int flag_short_enums; | |
256 | ||
257 | /* Nonzero for -fcaller-saves: allocate values in regs that need to | |
258 | be saved across function calls, if that produces overall better code. | |
259 | Optional now, so people can test it. */ | |
260 | ||
261 | #ifdef DEFAULT_CALLER_SAVES | |
262 | int flag_caller_saves = 1; | |
263 | #else | |
264 | int flag_caller_saves = 0; | |
265 | #endif | |
266 | ||
267 | /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ | |
268 | ||
269 | int flag_pcc_struct_return = 0; | |
270 | ||
271 | /* Nonzero for -fforce-mem: load memory value into a register | |
272 | before arithmetic on it. This makes better cse but slower compilation. */ | |
273 | ||
274 | int flag_force_mem = 0; | |
275 | ||
276 | /* Nonzero for -fforce-addr: load memory address into a register before | |
277 | reference to memory. This makes better cse but slower compilation. */ | |
278 | ||
279 | int flag_force_addr = 0; | |
280 | ||
281 | /* Nonzero for -fdefer-pop: don't pop args after each function call; | |
282 | instead save them up to pop many calls' args with one insns. */ | |
283 | ||
284 | int flag_defer_pop = 1; | |
285 | ||
286 | /* Nonzero for -ffloat-store: don't allocate floats and doubles | |
287 | in extended-precision registers. */ | |
288 | ||
289 | int flag_float_store = 0; | |
290 | ||
291 | /* Nonzero for -fcse-follow-jumps: | |
292 | have cse follow jumps to do a more extensive job. */ | |
293 | ||
294 | int flag_cse_follow_jumps; | |
295 | ||
8b3686ed RK |
296 | /* Nonzero for -fcse-skip-blocks: |
297 | have cse follow a branch around a block. */ | |
298 | int flag_cse_skip_blocks; | |
299 | ||
4291d9c8 RS |
300 | /* Nonzero for -fexpensive-optimizations: |
301 | perform miscellaneous relatively-expensive optimizations. */ | |
302 | int flag_expensive_optimizations; | |
303 | ||
304 | /* Nonzero for -fthread-jumps: | |
305 | have jump optimize output of loop. */ | |
306 | ||
307 | int flag_thread_jumps; | |
308 | ||
309 | /* Nonzero enables strength-reduction in loop.c. */ | |
310 | ||
311 | int flag_strength_reduce = 0; | |
312 | ||
313 | /* Nonzero enables loop unrolling in unroll.c. Only loops for which the | |
314 | number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, | |
315 | UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are | |
316 | unrolled. */ | |
317 | ||
318 | int flag_unroll_loops; | |
319 | ||
320 | /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. | |
321 | This is generally not a win. */ | |
322 | ||
323 | int flag_unroll_all_loops; | |
324 | ||
325 | /* Nonzero for -fwritable-strings: | |
326 | store string constants in data segment and don't uniquize them. */ | |
327 | ||
328 | int flag_writable_strings = 0; | |
329 | ||
330 | /* Nonzero means don't put addresses of constant functions in registers. | |
331 | Used for compiling the Unix kernel, where strange substitutions are | |
332 | done on the assembly output. */ | |
333 | ||
334 | int flag_no_function_cse = 0; | |
335 | ||
336 | /* Nonzero for -fomit-frame-pointer: | |
337 | don't make a frame pointer in simple functions that don't require one. */ | |
338 | ||
339 | int flag_omit_frame_pointer = 0; | |
340 | ||
341 | /* Nonzero to inhibit use of define_optimization peephole opts. */ | |
342 | ||
343 | int flag_no_peephole = 0; | |
344 | ||
43855b28 JL |
345 | /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math |
346 | operations in the interest of optimization. For example it allows | |
347 | GCC to assume arguments to sqrt are nonnegative numbers, allowing | |
348 | faster code for sqrt to be generated. */ | |
349 | ||
350 | int flag_fast_math = 0; | |
351 | ||
4291d9c8 RS |
352 | /* Nonzero means all references through pointers are volatile. */ |
353 | ||
354 | int flag_volatile; | |
355 | ||
356 | /* Nonzero means just do syntax checking; don't output anything. */ | |
357 | ||
358 | int flag_syntax_only = 0; | |
359 | ||
360 | /* Nonzero means to rerun cse after loop optimization. This increases | |
361 | compilation time about 20% and picks up a few more common expressions. */ | |
362 | ||
363 | static int flag_rerun_cse_after_loop; | |
364 | ||
365 | /* Nonzero for -finline-functions: ok to inline functions that look like | |
366 | good inline candidates. */ | |
367 | ||
368 | int flag_inline_functions; | |
369 | ||
370 | /* Nonzero for -fkeep-inline-functions: even if we make a function | |
371 | go inline everywhere, keep its defintion around for debugging | |
372 | purposes. */ | |
373 | ||
374 | int flag_keep_inline_functions; | |
375 | ||
376 | /* Nonzero means that functions declared `inline' will be treated | |
377 | as `static'. Prevents generation of zillions of copies of unused | |
378 | static inline functions; instead, `inlines' are written out | |
379 | only when actually used. Used in conjunction with -g. Also | |
380 | does the right thing with #pragma interface. */ | |
381 | ||
382 | int flag_no_inline; | |
383 | ||
384 | /* Nonzero means we should be saving declaration info into a .X file. */ | |
385 | ||
386 | int flag_gen_aux_info = 0; | |
387 | ||
f246a305 RS |
388 | /* Specified name of aux-info file. */ |
389 | ||
390 | static char *aux_info_file_name; | |
391 | ||
4291d9c8 RS |
392 | /* Nonzero means make the text shared if supported. */ |
393 | ||
394 | int flag_shared_data; | |
395 | ||
396 | /* Nonzero means schedule into delayed branch slots if supported. */ | |
397 | ||
398 | int flag_delayed_branch; | |
399 | ||
400 | /* Nonzero if we are compiling pure (sharable) code. | |
401 | Value is 1 if we are doing reasonable (i.e. simple | |
402 | offset into offset table) pic. Value is 2 if we can | |
403 | only perform register offsets. */ | |
404 | ||
405 | int flag_pic; | |
406 | ||
0382002b | 407 | /* Nonzero means place uninitialized global data in the bss section. */ |
4291d9c8 RS |
408 | |
409 | int flag_no_common; | |
410 | ||
411 | /* Nonzero means pretend it is OK to examine bits of target floats, | |
412 | even if that isn't true. The resulting code will have incorrect constants, | |
413 | but the same series of instructions that the native compiler would make. */ | |
414 | ||
415 | int flag_pretend_float; | |
416 | ||
417 | /* Nonzero means change certain warnings into errors. | |
418 | Usually these are warnings about failure to conform to some standard. */ | |
419 | ||
420 | int flag_pedantic_errors = 0; | |
421 | ||
422 | /* flag_schedule_insns means schedule insns within basic blocks (before | |
423 | local_alloc). | |
424 | flag_schedule_insns_after_reload means schedule insns after | |
425 | global_alloc. */ | |
426 | ||
427 | int flag_schedule_insns = 0; | |
428 | int flag_schedule_insns_after_reload = 0; | |
429 | ||
430 | /* -finhibit-size-directive inhibits output of .size for ELF. | |
431 | This is used only for compiling crtstuff.c, | |
432 | and it may be extended to other effects | |
433 | needed for crtstuff.c on other systems. */ | |
434 | int flag_inhibit_size_directive = 0; | |
435 | ||
9a631e8e RS |
436 | /* -fverbose-asm causes extra commentary information to be produced in |
437 | the generated assembly code (to make it more readable). This option | |
438 | is generally only of use to those who actually need to read the | |
439 | generated assembly code (perhaps while debugging the compiler itself). */ | |
440 | ||
441 | int flag_verbose_asm = 0; | |
442 | ||
4291d9c8 | 443 | /* -fgnu-linker specifies use of the GNU linker for initializations. |
d68c507d RS |
444 | (Or, more generally, a linker that handles initializations.) |
445 | -fno-gnu-linker says that collect2 will be used. */ | |
446 | #ifdef USE_COLLECT2 | |
447 | int flag_gnu_linker = 0; | |
448 | #else | |
4291d9c8 | 449 | int flag_gnu_linker = 1; |
d68c507d | 450 | #endif |
4291d9c8 RS |
451 | |
452 | /* Table of language-independent -f options. | |
453 | STRING is the option name. VARIABLE is the address of the variable. | |
454 | ON_VALUE is the value to store in VARIABLE | |
455 | if `-fSTRING' is seen as an option. | |
456 | (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ | |
457 | ||
458 | struct { char *string; int *variable; int on_value;} f_options[] = | |
459 | { | |
460 | {"float-store", &flag_float_store, 1}, | |
461 | {"volatile", &flag_volatile, 1}, | |
462 | {"defer-pop", &flag_defer_pop, 1}, | |
463 | {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, | |
464 | {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, | |
8b3686ed | 465 | {"cse-skip-blocks", &flag_cse_skip_blocks, 1}, |
4291d9c8 RS |
466 | {"expensive-optimizations", &flag_expensive_optimizations, 1}, |
467 | {"thread-jumps", &flag_thread_jumps, 1}, | |
468 | {"strength-reduce", &flag_strength_reduce, 1}, | |
469 | {"unroll-loops", &flag_unroll_loops, 1}, | |
470 | {"unroll-all-loops", &flag_unroll_all_loops, 1}, | |
471 | {"writable-strings", &flag_writable_strings, 1}, | |
472 | {"peephole", &flag_no_peephole, 0}, | |
473 | {"force-mem", &flag_force_mem, 1}, | |
474 | {"force-addr", &flag_force_addr, 1}, | |
475 | {"function-cse", &flag_no_function_cse, 0}, | |
476 | {"inline-functions", &flag_inline_functions, 1}, | |
477 | {"keep-inline-functions", &flag_keep_inline_functions, 1}, | |
478 | {"inline", &flag_no_inline, 0}, | |
479 | {"syntax-only", &flag_syntax_only, 1}, | |
4291d9c8 RS |
480 | {"shared-data", &flag_shared_data, 1}, |
481 | {"caller-saves", &flag_caller_saves, 1}, | |
482 | {"pcc-struct-return", &flag_pcc_struct_return, 1}, | |
483 | {"delayed-branch", &flag_delayed_branch, 1}, | |
484 | {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1}, | |
485 | {"pretend-float", &flag_pretend_float, 1}, | |
486 | {"schedule-insns", &flag_schedule_insns, 1}, | |
487 | {"schedule-insns2", &flag_schedule_insns_after_reload, 1}, | |
488 | {"pic", &flag_pic, 1}, | |
489 | {"PIC", &flag_pic, 2}, | |
43855b28 | 490 | {"fast-math", &flag_fast_math, 1}, |
4291d9c8 RS |
491 | {"common", &flag_no_common, 0}, |
492 | {"inhibit-size-directive", &flag_inhibit_size_directive, 1}, | |
9a631e8e | 493 | {"verbose-asm", &flag_verbose_asm, 1}, |
4291d9c8 RS |
494 | {"gnu-linker", &flag_gnu_linker, 1} |
495 | }; | |
496 | \f | |
497 | /* Options controlling warnings */ | |
498 | ||
499 | /* Don't print warning messages. -w. */ | |
500 | ||
501 | int inhibit_warnings = 0; | |
502 | ||
503 | /* Print various extra warnings. -W. */ | |
504 | ||
505 | int extra_warnings = 0; | |
506 | ||
507 | /* Treat warnings as errors. -Werror. */ | |
508 | ||
509 | int warnings_are_errors = 0; | |
510 | ||
511 | /* Nonzero to warn about unused local variables. */ | |
512 | ||
513 | int warn_unused; | |
514 | ||
515 | /* Nonzero to warn about variables used before they are initialized. */ | |
516 | ||
517 | int warn_uninitialized; | |
518 | ||
519 | /* Nonzero means warn about all declarations which shadow others. */ | |
520 | ||
521 | int warn_shadow; | |
522 | ||
523 | /* Warn if a switch on an enum fails to have a case for every enum value. */ | |
524 | ||
525 | int warn_switch; | |
526 | ||
527 | /* Nonzero means warn about function definitions that default the return type | |
528 | or that use a null return and have a return-type other than void. */ | |
529 | ||
530 | int warn_return_type; | |
531 | ||
532 | /* Nonzero means warn about pointer casts that increase the required | |
533 | alignment of the target type (and might therefore lead to a crash | |
534 | due to a misaligned access). */ | |
535 | ||
536 | int warn_cast_align; | |
537 | ||
538 | /* Nonzero means warn about any identifiers that match in the first N | |
539 | characters. The value N is in `id_clash_len'. */ | |
540 | ||
541 | int warn_id_clash; | |
542 | int id_clash_len; | |
543 | ||
544 | /* Nonzero means warn if inline function is too large. */ | |
545 | ||
546 | int warn_inline; | |
547 | ||
548 | /* Warn if a function returns an aggregate, | |
549 | since there are often incompatible calling conventions for doing this. */ | |
550 | ||
551 | int warn_aggregate_return; | |
552 | ||
553 | /* Likewise for -W. */ | |
554 | ||
555 | struct { char *string; int *variable; int on_value;} W_options[] = | |
556 | { | |
557 | {"unused", &warn_unused, 1}, | |
558 | {"error", &warnings_are_errors, 1}, | |
559 | {"shadow", &warn_shadow, 1}, | |
560 | {"switch", &warn_switch, 1}, | |
561 | {"return-type", &warn_return_type, 1}, | |
562 | {"aggregate-return", &warn_aggregate_return, 1}, | |
563 | {"cast-align", &warn_cast_align, 1}, | |
f246a305 RS |
564 | {"uninitialized", &warn_uninitialized, 1}, |
565 | {"inline", &warn_inline, 1} | |
4291d9c8 RS |
566 | }; |
567 | \f | |
568 | /* Output files for assembler code (real compiler output) | |
569 | and debugging dumps. */ | |
570 | ||
571 | FILE *asm_out_file; | |
572 | FILE *aux_info_file; | |
573 | FILE *rtl_dump_file; | |
574 | FILE *jump_opt_dump_file; | |
575 | FILE *cse_dump_file; | |
576 | FILE *loop_dump_file; | |
577 | FILE *cse2_dump_file; | |
578 | FILE *flow_dump_file; | |
579 | FILE *combine_dump_file; | |
580 | FILE *sched_dump_file; | |
581 | FILE *local_reg_dump_file; | |
582 | FILE *global_reg_dump_file; | |
583 | FILE *sched2_dump_file; | |
584 | FILE *jump2_opt_dump_file; | |
585 | FILE *dbr_sched_dump_file; | |
586 | FILE *stack_reg_dump_file; | |
587 | ||
588 | /* Time accumulators, to count the total time spent in various passes. */ | |
589 | ||
590 | int parse_time; | |
591 | int varconst_time; | |
592 | int integration_time; | |
593 | int jump_time; | |
594 | int cse_time; | |
595 | int loop_time; | |
596 | int cse2_time; | |
597 | int flow_time; | |
598 | int combine_time; | |
599 | int sched_time; | |
600 | int local_alloc_time; | |
601 | int global_alloc_time; | |
602 | int sched2_time; | |
603 | int dbr_sched_time; | |
604 | int shorten_branch_time; | |
605 | int stack_reg_time; | |
606 | int final_time; | |
607 | int symout_time; | |
608 | int dump_time; | |
609 | \f | |
610 | /* Return time used so far, in microseconds. */ | |
611 | ||
612 | int | |
613 | get_run_time () | |
614 | { | |
615 | #ifdef USG | |
616 | struct tms tms; | |
617 | #else | |
618 | #ifndef VMS | |
619 | struct rusage rusage; | |
620 | #else /* VMS */ | |
621 | struct | |
622 | { | |
623 | int proc_user_time; | |
624 | int proc_system_time; | |
625 | int child_user_time; | |
626 | int child_system_time; | |
627 | } vms_times; | |
628 | #endif | |
629 | #endif | |
630 | ||
631 | if (quiet_flag) | |
632 | return 0; | |
633 | ||
634 | #ifdef USG | |
635 | times (&tms); | |
636 | return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); | |
637 | #else | |
638 | #ifndef VMS | |
639 | getrusage (0, &rusage); | |
640 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
641 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
642 | #else /* VMS */ | |
643 | times (&vms_times); | |
644 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
645 | #endif | |
646 | #endif | |
647 | } | |
648 | ||
649 | #define TIMEVAR(VAR, BODY) \ | |
650 | do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) | |
651 | ||
652 | void | |
653 | print_time (str, total) | |
654 | char *str; | |
655 | int total; | |
656 | { | |
657 | fprintf (stderr, | |
658 | "time in %s: %d.%06d\n", | |
659 | str, total / 1000000, total % 1000000); | |
660 | } | |
661 | ||
662 | /* Count an error or warning. Return 1 if the message should be printed. */ | |
663 | ||
664 | int | |
665 | count_error (warningp) | |
666 | int warningp; | |
667 | { | |
668 | if (warningp && inhibit_warnings) | |
669 | return 0; | |
670 | ||
671 | if (warningp && !warnings_are_errors) | |
672 | warningcount++; | |
673 | else | |
674 | { | |
675 | static int warning_message = 0; | |
676 | ||
677 | if (warningp && !warning_message) | |
678 | { | |
679 | fprintf (stderr, "%s: warnings being treated as errors\n", progname); | |
680 | warning_message = 1; | |
681 | } | |
682 | errorcount++; | |
683 | } | |
684 | ||
685 | return 1; | |
686 | } | |
687 | ||
688 | /* Print a fatal error message. NAME is the text. | |
689 | Also include a system error message based on `errno'. */ | |
690 | ||
691 | void | |
692 | pfatal_with_name (name) | |
693 | char *name; | |
694 | { | |
695 | fprintf (stderr, "%s: ", progname); | |
696 | perror (name); | |
697 | exit (35); | |
698 | } | |
699 | ||
700 | void | |
701 | fatal_io_error (name) | |
702 | char *name; | |
703 | { | |
704 | fprintf (stderr, "%s: %s: I/O error\n", progname, name); | |
705 | exit (35); | |
706 | } | |
707 | ||
708 | void | |
709 | fatal (s, v) | |
710 | char *s; | |
711 | int v; | |
712 | { | |
713 | error (s, v); | |
714 | exit (34); | |
715 | } | |
716 | ||
717 | /* Called to give a better error message when we don't have an insn to match | |
718 | what we are looking for or if the insn's constraints aren't satisfied, | |
719 | rather than just calling abort(). */ | |
720 | ||
721 | void | |
722 | fatal_insn_not_found (insn) | |
723 | rtx insn; | |
724 | { | |
725 | if (INSN_CODE (insn) < 0) | |
726 | error ("internal error--unrecognizable insn:", 0); | |
727 | else | |
728 | error ("internal error--insn does not satisfy its constraints:", 0); | |
729 | debug_rtx (insn); | |
730 | if (asm_out_file) | |
731 | fflush (asm_out_file); | |
732 | if (aux_info_file) | |
733 | fflush (aux_info_file); | |
734 | if (rtl_dump_file) | |
735 | fflush (rtl_dump_file); | |
736 | if (jump_opt_dump_file) | |
737 | fflush (jump_opt_dump_file); | |
738 | if (cse_dump_file) | |
739 | fflush (cse_dump_file); | |
740 | if (loop_dump_file) | |
741 | fflush (loop_dump_file); | |
742 | if (cse2_dump_file) | |
743 | fflush (cse2_dump_file); | |
744 | if (flow_dump_file) | |
745 | fflush (flow_dump_file); | |
746 | if (combine_dump_file) | |
747 | fflush (combine_dump_file); | |
748 | if (sched_dump_file) | |
749 | fflush (sched_dump_file); | |
750 | if (local_reg_dump_file) | |
751 | fflush (local_reg_dump_file); | |
752 | if (global_reg_dump_file) | |
753 | fflush (global_reg_dump_file); | |
754 | if (sched2_dump_file) | |
755 | fflush (sched2_dump_file); | |
756 | if (jump2_opt_dump_file) | |
757 | fflush (jump2_opt_dump_file); | |
758 | if (dbr_sched_dump_file) | |
759 | fflush (dbr_sched_dump_file); | |
760 | if (stack_reg_dump_file) | |
761 | fflush (stack_reg_dump_file); | |
762 | abort (); | |
763 | } | |
764 | ||
765 | /* This is the default decl_printable_name function. */ | |
766 | ||
767 | static char * | |
768 | decl_name (decl, kind) | |
769 | tree decl; | |
770 | char **kind; | |
771 | { | |
772 | return IDENTIFIER_POINTER (DECL_NAME (decl)); | |
773 | } | |
774 | \f | |
775 | static int need_error_newline; | |
776 | ||
777 | /* Function of last error message; | |
778 | more generally, function such that if next error message is in it | |
779 | then we don't have to mention the function name. */ | |
780 | static tree last_error_function = NULL; | |
781 | ||
782 | /* Used to detect when input_file_stack has changed since last described. */ | |
783 | static int last_error_tick; | |
784 | ||
785 | /* Called when the start of a function definition is parsed, | |
786 | this function prints on stderr the name of the function. */ | |
787 | ||
788 | void | |
789 | announce_function (decl) | |
790 | tree decl; | |
791 | { | |
792 | if (! quiet_flag) | |
793 | { | |
794 | char *junk; | |
795 | if (rtl_dump_and_exit) | |
796 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
797 | else | |
798 | fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk)); | |
799 | fflush (stderr); | |
800 | need_error_newline = 1; | |
801 | last_error_function = current_function_decl; | |
802 | } | |
803 | } | |
804 | ||
805 | /* Prints out, if necessary, the name of the current function | |
806 | which caused an error. Called from all error and warning functions. */ | |
807 | ||
808 | void | |
809 | report_error_function (file) | |
810 | char *file; | |
811 | { | |
812 | struct file_stack *p; | |
813 | ||
814 | if (need_error_newline) | |
815 | { | |
816 | fprintf (stderr, "\n"); | |
817 | need_error_newline = 0; | |
818 | } | |
819 | ||
820 | if (last_error_function != current_function_decl) | |
821 | { | |
822 | char *kind = "function"; | |
823 | if (current_function_decl != 0 | |
824 | && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) | |
825 | kind = "method"; | |
826 | ||
827 | if (file) | |
828 | fprintf (stderr, "%s: ", file); | |
829 | ||
830 | if (current_function_decl == NULL) | |
831 | fprintf (stderr, "At top level:\n"); | |
832 | else | |
833 | { | |
834 | char *name = (*decl_printable_name) (current_function_decl, &kind); | |
835 | fprintf (stderr, "In %s `%s':\n", kind, name); | |
836 | } | |
837 | ||
838 | last_error_function = current_function_decl; | |
839 | } | |
840 | if (input_file_stack && input_file_stack->next != 0 | |
841 | && input_file_stack_tick != last_error_tick) | |
842 | { | |
843 | fprintf (stderr, "In file included"); | |
844 | for (p = input_file_stack->next; p; p = p->next) | |
845 | { | |
846 | fprintf (stderr, " from %s:%d", p->name, p->line); | |
847 | if (p->next) | |
848 | fprintf (stderr, ","); | |
849 | } | |
850 | fprintf (stderr, ":\n"); | |
851 | last_error_tick = input_file_stack_tick; | |
852 | } | |
853 | } | |
854 | ||
855 | /* Report an error at the current line number. | |
856 | S and V are a string and an arg for `printf'. */ | |
857 | ||
858 | void | |
859 | error (s, v, v2) | |
860 | char *s; | |
861 | int v; /* @@also used as pointer */ | |
862 | int v2; /* @@also used as pointer */ | |
863 | { | |
864 | error_with_file_and_line (input_filename, lineno, s, v, v2); | |
865 | } | |
866 | ||
867 | /* Report an error at line LINE of file FILE. | |
868 | S and V are a string and an arg for `printf'. */ | |
869 | ||
870 | void | |
871 | error_with_file_and_line (file, line, s, v, v2) | |
872 | char *file; | |
873 | int line; | |
874 | char *s; | |
875 | int v; | |
876 | int v2; | |
877 | { | |
878 | count_error (0); | |
879 | ||
880 | report_error_function (file); | |
881 | ||
882 | if (file) | |
883 | fprintf (stderr, "%s:%d: ", file, line); | |
884 | else | |
885 | fprintf (stderr, "%s: ", progname); | |
886 | fprintf (stderr, s, v, v2); | |
887 | fprintf (stderr, "\n"); | |
888 | } | |
889 | ||
890 | /* Report an error at the declaration DECL. | |
891 | S and V are a string and an arg which uses %s to substitute the declaration name. */ | |
892 | ||
893 | void | |
894 | error_with_decl (decl, s, v) | |
895 | tree decl; | |
896 | char *s; | |
897 | int v; | |
898 | { | |
899 | char *junk; | |
900 | count_error (0); | |
901 | ||
902 | report_error_function (DECL_SOURCE_FILE (decl)); | |
903 | ||
904 | fprintf (stderr, "%s:%d: ", | |
905 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
906 | ||
907 | if (DECL_NAME (decl)) | |
908 | fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v); | |
909 | else | |
910 | fprintf (stderr, s, "((anonymous))", v); | |
911 | fprintf (stderr, "\n"); | |
912 | } | |
913 | ||
914 | /* Report an error at the line number of the insn INSN. | |
915 | S and V are a string and an arg for `printf'. | |
916 | This is used only when INSN is an `asm' with operands, | |
917 | and each ASM_OPERANDS records its own source file and line. */ | |
918 | ||
919 | void | |
920 | error_for_asm (insn, s, v, v2) | |
921 | rtx insn; | |
922 | char *s; | |
923 | int v; /* @@also used as pointer */ | |
924 | int v2; /* @@also used as pointer */ | |
925 | { | |
926 | char *filename; | |
927 | int line; | |
928 | rtx body = PATTERN (insn); | |
929 | rtx asmop; | |
930 | ||
931 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
932 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
933 | asmop = SET_SRC (body); | |
934 | else if (GET_CODE (body) == ASM_OPERANDS) | |
935 | asmop = body; | |
936 | else if (GET_CODE (body) == PARALLEL | |
937 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
938 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
939 | else if (GET_CODE (body) == PARALLEL | |
940 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
941 | asmop = XVECEXP (body, 0, 0); | |
942 | ||
943 | filename = ASM_OPERANDS_SOURCE_FILE (asmop); | |
944 | line = ASM_OPERANDS_SOURCE_LINE (asmop); | |
945 | ||
946 | error_with_file_and_line (filename, line, s, v, v2); | |
947 | } | |
948 | ||
949 | /* Report a warning at line LINE. | |
950 | S and V are a string and an arg for `printf'. */ | |
951 | ||
952 | void | |
953 | warning_with_file_and_line (file, line, s, v, v2, v3) | |
954 | char *file; | |
955 | int line; | |
956 | char *s; | |
957 | int v; | |
958 | int v2; | |
959 | int v3; | |
960 | { | |
961 | if (count_error (1) == 0) | |
962 | return; | |
963 | ||
964 | report_error_function (file); | |
965 | ||
966 | if (file) | |
967 | fprintf (stderr, "%s:%d: ", file, line); | |
968 | else | |
969 | fprintf (stderr, "%s: ", progname); | |
970 | ||
971 | fprintf (stderr, "warning: "); | |
972 | fprintf (stderr, s, v, v2, v3); | |
973 | fprintf (stderr, "\n"); | |
974 | } | |
975 | ||
976 | /* Report a warning at the current line number. | |
977 | S and V are a string and an arg for `printf'. */ | |
978 | ||
979 | void | |
980 | warning (s, v, v2, v3) | |
981 | char *s; | |
982 | int v; /* @@also used as pointer */ | |
983 | int v2; | |
984 | int v3; | |
985 | { | |
986 | warning_with_file_and_line (input_filename, lineno, s, v, v2, v3); | |
987 | } | |
988 | ||
989 | /* Report a warning at the declaration DECL. | |
990 | S is string which uses %s to substitute the declaration name. | |
991 | V is a second parameter that S can refer to. */ | |
992 | ||
993 | void | |
994 | warning_with_decl (decl, s, v) | |
995 | tree decl; | |
996 | char *s; | |
997 | int v; | |
998 | { | |
999 | char *junk; | |
1000 | ||
1001 | if (count_error (1) == 0) | |
1002 | return; | |
1003 | ||
1004 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1005 | ||
1006 | fprintf (stderr, "%s:%d: ", | |
1007 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
1008 | ||
1009 | fprintf (stderr, "warning: "); | |
1010 | if (DECL_NAME (decl)) | |
1011 | fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v); | |
1012 | else | |
1013 | fprintf (stderr, s, "((anonymous))", v); | |
1014 | fprintf (stderr, "\n"); | |
1015 | } | |
1016 | ||
1017 | /* Report a warning at the line number of the insn INSN. | |
1018 | S and V are a string and an arg for `printf'. | |
1019 | This is used only when INSN is an `asm' with operands, | |
1020 | and each ASM_OPERANDS records its own source file and line. */ | |
1021 | ||
1022 | void | |
1023 | warning_for_asm (insn, s, v, v2) | |
1024 | rtx insn; | |
1025 | char *s; | |
1026 | int v; /* @@also used as pointer */ | |
1027 | int v2; /* @@also used as pointer */ | |
1028 | { | |
1029 | char *filename; | |
1030 | int line; | |
1031 | rtx body = PATTERN (insn); | |
1032 | rtx asmop; | |
1033 | ||
1034 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
1035 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
1036 | asmop = SET_SRC (body); | |
1037 | else if (GET_CODE (body) == ASM_OPERANDS) | |
1038 | asmop = body; | |
1039 | else if (GET_CODE (body) == PARALLEL | |
1040 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
1041 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
1042 | else if (GET_CODE (body) == PARALLEL | |
1043 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
1044 | asmop = XVECEXP (body, 0, 0); | |
1045 | ||
1046 | filename = ASM_OPERANDS_SOURCE_FILE (asmop); | |
1047 | line = ASM_OPERANDS_SOURCE_LINE (asmop); | |
1048 | ||
1049 | warning_with_file_and_line (filename, line, s, v, v2); | |
1050 | } | |
1051 | \f | |
1052 | /* These functions issue either warnings or errors depending on | |
1053 | -pedantic-errors. */ | |
1054 | ||
1055 | void | |
1056 | pedwarn (s, v, v2) | |
1057 | char *s; | |
1058 | int v; /* @@also used as pointer */ | |
1059 | int v2; | |
1060 | { | |
1061 | if (flag_pedantic_errors) | |
1062 | error (s, v, v2); | |
1063 | else | |
1064 | warning (s, v, v2); | |
1065 | } | |
1066 | ||
1067 | void | |
1068 | pedwarn_with_decl (decl, s, v) | |
1069 | tree decl; | |
1070 | char *s; | |
1071 | int v; | |
1072 | { | |
1073 | if (flag_pedantic_errors) | |
1074 | error_with_decl (decl, s, v); | |
1075 | else | |
1076 | warning_with_decl (decl, s, v); | |
1077 | } | |
1078 | ||
1079 | void | |
1080 | pedwarn_with_file_and_line (file, line, s, v, v2) | |
1081 | char *file; | |
1082 | int line; | |
1083 | char *s; | |
1084 | int v; | |
1085 | int v2; | |
1086 | { | |
1087 | if (flag_pedantic_errors) | |
1088 | error_with_file_and_line (file, line, s, v, v2); | |
1089 | else | |
1090 | warning_with_file_and_line (file, line, s, v, v2); | |
1091 | } | |
1092 | ||
1093 | /* Apologize for not implementing some feature. | |
1094 | S, V, and V2 are a string and args for `printf'. */ | |
1095 | ||
1096 | void | |
1097 | sorry (s, v, v2) | |
1098 | char *s; | |
1099 | int v, v2; | |
1100 | { | |
1101 | sorrycount++; | |
1102 | if (input_filename) | |
1103 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1104 | else | |
1105 | fprintf (stderr, "%s: ", progname); | |
1106 | ||
1107 | fprintf (stderr, "sorry, not implemented: "); | |
1108 | fprintf (stderr, s, v, v2); | |
1109 | fprintf (stderr, "\n"); | |
1110 | } | |
1111 | ||
1112 | /* Apologize for not implementing some feature, then quit. | |
1113 | S, V, and V2 are a string and args for `printf'. */ | |
1114 | ||
1115 | void | |
1116 | really_sorry (s, v, v2) | |
1117 | char *s; | |
1118 | int v, v2; | |
1119 | { | |
1120 | if (input_filename) | |
1121 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1122 | else | |
1123 | fprintf (stderr, "c++: "); | |
1124 | ||
1125 | fprintf (stderr, "sorry, not implemented: "); | |
1126 | fprintf (stderr, s, v, v2); | |
1127 | fatal (" (fatal)\n"); | |
1128 | } | |
1129 | \f | |
1130 | /* More 'friendly' abort that prints the line and file. | |
1131 | config.h can #define abort fancy_abort if you like that sort of thing. | |
1132 | ||
1133 | I don't think this is actually a good idea. | |
1134 | Other sorts of crashes will look a certain way. | |
1135 | It is a good thing if crashes from calling abort look the same way. | |
1136 | -- RMS */ | |
1137 | ||
1138 | void | |
1139 | fancy_abort () | |
1140 | { | |
1141 | fatal ("internal gcc abort"); | |
1142 | } | |
1143 | ||
1144 | /* This calls abort and is used to avoid problems when abort if a macro. | |
1145 | It is used when we need to pass the address of abort. */ | |
1146 | ||
1147 | void | |
1148 | do_abort () | |
1149 | { | |
1150 | abort (); | |
1151 | } | |
1152 | ||
1153 | /* When `malloc.c' is compiled with `rcheck' defined, | |
1154 | it calls this function to report clobberage. */ | |
1155 | ||
1156 | void | |
1157 | botch (s) | |
1158 | { | |
1159 | abort (); | |
1160 | } | |
1161 | ||
1162 | /* Same as `malloc' but report error if no memory available. */ | |
1163 | ||
4b980e20 | 1164 | char * |
4291d9c8 RS |
1165 | xmalloc (size) |
1166 | unsigned size; | |
1167 | { | |
4b980e20 | 1168 | register char *value = (char *) malloc (size); |
4291d9c8 RS |
1169 | if (value == 0) |
1170 | fatal ("virtual memory exhausted"); | |
1171 | return value; | |
1172 | } | |
1173 | ||
1174 | /* Same as `realloc' but report error if no memory available. */ | |
1175 | ||
4b980e20 | 1176 | char * |
4291d9c8 RS |
1177 | xrealloc (ptr, size) |
1178 | char *ptr; | |
1179 | int size; | |
1180 | { | |
4b980e20 | 1181 | char *result = (char *) realloc (ptr, size); |
4291d9c8 RS |
1182 | if (!result) |
1183 | fatal ("virtual memory exhausted"); | |
1184 | return result; | |
1185 | } | |
1186 | \f | |
1187 | /* Return the logarithm of X, base 2, considering X unsigned, | |
1188 | if X is a power of 2. Otherwise, returns -1. */ | |
1189 | ||
1190 | int | |
1191 | exact_log2 (x) | |
1192 | register unsigned int x; | |
1193 | { | |
1194 | register int log = 0; | |
1195 | /* Test for 0 or a power of 2. */ | |
1196 | if (x == 0 || x != (x & -x)) | |
1197 | return -1; | |
1198 | while ((x >>= 1) != 0) | |
1199 | log++; | |
1200 | return log; | |
1201 | } | |
1202 | ||
1203 | /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. | |
1204 | If X is 0, return -1. */ | |
1205 | ||
1206 | int | |
1207 | floor_log2 (x) | |
1208 | register unsigned int x; | |
1209 | { | |
1210 | register int log = -1; | |
1211 | while (x != 0) | |
1212 | log++, | |
1213 | x >>= 1; | |
1214 | return log; | |
1215 | } | |
1216 | ||
1217 | int float_handled; | |
1218 | jmp_buf float_handler; | |
1219 | ||
1220 | /* Specify where to longjmp to when a floating arithmetic error happens. | |
1221 | If HANDLER is 0, it means don't handle the errors any more. */ | |
1222 | ||
1223 | void | |
1224 | set_float_handler (handler) | |
1225 | jmp_buf handler; | |
1226 | { | |
1227 | float_handled = (handler != 0); | |
1228 | if (handler) | |
1229 | bcopy (handler, float_handler, sizeof (float_handler)); | |
1230 | } | |
1231 | ||
1232 | /* Signals actually come here. */ | |
1233 | ||
1234 | static void | |
1235 | float_signal (signo) | |
1236 | /* If this is missing, some compilers complain. */ | |
1237 | int signo; | |
1238 | { | |
1239 | if (float_handled == 0) | |
1240 | abort (); | |
1241 | #if defined (USG) || defined (hpux) | |
1242 | signal (SIGFPE, float_signal); /* re-enable the signal catcher */ | |
1243 | #endif | |
1244 | float_handled = 0; | |
1245 | signal (SIGFPE, float_signal); | |
1246 | longjmp (float_handler, 1); | |
1247 | } | |
1248 | ||
1249 | /* Handler for SIGPIPE. */ | |
1250 | ||
1251 | static void | |
1252 | pipe_closed (signo) | |
1253 | /* If this is missing, some compilers complain. */ | |
1254 | int signo; | |
1255 | { | |
1256 | fatal ("output pipe has been closed"); | |
1257 | } | |
1258 | ||
1259 | /* Strip off a legitimate source ending from the input string NAME of | |
1260 | length LEN. */ | |
1261 | ||
1262 | void | |
1263 | strip_off_ending (name, len) | |
1264 | char *name; | |
1265 | int len; | |
1266 | { | |
1267 | if (len > 2 && ! strcmp (".c", name + len - 2)) | |
1268 | name[len - 2] = 0; | |
1269 | else if (len > 2 && ! strcmp (".m", name + len - 2)) | |
1270 | name[len - 2] = 0; | |
1271 | else if (len > 2 && ! strcmp (".i", name + len - 2)) | |
1272 | name[len - 2] = 0; | |
1273 | else if (len > 3 && ! strcmp (".ii", name + len - 3)) | |
1274 | name[len - 3] = 0; | |
1275 | else if (len > 3 && ! strcmp (".co", name + len - 3)) | |
1276 | name[len - 3] = 0; | |
1277 | else if (len > 3 && ! strcmp (".cc", name + len - 3)) | |
1278 | name[len - 3] = 0; | |
9cc00e36 RS |
1279 | else if (len > 2 && ! strcmp (".C", name + len - 2)) |
1280 | name[len - 2] = 0; | |
1281 | else if (len > 4 && ! strcmp (".cxx", name + len - 4)) | |
1282 | name[len - 4] = 0; | |
4291d9c8 RS |
1283 | else if (len > 2 && ! strcmp (".f", name + len - 2)) |
1284 | name[len - 2] = 0; | |
1285 | else if (len > 4 && ! strcmp (".ada", name + len - 4)) | |
1286 | name[len - 4] = 0; | |
1287 | } | |
1288 | ||
1289 | /* Output a file name in the form wanted by System V. */ | |
1290 | ||
1291 | void | |
1292 | output_file_directive (asm_file, input_name) | |
1293 | FILE *asm_file; | |
1294 | char *input_name; | |
1295 | { | |
1296 | int len = strlen (input_name); | |
1297 | char *na = input_name + len; | |
1298 | ||
1299 | /* NA gets INPUT_NAME sans directory names. */ | |
1300 | while (na > input_name) | |
1301 | { | |
1302 | if (na[-1] == '/') | |
1303 | break; | |
1304 | na--; | |
1305 | } | |
1306 | ||
1307 | #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME | |
1308 | ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); | |
1309 | #else | |
1310 | #ifdef ASM_OUTPUT_SOURCE_FILENAME | |
1311 | ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); | |
1312 | #else | |
1313 | fprintf (asm_file, "\t.file\t\"%s\"\n", na); | |
1314 | #endif | |
1315 | #endif | |
1316 | } | |
1317 | \f | |
1318 | /* Compile an entire file of output from cpp, named NAME. | |
1319 | Write a file of assembly output and various debugging dumps. */ | |
1320 | ||
1321 | static void | |
1322 | compile_file (name) | |
1323 | char *name; | |
1324 | { | |
1325 | tree globals; | |
1326 | int start_time; | |
1327 | int dump_base_name_length; | |
4291d9c8 RS |
1328 | |
1329 | int name_specified = name != 0; | |
1330 | ||
1331 | if (dump_base_name == 0) | |
1332 | dump_base_name = name ? name : "gccdump"; | |
1333 | dump_base_name_length = strlen (dump_base_name); | |
1334 | ||
1335 | parse_time = 0; | |
1336 | varconst_time = 0; | |
1337 | integration_time = 0; | |
1338 | jump_time = 0; | |
1339 | cse_time = 0; | |
1340 | loop_time = 0; | |
1341 | cse2_time = 0; | |
1342 | flow_time = 0; | |
1343 | combine_time = 0; | |
1344 | sched_time = 0; | |
1345 | local_alloc_time = 0; | |
1346 | global_alloc_time = 0; | |
1347 | sched2_time = 0; | |
1348 | dbr_sched_time = 0; | |
1349 | shorten_branch_time = 0; | |
1350 | stack_reg_time = 0; | |
1351 | final_time = 0; | |
1352 | symout_time = 0; | |
1353 | dump_time = 0; | |
1354 | ||
1355 | /* Open input file. */ | |
1356 | ||
1357 | if (name == 0 || !strcmp (name, "-")) | |
1358 | { | |
1359 | finput = stdin; | |
1360 | name = "stdin"; | |
1361 | } | |
1362 | else | |
1363 | finput = fopen (name, "r"); | |
1364 | if (finput == 0) | |
1365 | pfatal_with_name (name); | |
1366 | ||
282ea52a | 1367 | #ifdef IO_BUFFER_SIZE |
d7cedf4b | 1368 | setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); |
282ea52a RS |
1369 | #endif |
1370 | ||
4291d9c8 RS |
1371 | /* Initialize data in various passes. */ |
1372 | ||
1373 | init_obstacks (); | |
1374 | init_tree_codes (); | |
1375 | init_lex (); | |
1376 | init_rtl (); | |
1377 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
1378 | || debug_info_level == DINFO_LEVEL_VERBOSE); | |
1379 | init_decl_processing (); | |
1380 | init_optabs (); | |
1381 | init_stmt (); | |
1382 | init_expmed (); | |
4fa52007 | 1383 | init_expr_once (); |
4291d9c8 RS |
1384 | init_loop (); |
1385 | init_reload (); | |
1386 | ||
1387 | if (flag_caller_saves) | |
1388 | init_caller_save (); | |
1389 | ||
f246a305 RS |
1390 | /* If auxiliary info generation is desired, open the output file. |
1391 | This goes in the same directory as the source file--unlike | |
1392 | all the other output files. */ | |
4291d9c8 RS |
1393 | if (flag_gen_aux_info) |
1394 | { | |
4291d9c8 RS |
1395 | aux_info_file = fopen (aux_info_file_name, "w"); |
1396 | if (aux_info_file == 0) | |
1397 | pfatal_with_name (aux_info_file_name); | |
1398 | } | |
1399 | ||
1400 | /* If rtl dump desired, open the output file. */ | |
1401 | if (rtl_dump) | |
1402 | { | |
1403 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1404 | strcpy (dumpname, dump_base_name); | |
1405 | strcat (dumpname, ".rtl"); | |
1406 | rtl_dump_file = fopen (dumpname, "w"); | |
1407 | if (rtl_dump_file == 0) | |
1408 | pfatal_with_name (dumpname); | |
1409 | } | |
1410 | ||
1411 | /* If jump_opt dump desired, open the output file. */ | |
1412 | if (jump_opt_dump) | |
1413 | { | |
1414 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1415 | strcpy (dumpname, dump_base_name); | |
1416 | strcat (dumpname, ".jump"); | |
1417 | jump_opt_dump_file = fopen (dumpname, "w"); | |
1418 | if (jump_opt_dump_file == 0) | |
1419 | pfatal_with_name (dumpname); | |
1420 | } | |
1421 | ||
1422 | /* If cse dump desired, open the output file. */ | |
1423 | if (cse_dump) | |
1424 | { | |
1425 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1426 | strcpy (dumpname, dump_base_name); | |
1427 | strcat (dumpname, ".cse"); | |
1428 | cse_dump_file = fopen (dumpname, "w"); | |
1429 | if (cse_dump_file == 0) | |
1430 | pfatal_with_name (dumpname); | |
1431 | } | |
1432 | ||
1433 | /* If loop dump desired, open the output file. */ | |
1434 | if (loop_dump) | |
1435 | { | |
1436 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1437 | strcpy (dumpname, dump_base_name); | |
1438 | strcat (dumpname, ".loop"); | |
1439 | loop_dump_file = fopen (dumpname, "w"); | |
1440 | if (loop_dump_file == 0) | |
1441 | pfatal_with_name (dumpname); | |
1442 | } | |
1443 | ||
1444 | /* If cse2 dump desired, open the output file. */ | |
1445 | if (cse2_dump) | |
1446 | { | |
1447 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1448 | strcpy (dumpname, dump_base_name); | |
1449 | strcat (dumpname, ".cse2"); | |
1450 | cse2_dump_file = fopen (dumpname, "w"); | |
1451 | if (cse2_dump_file == 0) | |
1452 | pfatal_with_name (dumpname); | |
1453 | } | |
1454 | ||
1455 | /* If flow dump desired, open the output file. */ | |
1456 | if (flow_dump) | |
1457 | { | |
1458 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1459 | strcpy (dumpname, dump_base_name); | |
1460 | strcat (dumpname, ".flow"); | |
1461 | flow_dump_file = fopen (dumpname, "w"); | |
1462 | if (flow_dump_file == 0) | |
1463 | pfatal_with_name (dumpname); | |
1464 | } | |
1465 | ||
1466 | /* If combine dump desired, open the output file. */ | |
1467 | if (combine_dump) | |
1468 | { | |
1469 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 10); | |
1470 | strcpy (dumpname, dump_base_name); | |
1471 | strcat (dumpname, ".combine"); | |
1472 | combine_dump_file = fopen (dumpname, "w"); | |
1473 | if (combine_dump_file == 0) | |
1474 | pfatal_with_name (dumpname); | |
1475 | } | |
1476 | ||
1477 | /* If scheduling dump desired, open the output file. */ | |
1478 | if (sched_dump) | |
1479 | { | |
1480 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); | |
1481 | strcpy (dumpname, dump_base_name); | |
1482 | strcat (dumpname, ".sched"); | |
1483 | sched_dump_file = fopen (dumpname, "w"); | |
1484 | if (sched_dump_file == 0) | |
1485 | pfatal_with_name (dumpname); | |
1486 | } | |
1487 | ||
1488 | /* If local_reg dump desired, open the output file. */ | |
1489 | if (local_reg_dump) | |
1490 | { | |
1491 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1492 | strcpy (dumpname, dump_base_name); | |
1493 | strcat (dumpname, ".lreg"); | |
1494 | local_reg_dump_file = fopen (dumpname, "w"); | |
1495 | if (local_reg_dump_file == 0) | |
1496 | pfatal_with_name (dumpname); | |
1497 | } | |
1498 | ||
1499 | /* If global_reg dump desired, open the output file. */ | |
1500 | if (global_reg_dump) | |
1501 | { | |
1502 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1503 | strcpy (dumpname, dump_base_name); | |
1504 | strcat (dumpname, ".greg"); | |
1505 | global_reg_dump_file = fopen (dumpname, "w"); | |
1506 | if (global_reg_dump_file == 0) | |
1507 | pfatal_with_name (dumpname); | |
1508 | } | |
1509 | ||
1510 | /* If 2nd scheduling dump desired, open the output file. */ | |
1511 | if (sched2_dump) | |
1512 | { | |
1513 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 8); | |
1514 | strcpy (dumpname, dump_base_name); | |
1515 | strcat (dumpname, ".sched2"); | |
1516 | sched2_dump_file = fopen (dumpname, "w"); | |
1517 | if (sched2_dump_file == 0) | |
1518 | pfatal_with_name (dumpname); | |
1519 | } | |
1520 | ||
1521 | /* If jump2_opt dump desired, open the output file. */ | |
1522 | if (jump2_opt_dump) | |
1523 | { | |
1524 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); | |
1525 | strcpy (dumpname, dump_base_name); | |
1526 | strcat (dumpname, ".jump2"); | |
1527 | jump2_opt_dump_file = fopen (dumpname, "w"); | |
1528 | if (jump2_opt_dump_file == 0) | |
1529 | pfatal_with_name (dumpname); | |
1530 | } | |
1531 | ||
1532 | /* If dbr_sched dump desired, open the output file. */ | |
1533 | if (dbr_sched_dump) | |
1534 | { | |
1535 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); | |
1536 | strcpy (dumpname, dump_base_name); | |
1537 | strcat (dumpname, ".dbr"); | |
1538 | dbr_sched_dump_file = fopen (dumpname, "w"); | |
1539 | if (dbr_sched_dump_file == 0) | |
1540 | pfatal_with_name (dumpname); | |
1541 | } | |
1542 | ||
1543 | #ifdef STACK_REGS | |
1544 | ||
1545 | /* If stack_reg dump desired, open the output file. */ | |
1546 | if (stack_reg_dump) | |
1547 | { | |
1548 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 10); | |
1549 | strcpy (dumpname, dump_base_name); | |
1550 | strcat (dumpname, ".stack"); | |
1551 | stack_reg_dump_file = fopen (dumpname, "w"); | |
1552 | if (stack_reg_dump_file == 0) | |
1553 | pfatal_with_name (dumpname); | |
1554 | } | |
1555 | ||
1556 | #endif | |
1557 | ||
1558 | /* Open assembler code output file. */ | |
1559 | ||
1560 | if (! name_specified && asm_file_name == 0) | |
1561 | asm_out_file = stdout; | |
1562 | else | |
1563 | { | |
1564 | register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); | |
1565 | int len = strlen (dump_base_name); | |
1566 | strcpy (dumpname, dump_base_name); | |
1567 | strip_off_ending (dumpname, len); | |
1568 | strcat (dumpname, ".s"); | |
1569 | if (asm_file_name == 0) | |
1570 | { | |
1571 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
1572 | strcpy (asm_file_name, dumpname); | |
1573 | } | |
1574 | if (!strcmp (asm_file_name, "-")) | |
1575 | asm_out_file = stdout; | |
1576 | else | |
1577 | asm_out_file = fopen (asm_file_name, "w"); | |
1578 | if (asm_out_file == 0) | |
1579 | pfatal_with_name (asm_file_name); | |
1580 | } | |
1581 | ||
f246a305 | 1582 | #ifdef IO_BUFFER_SIZE |
d7cedf4b RS |
1583 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), |
1584 | _IOFBF, IO_BUFFER_SIZE); | |
f246a305 RS |
1585 | #endif |
1586 | ||
4291d9c8 RS |
1587 | input_filename = name; |
1588 | ||
1589 | /* Perform language-specific initialization. | |
1590 | This may set main_input_filename. */ | |
1591 | lang_init (); | |
1592 | ||
1593 | /* If the input doesn't start with a #line, use the input name | |
1594 | as the official input file name. */ | |
1595 | if (main_input_filename == 0) | |
1596 | main_input_filename = name; | |
1597 | ||
1598 | /* Put an entry on the input file stack for the main input file. */ | |
1599 | input_file_stack | |
1600 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
1601 | input_file_stack->next = 0; | |
1602 | input_file_stack->name = input_filename; | |
1603 | ||
1604 | ASM_FILE_START (asm_out_file); | |
1605 | ||
1606 | /* Output something to inform GDB that this compilation was by GCC. */ | |
1607 | #ifndef ASM_IDENTIFY_GCC | |
1608 | fprintf (asm_out_file, "gcc2_compiled.:\n"); | |
1609 | #else | |
1610 | ASM_IDENTIFY_GCC (asm_out_file); | |
1611 | #endif | |
1612 | /* Don't let the first function fall at the same address | |
1613 | as gcc_compiled., if profiling. */ | |
1614 | if (profile_flag || profile_block_flag) | |
1615 | assemble_zeros (UNITS_PER_WORD); | |
1616 | ||
1617 | /* If dbx symbol table desired, initialize writing it | |
1618 | and output the predefined types. */ | |
f246a305 RS |
1619 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
1620 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
1621 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, |
1622 | getdecls ())); | |
1623 | #endif | |
1624 | #ifdef SDB_DEBUGGING_INFO | |
1625 | if (write_symbols == SDB_DEBUG) | |
1626 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
1627 | getdecls ())); | |
1628 | #endif | |
1629 | #ifdef DWARF_DEBUGGING_INFO | |
1630 | if (write_symbols == DWARF_DEBUG) | |
1631 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
1632 | #endif | |
1633 | ||
1634 | /* Initialize yet another pass. */ | |
1635 | ||
1636 | init_final (main_input_filename); | |
1637 | ||
1638 | start_time = get_run_time (); | |
1639 | ||
1640 | /* Call the parser, which parses the entire file | |
1641 | (calling rest_of_compilation for each function). */ | |
1642 | ||
1643 | if (yyparse () != 0) | |
1644 | if (errorcount == 0) | |
1645 | fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); | |
1646 | ||
1647 | /* Compilation is now finished except for writing | |
1648 | what's left of the symbol table output. */ | |
1649 | ||
1650 | parse_time += get_run_time () - start_time; | |
1651 | ||
1652 | parse_time -= integration_time; | |
1653 | parse_time -= varconst_time; | |
1654 | ||
1655 | globals = getdecls (); | |
1656 | ||
1657 | /* Really define vars that have had only a tentative definition. | |
1658 | Really output inline functions that must actually be callable | |
1659 | and have not been output so far. */ | |
1660 | ||
1661 | { | |
1662 | int len = list_length (globals); | |
1663 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
1664 | int i; | |
1665 | tree decl; | |
1666 | ||
1667 | /* Process the decls in reverse order--earliest first. | |
1668 | Put them into VEC from back to front, then take out from front. */ | |
1669 | ||
1670 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
1671 | vec[len - i - 1] = decl; | |
1672 | ||
1673 | for (i = 0; i < len; i++) | |
1674 | { | |
1675 | decl = vec[i]; | |
1676 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
1677 | && ! TREE_ASM_WRITTEN (decl)) | |
1678 | { | |
1679 | /* Don't write out static consts, unless we used them. | |
1680 | (This used to write them out only if the address was | |
1681 | taken, but that was wrong; if the variable was simply | |
1682 | referred to, it still needs to exist or else it will | |
1683 | be undefined in the linker.) */ | |
1684 | if (! TREE_READONLY (decl) | |
1685 | || TREE_PUBLIC (decl) | |
1686 | || TREE_USED (decl) | |
1687 | || TREE_ADDRESSABLE (decl) | |
1688 | || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl))) | |
1689 | rest_of_decl_compilation (decl, 0, 1, 1); | |
1690 | else | |
1691 | /* Cancel the RTL for this decl so that, if debugging info | |
1692 | output for global variables is still to come, | |
1693 | this one will be omitted. */ | |
1694 | DECL_RTL (decl) = NULL; | |
1695 | } | |
1696 | ||
1697 | if (TREE_CODE (decl) == FUNCTION_DECL | |
1698 | && ! TREE_ASM_WRITTEN (decl) | |
1699 | && DECL_INITIAL (decl) != 0 | |
1700 | && (TREE_ADDRESSABLE (decl) | |
1701 | || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl))) | |
1702 | && ! TREE_EXTERNAL (decl)) | |
1703 | output_inline_function (decl); | |
1704 | ||
ac266247 RS |
1705 | /* Warn about any function |
1706 | declared static but not defined. | |
1707 | We don't warn about variables, | |
1708 | because many programs have static variables | |
1709 | that exist only to get some text into the object file. */ | |
4291d9c8 RS |
1710 | if ((warn_unused |
1711 | || TREE_USED (decl) | |
1712 | || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))) | |
ac266247 | 1713 | && TREE_CODE (decl) == FUNCTION_DECL |
4291d9c8 RS |
1714 | && DECL_INITIAL (decl) == 0 |
1715 | && TREE_EXTERNAL (decl) | |
1716 | && ! TREE_PUBLIC (decl)) | |
1717 | warning_with_decl (decl, "`%s' declared `static' but never defined"); | |
1718 | /* Warn about static fns or vars defined but not used, | |
1719 | but not about inline functions | |
1720 | since unused inline statics is normal practice. */ | |
1721 | if (warn_unused | |
1722 | && (TREE_CODE (decl) == FUNCTION_DECL | |
1723 | || TREE_CODE (decl) == VAR_DECL) | |
1724 | && ! TREE_EXTERNAL (decl) | |
1725 | && ! TREE_PUBLIC (decl) | |
1726 | && ! TREE_USED (decl) | |
1727 | && ! TREE_INLINE (decl) | |
1728 | /* The TREE_USED bit for file-scope decls | |
1729 | is kept in the identifier, to handle multiple | |
1730 | external decls in different scopes. */ | |
1731 | && ! TREE_USED (DECL_NAME (decl))) | |
1732 | warning_with_decl (decl, "`%s' defined but not used"); | |
1733 | ||
1734 | #ifdef SDB_DEBUGGING_INFO | |
1735 | /* The COFF linker can move initialized global vars to the end. | |
1736 | And that can screw up the symbol ordering. | |
1737 | By putting the symbols in that order to begin with, | |
1738 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
1739 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
1740 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
1741 | && DECL_RTL (decl) != 0) | |
1742 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
1743 | ||
1744 | /* Output COFF information for non-global | |
1745 | file-scope initialized variables. */ | |
1746 | if (write_symbols == SDB_DEBUG | |
1747 | && TREE_CODE (decl) == VAR_DECL | |
1748 | && DECL_INITIAL (decl) | |
1749 | && DECL_RTL (decl) != 0 | |
1750 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
1751 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
1752 | #endif /* SDB_DEBUGGING_INFO */ | |
1753 | #ifdef DWARF_DEBUGGING_INFO | |
6dc42e49 | 1754 | /* Output DWARF information for file-scope tentative data object |
4291d9c8 RS |
1755 | declarations, file-scope (extern) function declarations (which |
1756 | had no corresponding body) and file-scope tagged type declarations | |
1757 | and definitions which have not yet been forced out. */ | |
1758 | ||
1759 | if (write_symbols == DWARF_DEBUG | |
1760 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
1761 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
1762 | #endif | |
1763 | } | |
1764 | } | |
1765 | ||
1766 | /* Do dbx symbols */ | |
f246a305 RS |
1767 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
1768 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
1769 | TIMEVAR (symout_time, |
1770 | { | |
1771 | dbxout_finish (asm_out_file, main_input_filename); | |
1772 | }); | |
1773 | #endif | |
1774 | ||
1775 | #ifdef DWARF_DEBUGGING_INFO | |
1776 | if (write_symbols == DWARF_DEBUG) | |
1777 | TIMEVAR (symout_time, | |
1778 | { | |
1779 | dwarfout_finish (); | |
1780 | }); | |
1781 | #endif | |
1782 | ||
1783 | /* Output some stuff at end of file if nec. */ | |
1784 | ||
1785 | end_final (main_input_filename); | |
1786 | ||
1787 | #ifdef ASM_FILE_END | |
1788 | ASM_FILE_END (asm_out_file); | |
1789 | #endif | |
1790 | ||
1791 | after_finish_compilation: | |
1792 | ||
1793 | /* Language-specific end of compilation actions. */ | |
1794 | ||
1795 | lang_finish (); | |
1796 | ||
1797 | /* Close the dump files. */ | |
1798 | ||
1799 | if (flag_gen_aux_info) | |
1800 | { | |
1801 | fclose (aux_info_file); | |
1802 | if (errorcount) | |
1803 | unlink (aux_info_file_name); | |
1804 | } | |
1805 | ||
1806 | if (rtl_dump) | |
1807 | fclose (rtl_dump_file); | |
1808 | ||
1809 | if (jump_opt_dump) | |
1810 | fclose (jump_opt_dump_file); | |
1811 | ||
1812 | if (cse_dump) | |
1813 | fclose (cse_dump_file); | |
1814 | ||
1815 | if (loop_dump) | |
1816 | fclose (loop_dump_file); | |
1817 | ||
1818 | if (cse2_dump) | |
1819 | fclose (cse2_dump_file); | |
1820 | ||
1821 | if (flow_dump) | |
1822 | fclose (flow_dump_file); | |
1823 | ||
1824 | if (combine_dump) | |
1825 | { | |
1826 | dump_combine_total_stats (combine_dump_file); | |
1827 | fclose (combine_dump_file); | |
1828 | } | |
1829 | ||
1830 | if (sched_dump) | |
1831 | fclose (sched_dump_file); | |
1832 | ||
1833 | if (local_reg_dump) | |
1834 | fclose (local_reg_dump_file); | |
1835 | ||
1836 | if (global_reg_dump) | |
1837 | fclose (global_reg_dump_file); | |
1838 | ||
1839 | if (sched2_dump) | |
1840 | fclose (sched2_dump_file); | |
1841 | ||
1842 | if (jump2_opt_dump) | |
1843 | fclose (jump2_opt_dump_file); | |
1844 | ||
1845 | if (dbr_sched_dump) | |
1846 | fclose (dbr_sched_dump_file); | |
1847 | ||
1848 | #ifdef STACK_REGS | |
1849 | if (stack_reg_dump) | |
1850 | fclose (stack_reg_dump_file); | |
1851 | #endif | |
1852 | ||
1853 | /* Close non-debugging input and output files. Take special care to note | |
1854 | whether fclose returns an error, since the pages might still be on the | |
1855 | buffer chain while the file is open. */ | |
1856 | ||
1857 | fclose (finput); | |
1858 | if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) | |
1859 | fatal_io_error (asm_file_name); | |
1860 | ||
1861 | /* Print the times. */ | |
1862 | ||
1863 | if (! quiet_flag) | |
1864 | { | |
1865 | fprintf (stderr,"\n"); | |
1866 | print_time ("parse", parse_time); | |
1867 | print_time ("integration", integration_time); | |
1868 | print_time ("jump", jump_time); | |
1869 | print_time ("cse", cse_time); | |
1870 | print_time ("loop", loop_time); | |
1871 | print_time ("cse2", cse2_time); | |
1872 | print_time ("flow", flow_time); | |
1873 | print_time ("combine", combine_time); | |
1874 | print_time ("sched", sched_time); | |
1875 | print_time ("local-alloc", local_alloc_time); | |
1876 | print_time ("global-alloc", global_alloc_time); | |
1877 | print_time ("sched2", sched2_time); | |
1878 | print_time ("dbranch", dbr_sched_time); | |
1879 | print_time ("shorten-branch", shorten_branch_time); | |
1880 | print_time ("stack-reg", stack_reg_time); | |
1881 | print_time ("final", final_time); | |
1882 | print_time ("varconst", varconst_time); | |
1883 | print_time ("symout", symout_time); | |
1884 | print_time ("dump", dump_time); | |
1885 | } | |
1886 | } | |
1887 | \f | |
1888 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
1889 | and TYPE_DECL nodes. | |
1890 | ||
1891 | This does nothing for local (non-static) variables. | |
1892 | Otherwise, it sets up the RTL and outputs any assembler code | |
1893 | (label definition, storage allocation and initialization). | |
1894 | ||
1895 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
1896 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
1897 | if this declaration is not within a function. */ | |
1898 | ||
1899 | void | |
1900 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
1901 | tree decl; | |
1902 | char *asmspec; | |
1903 | int top_level; | |
1904 | int at_end; | |
1905 | { | |
1906 | /* Declarations of variables, and of functions defined elsewhere. */ | |
1907 | ||
1908 | /* Forward declarations for nested functions are not "external", | |
1909 | but we need to treat them as if they were. */ | |
1910 | if (TREE_STATIC (decl) || TREE_EXTERNAL (decl) | |
1911 | || TREE_CODE (decl) == FUNCTION_DECL) | |
1912 | TIMEVAR (varconst_time, | |
1913 | { | |
1914 | make_decl_rtl (decl, asmspec, top_level); | |
6dbf678a RS |
1915 | /* For a user-invisible decl that should be replaced |
1916 | by its value when used, don't output anything. */ | |
1917 | if (! (TREE_CODE (decl) == VAR_DECL | |
1918 | && DECL_IGNORED_P (decl) && TREE_READONLY (decl) | |
1919 | && DECL_INITIAL (decl) != 0)) | |
1920 | /* Don't output anything | |
1921 | when a tentative file-scope definition is seen. | |
1922 | But at end of compilation, do output code for them. */ | |
1923 | if (! (! at_end && top_level | |
1924 | && (DECL_INITIAL (decl) == 0 | |
1925 | || DECL_INITIAL (decl) == error_mark_node | |
1926 | || DECL_IGNORED_P (decl)))) | |
1927 | assemble_variable (decl, top_level, at_end); | |
4291d9c8 RS |
1928 | }); |
1929 | else if (TREE_REGDECL (decl) && asmspec != 0) | |
1930 | { | |
1931 | if (decode_reg_name (asmspec) >= 0) | |
1932 | { | |
1933 | DECL_RTL (decl) = 0; | |
1934 | make_decl_rtl (decl, asmspec, top_level); | |
1935 | } | |
1936 | else | |
1937 | error ("invalid register name `%s' for register variable", asmspec); | |
1938 | } | |
f246a305 RS |
1939 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
1940 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
1941 | && TREE_CODE (decl) == TYPE_DECL) | |
4291d9c8 RS |
1942 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); |
1943 | #endif | |
1944 | #ifdef SDB_DEBUGGING_INFO | |
1945 | else if (write_symbols == SDB_DEBUG && top_level | |
1946 | && TREE_CODE (decl) == TYPE_DECL) | |
1947 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
1948 | #endif | |
1949 | } | |
1950 | ||
1951 | /* Called after finishing a record, union or enumeral type. */ | |
1952 | ||
1953 | void | |
1954 | rest_of_type_compilation (type, toplev) | |
1955 | tree type; | |
1956 | int toplev; | |
1957 | { | |
f246a305 RS |
1958 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
1959 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
1960 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); |
1961 | #endif | |
1962 | #ifdef SDB_DEBUGGING_INFO | |
1963 | if (write_symbols == SDB_DEBUG) | |
1964 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
1965 | #endif | |
1966 | } | |
1967 | ||
1968 | /* This is called from finish_function (within yyparse) | |
1969 | after each top-level definition is parsed. | |
1970 | It is supposed to compile that function or variable | |
1971 | and output the assembler code for it. | |
1972 | After we return, the tree storage is freed. */ | |
1973 | ||
1974 | void | |
1975 | rest_of_compilation (decl) | |
1976 | tree decl; | |
1977 | { | |
1978 | register rtx insns; | |
1979 | int start_time = get_run_time (); | |
1980 | int tem; | |
1981 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
1982 | to be restored after we finish compiling the function | |
1983 | (for use when compiling inline calls to this function). */ | |
1984 | tree saved_block_tree = 0; | |
ab40ad2b | 1985 | int failure = 0; |
4291d9c8 RS |
1986 | |
1987 | /* If we are reconsidering an inline function | |
1988 | at the end of compilation, skip the stuff for making it inline. */ | |
1989 | ||
1990 | if (DECL_SAVED_INSNS (decl) == 0) | |
1991 | { | |
1992 | int specd = TREE_INLINE (decl); | |
1993 | char *lose; | |
1994 | ||
1995 | /* If requested, consider whether to make this function inline. */ | |
1996 | if (specd || flag_inline_functions) | |
1997 | TIMEVAR (integration_time, | |
1998 | { | |
1999 | lose = function_cannot_inline_p (decl); | |
2000 | if (lose) | |
2001 | { | |
2002 | if (warn_inline && specd) | |
2003 | warning_with_decl (decl, lose); | |
2004 | TREE_INLINE (decl) = 0; | |
2005 | } | |
2006 | else | |
2007 | TREE_INLINE (decl) = 1; | |
2008 | }); | |
2009 | ||
2010 | insns = get_insns (); | |
2011 | ||
2012 | /* Dump the rtl code if we are dumping rtl. */ | |
2013 | ||
2014 | if (rtl_dump) | |
2015 | TIMEVAR (dump_time, | |
2016 | { | |
2017 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", | |
2018 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2019 | if (DECL_SAVED_INSNS (decl)) | |
2020 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
2021 | print_rtl (rtl_dump_file, insns); | |
2022 | fflush (rtl_dump_file); | |
2023 | }); | |
2024 | ||
2025 | /* If function is inline, and we don't yet know whether to | |
2026 | compile it by itself, defer decision till end of compilation. | |
2027 | finish_compilation will call rest_of_compilation again | |
2028 | for those functions that need to be output. */ | |
2029 | ||
2030 | if (TREE_INLINE (decl) | |
2031 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) | |
2032 | && ! flag_keep_inline_functions) | |
2033 | || TREE_EXTERNAL (decl))) | |
2034 | { | |
2035 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
2036 | goto exit_rest_of_compilation; | |
2037 | } | |
2038 | ||
2039 | /* If we have to compile the function now, save its rtl | |
2040 | so that its compilation will not affect what others get. */ | |
2041 | if (TREE_INLINE (decl)) | |
2042 | { | |
2043 | saved_block_tree = DECL_INITIAL (decl); | |
2044 | TIMEVAR (integration_time, save_for_inline_copying (decl)); | |
2045 | } | |
2046 | } | |
2047 | ||
2048 | /* Suppress warnings for unused static functions | |
2049 | defined (not just declared) in system headers. */ | |
2050 | if (in_system_header && TREE_STATIC (decl) && !TREE_INLINE (decl)) | |
2051 | TREE_USED (decl) = 1; | |
2052 | ||
2053 | TREE_ASM_WRITTEN (decl) = 1; | |
2054 | ||
2055 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
2056 | between the return value of this function and the return value of called | |
2057 | functions. */ | |
2058 | rtx_equal_function_value_matters = 0; | |
2059 | ||
32235b30 RS |
2060 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ |
2061 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
4291d9c8 RS |
2062 | { |
2063 | goto exit_rest_of_compilation; | |
2064 | } | |
2065 | ||
2066 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. | |
2067 | Note that that may have been done above, in save_for_inline_copying. | |
2068 | The call to resume_temporary_allocation near the end of this function | |
2069 | goes back to the usual state of affairs. */ | |
2070 | ||
2071 | rtl_in_current_obstack (); | |
2072 | ||
2073 | #ifdef FINALIZE_PIC | |
2074 | /* If we are doing position-independent code generation, now | |
2075 | is the time to output special prologues and epilogues. | |
2076 | We do not want to do this earlier, because it just clutters | |
2077 | up inline functions with meaningless insns. */ | |
2078 | if (flag_pic) | |
2079 | FINALIZE_PIC; | |
2080 | #endif | |
2081 | ||
2082 | insns = get_insns (); | |
2083 | ||
2084 | /* Copy any shared structure that should not be shared. */ | |
2085 | ||
2086 | unshare_all_rtl (insns); | |
2087 | ||
2088 | /* Instantiate all virtual registers. */ | |
2089 | ||
2090 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
2091 | ||
2092 | /* See if we have allocated stack slots that are not directly addressable. | |
2093 | If so, scan all the insns and create explicit address computation | |
2094 | for all references to such slots. */ | |
2095 | /* fixup_stack_slots (); */ | |
2096 | ||
2097 | /* Do jump optimization the first time, if -opt. | |
2098 | Also do it if -W, but in that case it doesn't change the rtl code, | |
2099 | it only computes whether control can drop off the end of the function. */ | |
2100 | ||
2101 | if (optimize > 0 || extra_warnings || warn_return_type | |
2102 | /* If function is `volatile', we should warn if it tries to return. */ | |
2103 | || TREE_THIS_VOLATILE (decl)) | |
2104 | { | |
2105 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
2106 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
2107 | } | |
2108 | ||
32235b30 RS |
2109 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ |
2110 | if (rtl_dump_and_exit || flag_syntax_only) | |
2111 | goto exit_rest_of_compilation; | |
2112 | ||
4291d9c8 RS |
2113 | /* Dump rtl code after jump, if we are doing that. */ |
2114 | ||
2115 | if (jump_opt_dump) | |
2116 | TIMEVAR (dump_time, | |
2117 | { | |
2118 | fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", | |
2119 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2120 | print_rtl (jump_opt_dump_file, insns); | |
2121 | fflush (jump_opt_dump_file); | |
2122 | }); | |
2123 | ||
2124 | /* Perform common subexpression elimination. | |
2125 | Nonzero value from `cse_main' means that jumps were simplified | |
2126 | and some code may now be unreachable, so do | |
2127 | jump optimization again. */ | |
2128 | ||
2129 | if (cse_dump) | |
2130 | TIMEVAR (dump_time, | |
2131 | { | |
2132 | fprintf (cse_dump_file, "\n;; Function %s\n\n", | |
2133 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2134 | }); | |
2135 | ||
2136 | if (optimize > 0) | |
2137 | { | |
2138 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); | |
2139 | ||
2140 | if (flag_thread_jumps) | |
2141 | /* Hacks by tiemann & kenner. */ | |
2142 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
2143 | ||
2144 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
2145 | 0, cse_dump_file)); | |
2146 | TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); | |
2147 | ||
2148 | if (tem) | |
2149 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
2150 | } | |
2151 | ||
2152 | /* Dump rtl code after cse, if we are doing that. */ | |
2153 | ||
2154 | if (cse_dump) | |
2155 | TIMEVAR (dump_time, | |
2156 | { | |
2157 | print_rtl (cse_dump_file, insns); | |
2158 | fflush (cse_dump_file); | |
2159 | }); | |
2160 | ||
2161 | if (loop_dump) | |
2162 | TIMEVAR (dump_time, | |
2163 | { | |
2164 | fprintf (loop_dump_file, "\n;; Function %s\n\n", | |
2165 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2166 | }); | |
2167 | ||
2168 | /* Move constant computations out of loops. */ | |
2169 | ||
2170 | if (optimize > 0) | |
2171 | { | |
2172 | TIMEVAR (loop_time, | |
2173 | { | |
2174 | loop_optimize (insns, loop_dump ? loop_dump_file : 0); | |
2175 | }); | |
2176 | } | |
2177 | ||
2178 | /* Dump rtl code after loop opt, if we are doing that. */ | |
2179 | ||
2180 | if (loop_dump) | |
2181 | TIMEVAR (dump_time, | |
2182 | { | |
2183 | print_rtl (loop_dump_file, insns); | |
2184 | fflush (loop_dump_file); | |
2185 | }); | |
2186 | ||
2187 | if (cse2_dump) | |
2188 | TIMEVAR (dump_time, | |
2189 | { | |
2190 | fprintf (cse2_dump_file, "\n;; Function %s\n\n", | |
2191 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2192 | }); | |
2193 | ||
2194 | if (optimize > 0 && flag_rerun_cse_after_loop) | |
2195 | { | |
2196 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); | |
2197 | ||
2198 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), | |
2199 | 1, cse2_dump_file)); | |
2200 | if (tem) | |
2201 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
2202 | } | |
2203 | ||
2204 | if (optimize > 0 && flag_thread_jumps) | |
2205 | /* This pass of jump threading straightens out code | |
2206 | that was kinked by loop optimization. */ | |
2207 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
2208 | ||
2209 | /* Dump rtl code after cse, if we are doing that. */ | |
2210 | ||
2211 | if (cse2_dump) | |
2212 | TIMEVAR (dump_time, | |
2213 | { | |
2214 | print_rtl (cse2_dump_file, insns); | |
2215 | fflush (cse2_dump_file); | |
2216 | }); | |
2217 | ||
2218 | /* We are no longer anticipating cse in this function, at least. */ | |
2219 | ||
2220 | cse_not_expected = 1; | |
2221 | ||
2222 | /* Now we choose between stupid (pcc-like) register allocation | |
2223 | (if we got the -noreg switch and not -opt) | |
2224 | and smart register allocation. */ | |
2225 | ||
2226 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
2227 | obey_regdecls = 0; /* if optimizations being done. */ | |
2228 | ||
2229 | regclass_init (); | |
2230 | ||
2231 | /* Print function header into flow dump now | |
2232 | because doing the flow analysis makes some of the dump. */ | |
2233 | ||
2234 | if (flow_dump) | |
2235 | TIMEVAR (dump_time, | |
2236 | { | |
2237 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
2238 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2239 | }); | |
2240 | ||
2241 | if (obey_regdecls) | |
2242 | { | |
2243 | TIMEVAR (flow_time, | |
2244 | { | |
2245 | regclass (insns, max_reg_num ()); | |
2246 | stupid_life_analysis (insns, max_reg_num (), | |
2247 | flow_dump_file); | |
2248 | }); | |
2249 | } | |
2250 | else | |
2251 | { | |
2252 | /* Do control and data flow analysis, | |
2253 | and write some of the results to dump file. */ | |
2254 | ||
2255 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
2256 | flow_dump_file)); | |
2257 | if (warn_uninitialized) | |
2258 | { | |
2259 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
2260 | setjmp_args_warning (); | |
2261 | } | |
2262 | } | |
2263 | ||
2264 | /* Dump rtl after flow analysis. */ | |
2265 | ||
2266 | if (flow_dump) | |
2267 | TIMEVAR (dump_time, | |
2268 | { | |
2269 | print_rtl (flow_dump_file, insns); | |
2270 | fflush (flow_dump_file); | |
2271 | }); | |
2272 | ||
2273 | /* If -opt, try combining insns through substitution. */ | |
2274 | ||
2275 | if (optimize > 0) | |
2276 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
2277 | ||
2278 | /* Dump rtl code after insn combination. */ | |
2279 | ||
2280 | if (combine_dump) | |
2281 | TIMEVAR (dump_time, | |
2282 | { | |
2283 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
2284 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2285 | dump_combine_stats (combine_dump_file); | |
2286 | print_rtl (combine_dump_file, insns); | |
2287 | fflush (combine_dump_file); | |
2288 | }); | |
2289 | ||
2290 | /* Print function header into sched dump now | |
2291 | because doing the sched analysis makes some of the dump. */ | |
2292 | ||
2293 | if (sched_dump) | |
2294 | TIMEVAR (dump_time, | |
2295 | { | |
2296 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
2297 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2298 | }); | |
2299 | ||
2300 | if (optimize > 0 && flag_schedule_insns) | |
2301 | { | |
2302 | /* Do control and data sched analysis, | |
2303 | and write some of the results to dump file. */ | |
2304 | ||
2305 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
2306 | } | |
2307 | ||
2308 | /* Dump rtl after instruction scheduling. */ | |
2309 | ||
2310 | if (sched_dump) | |
2311 | TIMEVAR (dump_time, | |
2312 | { | |
2313 | print_rtl (sched_dump_file, insns); | |
2314 | fflush (sched_dump_file); | |
2315 | }); | |
2316 | ||
2317 | /* Unless we did stupid register allocation, | |
2318 | allocate pseudo-regs that are used only within 1 basic block. */ | |
2319 | ||
2320 | if (!obey_regdecls) | |
2321 | TIMEVAR (local_alloc_time, | |
2322 | { | |
2323 | regclass (insns, max_reg_num ()); | |
2324 | local_alloc (); | |
2325 | }); | |
2326 | ||
2327 | /* Dump rtl code after allocating regs within basic blocks. */ | |
2328 | ||
2329 | if (local_reg_dump) | |
2330 | TIMEVAR (dump_time, | |
2331 | { | |
2332 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
2333 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2334 | dump_flow_info (local_reg_dump_file); | |
2335 | dump_local_alloc (local_reg_dump_file); | |
2336 | print_rtl (local_reg_dump_file, insns); | |
2337 | fflush (local_reg_dump_file); | |
2338 | }); | |
2339 | ||
2340 | if (global_reg_dump) | |
2341 | TIMEVAR (dump_time, | |
2342 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
2343 | IDENTIFIER_POINTER (DECL_NAME (decl)))); | |
2344 | ||
2345 | /* Unless we did stupid register allocation, | |
2346 | allocate remaining pseudo-regs, then do the reload pass | |
2347 | fixing up any insns that are invalid. */ | |
2348 | ||
2349 | TIMEVAR (global_alloc_time, | |
2350 | { | |
2351 | if (!obey_regdecls) | |
ab40ad2b | 2352 | failure = global_alloc (global_reg_dump ? global_reg_dump_file : 0); |
4291d9c8 | 2353 | else |
ab40ad2b RS |
2354 | failure = reload (insns, 0, |
2355 | global_reg_dump ? global_reg_dump_file : 0); | |
4291d9c8 RS |
2356 | }); |
2357 | ||
2358 | if (global_reg_dump) | |
2359 | TIMEVAR (dump_time, | |
2360 | { | |
2361 | dump_global_regs (global_reg_dump_file); | |
2362 | print_rtl (global_reg_dump_file, insns); | |
2363 | fflush (global_reg_dump_file); | |
2364 | }); | |
2365 | ||
ab40ad2b RS |
2366 | if (failure) |
2367 | goto exit_rest_of_compilation; | |
2368 | ||
4291d9c8 RS |
2369 | reload_completed = 1; |
2370 | ||
2371 | if (optimize > 0 && flag_schedule_insns_after_reload) | |
2372 | { | |
2373 | if (sched2_dump) | |
2374 | TIMEVAR (dump_time, | |
2375 | { | |
2376 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
2377 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2378 | }); | |
2379 | ||
2380 | /* Do control and data sched analysis again, | |
2381 | and write some more of the results to dump file. */ | |
2382 | ||
2383 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
2384 | ||
2385 | /* Dump rtl after post-reorder instruction scheduling. */ | |
2386 | ||
2387 | if (sched2_dump) | |
2388 | TIMEVAR (dump_time, | |
2389 | { | |
2390 | print_rtl (sched2_dump_file, insns); | |
2391 | fflush (sched2_dump_file); | |
2392 | }); | |
2393 | } | |
2394 | ||
2395 | #ifdef LEAF_REGISTERS | |
2396 | leaf_function = 0; | |
2397 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 2398 | leaf_function = 1; |
4291d9c8 RS |
2399 | #endif |
2400 | ||
2401 | /* One more attempt to remove jumps to .+1 | |
2402 | left by dead-store-elimination. | |
2403 | Also do cross-jumping this time | |
2404 | and delete no-op move insns. */ | |
2405 | ||
2406 | if (optimize > 0) | |
2407 | { | |
2408 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
2409 | } | |
2410 | ||
2411 | /* Dump rtl code after jump, if we are doing that. */ | |
2412 | ||
2413 | if (jump2_opt_dump) | |
2414 | TIMEVAR (dump_time, | |
2415 | { | |
2416 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
2417 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2418 | print_rtl (jump2_opt_dump_file, insns); | |
2419 | fflush (jump2_opt_dump_file); | |
2420 | }); | |
2421 | ||
2422 | /* If a scheduling pass for delayed branches is to be done, | |
2423 | call the scheduling code. */ | |
2424 | ||
2425 | #ifdef DELAY_SLOTS | |
2426 | if (optimize > 0 && flag_delayed_branch) | |
2427 | { | |
2428 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
2429 | if (dbr_sched_dump) | |
2430 | { | |
2431 | TIMEVAR (dump_time, | |
2432 | { | |
2433 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
2434 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2435 | print_rtl (dbr_sched_dump_file, insns); | |
2436 | fflush (dbr_sched_dump_file); | |
2437 | }); | |
2438 | } | |
2439 | } | |
2440 | #endif | |
2441 | ||
2442 | if (optimize > 0) | |
2443 | /* Shorten branches. */ | |
2444 | TIMEVAR (shorten_branch_time, | |
2445 | { | |
2446 | shorten_branches (get_insns ()); | |
2447 | }); | |
2448 | ||
2449 | #ifdef STACK_REGS | |
2450 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
2451 | if (stack_reg_dump) | |
2452 | { | |
2453 | TIMEVAR (dump_time, | |
2454 | { | |
2455 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
2456 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2457 | print_rtl (stack_reg_dump_file, insns); | |
2458 | fflush (stack_reg_dump_file); | |
2459 | }); | |
2460 | } | |
2461 | #endif | |
2462 | ||
2463 | /* Now turn the rtl into assembler code. */ | |
2464 | ||
2465 | TIMEVAR (final_time, | |
2466 | { | |
2467 | rtx x; | |
2468 | char *fnname; | |
2469 | ||
2470 | /* Get the function's name, as described by its RTL. | |
2471 | This may be different from the DECL_NAME name used | |
2472 | in the source file. */ | |
2473 | ||
2474 | x = DECL_RTL (decl); | |
2475 | if (GET_CODE (x) != MEM) | |
2476 | abort (); | |
2477 | x = XEXP (x, 0); | |
2478 | if (GET_CODE (x) != SYMBOL_REF) | |
2479 | abort (); | |
2480 | fnname = XSTR (x, 0); | |
2481 | ||
2482 | assemble_start_function (decl, fnname); | |
2483 | final_start_function (insns, asm_out_file, optimize); | |
2484 | final (insns, asm_out_file, optimize, 0); | |
2485 | final_end_function (insns, asm_out_file, optimize); | |
2486 | assemble_end_function (decl, fnname); | |
2487 | fflush (asm_out_file); | |
2488 | }); | |
2489 | ||
2490 | /* Write DBX symbols if requested */ | |
2491 | ||
2492 | /* Note that for those inline functions where we don't initially | |
2493 | know for certain that we will be generating an out-of-line copy, | |
2494 | the first invocation of this routine (rest_of_compilation) will | |
2495 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
2496 | Later on, finish_compilation will call rest_of_compilation again | |
2497 | for those inline functions that need to have out-of-line copies | |
2498 | generated. During that call, we *will* be routed past here. */ | |
2499 | ||
2500 | #ifdef DBX_DEBUGGING_INFO | |
2501 | if (write_symbols == DBX_DEBUG) | |
2502 | TIMEVAR (symout_time, dbxout_function (decl)); | |
2503 | #endif | |
2504 | ||
2505 | #ifdef DWARF_DEBUGGING_INFO | |
2506 | if (write_symbols == DWARF_DEBUG) | |
2507 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
2508 | #endif | |
2509 | ||
2510 | exit_rest_of_compilation: | |
2511 | ||
f246a305 RS |
2512 | /* In case the function was not output, |
2513 | don't leave any temporary anonymous types | |
2514 | queued up for sdb output. */ | |
2515 | #ifdef SDB_DEBUGGING_INFO | |
2516 | if (write_symbols == SDB_DEBUG) | |
2517 | sdbout_types (0); | |
2518 | #endif | |
2519 | ||
4291d9c8 RS |
2520 | /* Put back the tree of subblocks from before we copied it. |
2521 | Code generation and the output of debugging info may have modified | |
2522 | the copy, but the original is unchanged. */ | |
2523 | ||
2524 | if (saved_block_tree != 0) | |
2525 | DECL_INITIAL (decl) = saved_block_tree; | |
2526 | ||
2527 | reload_completed = 0; | |
2528 | ||
2529 | /* Clear out the real_constant_chain before some of the rtx's | |
2530 | it runs through become garbage. */ | |
2531 | ||
2532 | clear_const_double_mem (); | |
2533 | ||
2534 | /* Cancel the effect of rtl_in_current_obstack. */ | |
2535 | ||
2536 | resume_temporary_allocation (); | |
2537 | ||
2538 | /* The parsing time is all the time spent in yyparse | |
2539 | *except* what is spent in this function. */ | |
2540 | ||
2541 | parse_time -= get_run_time () - start_time; | |
2542 | } | |
2543 | \f | |
2544 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
2545 | Exit code is 35 if can't open files, 34 if fatal error, | |
2546 | 33 if had nonfatal errors, else success. */ | |
2547 | ||
2548 | int | |
2549 | main (argc, argv, envp) | |
2550 | int argc; | |
2551 | char **argv; | |
2552 | char **envp; | |
2553 | { | |
2554 | register int i; | |
2555 | char *filename = 0; | |
2556 | int flag_print_mem = 0; | |
2557 | int version_flag = 0; | |
2558 | char *p; | |
2559 | ||
2560 | /* save in case md file wants to emit args as a comment. */ | |
2561 | save_argc = argc; | |
2562 | save_argv = argv; | |
2563 | ||
2564 | p = argv[0] + strlen (argv[0]); | |
2565 | while (p != argv[0] && p[-1] != '/') --p; | |
2566 | progname = p; | |
2567 | ||
2568 | #ifdef RLIMIT_STACK | |
2569 | /* Get rid of any avoidable limit on stack size. */ | |
2570 | { | |
2571 | struct rlimit rlim; | |
2572 | ||
2573 | /* Set the stack limit huge so that alloca does not fail. */ | |
2574 | getrlimit (RLIMIT_STACK, &rlim); | |
2575 | rlim.rlim_cur = rlim.rlim_max; | |
2576 | setrlimit (RLIMIT_STACK, &rlim); | |
2577 | } | |
2578 | #endif /* RLIMIT_STACK */ | |
2579 | ||
2580 | signal (SIGFPE, float_signal); | |
2581 | ||
2582 | signal (SIGPIPE, pipe_closed); | |
2583 | ||
2584 | decl_printable_name = decl_name; | |
2585 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
2586 | ||
2587 | /* Initialize whether `char' is signed. */ | |
2588 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
2589 | #ifdef DEFAULT_SHORT_ENUMS | |
2590 | /* Initialize how much space enums occupy, by default. */ | |
2591 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
2592 | #endif | |
2593 | ||
2594 | /* Scan to see what optimization level has been specified. That will | |
2595 | determine the default value of many flags. */ | |
2596 | for (i = 1; i < argc; i++) | |
2597 | { | |
2598 | if (!strcmp (argv[i], "-O")) | |
2599 | { | |
2600 | optimize = 1; | |
2601 | } | |
2602 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
2603 | { | |
2604 | /* Handle -O2, -O3, -O69, ... */ | |
2605 | char *p = &argv[i][2]; | |
2606 | int c; | |
2607 | ||
2608 | while (c = *p++) | |
2609 | if (! (c >= '0' && c <= '9')) | |
2610 | break; | |
2611 | if (c == 0) | |
2612 | optimize = atoi (&argv[i][2]); | |
2613 | } | |
2614 | } | |
2615 | ||
2616 | obey_regdecls = (optimize == 0); | |
f246a305 RS |
2617 | if (optimize == 0) |
2618 | { | |
2619 | flag_no_inline = 1; | |
2620 | warn_inline = 0; | |
2621 | } | |
4291d9c8 RS |
2622 | |
2623 | if (optimize >= 1) | |
2624 | { | |
2625 | flag_thread_jumps = 1; | |
2626 | #ifdef DELAY_SLOTS | |
2627 | flag_delayed_branch = 1; | |
2628 | #endif | |
2629 | } | |
2630 | ||
2631 | if (optimize >= 2) | |
2632 | { | |
2633 | flag_cse_follow_jumps = 1; | |
8b3686ed | 2634 | flag_cse_skip_blocks = 1; |
4291d9c8 RS |
2635 | flag_expensive_optimizations = 1; |
2636 | flag_strength_reduce = 1; | |
2637 | flag_rerun_cse_after_loop = 1; | |
ac266247 | 2638 | flag_caller_saves = 1; |
4291d9c8 RS |
2639 | #ifdef INSN_SCHEDULING |
2640 | flag_schedule_insns = 1; | |
2641 | flag_schedule_insns_after_reload = 1; | |
2642 | #endif | |
2643 | } | |
2644 | ||
2645 | #ifdef OPTIMIZATION_OPTIONS | |
2646 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
2647 | OPTIMIZATION_OPTIONS (optimize); | |
2648 | #endif | |
2649 | ||
2650 | /* Initialize register usage now so switches may override. */ | |
2651 | init_reg_sets (); | |
2652 | ||
2653 | target_flags = 0; | |
2654 | set_target_switch (""); | |
2655 | ||
2656 | for (i = 1; i < argc; i++) | |
2657 | { | |
2658 | if (argv[i][0] == '-' && argv[i][1] != 0) | |
2659 | { | |
2660 | register char *str = argv[i] + 1; | |
2661 | if (str[0] == 'Y') | |
2662 | str++; | |
2663 | ||
2664 | if (str[0] == 'm') | |
2665 | set_target_switch (&str[1]); | |
2666 | else if (!strcmp (str, "dumpbase")) | |
2667 | { | |
2668 | dump_base_name = argv[++i]; | |
2669 | } | |
2670 | else if (str[0] == 'd') | |
2671 | { | |
2672 | register char *p = &str[1]; | |
2673 | while (*p) | |
2674 | switch (*p++) | |
2675 | { | |
2676 | case 'a': | |
2677 | combine_dump = 1; | |
2678 | dbr_sched_dump = 1; | |
2679 | flow_dump = 1; | |
2680 | global_reg_dump = 1; | |
2681 | jump_opt_dump = 1; | |
2682 | jump2_opt_dump = 1; | |
2683 | local_reg_dump = 1; | |
2684 | loop_dump = 1; | |
2685 | rtl_dump = 1; | |
2686 | cse_dump = 1, cse2_dump = 1; | |
2687 | sched_dump = 1; | |
2688 | sched2_dump = 1; | |
2689 | stack_reg_dump = 1; | |
2690 | break; | |
2691 | case 'k': | |
2692 | stack_reg_dump = 1; | |
2693 | break; | |
2694 | case 'c': | |
2695 | combine_dump = 1; | |
2696 | break; | |
2697 | case 'd': | |
2698 | dbr_sched_dump = 1; | |
2699 | break; | |
2700 | case 'f': | |
2701 | flow_dump = 1; | |
2702 | break; | |
2703 | case 'g': | |
2704 | global_reg_dump = 1; | |
2705 | break; | |
2706 | case 'j': | |
2707 | jump_opt_dump = 1; | |
2708 | break; | |
2709 | case 'J': | |
2710 | jump2_opt_dump = 1; | |
2711 | break; | |
2712 | case 'l': | |
2713 | local_reg_dump = 1; | |
2714 | break; | |
2715 | case 'L': | |
2716 | loop_dump = 1; | |
2717 | break; | |
2718 | case 'm': | |
2719 | flag_print_mem = 1; | |
2720 | break; | |
2721 | case 'p': | |
2722 | flag_print_asm_name = 1; | |
2723 | break; | |
2724 | case 'r': | |
2725 | rtl_dump = 1; | |
2726 | break; | |
2727 | case 's': | |
2728 | cse_dump = 1; | |
2729 | break; | |
2730 | case 't': | |
2731 | cse2_dump = 1; | |
2732 | break; | |
2733 | case 'S': | |
2734 | sched_dump = 1; | |
2735 | break; | |
2736 | case 'R': | |
2737 | sched2_dump = 1; | |
2738 | break; | |
2739 | case 'y': | |
2740 | set_yydebug (1); | |
2741 | break; | |
2742 | ||
2743 | case 'x': | |
2744 | rtl_dump_and_exit = 1; | |
2745 | break; | |
2746 | } | |
2747 | } | |
2748 | else if (str[0] == 'f') | |
2749 | { | |
2750 | int j; | |
2751 | register char *p = &str[1]; | |
2752 | int found = 0; | |
2753 | ||
2754 | /* Some kind of -f option. | |
2755 | P's value is the option sans `-f'. | |
2756 | Search for it in the table of options. */ | |
2757 | ||
2758 | for (j = 0; | |
2759 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
2760 | j++) | |
2761 | { | |
2762 | if (!strcmp (p, f_options[j].string)) | |
2763 | { | |
2764 | *f_options[j].variable = f_options[j].on_value; | |
2765 | /* A goto here would be cleaner, | |
2766 | but breaks the vax pcc. */ | |
2767 | found = 1; | |
2768 | } | |
2769 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
2770 | && ! strcmp (p+3, f_options[j].string)) | |
2771 | { | |
2772 | *f_options[j].variable = ! f_options[j].on_value; | |
2773 | found = 1; | |
2774 | } | |
2775 | } | |
2776 | ||
2777 | if (found) | |
2778 | ; | |
2779 | else if (!strncmp (p, "fixed-", 6)) | |
2780 | fix_register (&p[6], 1, 1); | |
2781 | else if (!strncmp (p, "call-used-", 10)) | |
2782 | fix_register (&p[10], 0, 1); | |
2783 | else if (!strncmp (p, "call-saved-", 11)) | |
2784 | fix_register (&p[11], 0, 0); | |
2785 | else if (! lang_decode_option (argv[i])) | |
2786 | error ("Invalid option `%s'", argv[i]); | |
2787 | } | |
2788 | else if (str[0] == 'O') | |
2789 | { | |
2790 | register char *p = str+1; | |
2791 | while (*p && *p >= '0' && *p <= '9') | |
2792 | p++; | |
2793 | if (*p == '\0') | |
2794 | ; | |
2795 | else | |
2796 | error ("Invalid option `%s'", argv[i]); | |
2797 | } | |
2798 | else if (!strcmp (str, "pedantic")) | |
2799 | pedantic = 1; | |
2800 | else if (!strcmp (str, "pedantic-errors")) | |
2801 | flag_pedantic_errors = pedantic = 1; | |
2802 | else if (lang_decode_option (argv[i])) | |
2803 | ; | |
2804 | else if (!strcmp (str, "quiet")) | |
2805 | quiet_flag = 1; | |
2806 | else if (!strcmp (str, "version")) | |
2807 | version_flag = 1; | |
2808 | else if (!strcmp (str, "w")) | |
2809 | inhibit_warnings = 1; | |
2810 | else if (!strcmp (str, "W")) | |
2811 | { | |
2812 | extra_warnings = 1; | |
2813 | warn_uninitialized = 1; | |
2814 | } | |
2815 | else if (str[0] == 'W') | |
2816 | { | |
2817 | int j; | |
2818 | register char *p = &str[1]; | |
2819 | int found = 0; | |
2820 | ||
2821 | /* Some kind of -W option. | |
2822 | P's value is the option sans `-W'. | |
2823 | Search for it in the table of options. */ | |
2824 | ||
2825 | for (j = 0; | |
2826 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
2827 | j++) | |
2828 | { | |
2829 | if (!strcmp (p, W_options[j].string)) | |
2830 | { | |
2831 | *W_options[j].variable = W_options[j].on_value; | |
2832 | /* A goto here would be cleaner, | |
2833 | but breaks the vax pcc. */ | |
2834 | found = 1; | |
2835 | } | |
2836 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
2837 | && ! strcmp (p+3, W_options[j].string)) | |
2838 | { | |
2839 | *W_options[j].variable = ! W_options[j].on_value; | |
2840 | found = 1; | |
2841 | } | |
2842 | } | |
2843 | ||
2844 | if (found) | |
2845 | ; | |
2846 | else if (!strncmp (p, "id-clash-", 9)) | |
2847 | { | |
2848 | char *endp = p + 9; | |
2849 | ||
2850 | while (*endp) | |
2851 | { | |
2852 | if (*endp >= '0' && *endp <= '9') | |
2853 | endp++; | |
2854 | else | |
2855 | error ("Invalid option `%s'", argv[i]); | |
2856 | } | |
2857 | warn_id_clash = 1; | |
2858 | id_clash_len = atoi (str + 10); | |
2859 | } | |
2860 | else | |
2861 | error ("Invalid option `%s'", argv[i]); | |
2862 | } | |
2863 | else if (!strcmp (str, "p")) | |
2864 | profile_flag = 1; | |
2865 | else if (!strcmp (str, "a")) | |
2866 | { | |
2867 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
2868 | warning ("`-a' option (basic block profile) not supported"); | |
2869 | #else | |
2870 | profile_block_flag = 1; | |
2871 | #endif | |
2872 | } | |
2873 | else if (str[0] == 'g') | |
2874 | { | |
2875 | char *p = str + 1; | |
2876 | char *q; | |
2877 | unsigned len; | |
2878 | unsigned level; | |
2879 | ||
2880 | while (*p && (*p < '0' || *p > '9')) | |
2881 | p++; | |
2882 | len = p - str; | |
2883 | q = p; | |
2884 | while (*q && (*q >= '0' && *q <= '9')) | |
2885 | q++; | |
2886 | if (*p) | |
2887 | level = atoi (p); | |
2888 | else | |
2889 | level = 2; /* default debugging info level */ | |
2890 | if (*q || level > 3) | |
2891 | { | |
2892 | warning ("invalid debug level specification in option: `-%s'", | |
2893 | str); | |
2894 | warning ("no debugging information will be generated"); | |
2895 | level = 0; | |
2896 | } | |
2897 | ||
2898 | /* If more than one debugging type is supported, | |
2899 | you must define PREFERRED_DEBUGGING_TYPE | |
2900 | to choose a format in a system-dependent way. */ | |
2901 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) \ | |
f246a305 | 2902 | + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) |
4291d9c8 RS |
2903 | #ifdef PREFERRED_DEBUGGING_TYPE |
2904 | if (!strncmp (str, "ggdb", len)) | |
2905 | write_symbols = PREFERRED_DEBUGGING_TYPE; | |
2906 | #else /* no PREFERRED_DEBUGGING_TYPE */ | |
2907 | You Lose! You must define PREFERRED_DEBUGGING_TYPE! | |
2908 | #endif /* no PREFERRED_DEBUGGING_TYPE */ | |
2909 | #endif /* More than one debugger format enabled. */ | |
2910 | #ifdef DBX_DEBUGGING_INFO | |
2911 | if (write_symbols != NO_DEBUG) | |
2912 | ; | |
2913 | else if (!strncmp (str, "ggdb", len)) | |
2914 | write_symbols = DBX_DEBUG; | |
2915 | else if (!strncmp (str, "gstabs", len)) | |
2916 | write_symbols = DBX_DEBUG; | |
2917 | ||
2918 | /* Always enable extensions for -ggdb or -gstabs+, | |
2919 | always disable for -gstabs. | |
2920 | For plain -g, use system-specific default. */ | |
2921 | if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len) | |
2922 | && len >= 2) | |
2923 | use_gdb_dbx_extensions = 1; | |
2924 | else if (write_symbols == DBX_DEBUG && !strcmp (str, "gstabs+")) | |
2925 | use_gdb_dbx_extensions = 1; | |
2926 | else if (write_symbols == DBX_DEBUG | |
2927 | && !strncmp (str, "gstabs", len) && len >= 2) | |
2928 | use_gdb_dbx_extensions = 0; | |
2929 | else | |
2930 | use_gdb_dbx_extensions = DEFAULT_GDB_EXTENSIONS; | |
2931 | #endif /* DBX_DEBUGGING_INFO */ | |
2932 | #ifdef DWARF_DEBUGGING_INFO | |
2933 | if (write_symbols != NO_DEBUG) | |
2934 | ; | |
2935 | else if (!strncmp (str, "ggdb", len)) | |
2936 | write_symbols = DWARF_DEBUG; | |
2937 | /* For orthogonality. */ | |
2938 | else if (!strncmp (str, "gdwarf", len)) | |
2939 | write_symbols = DWARF_DEBUG; | |
2940 | #endif | |
2941 | #ifdef SDB_DEBUGGING_INFO | |
2942 | if (write_symbols != NO_DEBUG) | |
2943 | ; | |
2944 | else if (!strncmp (str, "ggdb", len)) | |
2945 | write_symbols = SDB_DEBUG; | |
2946 | else if (!strncmp (str, "gcoff", len)) | |
2947 | write_symbols = SDB_DEBUG; | |
2948 | #endif /* SDB_DEBUGGING_INFO */ | |
f246a305 RS |
2949 | #ifdef XCOFF_DEBUGGING_INFO |
2950 | if (write_symbols != NO_DEBUG) | |
2951 | ; | |
2952 | else if (!strncmp (str, "ggdb", len)) | |
2953 | write_symbols = XCOFF_DEBUG; | |
2954 | else if (!strncmp (str, "gxcoff", len)) | |
2955 | write_symbols = XCOFF_DEBUG; | |
2956 | ||
2957 | /* Always enable extensions for -ggdb, | |
2958 | always disable for -gxcoff. | |
2959 | For plain -g, use system-specific default. */ | |
2960 | if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len) | |
2961 | && len >= 2) | |
2962 | use_gdb_dbx_extensions = 1; | |
a56addeb | 2963 | else if (write_symbols == XCOFF_DEBUG |
f246a305 RS |
2964 | && !strncmp (str, "gxcoff", len) && len >= 2) |
2965 | use_gdb_dbx_extensions = 0; | |
2966 | else | |
2967 | use_gdb_dbx_extensions = DEFAULT_GDB_EXTENSIONS; | |
2968 | #endif | |
4291d9c8 RS |
2969 | if (write_symbols == NO_DEBUG) |
2970 | warning ("`-%s' option not supported on this version of GCC", str); | |
2971 | else if (level == 0) | |
2972 | write_symbols = NO_DEBUG; | |
2973 | else | |
d68c507d | 2974 | debug_info_level = (enum debug_info_level) level; |
4291d9c8 RS |
2975 | } |
2976 | else if (!strcmp (str, "o")) | |
2977 | { | |
2978 | asm_file_name = argv[++i]; | |
2979 | } | |
2980 | else if (str[0] == 'G') | |
2981 | { | |
2982 | g_switch_set = TRUE; | |
2983 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
2984 | } | |
f246a305 RS |
2985 | else if (!strncmp (str, "aux-info", 8)) |
2986 | { | |
2987 | flag_gen_aux_info = 1; | |
2988 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
2989 | } | |
4291d9c8 RS |
2990 | else |
2991 | error ("Invalid option `%s'", argv[i]); | |
2992 | } | |
2993 | else if (argv[i][0] == '+') | |
2994 | { | |
2995 | if (lang_decode_option (argv[i])) | |
2996 | ; | |
2997 | else | |
2998 | error ("Invalid option `%s'", argv[i]); | |
2999 | } | |
3000 | else | |
3001 | filename = argv[i]; | |
3002 | } | |
3003 | ||
f246a305 RS |
3004 | /* Inlining does not work if not optimizing, |
3005 | so force it not to be done. */ | |
3006 | if (optimize == 0) | |
3007 | { | |
3008 | flag_no_inline = 1; | |
3009 | warn_inline = 0; | |
3010 | } | |
3011 | ||
4291d9c8 RS |
3012 | #ifdef OVERRIDE_OPTIONS |
3013 | /* Some machines may reject certain combinations of options. */ | |
3014 | OVERRIDE_OPTIONS; | |
3015 | #endif | |
3016 | ||
3017 | /* Unrolling all loops implies that standard loop unrolling must also | |
3018 | be done. */ | |
3019 | if (flag_unroll_all_loops) | |
3020 | flag_unroll_loops = 1; | |
3021 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
3022 | turn on strength reduction here if it isn't already on. Also, the loop | |
3023 | unrolling code assumes that cse will be run after loop, so that must | |
3024 | be turned on also. */ | |
3025 | if (flag_unroll_loops) | |
3026 | { | |
3027 | flag_strength_reduce = 1; | |
3028 | flag_rerun_cse_after_loop = 1; | |
3029 | } | |
3030 | ||
3031 | /* Warn about options that are not supported on this machine. */ | |
3032 | #ifndef INSN_SCHEDULING | |
3033 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
3034 | warning ("instruction scheduling not supported on this target machine"); | |
3035 | #endif | |
3036 | #ifndef DELAY_SLOTS | |
3037 | if (flag_delayed_branch) | |
3038 | warning ("this target machine does not have delayed branches"); | |
3039 | #endif | |
3040 | ||
3041 | /* If we are in verbose mode, write out the version and maybe all the | |
3042 | option flags in use. */ | |
3043 | if (version_flag) | |
3044 | { | |
3045 | fprintf (stderr, "%s version %s", language_string, version_string); | |
3046 | #ifdef TARGET_VERSION | |
3047 | TARGET_VERSION; | |
3048 | #endif | |
3049 | #ifdef __GNUC__ | |
3050 | #ifndef __VERSION__ | |
3051 | #define __VERSION__ "[unknown]" | |
3052 | #endif | |
3053 | fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__); | |
3054 | #else | |
3055 | fprintf (stderr, " compiled by CC.\n"); | |
3056 | #endif | |
3057 | if (! quiet_flag) | |
3058 | print_switch_values (); | |
3059 | } | |
3060 | ||
3061 | /* Now that register usage is specified, convert it to HARD_REG_SETs. */ | |
3062 | init_reg_sets_1 (); | |
3063 | ||
3064 | compile_file (filename); | |
3065 | ||
a56addeb | 3066 | #ifndef OS2 |
4291d9c8 RS |
3067 | #ifndef VMS |
3068 | if (flag_print_mem) | |
3069 | { | |
3070 | char *lim = (char *) sbrk (0); | |
3071 | ||
3072 | fprintf (stderr, "Data size %d.\n", | |
3073 | (int) lim - (int) &environ); | |
3074 | fflush (stderr); | |
3075 | ||
3076 | #ifdef USG | |
3077 | system ("ps -l 1>&2"); | |
3078 | #else /* not USG */ | |
3079 | system ("ps v"); | |
3080 | #endif /* not USG */ | |
3081 | } | |
3082 | #endif /* not VMS */ | |
a56addeb | 3083 | #endif /* not OS2 */ |
4291d9c8 RS |
3084 | |
3085 | if (errorcount) | |
3086 | exit (FATAL_EXIT_CODE); | |
3087 | if (sorrycount) | |
3088 | exit (FATAL_EXIT_CODE); | |
3089 | exit (SUCCESS_EXIT_CODE); | |
3090 | return 34; | |
3091 | } | |
3092 | \f | |
3093 | /* Decode -m switches. */ | |
3094 | ||
3095 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
3096 | and which bits in `target_switches' it should set or clear. | |
3097 | If VALUE is positive, it is bits to set. | |
3098 | If VALUE is negative, -VALUE is bits to clear. | |
3099 | (The sign bit is not used so there is no confusion.) */ | |
3100 | ||
3101 | struct {char *name; int value;} target_switches [] | |
3102 | = TARGET_SWITCHES; | |
3103 | ||
3104 | /* This table is similar, but allows the switch to have a value. */ | |
3105 | ||
3106 | #ifdef TARGET_OPTIONS | |
3107 | struct {char *prefix; char ** variable;} target_options [] | |
3108 | = TARGET_OPTIONS; | |
3109 | #endif | |
3110 | ||
3111 | /* Decode the switch -mNAME. */ | |
3112 | ||
3113 | void | |
3114 | set_target_switch (name) | |
3115 | char *name; | |
3116 | { | |
3117 | register int j; | |
3118 | int valid = 0; | |
3119 | ||
3120 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
3121 | if (!strcmp (target_switches[j].name, name)) | |
3122 | { | |
3123 | if (target_switches[j].value < 0) | |
3124 | target_flags &= ~-target_switches[j].value; | |
3125 | else | |
3126 | target_flags |= target_switches[j].value; | |
3127 | valid = 1; | |
3128 | } | |
3129 | ||
3130 | #ifdef TARGET_OPTIONS | |
3131 | if (!valid) | |
3132 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
3133 | { | |
3134 | int len = strlen (target_options[j].prefix); | |
3135 | if (!strncmp (target_options[j].prefix, name, len)) | |
3136 | { | |
3137 | *target_options[j].variable = name + len; | |
3138 | valid = 1; | |
3139 | } | |
3140 | } | |
3141 | #endif | |
3142 | ||
3143 | if (!valid) | |
3144 | error ("Invalid option `%s'", name); | |
3145 | } | |
3146 | \f | |
3147 | /* Variable used for communication between the following two routines. */ | |
3148 | ||
3149 | static int line_position; | |
3150 | ||
3151 | /* Print an option value and adjust the position in the line. */ | |
3152 | ||
3153 | static void | |
3154 | print_single_switch (type, name) | |
3155 | char *type, *name; | |
3156 | { | |
3157 | fprintf (stderr, " %s%s", type, name); | |
3158 | ||
3159 | line_position += strlen (type) + strlen (name) + 1; | |
3160 | ||
3161 | if (line_position > 65) | |
3162 | { | |
3163 | fprintf (stderr, "\n\t"); | |
3164 | line_position = 8; | |
3165 | } | |
3166 | } | |
3167 | ||
3168 | /* Print default target switches for -version. */ | |
3169 | ||
3170 | static void | |
3171 | print_switch_values () | |
3172 | { | |
3173 | register int j; | |
3174 | ||
3175 | fprintf (stderr, "enabled:"); | |
3176 | line_position = 8; | |
3177 | ||
3178 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
3179 | if (*f_options[j].variable == f_options[j].on_value) | |
3180 | print_single_switch ("-f", f_options[j].string); | |
3181 | ||
3182 | for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++) | |
3183 | if (*W_options[j].variable == W_options[j].on_value) | |
3184 | print_single_switch ("-W", W_options[j].string); | |
3185 | ||
3186 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
3187 | if (target_switches[j].name[0] != '\0' | |
3188 | && target_switches[j].value > 0 | |
3189 | && ((target_switches[j].value & target_flags) | |
3190 | == target_switches[j].value)) | |
3191 | print_single_switch ("-m", target_switches[j].name); | |
3192 | ||
3193 | fprintf (stderr, "\n"); | |
3194 | } |