]>
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. */ | |
6f606d63 | 2508 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); |
4291d9c8 RS |
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 | { | |
44333223 JL |
2562 | /* Running another jump optimization pass before the second |
2563 | cse pass sometimes simplifies the RTL enough to allow | |
2564 | the second CSE pass to do a better job. */ | |
4291d9c8 | 2565 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); |
44333223 | 2566 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); |
4291d9c8 RS |
2567 | |
2568 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), | |
2569 | 1, cse2_dump_file)); | |
2570 | if (tem) | |
2571 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
2572 | } | |
2573 | ||
2574 | if (optimize > 0 && flag_thread_jumps) | |
2575 | /* This pass of jump threading straightens out code | |
2576 | that was kinked by loop optimization. */ | |
2577 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
2578 | ||
2579 | /* Dump rtl code after cse, if we are doing that. */ | |
2580 | ||
2581 | if (cse2_dump) | |
2582 | TIMEVAR (dump_time, | |
2583 | { | |
2584 | print_rtl (cse2_dump_file, insns); | |
2585 | fflush (cse2_dump_file); | |
2586 | }); | |
2587 | ||
2588 | /* We are no longer anticipating cse in this function, at least. */ | |
2589 | ||
2590 | cse_not_expected = 1; | |
2591 | ||
2592 | /* Now we choose between stupid (pcc-like) register allocation | |
2593 | (if we got the -noreg switch and not -opt) | |
2594 | and smart register allocation. */ | |
2595 | ||
2596 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
2597 | obey_regdecls = 0; /* if optimizations being done. */ | |
2598 | ||
2599 | regclass_init (); | |
2600 | ||
2601 | /* Print function header into flow dump now | |
2602 | because doing the flow analysis makes some of the dump. */ | |
2603 | ||
2604 | if (flow_dump) | |
2605 | TIMEVAR (dump_time, | |
2606 | { | |
2607 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
2608 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2609 | }); | |
2610 | ||
2611 | if (obey_regdecls) | |
2612 | { | |
2613 | TIMEVAR (flow_time, | |
2614 | { | |
2615 | regclass (insns, max_reg_num ()); | |
2616 | stupid_life_analysis (insns, max_reg_num (), | |
2617 | flow_dump_file); | |
2618 | }); | |
2619 | } | |
2620 | else | |
2621 | { | |
2622 | /* Do control and data flow analysis, | |
2623 | and write some of the results to dump file. */ | |
2624 | ||
2625 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
2626 | flow_dump_file)); | |
2627 | if (warn_uninitialized) | |
2628 | { | |
2629 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
2630 | setjmp_args_warning (); | |
2631 | } | |
2632 | } | |
2633 | ||
2634 | /* Dump rtl after flow analysis. */ | |
2635 | ||
2636 | if (flow_dump) | |
2637 | TIMEVAR (dump_time, | |
2638 | { | |
2639 | print_rtl (flow_dump_file, insns); | |
2640 | fflush (flow_dump_file); | |
2641 | }); | |
2642 | ||
2643 | /* If -opt, try combining insns through substitution. */ | |
2644 | ||
2645 | if (optimize > 0) | |
2646 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
2647 | ||
2648 | /* Dump rtl code after insn combination. */ | |
2649 | ||
2650 | if (combine_dump) | |
2651 | TIMEVAR (dump_time, | |
2652 | { | |
2653 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
2654 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2655 | dump_combine_stats (combine_dump_file); | |
2656 | print_rtl (combine_dump_file, insns); | |
2657 | fflush (combine_dump_file); | |
2658 | }); | |
2659 | ||
2660 | /* Print function header into sched dump now | |
2661 | because doing the sched analysis makes some of the dump. */ | |
2662 | ||
2663 | if (sched_dump) | |
2664 | TIMEVAR (dump_time, | |
2665 | { | |
2666 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
2667 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2668 | }); | |
2669 | ||
2670 | if (optimize > 0 && flag_schedule_insns) | |
2671 | { | |
2672 | /* Do control and data sched analysis, | |
2673 | and write some of the results to dump file. */ | |
2674 | ||
2675 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
2676 | } | |
2677 | ||
2678 | /* Dump rtl after instruction scheduling. */ | |
2679 | ||
2680 | if (sched_dump) | |
2681 | TIMEVAR (dump_time, | |
2682 | { | |
2683 | print_rtl (sched_dump_file, insns); | |
2684 | fflush (sched_dump_file); | |
2685 | }); | |
2686 | ||
2687 | /* Unless we did stupid register allocation, | |
2688 | allocate pseudo-regs that are used only within 1 basic block. */ | |
2689 | ||
2690 | if (!obey_regdecls) | |
2691 | TIMEVAR (local_alloc_time, | |
2692 | { | |
2693 | regclass (insns, max_reg_num ()); | |
2694 | local_alloc (); | |
2695 | }); | |
2696 | ||
2697 | /* Dump rtl code after allocating regs within basic blocks. */ | |
2698 | ||
2699 | if (local_reg_dump) | |
2700 | TIMEVAR (dump_time, | |
2701 | { | |
2702 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
2703 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2704 | dump_flow_info (local_reg_dump_file); | |
2705 | dump_local_alloc (local_reg_dump_file); | |
2706 | print_rtl (local_reg_dump_file, insns); | |
2707 | fflush (local_reg_dump_file); | |
2708 | }); | |
2709 | ||
2710 | if (global_reg_dump) | |
2711 | TIMEVAR (dump_time, | |
2712 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
2713 | IDENTIFIER_POINTER (DECL_NAME (decl)))); | |
2714 | ||
2715 | /* Unless we did stupid register allocation, | |
2716 | allocate remaining pseudo-regs, then do the reload pass | |
2717 | fixing up any insns that are invalid. */ | |
2718 | ||
2719 | TIMEVAR (global_alloc_time, | |
2720 | { | |
2721 | if (!obey_regdecls) | |
37366632 | 2722 | failure = global_alloc (global_reg_dump_file); |
4291d9c8 | 2723 | else |
37366632 | 2724 | failure = reload (insns, 0, global_reg_dump_file); |
4291d9c8 RS |
2725 | }); |
2726 | ||
2727 | if (global_reg_dump) | |
2728 | TIMEVAR (dump_time, | |
2729 | { | |
2730 | dump_global_regs (global_reg_dump_file); | |
2731 | print_rtl (global_reg_dump_file, insns); | |
2732 | fflush (global_reg_dump_file); | |
2733 | }); | |
2734 | ||
ab40ad2b RS |
2735 | if (failure) |
2736 | goto exit_rest_of_compilation; | |
2737 | ||
4291d9c8 RS |
2738 | reload_completed = 1; |
2739 | ||
bdac5f58 TW |
2740 | /* On some machines, the prologue and epilogue code, or parts thereof, |
2741 | can be represented as RTL. Doing so lets us schedule insns between | |
2742 | it and the rest of the code and also allows delayed branch | |
2743 | scheduling to operate in the epilogue. */ | |
2744 | ||
2745 | thread_prologue_and_epilogue_insns (insns); | |
2746 | ||
4291d9c8 RS |
2747 | if (optimize > 0 && flag_schedule_insns_after_reload) |
2748 | { | |
2749 | if (sched2_dump) | |
2750 | TIMEVAR (dump_time, | |
2751 | { | |
2752 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
2753 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2754 | }); | |
2755 | ||
2756 | /* Do control and data sched analysis again, | |
2757 | and write some more of the results to dump file. */ | |
2758 | ||
2759 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
2760 | ||
2761 | /* Dump rtl after post-reorder instruction scheduling. */ | |
2762 | ||
2763 | if (sched2_dump) | |
2764 | TIMEVAR (dump_time, | |
2765 | { | |
2766 | print_rtl (sched2_dump_file, insns); | |
2767 | fflush (sched2_dump_file); | |
2768 | }); | |
2769 | } | |
2770 | ||
2771 | #ifdef LEAF_REGISTERS | |
2772 | leaf_function = 0; | |
2773 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 2774 | leaf_function = 1; |
4291d9c8 RS |
2775 | #endif |
2776 | ||
2777 | /* One more attempt to remove jumps to .+1 | |
2778 | left by dead-store-elimination. | |
2779 | Also do cross-jumping this time | |
2780 | and delete no-op move insns. */ | |
2781 | ||
2782 | if (optimize > 0) | |
2783 | { | |
2784 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
2785 | } | |
2786 | ||
2787 | /* Dump rtl code after jump, if we are doing that. */ | |
2788 | ||
2789 | if (jump2_opt_dump) | |
2790 | TIMEVAR (dump_time, | |
2791 | { | |
2792 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
2793 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2794 | print_rtl (jump2_opt_dump_file, insns); | |
2795 | fflush (jump2_opt_dump_file); | |
2796 | }); | |
2797 | ||
2798 | /* If a scheduling pass for delayed branches is to be done, | |
2799 | call the scheduling code. */ | |
2800 | ||
2801 | #ifdef DELAY_SLOTS | |
2802 | if (optimize > 0 && flag_delayed_branch) | |
2803 | { | |
2804 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
2805 | if (dbr_sched_dump) | |
2806 | { | |
2807 | TIMEVAR (dump_time, | |
2808 | { | |
2809 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
2810 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2811 | print_rtl (dbr_sched_dump_file, insns); | |
2812 | fflush (dbr_sched_dump_file); | |
2813 | }); | |
2814 | } | |
2815 | } | |
2816 | #endif | |
2817 | ||
2818 | if (optimize > 0) | |
2819 | /* Shorten branches. */ | |
2820 | TIMEVAR (shorten_branch_time, | |
2821 | { | |
2822 | shorten_branches (get_insns ()); | |
2823 | }); | |
2824 | ||
2825 | #ifdef STACK_REGS | |
2826 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
2827 | if (stack_reg_dump) | |
2828 | { | |
2829 | TIMEVAR (dump_time, | |
2830 | { | |
2831 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
2832 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
2833 | print_rtl (stack_reg_dump_file, insns); | |
2834 | fflush (stack_reg_dump_file); | |
2835 | }); | |
2836 | } | |
2837 | #endif | |
2838 | ||
2839 | /* Now turn the rtl into assembler code. */ | |
2840 | ||
2841 | TIMEVAR (final_time, | |
2842 | { | |
2843 | rtx x; | |
2844 | char *fnname; | |
2845 | ||
2846 | /* Get the function's name, as described by its RTL. | |
2847 | This may be different from the DECL_NAME name used | |
2848 | in the source file. */ | |
2849 | ||
2850 | x = DECL_RTL (decl); | |
2851 | if (GET_CODE (x) != MEM) | |
2852 | abort (); | |
2853 | x = XEXP (x, 0); | |
2854 | if (GET_CODE (x) != SYMBOL_REF) | |
2855 | abort (); | |
2856 | fnname = XSTR (x, 0); | |
2857 | ||
2858 | assemble_start_function (decl, fnname); | |
2859 | final_start_function (insns, asm_out_file, optimize); | |
2860 | final (insns, asm_out_file, optimize, 0); | |
2861 | final_end_function (insns, asm_out_file, optimize); | |
2862 | assemble_end_function (decl, fnname); | |
2863 | fflush (asm_out_file); | |
2864 | }); | |
2865 | ||
2866 | /* Write DBX symbols if requested */ | |
2867 | ||
2868 | /* Note that for those inline functions where we don't initially | |
2869 | know for certain that we will be generating an out-of-line copy, | |
2870 | the first invocation of this routine (rest_of_compilation) will | |
2871 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
2872 | Later on, finish_compilation will call rest_of_compilation again | |
2873 | for those inline functions that need to have out-of-line copies | |
2874 | generated. During that call, we *will* be routed past here. */ | |
2875 | ||
2876 | #ifdef DBX_DEBUGGING_INFO | |
2877 | if (write_symbols == DBX_DEBUG) | |
2878 | TIMEVAR (symout_time, dbxout_function (decl)); | |
2879 | #endif | |
2880 | ||
2881 | #ifdef DWARF_DEBUGGING_INFO | |
2882 | if (write_symbols == DWARF_DEBUG) | |
2883 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
2884 | #endif | |
2885 | ||
2886 | exit_rest_of_compilation: | |
2887 | ||
f246a305 RS |
2888 | /* In case the function was not output, |
2889 | don't leave any temporary anonymous types | |
2890 | queued up for sdb output. */ | |
2891 | #ifdef SDB_DEBUGGING_INFO | |
2892 | if (write_symbols == SDB_DEBUG) | |
37366632 | 2893 | sdbout_types (NULL_TREE); |
f246a305 RS |
2894 | #endif |
2895 | ||
8a958768 RS |
2896 | /* Put back the tree of subblocks and list of arguments |
2897 | from before we copied them. | |
4291d9c8 RS |
2898 | Code generation and the output of debugging info may have modified |
2899 | the copy, but the original is unchanged. */ | |
2900 | ||
2901 | if (saved_block_tree != 0) | |
2902 | DECL_INITIAL (decl) = saved_block_tree; | |
8a958768 RS |
2903 | if (saved_arguments != 0) |
2904 | DECL_ARGUMENTS (decl) = saved_arguments; | |
4291d9c8 RS |
2905 | |
2906 | reload_completed = 0; | |
2907 | ||
2908 | /* Clear out the real_constant_chain before some of the rtx's | |
2909 | it runs through become garbage. */ | |
2910 | ||
2911 | clear_const_double_mem (); | |
2912 | ||
2913 | /* Cancel the effect of rtl_in_current_obstack. */ | |
2914 | ||
2915 | resume_temporary_allocation (); | |
2916 | ||
2917 | /* The parsing time is all the time spent in yyparse | |
2918 | *except* what is spent in this function. */ | |
2919 | ||
2920 | parse_time -= get_run_time () - start_time; | |
2921 | } | |
2922 | \f | |
2923 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
2924 | Exit code is 35 if can't open files, 34 if fatal error, | |
2925 | 33 if had nonfatal errors, else success. */ | |
2926 | ||
2927 | int | |
2928 | main (argc, argv, envp) | |
2929 | int argc; | |
2930 | char **argv; | |
2931 | char **envp; | |
2932 | { | |
2933 | register int i; | |
2934 | char *filename = 0; | |
2935 | int flag_print_mem = 0; | |
2936 | int version_flag = 0; | |
2937 | char *p; | |
2938 | ||
2939 | /* save in case md file wants to emit args as a comment. */ | |
2940 | save_argc = argc; | |
2941 | save_argv = argv; | |
2942 | ||
2943 | p = argv[0] + strlen (argv[0]); | |
2944 | while (p != argv[0] && p[-1] != '/') --p; | |
2945 | progname = p; | |
2946 | ||
2947 | #ifdef RLIMIT_STACK | |
2948 | /* Get rid of any avoidable limit on stack size. */ | |
2949 | { | |
2950 | struct rlimit rlim; | |
2951 | ||
2952 | /* Set the stack limit huge so that alloca does not fail. */ | |
2953 | getrlimit (RLIMIT_STACK, &rlim); | |
2954 | rlim.rlim_cur = rlim.rlim_max; | |
2955 | setrlimit (RLIMIT_STACK, &rlim); | |
2956 | } | |
2957 | #endif /* RLIMIT_STACK */ | |
2958 | ||
2959 | signal (SIGFPE, float_signal); | |
2960 | ||
935d4b07 | 2961 | #ifdef SIGPIPE |
4291d9c8 | 2962 | signal (SIGPIPE, pipe_closed); |
935d4b07 | 2963 | #endif |
4291d9c8 RS |
2964 | |
2965 | decl_printable_name = decl_name; | |
2966 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
2967 | ||
2968 | /* Initialize whether `char' is signed. */ | |
2969 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
2970 | #ifdef DEFAULT_SHORT_ENUMS | |
2971 | /* Initialize how much space enums occupy, by default. */ | |
2972 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
2973 | #endif | |
2974 | ||
2975 | /* Scan to see what optimization level has been specified. That will | |
2976 | determine the default value of many flags. */ | |
2977 | for (i = 1; i < argc; i++) | |
2978 | { | |
2979 | if (!strcmp (argv[i], "-O")) | |
2980 | { | |
2981 | optimize = 1; | |
2982 | } | |
2983 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
2984 | { | |
2985 | /* Handle -O2, -O3, -O69, ... */ | |
2986 | char *p = &argv[i][2]; | |
2987 | int c; | |
2988 | ||
2989 | while (c = *p++) | |
2990 | if (! (c >= '0' && c <= '9')) | |
2991 | break; | |
2992 | if (c == 0) | |
2993 | optimize = atoi (&argv[i][2]); | |
2994 | } | |
2995 | } | |
2996 | ||
2997 | obey_regdecls = (optimize == 0); | |
f246a305 RS |
2998 | if (optimize == 0) |
2999 | { | |
3000 | flag_no_inline = 1; | |
3001 | warn_inline = 0; | |
3002 | } | |
4291d9c8 RS |
3003 | |
3004 | if (optimize >= 1) | |
3005 | { | |
6731a3e3 | 3006 | flag_defer_pop = 1; |
4291d9c8 RS |
3007 | flag_thread_jumps = 1; |
3008 | #ifdef DELAY_SLOTS | |
3009 | flag_delayed_branch = 1; | |
7e89c3a3 RK |
3010 | #endif |
3011 | #ifdef CAN_DEBUG_WITHOUT_FP | |
3012 | flag_omit_frame_pointer = 1; | |
4291d9c8 RS |
3013 | #endif |
3014 | } | |
3015 | ||
3016 | if (optimize >= 2) | |
3017 | { | |
3018 | flag_cse_follow_jumps = 1; | |
8b3686ed | 3019 | flag_cse_skip_blocks = 1; |
4291d9c8 RS |
3020 | flag_expensive_optimizations = 1; |
3021 | flag_strength_reduce = 1; | |
3022 | flag_rerun_cse_after_loop = 1; | |
ac266247 | 3023 | flag_caller_saves = 1; |
4291d9c8 RS |
3024 | #ifdef INSN_SCHEDULING |
3025 | flag_schedule_insns = 1; | |
3026 | flag_schedule_insns_after_reload = 1; | |
3027 | #endif | |
3028 | } | |
3029 | ||
7e89c3a3 RK |
3030 | if (optimize >= 3) |
3031 | { | |
3032 | flag_inline_functions = 1; | |
3033 | } | |
3034 | ||
4291d9c8 RS |
3035 | #ifdef OPTIMIZATION_OPTIONS |
3036 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
3037 | OPTIMIZATION_OPTIONS (optimize); | |
3038 | #endif | |
3039 | ||
3040 | /* Initialize register usage now so switches may override. */ | |
3041 | init_reg_sets (); | |
3042 | ||
3043 | target_flags = 0; | |
3044 | set_target_switch (""); | |
3045 | ||
3046 | for (i = 1; i < argc; i++) | |
3047 | { | |
b99933c7 RS |
3048 | int j; |
3049 | /* If this is a language-specific option, | |
3050 | decode it in a language-specific way. */ | |
3051 | for (j = 0; lang_options[j] != 0; j++) | |
3052 | if (!strncmp (argv[i], lang_options[j], | |
3053 | strlen (lang_options[j]))) | |
3054 | break; | |
3055 | if (lang_options[j] != 0) | |
3056 | /* If the option is valid for *some* language, | |
3057 | treat it as valid even if this language doesn't understand it. */ | |
3058 | lang_decode_option (argv[i]); | |
3059 | else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4291d9c8 RS |
3060 | { |
3061 | register char *str = argv[i] + 1; | |
3062 | if (str[0] == 'Y') | |
3063 | str++; | |
3064 | ||
3065 | if (str[0] == 'm') | |
3066 | set_target_switch (&str[1]); | |
3067 | else if (!strcmp (str, "dumpbase")) | |
3068 | { | |
3069 | dump_base_name = argv[++i]; | |
3070 | } | |
3071 | else if (str[0] == 'd') | |
3072 | { | |
3073 | register char *p = &str[1]; | |
3074 | while (*p) | |
3075 | switch (*p++) | |
3076 | { | |
3077 | case 'a': | |
3078 | combine_dump = 1; | |
3079 | dbr_sched_dump = 1; | |
3080 | flow_dump = 1; | |
3081 | global_reg_dump = 1; | |
3082 | jump_opt_dump = 1; | |
3083 | jump2_opt_dump = 1; | |
3084 | local_reg_dump = 1; | |
3085 | loop_dump = 1; | |
3086 | rtl_dump = 1; | |
3087 | cse_dump = 1, cse2_dump = 1; | |
3088 | sched_dump = 1; | |
3089 | sched2_dump = 1; | |
3090 | stack_reg_dump = 1; | |
3091 | break; | |
3092 | case 'k': | |
3093 | stack_reg_dump = 1; | |
3094 | break; | |
3095 | case 'c': | |
3096 | combine_dump = 1; | |
3097 | break; | |
3098 | case 'd': | |
3099 | dbr_sched_dump = 1; | |
3100 | break; | |
3101 | case 'f': | |
3102 | flow_dump = 1; | |
3103 | break; | |
3104 | case 'g': | |
3105 | global_reg_dump = 1; | |
3106 | break; | |
3107 | case 'j': | |
3108 | jump_opt_dump = 1; | |
3109 | break; | |
3110 | case 'J': | |
3111 | jump2_opt_dump = 1; | |
3112 | break; | |
3113 | case 'l': | |
3114 | local_reg_dump = 1; | |
3115 | break; | |
3116 | case 'L': | |
3117 | loop_dump = 1; | |
3118 | break; | |
3119 | case 'm': | |
3120 | flag_print_mem = 1; | |
3121 | break; | |
3122 | case 'p': | |
3123 | flag_print_asm_name = 1; | |
3124 | break; | |
3125 | case 'r': | |
3126 | rtl_dump = 1; | |
3127 | break; | |
3128 | case 's': | |
3129 | cse_dump = 1; | |
3130 | break; | |
3131 | case 't': | |
3132 | cse2_dump = 1; | |
3133 | break; | |
3134 | case 'S': | |
3135 | sched_dump = 1; | |
3136 | break; | |
3137 | case 'R': | |
3138 | sched2_dump = 1; | |
3139 | break; | |
3140 | case 'y': | |
3141 | set_yydebug (1); | |
3142 | break; | |
3143 | ||
3144 | case 'x': | |
3145 | rtl_dump_and_exit = 1; | |
3146 | break; | |
3147 | } | |
3148 | } | |
3149 | else if (str[0] == 'f') | |
3150 | { | |
4291d9c8 RS |
3151 | register char *p = &str[1]; |
3152 | int found = 0; | |
3153 | ||
3154 | /* Some kind of -f option. | |
3155 | P's value is the option sans `-f'. | |
3156 | Search for it in the table of options. */ | |
3157 | ||
3158 | for (j = 0; | |
3159 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
3160 | j++) | |
3161 | { | |
3162 | if (!strcmp (p, f_options[j].string)) | |
3163 | { | |
3164 | *f_options[j].variable = f_options[j].on_value; | |
3165 | /* A goto here would be cleaner, | |
3166 | but breaks the vax pcc. */ | |
3167 | found = 1; | |
3168 | } | |
3169 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
3170 | && ! strcmp (p+3, f_options[j].string)) | |
3171 | { | |
3172 | *f_options[j].variable = ! f_options[j].on_value; | |
3173 | found = 1; | |
3174 | } | |
3175 | } | |
3176 | ||
3177 | if (found) | |
3178 | ; | |
3179 | else if (!strncmp (p, "fixed-", 6)) | |
3180 | fix_register (&p[6], 1, 1); | |
3181 | else if (!strncmp (p, "call-used-", 10)) | |
3182 | fix_register (&p[10], 0, 1); | |
3183 | else if (!strncmp (p, "call-saved-", 11)) | |
3184 | fix_register (&p[11], 0, 0); | |
b99933c7 | 3185 | else |
4291d9c8 RS |
3186 | error ("Invalid option `%s'", argv[i]); |
3187 | } | |
3188 | else if (str[0] == 'O') | |
3189 | { | |
3190 | register char *p = str+1; | |
3191 | while (*p && *p >= '0' && *p <= '9') | |
3192 | p++; | |
3193 | if (*p == '\0') | |
3194 | ; | |
3195 | else | |
3196 | error ("Invalid option `%s'", argv[i]); | |
3197 | } | |
3198 | else if (!strcmp (str, "pedantic")) | |
3199 | pedantic = 1; | |
3200 | else if (!strcmp (str, "pedantic-errors")) | |
3201 | flag_pedantic_errors = pedantic = 1; | |
4291d9c8 RS |
3202 | else if (!strcmp (str, "quiet")) |
3203 | quiet_flag = 1; | |
3204 | else if (!strcmp (str, "version")) | |
3205 | version_flag = 1; | |
3206 | else if (!strcmp (str, "w")) | |
3207 | inhibit_warnings = 1; | |
3208 | else if (!strcmp (str, "W")) | |
3209 | { | |
3210 | extra_warnings = 1; | |
fa1a4543 RS |
3211 | /* We save the value of warn_uninitialized, since if they put |
3212 | -Wuninitialized on the command line, we need to generate a | |
3213 | warning about not using it without also specifying -O. */ | |
3214 | if (warn_uninitialized != 1) | |
3215 | warn_uninitialized = 2; | |
4291d9c8 RS |
3216 | } |
3217 | else if (str[0] == 'W') | |
3218 | { | |
4291d9c8 RS |
3219 | register char *p = &str[1]; |
3220 | int found = 0; | |
3221 | ||
3222 | /* Some kind of -W option. | |
3223 | P's value is the option sans `-W'. | |
3224 | Search for it in the table of options. */ | |
3225 | ||
3226 | for (j = 0; | |
3227 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
3228 | j++) | |
3229 | { | |
3230 | if (!strcmp (p, W_options[j].string)) | |
3231 | { | |
3232 | *W_options[j].variable = W_options[j].on_value; | |
3233 | /* A goto here would be cleaner, | |
3234 | but breaks the vax pcc. */ | |
3235 | found = 1; | |
3236 | } | |
3237 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
3238 | && ! strcmp (p+3, W_options[j].string)) | |
3239 | { | |
3240 | *W_options[j].variable = ! W_options[j].on_value; | |
3241 | found = 1; | |
3242 | } | |
3243 | } | |
3244 | ||
3245 | if (found) | |
3246 | ; | |
3247 | else if (!strncmp (p, "id-clash-", 9)) | |
3248 | { | |
3249 | char *endp = p + 9; | |
3250 | ||
3251 | while (*endp) | |
3252 | { | |
3253 | if (*endp >= '0' && *endp <= '9') | |
3254 | endp++; | |
3255 | else | |
7085b873 RS |
3256 | { |
3257 | error ("Invalid option `%s'", argv[i]); | |
3258 | goto id_clash_lose; | |
3259 | } | |
4291d9c8 RS |
3260 | } |
3261 | warn_id_clash = 1; | |
3262 | id_clash_len = atoi (str + 10); | |
7085b873 | 3263 | id_clash_lose: ; |
4291d9c8 RS |
3264 | } |
3265 | else | |
3266 | error ("Invalid option `%s'", argv[i]); | |
3267 | } | |
3268 | else if (!strcmp (str, "p")) | |
ca695ac9 JB |
3269 | { |
3270 | if (!output_bytecode) | |
3271 | profile_flag = 1; | |
3272 | else | |
3273 | error ("profiling not supported in bytecode compilation"); | |
3274 | } | |
4291d9c8 RS |
3275 | else if (!strcmp (str, "a")) |
3276 | { | |
3277 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
3278 | warning ("`-a' option (basic block profile) not supported"); | |
3279 | #else | |
3280 | profile_block_flag = 1; | |
3281 | #endif | |
3282 | } | |
3283 | else if (str[0] == 'g') | |
3284 | { | |
3285 | char *p = str + 1; | |
3286 | char *q; | |
3287 | unsigned len; | |
3288 | unsigned level; | |
3289 | ||
3290 | while (*p && (*p < '0' || *p > '9')) | |
3291 | p++; | |
3292 | len = p - str; | |
3293 | q = p; | |
3294 | while (*q && (*q >= '0' && *q <= '9')) | |
3295 | q++; | |
3296 | if (*p) | |
3297 | level = atoi (p); | |
3298 | else | |
3299 | level = 2; /* default debugging info level */ | |
3300 | if (*q || level > 3) | |
3301 | { | |
3302 | warning ("invalid debug level specification in option: `-%s'", | |
3303 | str); | |
3304 | warning ("no debugging information will be generated"); | |
3305 | level = 0; | |
3306 | } | |
3307 | ||
3308 | /* If more than one debugging type is supported, | |
3309 | you must define PREFERRED_DEBUGGING_TYPE | |
3310 | to choose a format in a system-dependent way. */ | |
4d7e336b RS |
3311 | /* This is one long line cause VAXC can't handle a \-newline. */ |
3312 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) | |
4291d9c8 RS |
3313 | #ifdef PREFERRED_DEBUGGING_TYPE |
3314 | if (!strncmp (str, "ggdb", len)) | |
3315 | write_symbols = PREFERRED_DEBUGGING_TYPE; | |
3316 | #else /* no PREFERRED_DEBUGGING_TYPE */ | |
3317 | You Lose! You must define PREFERRED_DEBUGGING_TYPE! | |
3318 | #endif /* no PREFERRED_DEBUGGING_TYPE */ | |
3319 | #endif /* More than one debugger format enabled. */ | |
3320 | #ifdef DBX_DEBUGGING_INFO | |
3321 | if (write_symbols != NO_DEBUG) | |
3322 | ; | |
3323 | else if (!strncmp (str, "ggdb", len)) | |
3324 | write_symbols = DBX_DEBUG; | |
3325 | else if (!strncmp (str, "gstabs", len)) | |
3326 | write_symbols = DBX_DEBUG; | |
efa89fb3 RS |
3327 | else if (!strncmp (str, "gstabs+", len)) |
3328 | write_symbols = DBX_DEBUG; | |
4291d9c8 RS |
3329 | |
3330 | /* Always enable extensions for -ggdb or -gstabs+, | |
3331 | always disable for -gstabs. | |
3332 | For plain -g, use system-specific default. */ | |
3333 | if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len) | |
3334 | && len >= 2) | |
a53d0bcc | 3335 | use_gnu_debug_info_extensions = 1; |
166792f0 RS |
3336 | else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len) |
3337 | && len >= 7) | |
a53d0bcc | 3338 | use_gnu_debug_info_extensions = 1; |
4291d9c8 RS |
3339 | else if (write_symbols == DBX_DEBUG |
3340 | && !strncmp (str, "gstabs", len) && len >= 2) | |
a53d0bcc | 3341 | use_gnu_debug_info_extensions = 0; |
4291d9c8 | 3342 | else |
a53d0bcc | 3343 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; |
4291d9c8 RS |
3344 | #endif /* DBX_DEBUGGING_INFO */ |
3345 | #ifdef DWARF_DEBUGGING_INFO | |
3346 | if (write_symbols != NO_DEBUG) | |
3347 | ; | |
a53d0bcc RS |
3348 | else if (!strncmp (str, "g", len)) |
3349 | write_symbols = DWARF_DEBUG; | |
4291d9c8 RS |
3350 | else if (!strncmp (str, "ggdb", len)) |
3351 | write_symbols = DWARF_DEBUG; | |
4291d9c8 RS |
3352 | else if (!strncmp (str, "gdwarf", len)) |
3353 | write_symbols = DWARF_DEBUG; | |
a53d0bcc RS |
3354 | |
3355 | /* Always enable extensions for -ggdb or -gdwarf+, | |
3356 | always disable for -gdwarf. | |
3357 | For plain -g, use system-specific default. */ | |
3358 | if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len) | |
3359 | && len >= 2) | |
3360 | use_gnu_debug_info_extensions = 1; | |
3361 | else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+")) | |
3362 | use_gnu_debug_info_extensions = 1; | |
3363 | else if (write_symbols == DWARF_DEBUG | |
3364 | && !strncmp (str, "gdwarf", len) && len >= 2) | |
3365 | use_gnu_debug_info_extensions = 0; | |
3366 | else | |
3367 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; | |
4291d9c8 RS |
3368 | #endif |
3369 | #ifdef SDB_DEBUGGING_INFO | |
3370 | if (write_symbols != NO_DEBUG) | |
3371 | ; | |
a53d0bcc RS |
3372 | else if (!strncmp (str, "g", len)) |
3373 | write_symbols = SDB_DEBUG; | |
3374 | else if (!strncmp (str, "gdb", len)) | |
4291d9c8 RS |
3375 | write_symbols = SDB_DEBUG; |
3376 | else if (!strncmp (str, "gcoff", len)) | |
3377 | write_symbols = SDB_DEBUG; | |
3378 | #endif /* SDB_DEBUGGING_INFO */ | |
f246a305 RS |
3379 | #ifdef XCOFF_DEBUGGING_INFO |
3380 | if (write_symbols != NO_DEBUG) | |
3381 | ; | |
a53d0bcc RS |
3382 | else if (!strncmp (str, "g", len)) |
3383 | write_symbols = XCOFF_DEBUG; | |
f246a305 RS |
3384 | else if (!strncmp (str, "ggdb", len)) |
3385 | write_symbols = XCOFF_DEBUG; | |
3386 | else if (!strncmp (str, "gxcoff", len)) | |
3387 | write_symbols = XCOFF_DEBUG; | |
3388 | ||
a53d0bcc | 3389 | /* Always enable extensions for -ggdb or -gxcoff+, |
f246a305 RS |
3390 | always disable for -gxcoff. |
3391 | For plain -g, use system-specific default. */ | |
3392 | if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len) | |
3393 | && len >= 2) | |
a53d0bcc RS |
3394 | use_gnu_debug_info_extensions = 1; |
3395 | else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+")) | |
3396 | use_gnu_debug_info_extensions = 1; | |
a56addeb | 3397 | else if (write_symbols == XCOFF_DEBUG |
f246a305 | 3398 | && !strncmp (str, "gxcoff", len) && len >= 2) |
a53d0bcc | 3399 | use_gnu_debug_info_extensions = 0; |
f246a305 | 3400 | else |
a53d0bcc | 3401 | use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; |
f246a305 | 3402 | #endif |
4291d9c8 RS |
3403 | if (write_symbols == NO_DEBUG) |
3404 | warning ("`-%s' option not supported on this version of GCC", str); | |
3405 | else if (level == 0) | |
3406 | write_symbols = NO_DEBUG; | |
3407 | else | |
d68c507d | 3408 | debug_info_level = (enum debug_info_level) level; |
4291d9c8 RS |
3409 | } |
3410 | else if (!strcmp (str, "o")) | |
3411 | { | |
3412 | asm_file_name = argv[++i]; | |
3413 | } | |
3414 | else if (str[0] == 'G') | |
3415 | { | |
3416 | g_switch_set = TRUE; | |
3417 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
3418 | } | |
f246a305 RS |
3419 | else if (!strncmp (str, "aux-info", 8)) |
3420 | { | |
3421 | flag_gen_aux_info = 1; | |
3422 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
3423 | } | |
4291d9c8 RS |
3424 | else |
3425 | error ("Invalid option `%s'", argv[i]); | |
3426 | } | |
3427 | else if (argv[i][0] == '+') | |
b99933c7 | 3428 | error ("Invalid option `%s'", argv[i]); |
4291d9c8 RS |
3429 | else |
3430 | filename = argv[i]; | |
3431 | } | |
3432 | ||
ca695ac9 JB |
3433 | /* Initialize for bytecode output. A good idea to do this as soon as |
3434 | possible after the "-f" options have been parsed. */ | |
3435 | if (output_bytecode) | |
3436 | { | |
3437 | #ifndef TARGET_SUPPORTS_BYTECODE | |
3438 | /* Just die with a fatal error if not supported */ | |
3439 | fatal ("-fbytecode can not be used for this target"); | |
3440 | #else | |
3441 | bc_initialize (); | |
3442 | #endif | |
3443 | } | |
3444 | ||
f246a305 RS |
3445 | if (optimize == 0) |
3446 | { | |
a2468e45 BK |
3447 | /* Inlining does not work if not optimizing, |
3448 | so force it not to be done. */ | |
f246a305 RS |
3449 | flag_no_inline = 1; |
3450 | warn_inline = 0; | |
a2468e45 BK |
3451 | |
3452 | /* The c_decode_option and lang_decode_option functions set | |
3453 | this to `2' if -Wall is used, so we can avoid giving out | |
3454 | lots of errors for people who don't realize what -Wall does. */ | |
3455 | if (warn_uninitialized == 1) | |
3456 | warning ("-Wuninitialized is not supported without -O"); | |
f246a305 RS |
3457 | } |
3458 | ||
7877bbb3 RS |
3459 | #if defined(DWARF_DEBUGGING_INFO) |
3460 | if (write_symbols == DWARF_DEBUG | |
3461 | && strcmp (language_string, "GNU C++") == 0) | |
3462 | { | |
2b5ddaab | 3463 | warning ("-g option not supported for C++ on SVR4 systems"); |
7877bbb3 RS |
3464 | write_symbols = NO_DEBUG; |
3465 | } | |
3466 | #endif /* defined(DWARF_DEBUGGING_INFO) */ | |
3467 | ||
4291d9c8 RS |
3468 | #ifdef OVERRIDE_OPTIONS |
3469 | /* Some machines may reject certain combinations of options. */ | |
3470 | OVERRIDE_OPTIONS; | |
3471 | #endif | |
3472 | ||
3473 | /* Unrolling all loops implies that standard loop unrolling must also | |
3474 | be done. */ | |
3475 | if (flag_unroll_all_loops) | |
3476 | flag_unroll_loops = 1; | |
3477 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
3478 | turn on strength reduction here if it isn't already on. Also, the loop | |
3479 | unrolling code assumes that cse will be run after loop, so that must | |
3480 | be turned on also. */ | |
3481 | if (flag_unroll_loops) | |
3482 | { | |
3483 | flag_strength_reduce = 1; | |
3484 | flag_rerun_cse_after_loop = 1; | |
3485 | } | |
3486 | ||
3487 | /* Warn about options that are not supported on this machine. */ | |
3488 | #ifndef INSN_SCHEDULING | |
3489 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
3490 | warning ("instruction scheduling not supported on this target machine"); | |
3491 | #endif | |
3492 | #ifndef DELAY_SLOTS | |
3493 | if (flag_delayed_branch) | |
3494 | warning ("this target machine does not have delayed branches"); | |
3495 | #endif | |
3496 | ||
3497 | /* If we are in verbose mode, write out the version and maybe all the | |
3498 | option flags in use. */ | |
3499 | if (version_flag) | |
3500 | { | |
3501 | fprintf (stderr, "%s version %s", language_string, version_string); | |
3502 | #ifdef TARGET_VERSION | |
3503 | TARGET_VERSION; | |
3504 | #endif | |
3505 | #ifdef __GNUC__ | |
3506 | #ifndef __VERSION__ | |
3507 | #define __VERSION__ "[unknown]" | |
3508 | #endif | |
3509 | fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__); | |
3510 | #else | |
3511 | fprintf (stderr, " compiled by CC.\n"); | |
3512 | #endif | |
3513 | if (! quiet_flag) | |
3514 | print_switch_values (); | |
3515 | } | |
3516 | ||
3517 | /* Now that register usage is specified, convert it to HARD_REG_SETs. */ | |
ca695ac9 JB |
3518 | if (!output_bytecode) |
3519 | init_reg_sets_1 (); | |
4291d9c8 RS |
3520 | |
3521 | compile_file (filename); | |
3522 | ||
ca695ac9 JB |
3523 | if (output_bytecode) |
3524 | bc_write_file (stdout); | |
3525 | ||
a56addeb | 3526 | #ifndef OS2 |
4291d9c8 RS |
3527 | #ifndef VMS |
3528 | if (flag_print_mem) | |
3529 | { | |
3530 | char *lim = (char *) sbrk (0); | |
3531 | ||
3532 | fprintf (stderr, "Data size %d.\n", | |
b61b1c91 | 3533 | lim - (char *) &environ); |
4291d9c8 RS |
3534 | fflush (stderr); |
3535 | ||
3536 | #ifdef USG | |
3537 | system ("ps -l 1>&2"); | |
3538 | #else /* not USG */ | |
3539 | system ("ps v"); | |
3540 | #endif /* not USG */ | |
3541 | } | |
3542 | #endif /* not VMS */ | |
a56addeb | 3543 | #endif /* not OS2 */ |
4291d9c8 RS |
3544 | |
3545 | if (errorcount) | |
3546 | exit (FATAL_EXIT_CODE); | |
3547 | if (sorrycount) | |
3548 | exit (FATAL_EXIT_CODE); | |
3549 | exit (SUCCESS_EXIT_CODE); | |
3550 | return 34; | |
3551 | } | |
3552 | \f | |
3553 | /* Decode -m switches. */ | |
3554 | ||
3555 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
3556 | and which bits in `target_switches' it should set or clear. | |
3557 | If VALUE is positive, it is bits to set. | |
3558 | If VALUE is negative, -VALUE is bits to clear. | |
3559 | (The sign bit is not used so there is no confusion.) */ | |
3560 | ||
3561 | struct {char *name; int value;} target_switches [] | |
3562 | = TARGET_SWITCHES; | |
3563 | ||
3564 | /* This table is similar, but allows the switch to have a value. */ | |
3565 | ||
3566 | #ifdef TARGET_OPTIONS | |
3567 | struct {char *prefix; char ** variable;} target_options [] | |
3568 | = TARGET_OPTIONS; | |
3569 | #endif | |
3570 | ||
3571 | /* Decode the switch -mNAME. */ | |
3572 | ||
3573 | void | |
3574 | set_target_switch (name) | |
3575 | char *name; | |
3576 | { | |
3577 | register int j; | |
3578 | int valid = 0; | |
3579 | ||
3580 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
3581 | if (!strcmp (target_switches[j].name, name)) | |
3582 | { | |
3583 | if (target_switches[j].value < 0) | |
3584 | target_flags &= ~-target_switches[j].value; | |
3585 | else | |
3586 | target_flags |= target_switches[j].value; | |
3587 | valid = 1; | |
3588 | } | |
3589 | ||
3590 | #ifdef TARGET_OPTIONS | |
3591 | if (!valid) | |
3592 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
3593 | { | |
3594 | int len = strlen (target_options[j].prefix); | |
3595 | if (!strncmp (target_options[j].prefix, name, len)) | |
3596 | { | |
3597 | *target_options[j].variable = name + len; | |
3598 | valid = 1; | |
3599 | } | |
3600 | } | |
3601 | #endif | |
3602 | ||
3603 | if (!valid) | |
3604 | error ("Invalid option `%s'", name); | |
3605 | } | |
3606 | \f | |
3607 | /* Variable used for communication between the following two routines. */ | |
3608 | ||
3609 | static int line_position; | |
3610 | ||
3611 | /* Print an option value and adjust the position in the line. */ | |
3612 | ||
3613 | static void | |
3614 | print_single_switch (type, name) | |
3615 | char *type, *name; | |
3616 | { | |
3617 | fprintf (stderr, " %s%s", type, name); | |
3618 | ||
3619 | line_position += strlen (type) + strlen (name) + 1; | |
3620 | ||
3621 | if (line_position > 65) | |
3622 | { | |
3623 | fprintf (stderr, "\n\t"); | |
3624 | line_position = 8; | |
3625 | } | |
3626 | } | |
3627 | ||
3628 | /* Print default target switches for -version. */ | |
3629 | ||
3630 | static void | |
3631 | print_switch_values () | |
3632 | { | |
3633 | register int j; | |
3634 | ||
3635 | fprintf (stderr, "enabled:"); | |
3636 | line_position = 8; | |
3637 | ||
3638 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
3639 | if (*f_options[j].variable == f_options[j].on_value) | |
3640 | print_single_switch ("-f", f_options[j].string); | |
3641 | ||
3642 | for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++) | |
3643 | if (*W_options[j].variable == W_options[j].on_value) | |
3644 | print_single_switch ("-W", W_options[j].string); | |
3645 | ||
3646 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
3647 | if (target_switches[j].name[0] != '\0' | |
3648 | && target_switches[j].value > 0 | |
3649 | && ((target_switches[j].value & target_flags) | |
3650 | == target_switches[j].value)) | |
3651 | print_single_switch ("-m", target_switches[j].name); | |
3652 | ||
3653 | fprintf (stderr, "\n"); | |
3654 | } |