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