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