]>
Commit | Line | Data |
---|---|---|
4291d9c8 | 1 | /* Top level of GNU C compiler |
5ae3bec5 | 2 | Copyright (C) 1987, 88, 89, 92-6, 1997 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 | |
e9fa0c7c RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
4291d9c8 | 20 | |
4291d9c8 RS |
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" | |
e0e2a8da | 27 | #ifdef __STDC__ |
04fe4385 | 28 | #include <stdarg.h> |
e0e2a8da | 29 | #else |
04fe4385 | 30 | #include <varargs.h> |
e0e2a8da | 31 | #endif |
4291d9c8 RS |
32 | #include <stdio.h> |
33 | #include <signal.h> | |
34 | #include <setjmp.h> | |
eb711c86 | 35 | #include <sys/types.h> |
ea9182cd | 36 | #include <ctype.h> |
4291d9c8 RS |
37 | #include <sys/stat.h> |
38 | ||
9580b583 | 39 | #ifndef _WIN32 |
4291d9c8 RS |
40 | #ifdef USG |
41 | #undef FLOAT | |
42 | #include <sys/param.h> | |
43 | /* This is for hpux. It is a real screw. They should change hpux. */ | |
44 | #undef FLOAT | |
45 | #include <sys/times.h> | |
46 | #include <time.h> /* Correct for hpux at least. Is it good on other USG? */ | |
47 | #undef FFS /* Some systems define this in param.h. */ | |
48 | #else | |
49 | #ifndef VMS | |
50 | #include <sys/time.h> | |
51 | #include <sys/resource.h> | |
52 | #endif | |
53 | #endif | |
eb910b5a | 54 | #endif |
4291d9c8 RS |
55 | |
56 | #include "input.h" | |
57 | #include "tree.h" | |
4291d9c8 RS |
58 | #include "rtl.h" |
59 | #include "flags.h" | |
60 | #include "insn-attr.h" | |
d0d4af87 | 61 | #include "defaults.h" |
e14417fa RK |
62 | #include "output.h" |
63 | #include "bytecode.h" | |
64 | #include "bc-emit.h" | |
3d195391 | 65 | #include "except.h" |
f246a305 RS |
66 | |
67 | #ifdef XCOFF_DEBUGGING_INFO | |
68 | #include "xcoffout.h" | |
69 | #endif | |
4291d9c8 RS |
70 | \f |
71 | #ifdef VMS | |
72 | /* The extra parameters substantially improve the I/O performance. */ | |
73 | static FILE * | |
37c9f674 | 74 | vms_fopen (fname, type) |
4291d9c8 RS |
75 | char * fname; |
76 | char * type; | |
77 | { | |
37c9f674 RK |
78 | /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two |
79 | fixed arguments, which matches ANSI's specification but not VAXCRTL's | |
80 | pre-ANSI implementation. This hack circumvents the mismatch problem. */ | |
81 | FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen; | |
82 | ||
83 | if (*type == 'w') | |
84 | return (*vmslib_fopen) (fname, type, "mbc=32", | |
85 | "deq=64", "fop=tef", "shr=nil"); | |
86 | else | |
87 | return (*vmslib_fopen) (fname, type, "mbc=32"); | |
4291d9c8 | 88 | } |
37c9f674 RK |
89 | #define fopen vms_fopen |
90 | #endif /* VMS */ | |
4291d9c8 RS |
91 | |
92 | #ifndef DEFAULT_GDB_EXTENSIONS | |
93 | #define DEFAULT_GDB_EXTENSIONS 1 | |
94 | #endif | |
95 | ||
30657ee3 RK |
96 | /* If more than one debugging type is supported, you must define |
97 | PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way. | |
98 | ||
99 | This is one long line cause VAXC can't handle a \-newline. */ | |
9a666dda | 100 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) |
30657ee3 RK |
101 | #ifndef PREFERRED_DEBUGGING_TYPE |
102 | You Lose! You must define PREFERRED_DEBUGGING_TYPE! | |
103 | #endif /* no PREFERRED_DEBUGGING_TYPE */ | |
104 | #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE | |
105 | so the following code needn't care. */ | |
106 | #ifdef DBX_DEBUGGING_INFO | |
107 | #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG | |
108 | #endif | |
109 | #ifdef SDB_DEBUGGING_INFO | |
110 | #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG | |
111 | #endif | |
112 | #ifdef DWARF_DEBUGGING_INFO | |
113 | #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG | |
114 | #endif | |
9a666dda JM |
115 | #ifdef DWARF2_DEBUGGING_INFO |
116 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG | |
117 | #endif | |
30657ee3 RK |
118 | #ifdef XCOFF_DEBUGGING_INFO |
119 | #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG | |
120 | #endif | |
121 | #endif /* More than one debugger format enabled. */ | |
122 | ||
123 | /* If still not defined, must have been because no debugging formats | |
124 | are supported. */ | |
125 | #ifndef PREFERRED_DEBUGGING_TYPE | |
126 | #define PREFERRED_DEBUGGING_TYPE NO_DEBUG | |
127 | #endif | |
128 | ||
4291d9c8 RS |
129 | extern int rtx_equal_function_value_matters; |
130 | ||
72c8bb7f | 131 | #if ! (defined (VMS) || defined (OS2)) |
4291d9c8 | 132 | extern char **environ; |
4d7e336b | 133 | #endif |
4291d9c8 RS |
134 | extern char *version_string, *language_string; |
135 | ||
b0316e35 RS |
136 | /* Carry information from ASM_DECLARE_OBJECT_NAME |
137 | to ASM_FINISH_DECLARE_OBJECT. */ | |
138 | ||
139 | extern int size_directive_output; | |
5e10b3cc | 140 | extern tree last_assemble_variable_decl; |
b0316e35 | 141 | |
4291d9c8 RS |
142 | extern void init_lex (); |
143 | extern void init_decl_processing (); | |
144 | extern void init_obstacks (); | |
145 | extern void init_tree_codes (); | |
146 | extern void init_rtl (); | |
34d0205f | 147 | extern void init_regs (); |
4291d9c8 RS |
148 | extern void init_optabs (); |
149 | extern void init_stmt (); | |
150 | extern void init_reg_sets (); | |
151 | extern void dump_flow_info (); | |
152 | extern void dump_sched_info (); | |
153 | extern void dump_local_alloc (); | |
9ddca353 | 154 | extern void regset_release_memory (); |
4291d9c8 RS |
155 | |
156 | void rest_of_decl_compilation (); | |
d18225c4 RK |
157 | void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); |
158 | void error_with_decl PVPROTO((tree decl, char *s, ...)); | |
159 | void error_for_asm PVPROTO((rtx insn, char *s, ...)); | |
160 | void error PVPROTO((char *s, ...)); | |
161 | void fatal PVPROTO((char *s, ...)); | |
162 | void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); | |
163 | void warning_with_decl PVPROTO((tree decl, char *s, ...)); | |
164 | void warning_for_asm PVPROTO((rtx insn, char *s, ...)); | |
165 | void warning PVPROTO((char *s, ...)); | |
166 | void pedwarn PVPROTO((char *s, ...)); | |
167 | void pedwarn_with_decl PVPROTO((tree decl, char *s, ...)); | |
168 | void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...)); | |
169 | void sorry PVPROTO((char *s, ...)); | |
170 | void really_sorry PVPROTO((char *s, ...)); | |
4291d9c8 RS |
171 | void fancy_abort (); |
172 | #ifndef abort | |
173 | void abort (); | |
174 | #endif | |
175 | void set_target_switch (); | |
4291d9c8 RS |
176 | static char *decl_name (); |
177 | ||
3d5cdd42 DE |
178 | void print_version (); |
179 | int print_single_switch (); | |
180 | void print_switch_values (); | |
181 | /* Length of line when printing switch values. */ | |
182 | #define MAX_LINE 75 | |
183 | ||
efa00f4e RK |
184 | #ifdef __alpha |
185 | extern char *sbrk (); | |
186 | #endif | |
187 | ||
4291d9c8 RS |
188 | /* Name of program invoked, sans directories. */ |
189 | ||
190 | char *progname; | |
191 | ||
192 | /* Copy of arguments to main. */ | |
193 | int save_argc; | |
194 | char **save_argv; | |
195 | \f | |
196 | /* Name of current original source file (what was input to cpp). | |
197 | This comes from each #-command in the actual input. */ | |
198 | ||
199 | char *input_filename; | |
200 | ||
201 | /* Name of top-level original source file (what was input to cpp). | |
202 | This comes from the #-command at the beginning of the actual input. | |
203 | If there isn't any there, then this is the cc1 input file name. */ | |
204 | ||
205 | char *main_input_filename; | |
206 | ||
e3d1fd32 | 207 | #if !USE_CPPLIB |
4291d9c8 | 208 | /* Stream for reading from the input file. */ |
4291d9c8 | 209 | FILE *finput; |
e3d1fd32 | 210 | #endif |
4291d9c8 RS |
211 | |
212 | /* Current line number in real source file. */ | |
213 | ||
214 | int lineno; | |
215 | ||
216 | /* Stack of currently pending input files. */ | |
217 | ||
218 | struct file_stack *input_file_stack; | |
219 | ||
220 | /* Incremented on each change to input_file_stack. */ | |
221 | int input_file_stack_tick; | |
222 | ||
223 | /* FUNCTION_DECL for function now being parsed or compiled. */ | |
224 | ||
225 | extern tree current_function_decl; | |
226 | ||
227 | /* Name to use as base of names for dump output files. */ | |
228 | ||
229 | char *dump_base_name; | |
230 | ||
231 | /* Bit flags that specify the machine subtype we are compiling for. | |
232 | Bits are tested using macros TARGET_... defined in the tm.h file | |
233 | and set by `-m...' switches. Must be defined in rtlanal.c. */ | |
234 | ||
235 | extern int target_flags; | |
236 | ||
237 | /* Flags saying which kinds of debugging dump have been requested. */ | |
238 | ||
239 | int rtl_dump = 0; | |
240 | int rtl_dump_and_exit = 0; | |
241 | int jump_opt_dump = 0; | |
242 | int cse_dump = 0; | |
243 | int loop_dump = 0; | |
244 | int cse2_dump = 0; | |
0d332add | 245 | int branch_prob_dump = 0; |
4291d9c8 RS |
246 | int flow_dump = 0; |
247 | int combine_dump = 0; | |
8c660648 | 248 | int regmove_dump = 0; |
4291d9c8 RS |
249 | int sched_dump = 0; |
250 | int local_reg_dump = 0; | |
251 | int global_reg_dump = 0; | |
252 | int sched2_dump = 0; | |
253 | int jump2_opt_dump = 0; | |
254 | int dbr_sched_dump = 0; | |
255 | int flag_print_asm_name = 0; | |
256 | int stack_reg_dump = 0; | |
257 | ||
258 | /* Name for output file of assembly code, specified with -o. */ | |
259 | ||
260 | char *asm_file_name; | |
261 | ||
262 | /* Value of the -G xx switch, and whether it was passed or not. */ | |
263 | int g_switch_value; | |
264 | int g_switch_set; | |
265 | ||
266 | /* Type(s) of debugging information we are producing (if any). | |
267 | See flags.h for the definitions of the different possible | |
268 | types of debugging information. */ | |
269 | enum debug_info_type write_symbols = NO_DEBUG; | |
270 | ||
271 | /* Level of debugging information we are producing. See flags.h | |
272 | for the definitions of the different possible levels. */ | |
273 | enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; | |
274 | ||
a53d0bcc RS |
275 | /* Nonzero means use GNU-only extensions in the generated symbolic |
276 | debugging information. */ | |
277 | /* Currently, this only has an effect when write_symbols is set to | |
278 | DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ | |
279 | int use_gnu_debug_info_extensions = 0; | |
4291d9c8 RS |
280 | |
281 | /* Nonzero means do optimizations. -O. | |
282 | Particular numeric values stand for particular amounts of optimization; | |
283 | thus, -O2 stores 2 here. However, the optimizations beyond the basic | |
284 | ones are not controlled directly by this variable. Instead, they are | |
285 | controlled by individual `flag_...' variables that are defaulted | |
286 | based on this variable. */ | |
287 | ||
288 | int optimize = 0; | |
289 | ||
290 | /* Number of error messages and warning messages so far. */ | |
291 | ||
292 | int errorcount = 0; | |
293 | int warningcount = 0; | |
294 | int sorrycount = 0; | |
295 | ||
ca695ac9 JB |
296 | /* Flag to output bytecode instead of native assembler */ |
297 | int output_bytecode = 0; | |
298 | ||
a1d7ffe3 JM |
299 | /* Pointer to function to compute the name to use to print a declaration. |
300 | DECL is the declaration in question. | |
301 | VERBOSITY determines what information will be printed: | |
302 | 0: DECL_NAME, demangled as necessary. | |
303 | 1: and scope information. | |
304 | 2: and any other information that might be interesting, such as function | |
305 | parameter types in C++. */ | |
4291d9c8 | 306 | |
a1d7ffe3 | 307 | char *(*decl_printable_name) (/* tree decl, int verbosity */); |
4291d9c8 RS |
308 | |
309 | /* Pointer to function to compute rtl for a language-specific tree code. */ | |
310 | ||
311 | struct rtx_def *(*lang_expand_expr) (); | |
312 | ||
2b599527 RS |
313 | /* Pointer to function to finish handling an incomplete decl at the |
314 | end of compilation. */ | |
315 | ||
316 | void (*incomplete_decl_finalize_hook) () = 0; | |
317 | ||
bf8b4985 RK |
318 | /* Highest label number used at the end of reload. */ |
319 | ||
320 | int max_label_num_after_reload; | |
321 | ||
4291d9c8 RS |
322 | /* Nonzero if generating code to do profiling. */ |
323 | ||
324 | int profile_flag = 0; | |
325 | ||
326 | /* Nonzero if generating code to do profiling on a line-by-line basis. */ | |
327 | ||
328 | int profile_block_flag; | |
329 | ||
0d332add DE |
330 | /* Nonzero if generating code to profile program flow graph arcs. */ |
331 | ||
332 | int profile_arc_flag = 0; | |
333 | ||
334 | /* Nonzero if generating info for gcov to calculate line test coverage. */ | |
335 | ||
336 | int flag_test_coverage = 0; | |
337 | ||
338 | /* Nonzero indicates that branch taken probabilities should be calculated. */ | |
339 | ||
340 | int flag_branch_probabilities = 0; | |
341 | ||
4291d9c8 RS |
342 | /* Nonzero for -pedantic switch: warn about anything |
343 | that standard spec forbids. */ | |
344 | ||
345 | int pedantic = 0; | |
346 | ||
347 | /* Temporarily suppress certain warnings. | |
348 | This is set while reading code from a system header file. */ | |
349 | ||
350 | int in_system_header = 0; | |
351 | ||
352 | /* Nonzero means do stupid register allocation. | |
353 | Currently, this is 1 if `optimize' is 0. */ | |
354 | ||
355 | int obey_regdecls = 0; | |
356 | ||
357 | /* Don't print functions as they are compiled and don't print | |
358 | times taken by the various passes. -quiet. */ | |
359 | ||
360 | int quiet_flag = 0; | |
361 | \f | |
362 | /* -f flags. */ | |
363 | ||
364 | /* Nonzero means `char' should be signed. */ | |
365 | ||
366 | int flag_signed_char; | |
367 | ||
368 | /* Nonzero means give an enum type only as many bytes as it needs. */ | |
369 | ||
370 | int flag_short_enums; | |
371 | ||
372 | /* Nonzero for -fcaller-saves: allocate values in regs that need to | |
373 | be saved across function calls, if that produces overall better code. | |
374 | Optional now, so people can test it. */ | |
375 | ||
376 | #ifdef DEFAULT_CALLER_SAVES | |
377 | int flag_caller_saves = 1; | |
378 | #else | |
379 | int flag_caller_saves = 0; | |
380 | #endif | |
381 | ||
958ec8ca JW |
382 | /* Nonzero if structures and unions should be returned in memory. |
383 | ||
384 | This should only be defined if compatibility with another compiler or | |
385 | with an ABI is needed, because it results in slower code. */ | |
386 | ||
387 | #ifndef DEFAULT_PCC_STRUCT_RETURN | |
388 | #define DEFAULT_PCC_STRUCT_RETURN 1 | |
389 | #endif | |
390 | ||
4291d9c8 RS |
391 | /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ |
392 | ||
958ec8ca | 393 | int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; |
4291d9c8 RS |
394 | |
395 | /* Nonzero for -fforce-mem: load memory value into a register | |
396 | before arithmetic on it. This makes better cse but slower compilation. */ | |
397 | ||
398 | int flag_force_mem = 0; | |
399 | ||
400 | /* Nonzero for -fforce-addr: load memory address into a register before | |
401 | reference to memory. This makes better cse but slower compilation. */ | |
402 | ||
403 | int flag_force_addr = 0; | |
404 | ||
405 | /* Nonzero for -fdefer-pop: don't pop args after each function call; | |
406 | instead save them up to pop many calls' args with one insns. */ | |
407 | ||
6731a3e3 | 408 | int flag_defer_pop = 0; |
4291d9c8 RS |
409 | |
410 | /* Nonzero for -ffloat-store: don't allocate floats and doubles | |
411 | in extended-precision registers. */ | |
412 | ||
413 | int flag_float_store = 0; | |
414 | ||
415 | /* Nonzero for -fcse-follow-jumps: | |
416 | have cse follow jumps to do a more extensive job. */ | |
417 | ||
418 | int flag_cse_follow_jumps; | |
419 | ||
8b3686ed RK |
420 | /* Nonzero for -fcse-skip-blocks: |
421 | have cse follow a branch around a block. */ | |
422 | int flag_cse_skip_blocks; | |
423 | ||
4291d9c8 RS |
424 | /* Nonzero for -fexpensive-optimizations: |
425 | perform miscellaneous relatively-expensive optimizations. */ | |
426 | int flag_expensive_optimizations; | |
427 | ||
428 | /* Nonzero for -fthread-jumps: | |
429 | have jump optimize output of loop. */ | |
430 | ||
431 | int flag_thread_jumps; | |
432 | ||
433 | /* Nonzero enables strength-reduction in loop.c. */ | |
434 | ||
435 | int flag_strength_reduce = 0; | |
436 | ||
437 | /* Nonzero enables loop unrolling in unroll.c. Only loops for which the | |
438 | number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, | |
439 | UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are | |
440 | unrolled. */ | |
441 | ||
442 | int flag_unroll_loops; | |
443 | ||
444 | /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. | |
445 | This is generally not a win. */ | |
446 | ||
447 | int flag_unroll_all_loops; | |
448 | ||
e5eb27e5 JL |
449 | /* Nonzero forces all invariant computations in loops to be moved |
450 | outside the loop. */ | |
451 | ||
452 | int flag_move_all_movables = 0; | |
453 | ||
454 | /* Nonzero forces all general induction variables in loops to be | |
455 | strength reduced. */ | |
456 | ||
457 | int flag_reduce_all_givs = 0; | |
458 | ||
4291d9c8 RS |
459 | /* Nonzero for -fwritable-strings: |
460 | store string constants in data segment and don't uniquize them. */ | |
461 | ||
462 | int flag_writable_strings = 0; | |
463 | ||
464 | /* Nonzero means don't put addresses of constant functions in registers. | |
465 | Used for compiling the Unix kernel, where strange substitutions are | |
466 | done on the assembly output. */ | |
467 | ||
468 | int flag_no_function_cse = 0; | |
469 | ||
470 | /* Nonzero for -fomit-frame-pointer: | |
471 | don't make a frame pointer in simple functions that don't require one. */ | |
472 | ||
473 | int flag_omit_frame_pointer = 0; | |
474 | ||
cf440348 JL |
475 | /* Nonzero means place each function into its own section on those platforms |
476 | which support arbitrary section names and unlimited numbers of sections. */ | |
477 | ||
478 | int flag_function_sections = 0; | |
479 | ||
4291d9c8 RS |
480 | /* Nonzero to inhibit use of define_optimization peephole opts. */ |
481 | ||
482 | int flag_no_peephole = 0; | |
483 | ||
43855b28 JL |
484 | /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math |
485 | operations in the interest of optimization. For example it allows | |
486 | GCC to assume arguments to sqrt are nonnegative numbers, allowing | |
0f41302f | 487 | faster code for sqrt to be generated. */ |
43855b28 JL |
488 | |
489 | int flag_fast_math = 0; | |
490 | ||
4291d9c8 RS |
491 | /* Nonzero means all references through pointers are volatile. */ |
492 | ||
493 | int flag_volatile; | |
c6e75897 RS |
494 | |
495 | /* Nonzero means treat all global and extern variables as global. */ | |
496 | ||
38d4d0c2 | 497 | int flag_volatile_global; |
4291d9c8 RS |
498 | |
499 | /* Nonzero means just do syntax checking; don't output anything. */ | |
500 | ||
501 | int flag_syntax_only = 0; | |
502 | ||
503 | /* Nonzero means to rerun cse after loop optimization. This increases | |
504 | compilation time about 20% and picks up a few more common expressions. */ | |
505 | ||
506 | static int flag_rerun_cse_after_loop; | |
507 | ||
508 | /* Nonzero for -finline-functions: ok to inline functions that look like | |
509 | good inline candidates. */ | |
510 | ||
511 | int flag_inline_functions; | |
512 | ||
513 | /* Nonzero for -fkeep-inline-functions: even if we make a function | |
ac2a9454 | 514 | go inline everywhere, keep its definition around for debugging |
4291d9c8 RS |
515 | purposes. */ |
516 | ||
517 | int flag_keep_inline_functions; | |
518 | ||
fadb3bc9 | 519 | /* Nonzero means that functions will not be inlined. */ |
4291d9c8 RS |
520 | |
521 | int flag_no_inline; | |
522 | ||
fbe912dd BK |
523 | /* Nonzero means that we should emit static const variables |
524 | regardless of whether or not optimization is turned on. */ | |
525 | ||
526 | int flag_keep_static_consts = 1; | |
527 | ||
4291d9c8 RS |
528 | /* Nonzero means we should be saving declaration info into a .X file. */ |
529 | ||
530 | int flag_gen_aux_info = 0; | |
531 | ||
f246a305 RS |
532 | /* Specified name of aux-info file. */ |
533 | ||
534 | static char *aux_info_file_name; | |
535 | ||
4291d9c8 RS |
536 | /* Nonzero means make the text shared if supported. */ |
537 | ||
538 | int flag_shared_data; | |
539 | ||
540 | /* Nonzero means schedule into delayed branch slots if supported. */ | |
541 | ||
542 | int flag_delayed_branch; | |
543 | ||
544 | /* Nonzero if we are compiling pure (sharable) code. | |
545 | Value is 1 if we are doing reasonable (i.e. simple | |
546 | offset into offset table) pic. Value is 2 if we can | |
547 | only perform register offsets. */ | |
548 | ||
549 | int flag_pic; | |
550 | ||
3d195391 MS |
551 | /* Nonzero means generate extra code for exception handling and enable |
552 | exception handling. */ | |
553 | ||
554 | int flag_exceptions = 1; | |
555 | ||
2786cbad | 556 | /* Nonzero means don't place uninitialized global data in common storage |
3d195391 | 557 | by default. */ |
4291d9c8 RS |
558 | |
559 | int flag_no_common; | |
560 | ||
561 | /* Nonzero means pretend it is OK to examine bits of target floats, | |
562 | even if that isn't true. The resulting code will have incorrect constants, | |
563 | but the same series of instructions that the native compiler would make. */ | |
564 | ||
565 | int flag_pretend_float; | |
566 | ||
567 | /* Nonzero means change certain warnings into errors. | |
568 | Usually these are warnings about failure to conform to some standard. */ | |
569 | ||
570 | int flag_pedantic_errors = 0; | |
571 | ||
572 | /* flag_schedule_insns means schedule insns within basic blocks (before | |
573 | local_alloc). | |
574 | flag_schedule_insns_after_reload means schedule insns after | |
575 | global_alloc. */ | |
576 | ||
577 | int flag_schedule_insns = 0; | |
578 | int flag_schedule_insns_after_reload = 0; | |
579 | ||
8c660648 JL |
580 | #ifdef HAIFA |
581 | /* The following flags have effect only for scheduling before register | |
582 | allocation: | |
583 | ||
584 | flag_schedule_interblock means schedule insns accross basic blocks. | |
585 | flag_schedule_speculative means allow speculative motion of non-load insns. | |
586 | flag_schedule_speculative_load means allow speculative motion of some | |
587 | load insns. | |
588 | flag_schedule_speculative_load_dangerous allows speculative motion of more | |
589 | load insns. | |
590 | flag_schedule_reverse_before_reload means try to reverse original order | |
591 | of insns (S). | |
592 | flag_schedule_reverse_after_reload means try to reverse original order | |
593 | of insns (R). */ | |
594 | ||
595 | int flag_schedule_interblock = 1; | |
596 | int flag_schedule_speculative = 1; | |
597 | int flag_schedule_speculative_load = 0; | |
598 | int flag_schedule_speculative_load_dangerous = 0; | |
599 | int flag_schedule_reverse_before_reload = 0; | |
600 | int flag_schedule_reverse_after_reload = 0; | |
601 | ||
602 | ||
603 | /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple | |
604 | by a cheaper branch, on a count register. */ | |
605 | int flag_branch_on_count_reg; | |
606 | #endif /* HAIFA */ | |
607 | ||
608 | ||
4291d9c8 RS |
609 | /* -finhibit-size-directive inhibits output of .size for ELF. |
610 | This is used only for compiling crtstuff.c, | |
611 | and it may be extended to other effects | |
612 | needed for crtstuff.c on other systems. */ | |
613 | int flag_inhibit_size_directive = 0; | |
614 | ||
9a631e8e RS |
615 | /* -fverbose-asm causes extra commentary information to be produced in |
616 | the generated assembly code (to make it more readable). This option | |
617 | is generally only of use to those who actually need to read the | |
3d5cdd42 DE |
618 | generated assembly code (perhaps while debugging the compiler itself). |
619 | -fverbose-asm is the default. -fno-verbose-asm causes the extra information | |
620 | to be omitted and is useful when comparing two assembler files. */ | |
621 | ||
622 | int flag_verbose_asm = 1; | |
9a631e8e | 623 | |
3d5cdd42 DE |
624 | /* -dA causes debug commentary information to be produced in |
625 | the generated assembly code (to make it more readable). This option | |
626 | is generally only of use to those who actually need to read the | |
627 | generated assembly code (perhaps while debugging the compiler itself). | |
628 | Currently, this switch is only used by dwarfout.c; however, it is intended | |
629 | to be a catchall for printing debug information in the assembler file. */ | |
630 | ||
631 | int flag_debug_asm = 0; | |
9a631e8e | 632 | |
4291d9c8 | 633 | /* -fgnu-linker specifies use of the GNU linker for initializations. |
d68c507d RS |
634 | (Or, more generally, a linker that handles initializations.) |
635 | -fno-gnu-linker says that collect2 will be used. */ | |
636 | #ifdef USE_COLLECT2 | |
637 | int flag_gnu_linker = 0; | |
638 | #else | |
4291d9c8 | 639 | int flag_gnu_linker = 1; |
d68c507d | 640 | #endif |
4291d9c8 | 641 | |
566cdc73 MM |
642 | /* Tag all structures with __attribute__(packed) */ |
643 | int flag_pack_struct = 0; | |
644 | ||
bd83d0ac RK |
645 | /* Emit code to check for stack overflow; also may cause large objects |
646 | to be allocated dynamically. */ | |
647 | int flag_stack_check; | |
648 | ||
f602c208 RK |
649 | /* -fcheck-memory-usage causes extra code to be generated in order to check |
650 | memory accesses. This is used by a detector of bad memory accesses such | |
651 | as Checker. */ | |
652 | int flag_check_memory_usage = 0; | |
653 | ||
654 | /* -fprefix-function-name causes function name to be prefixed. This | |
655 | can be used with -fcheck-memory-usage to isolate code compiled with | |
656 | -fcheck-memory-usage. */ | |
657 | int flag_prefix_function_name = 0; | |
658 | ||
8c660648 JL |
659 | int flag_regmove = 0; |
660 | ||
9ae8ffe7 JL |
661 | /* 1 if alias checking is on (by default, when -O). */ |
662 | int flag_alias_check = 0; | |
663 | ||
664 | /* 0 if pointer arguments may alias each other. True in C. | |
665 | 1 if pointer arguments may not alias each other but may alias | |
666 | global variables. | |
667 | 2 if pointer arguments may not alias each other and may not | |
668 | alias global variables. True in Fortran. | |
669 | This defaults to 0 for C. */ | |
670 | int flag_argument_noalias = 0; | |
671 | ||
4291d9c8 RS |
672 | /* Table of language-independent -f options. |
673 | STRING is the option name. VARIABLE is the address of the variable. | |
674 | ON_VALUE is the value to store in VARIABLE | |
675 | if `-fSTRING' is seen as an option. | |
676 | (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ | |
677 | ||
678 | struct { char *string; int *variable; int on_value;} f_options[] = | |
679 | { | |
680 | {"float-store", &flag_float_store, 1}, | |
681 | {"volatile", &flag_volatile, 1}, | |
38d4d0c2 | 682 | {"volatile-global", &flag_volatile_global, 1}, |
4291d9c8 RS |
683 | {"defer-pop", &flag_defer_pop, 1}, |
684 | {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, | |
685 | {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, | |
8b3686ed | 686 | {"cse-skip-blocks", &flag_cse_skip_blocks, 1}, |
4291d9c8 RS |
687 | {"expensive-optimizations", &flag_expensive_optimizations, 1}, |
688 | {"thread-jumps", &flag_thread_jumps, 1}, | |
689 | {"strength-reduce", &flag_strength_reduce, 1}, | |
690 | {"unroll-loops", &flag_unroll_loops, 1}, | |
691 | {"unroll-all-loops", &flag_unroll_all_loops, 1}, | |
e5eb27e5 JL |
692 | {"move-all-movables", &flag_move_all_movables, 1}, |
693 | {"reduce-all-givs", &flag_reduce_all_givs, 1}, | |
4291d9c8 RS |
694 | {"writable-strings", &flag_writable_strings, 1}, |
695 | {"peephole", &flag_no_peephole, 0}, | |
696 | {"force-mem", &flag_force_mem, 1}, | |
697 | {"force-addr", &flag_force_addr, 1}, | |
698 | {"function-cse", &flag_no_function_cse, 0}, | |
699 | {"inline-functions", &flag_inline_functions, 1}, | |
700 | {"keep-inline-functions", &flag_keep_inline_functions, 1}, | |
701 | {"inline", &flag_no_inline, 0}, | |
fbe912dd | 702 | {"keep-static-consts", &flag_keep_static_consts, 1}, |
4291d9c8 | 703 | {"syntax-only", &flag_syntax_only, 1}, |
4291d9c8 RS |
704 | {"shared-data", &flag_shared_data, 1}, |
705 | {"caller-saves", &flag_caller_saves, 1}, | |
706 | {"pcc-struct-return", &flag_pcc_struct_return, 1}, | |
958ec8ca | 707 | {"reg-struct-return", &flag_pcc_struct_return, 0}, |
4291d9c8 RS |
708 | {"delayed-branch", &flag_delayed_branch, 1}, |
709 | {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1}, | |
710 | {"pretend-float", &flag_pretend_float, 1}, | |
711 | {"schedule-insns", &flag_schedule_insns, 1}, | |
712 | {"schedule-insns2", &flag_schedule_insns_after_reload, 1}, | |
8c660648 JL |
713 | #ifdef HAIFA |
714 | {"sched-interblock",&flag_schedule_interblock, 1}, | |
715 | {"sched-spec",&flag_schedule_speculative, 1}, | |
716 | {"sched-spec-load",&flag_schedule_speculative_load, 1}, | |
717 | {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1}, | |
718 | {"sched-reverse-S",&flag_schedule_reverse_before_reload, 1}, | |
719 | {"sched-reverse-R",&flag_schedule_reverse_after_reload, 1}, | |
720 | {"branch-count-reg",&flag_branch_on_count_reg, 1}, | |
721 | #endif /* HAIFA */ | |
4291d9c8 RS |
722 | {"pic", &flag_pic, 1}, |
723 | {"PIC", &flag_pic, 2}, | |
3d195391 | 724 | {"exceptions", &flag_exceptions, 1}, |
e976b8b2 MS |
725 | {"sjlj-exceptions", &exceptions_via_longjmp, 1}, |
726 | {"asynchronous-exceptions", &asynchronous_exceptions, 1}, | |
0d332add DE |
727 | {"profile-arcs", &profile_arc_flag, 1}, |
728 | {"test-coverage", &flag_test_coverage, 1}, | |
729 | {"branch-probabilities", &flag_branch_probabilities, 1}, | |
43855b28 | 730 | {"fast-math", &flag_fast_math, 1}, |
4291d9c8 RS |
731 | {"common", &flag_no_common, 0}, |
732 | {"inhibit-size-directive", &flag_inhibit_size_directive, 1}, | |
cf440348 | 733 | {"function-sections", &flag_function_sections, 1}, |
9a631e8e | 734 | {"verbose-asm", &flag_verbose_asm, 1}, |
422e2ed3 | 735 | {"gnu-linker", &flag_gnu_linker, 1}, |
8c660648 | 736 | {"regmove", &flag_regmove, 1}, |
566cdc73 | 737 | {"pack-struct", &flag_pack_struct, 1}, |
bd83d0ac | 738 | {"stack-check", &flag_stack_check, 1}, |
f602c208 | 739 | {"bytecode", &output_bytecode, 1}, |
9ae8ffe7 JL |
740 | {"alias-check", &flag_alias_check, 1}, |
741 | {"argument-alias", &flag_argument_noalias, 0}, | |
742 | {"argument-noalias", &flag_argument_noalias, 1}, | |
743 | {"argument-noalias-global", &flag_argument_noalias, 2}, | |
f602c208 RK |
744 | {"check-memory-usage", &flag_check_memory_usage, 1}, |
745 | {"prefix-function-name", &flag_prefix_function_name, 1} | |
4291d9c8 | 746 | }; |
b99933c7 RS |
747 | |
748 | /* Table of language-specific options. */ | |
749 | ||
750 | char *lang_options[] = | |
751 | { | |
4200c8de | 752 | "-ansi", |
8305445b | 753 | "-fallow-single-precision", |
4200c8de | 754 | |
b99933c7 RS |
755 | "-fsigned-bitfields", |
756 | "-funsigned-bitfields", | |
757 | "-fno-signed-bitfields", | |
758 | "-fno-unsigned-bitfields", | |
4200c8de RK |
759 | "-fsigned-char", |
760 | "-funsigned-char", | |
761 | "-fno-signed-char", | |
762 | "-fno-unsigned-char", | |
763 | ||
764 | "-ftraditional", | |
765 | "-traditional", | |
766 | "-fnotraditional", | |
767 | "-fno-traditional", | |
768 | ||
b99933c7 RS |
769 | "-fasm", |
770 | "-fno-asm", | |
771 | "-fbuiltin", | |
772 | "-fno-builtin", | |
5ae3bec5 RK |
773 | "-fhosted", |
774 | "-fno-hosted", | |
775 | "-ffreestanding", | |
776 | "-fno-freestanding", | |
4200c8de RK |
777 | "-fcond-mismatch", |
778 | "-fno-cond-mismatch", | |
c7daad38 | 779 | "-fdollars-in-identifiers", |
57f0a224 | 780 | "-fno-dollars-in-identifiers", |
4200c8de RK |
781 | "-fident", |
782 | "-fno-ident", | |
783 | "-fshort-double", | |
784 | "-fno-short-double", | |
785 | "-fshort-enums", | |
786 | "-fno-short-enums", | |
787 | ||
788 | "-Wall", | |
289871f0 RK |
789 | "-Wbad-function-cast", |
790 | "-Wno-bad-function-cast", | |
b99933c7 RS |
791 | "-Wcast-qual", |
792 | "-Wno-cast-qual", | |
b99933c7 RS |
793 | "-Wchar-subscripts", |
794 | "-Wno-char-subscripts", | |
b99933c7 RS |
795 | "-Wcomment", |
796 | "-Wno-comment", | |
797 | "-Wcomments", | |
798 | "-Wno-comments", | |
4200c8de RK |
799 | "-Wconversion", |
800 | "-Wno-conversion", | |
801 | "-Wformat", | |
802 | "-Wno-format", | |
b99933c7 RS |
803 | "-Wimport", |
804 | "-Wno-import", | |
4200c8de RK |
805 | "-Wimplicit", |
806 | "-Wno-implicit", | |
5ae3bec5 RK |
807 | "-Wmain", |
808 | "-Wno-main", | |
f41372d4 RS |
809 | "-Wmissing-braces", |
810 | "-Wno-missing-braces", | |
4200c8de RK |
811 | "-Wmissing-declarations", |
812 | "-Wno-missing-declarations", | |
813 | "-Wmissing-prototypes", | |
814 | "-Wno-missing-prototypes", | |
815 | "-Wnested-externs", | |
816 | "-Wno-nested-externs", | |
817 | "-Wparentheses", | |
818 | "-Wno-parentheses", | |
819 | "-Wpointer-arith", | |
820 | "-Wno-pointer-arith", | |
821 | "-Wredundant-decls", | |
822 | "-Wno-redundant-decls", | |
d51f9363 JM |
823 | "-Wsign-compare", |
824 | "-Wno-sign-compare", | |
4200c8de RK |
825 | "-Wstrict-prototypes", |
826 | "-Wno-strict-prototypes", | |
827 | "-Wtraditional", | |
828 | "-Wno-traditional", | |
829 | "-Wtrigraphs", | |
830 | "-Wno-trigraphs", | |
c7710c1f RK |
831 | "-Wundef", |
832 | "-Wno-undef", | |
4200c8de RK |
833 | "-Wwrite-strings", |
834 | "-Wno-write-strings", | |
b99933c7 | 835 | |
65faa6a4 RS |
836 | /* these are for obj c */ |
837 | "-lang-objc", | |
838 | "-gen-decls", | |
f5309ddf TW |
839 | "-fgnu-runtime", |
840 | "-fno-gnu-runtime", | |
841 | "-fnext-runtime", | |
842 | "-fno-next-runtime", | |
65faa6a4 RS |
843 | "-Wselector", |
844 | "-Wno-selector", | |
b800a01b KKT |
845 | "-Wprotocol", |
846 | "-Wno-protocol", | |
a457294f | 847 | |
2a95de17 | 848 | #include "options.h" |
b99933c7 RS |
849 | 0 |
850 | }; | |
4291d9c8 RS |
851 | \f |
852 | /* Options controlling warnings */ | |
853 | ||
854 | /* Don't print warning messages. -w. */ | |
855 | ||
856 | int inhibit_warnings = 0; | |
857 | ||
858 | /* Print various extra warnings. -W. */ | |
859 | ||
860 | int extra_warnings = 0; | |
861 | ||
862 | /* Treat warnings as errors. -Werror. */ | |
863 | ||
864 | int warnings_are_errors = 0; | |
865 | ||
866 | /* Nonzero to warn about unused local variables. */ | |
867 | ||
868 | int warn_unused; | |
869 | ||
870 | /* Nonzero to warn about variables used before they are initialized. */ | |
871 | ||
872 | int warn_uninitialized; | |
873 | ||
874 | /* Nonzero means warn about all declarations which shadow others. */ | |
875 | ||
876 | int warn_shadow; | |
877 | ||
878 | /* Warn if a switch on an enum fails to have a case for every enum value. */ | |
879 | ||
880 | int warn_switch; | |
881 | ||
882 | /* Nonzero means warn about function definitions that default the return type | |
883 | or that use a null return and have a return-type other than void. */ | |
884 | ||
885 | int warn_return_type; | |
886 | ||
887 | /* Nonzero means warn about pointer casts that increase the required | |
888 | alignment of the target type (and might therefore lead to a crash | |
889 | due to a misaligned access). */ | |
890 | ||
891 | int warn_cast_align; | |
892 | ||
893 | /* Nonzero means warn about any identifiers that match in the first N | |
894 | characters. The value N is in `id_clash_len'. */ | |
895 | ||
896 | int warn_id_clash; | |
b51e9c62 RK |
897 | unsigned id_clash_len; |
898 | ||
899 | /* Nonzero means warn about any objects definitions whose size is larger | |
900 | than N bytes. Also want about function definitions whose returned | |
901 | values are larger than N bytes. The value N is in `larger_than_size'. */ | |
902 | ||
903 | int warn_larger_than; | |
904 | unsigned larger_than_size; | |
4291d9c8 RS |
905 | |
906 | /* Nonzero means warn if inline function is too large. */ | |
907 | ||
908 | int warn_inline; | |
909 | ||
910 | /* Warn if a function returns an aggregate, | |
911 | since there are often incompatible calling conventions for doing this. */ | |
912 | ||
913 | int warn_aggregate_return; | |
914 | ||
915 | /* Likewise for -W. */ | |
916 | ||
917 | struct { char *string; int *variable; int on_value;} W_options[] = | |
918 | { | |
919 | {"unused", &warn_unused, 1}, | |
920 | {"error", &warnings_are_errors, 1}, | |
921 | {"shadow", &warn_shadow, 1}, | |
922 | {"switch", &warn_switch, 1}, | |
4291d9c8 RS |
923 | {"aggregate-return", &warn_aggregate_return, 1}, |
924 | {"cast-align", &warn_cast_align, 1}, | |
f246a305 RS |
925 | {"uninitialized", &warn_uninitialized, 1}, |
926 | {"inline", &warn_inline, 1} | |
4291d9c8 RS |
927 | }; |
928 | \f | |
929 | /* Output files for assembler code (real compiler output) | |
930 | and debugging dumps. */ | |
931 | ||
932 | FILE *asm_out_file; | |
933 | FILE *aux_info_file; | |
934 | FILE *rtl_dump_file; | |
935 | FILE *jump_opt_dump_file; | |
936 | FILE *cse_dump_file; | |
937 | FILE *loop_dump_file; | |
938 | FILE *cse2_dump_file; | |
0d332add | 939 | FILE *branch_prob_dump_file; |
4291d9c8 RS |
940 | FILE *flow_dump_file; |
941 | FILE *combine_dump_file; | |
8c660648 | 942 | FILE *regmove_dump_file; |
4291d9c8 RS |
943 | FILE *sched_dump_file; |
944 | FILE *local_reg_dump_file; | |
945 | FILE *global_reg_dump_file; | |
946 | FILE *sched2_dump_file; | |
947 | FILE *jump2_opt_dump_file; | |
948 | FILE *dbr_sched_dump_file; | |
949 | FILE *stack_reg_dump_file; | |
950 | ||
951 | /* Time accumulators, to count the total time spent in various passes. */ | |
952 | ||
953 | int parse_time; | |
954 | int varconst_time; | |
955 | int integration_time; | |
956 | int jump_time; | |
957 | int cse_time; | |
958 | int loop_time; | |
959 | int cse2_time; | |
0d332add | 960 | int branch_prob_time; |
4291d9c8 RS |
961 | int flow_time; |
962 | int combine_time; | |
8c660648 | 963 | int regmove_time; |
4291d9c8 RS |
964 | int sched_time; |
965 | int local_alloc_time; | |
966 | int global_alloc_time; | |
967 | int sched2_time; | |
968 | int dbr_sched_time; | |
969 | int shorten_branch_time; | |
970 | int stack_reg_time; | |
971 | int final_time; | |
972 | int symout_time; | |
973 | int dump_time; | |
974 | \f | |
975 | /* Return time used so far, in microseconds. */ | |
976 | ||
977 | int | |
978 | get_run_time () | |
979 | { | |
9580b583 | 980 | #ifndef _WIN32 |
4291d9c8 RS |
981 | #ifdef USG |
982 | struct tms tms; | |
983 | #else | |
984 | #ifndef VMS | |
985 | struct rusage rusage; | |
15f00097 | 986 | #else |
4291d9c8 RS |
987 | struct |
988 | { | |
989 | int proc_user_time; | |
990 | int proc_system_time; | |
991 | int child_user_time; | |
992 | int child_system_time; | |
993 | } vms_times; | |
994 | #endif | |
15f00097 | 995 | #endif |
4291d9c8 RS |
996 | #endif |
997 | ||
998 | if (quiet_flag) | |
999 | return 0; | |
9580b583 | 1000 | #ifdef _WIN32 |
15f00097 RK |
1001 | if (clock() < 0) |
1002 | return 0; | |
1003 | else | |
1004 | return (clock() * 1000); | |
9580b583 | 1005 | #else /* not _WIN32 */ |
4291d9c8 RS |
1006 | #ifdef USG |
1007 | times (&tms); | |
1008 | return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); | |
1009 | #else | |
1010 | #ifndef VMS | |
1011 | getrusage (0, &rusage); | |
1012 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
1013 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
1014 | #else /* VMS */ | |
1015 | times (&vms_times); | |
1016 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
1017 | #endif | |
1018 | #endif | |
eb910b5a | 1019 | #endif |
4291d9c8 RS |
1020 | } |
1021 | ||
1022 | #define TIMEVAR(VAR, BODY) \ | |
1023 | do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) | |
1024 | ||
1025 | void | |
1026 | print_time (str, total) | |
1027 | char *str; | |
1028 | int total; | |
1029 | { | |
1030 | fprintf (stderr, | |
1031 | "time in %s: %d.%06d\n", | |
1032 | str, total / 1000000, total % 1000000); | |
1033 | } | |
1034 | ||
1035 | /* Count an error or warning. Return 1 if the message should be printed. */ | |
1036 | ||
1037 | int | |
1038 | count_error (warningp) | |
1039 | int warningp; | |
1040 | { | |
1041 | if (warningp && inhibit_warnings) | |
1042 | return 0; | |
1043 | ||
1044 | if (warningp && !warnings_are_errors) | |
1045 | warningcount++; | |
1046 | else | |
1047 | { | |
1048 | static int warning_message = 0; | |
1049 | ||
1050 | if (warningp && !warning_message) | |
1051 | { | |
1052 | fprintf (stderr, "%s: warnings being treated as errors\n", progname); | |
1053 | warning_message = 1; | |
1054 | } | |
1055 | errorcount++; | |
1056 | } | |
1057 | ||
1058 | return 1; | |
1059 | } | |
1060 | ||
1061 | /* Print a fatal error message. NAME is the text. | |
1062 | Also include a system error message based on `errno'. */ | |
1063 | ||
1064 | void | |
1065 | pfatal_with_name (name) | |
1066 | char *name; | |
1067 | { | |
1068 | fprintf (stderr, "%s: ", progname); | |
1069 | perror (name); | |
299846f2 | 1070 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1071 | } |
1072 | ||
1073 | void | |
1074 | fatal_io_error (name) | |
1075 | char *name; | |
1076 | { | |
1077 | fprintf (stderr, "%s: %s: I/O error\n", progname, name); | |
299846f2 | 1078 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1079 | } |
1080 | ||
a89b2cc4 MM |
1081 | /* Called to give a better error message for a bad insn rather than |
1082 | just calling abort(). */ | |
4291d9c8 RS |
1083 | |
1084 | void | |
a89b2cc4 MM |
1085 | fatal_insn (message, insn) |
1086 | char *message; | |
4291d9c8 RS |
1087 | rtx insn; |
1088 | { | |
ca695ac9 JB |
1089 | if (!output_bytecode) |
1090 | { | |
a89b2cc4 | 1091 | error (message); |
ca695ac9 JB |
1092 | debug_rtx (insn); |
1093 | } | |
4291d9c8 RS |
1094 | if (asm_out_file) |
1095 | fflush (asm_out_file); | |
1096 | if (aux_info_file) | |
1097 | fflush (aux_info_file); | |
1098 | if (rtl_dump_file) | |
1099 | fflush (rtl_dump_file); | |
1100 | if (jump_opt_dump_file) | |
1101 | fflush (jump_opt_dump_file); | |
1102 | if (cse_dump_file) | |
1103 | fflush (cse_dump_file); | |
1104 | if (loop_dump_file) | |
1105 | fflush (loop_dump_file); | |
1106 | if (cse2_dump_file) | |
1107 | fflush (cse2_dump_file); | |
1108 | if (flow_dump_file) | |
1109 | fflush (flow_dump_file); | |
1110 | if (combine_dump_file) | |
1111 | fflush (combine_dump_file); | |
8c660648 JL |
1112 | if (regmove_dump_file) |
1113 | fflush (regmove_dump_file); | |
4291d9c8 RS |
1114 | if (sched_dump_file) |
1115 | fflush (sched_dump_file); | |
1116 | if (local_reg_dump_file) | |
1117 | fflush (local_reg_dump_file); | |
1118 | if (global_reg_dump_file) | |
1119 | fflush (global_reg_dump_file); | |
1120 | if (sched2_dump_file) | |
1121 | fflush (sched2_dump_file); | |
1122 | if (jump2_opt_dump_file) | |
1123 | fflush (jump2_opt_dump_file); | |
1124 | if (dbr_sched_dump_file) | |
1125 | fflush (dbr_sched_dump_file); | |
1126 | if (stack_reg_dump_file) | |
1127 | fflush (stack_reg_dump_file); | |
1902f7fd MM |
1128 | fflush (stdout); |
1129 | fflush (stderr); | |
4291d9c8 RS |
1130 | abort (); |
1131 | } | |
1132 | ||
a89b2cc4 MM |
1133 | /* Called to give a better error message when we don't have an insn to match |
1134 | what we are looking for or if the insn's constraints aren't satisfied, | |
1135 | rather than just calling abort(). */ | |
1136 | ||
1137 | void | |
1138 | fatal_insn_not_found (insn) | |
1139 | rtx insn; | |
1140 | { | |
1141 | if (INSN_CODE (insn) < 0) | |
1142 | fatal_insn ("internal error--unrecognizable insn:", insn); | |
1143 | else | |
1144 | fatal_insn ("internal error--insn does not satisfy its constraints:", insn); | |
1145 | } | |
1146 | ||
4291d9c8 RS |
1147 | /* This is the default decl_printable_name function. */ |
1148 | ||
1149 | static char * | |
a1d7ffe3 | 1150 | decl_name (decl, verbosity) |
4291d9c8 | 1151 | tree decl; |
a1d7ffe3 | 1152 | int verbosity; |
4291d9c8 RS |
1153 | { |
1154 | return IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1155 | } | |
1156 | \f | |
1157 | static int need_error_newline; | |
1158 | ||
1159 | /* Function of last error message; | |
1160 | more generally, function such that if next error message is in it | |
1161 | then we don't have to mention the function name. */ | |
1162 | static tree last_error_function = NULL; | |
1163 | ||
1164 | /* Used to detect when input_file_stack has changed since last described. */ | |
1165 | static int last_error_tick; | |
1166 | ||
1167 | /* Called when the start of a function definition is parsed, | |
1168 | this function prints on stderr the name of the function. */ | |
1169 | ||
1170 | void | |
1171 | announce_function (decl) | |
1172 | tree decl; | |
1173 | { | |
1174 | if (! quiet_flag) | |
1175 | { | |
4291d9c8 RS |
1176 | if (rtl_dump_and_exit) |
1177 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
1178 | else | |
a1d7ffe3 | 1179 | fprintf (stderr, " %s", (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
1180 | fflush (stderr); |
1181 | need_error_newline = 1; | |
1182 | last_error_function = current_function_decl; | |
1183 | } | |
1184 | } | |
1185 | ||
b64e9948 PB |
1186 | /* The default function to print out name of current function that caused |
1187 | an error. */ | |
4291d9c8 RS |
1188 | |
1189 | void | |
b64e9948 | 1190 | default_print_error_function (file) |
4291d9c8 RS |
1191 | char *file; |
1192 | { | |
4291d9c8 RS |
1193 | if (last_error_function != current_function_decl) |
1194 | { | |
1195 | char *kind = "function"; | |
1196 | if (current_function_decl != 0 | |
1197 | && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) | |
1198 | kind = "method"; | |
1199 | ||
1200 | if (file) | |
1201 | fprintf (stderr, "%s: ", file); | |
1202 | ||
1203 | if (current_function_decl == NULL) | |
1204 | fprintf (stderr, "At top level:\n"); | |
1205 | else | |
1206 | { | |
a1d7ffe3 | 1207 | char *name = (*decl_printable_name) (current_function_decl, 2); |
4291d9c8 RS |
1208 | fprintf (stderr, "In %s `%s':\n", kind, name); |
1209 | } | |
1210 | ||
1211 | last_error_function = current_function_decl; | |
1212 | } | |
b64e9948 PB |
1213 | } |
1214 | ||
1215 | /* Called by report_error_function to print out function name. | |
0f41302f | 1216 | * Default may be overridden by language front-ends. */ |
b64e9948 | 1217 | |
0f41302f | 1218 | void (*print_error_function) PROTO((char *)) = default_print_error_function; |
b64e9948 PB |
1219 | |
1220 | /* Prints out, if necessary, the name of the current function | |
1221 | that caused an error. Called from all error and warning functions. */ | |
1222 | ||
1223 | void | |
1224 | report_error_function (file) | |
1225 | char *file; | |
1226 | { | |
1227 | struct file_stack *p; | |
1228 | ||
1229 | if (need_error_newline) | |
1230 | { | |
1231 | fprintf (stderr, "\n"); | |
1232 | need_error_newline = 0; | |
1233 | } | |
1234 | ||
1235 | (*print_error_function) (file); | |
1236 | ||
4291d9c8 | 1237 | if (input_file_stack && input_file_stack->next != 0 |
2efc92ed RK |
1238 | && input_file_stack_tick != last_error_tick |
1239 | && file == input_filename) | |
4291d9c8 RS |
1240 | { |
1241 | fprintf (stderr, "In file included"); | |
1242 | for (p = input_file_stack->next; p; p = p->next) | |
1243 | { | |
1244 | fprintf (stderr, " from %s:%d", p->name, p->line); | |
1245 | if (p->next) | |
e5301904 | 1246 | fprintf (stderr, ",\n "); |
4291d9c8 RS |
1247 | } |
1248 | fprintf (stderr, ":\n"); | |
1249 | last_error_tick = input_file_stack_tick; | |
1250 | } | |
1251 | } | |
eb711c86 RK |
1252 | \f |
1253 | /* Print a message. */ | |
4291d9c8 | 1254 | |
eb711c86 RK |
1255 | static void |
1256 | vmessage (prefix, s, ap) | |
1257 | char *prefix; | |
4291d9c8 | 1258 | char *s; |
eb711c86 | 1259 | va_list ap; |
4291d9c8 | 1260 | { |
eb711c86 RK |
1261 | if (prefix) |
1262 | fprintf (stderr, "%s: ", prefix); | |
1263 | ||
1264 | #ifdef HAVE_VPRINTF | |
1265 | vfprintf (stderr, s, ap); | |
1266 | #else | |
1267 | { | |
1268 | HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT); | |
1269 | HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT); | |
1270 | HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT); | |
a4326b4d RK |
1271 | HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT); |
1272 | fprintf (stderr, s, v1, v2, v3, v4); | |
eb711c86 RK |
1273 | } |
1274 | #endif | |
4291d9c8 RS |
1275 | } |
1276 | ||
eb711c86 | 1277 | /* Print a message relevant to line LINE of file FILE. */ |
4291d9c8 | 1278 | |
eb711c86 RK |
1279 | static void |
1280 | v_message_with_file_and_line (file, line, prefix, s, ap) | |
4291d9c8 RS |
1281 | char *file; |
1282 | int line; | |
eb711c86 | 1283 | char *prefix; |
4291d9c8 | 1284 | char *s; |
eb711c86 | 1285 | va_list ap; |
4291d9c8 | 1286 | { |
4291d9c8 RS |
1287 | if (file) |
1288 | fprintf (stderr, "%s:%d: ", file, line); | |
1289 | else | |
1290 | fprintf (stderr, "%s: ", progname); | |
d78c6ad5 | 1291 | |
eb711c86 RK |
1292 | vmessage (prefix, s, ap); |
1293 | fputc ('\n', stderr); | |
4291d9c8 RS |
1294 | } |
1295 | ||
eb711c86 | 1296 | /* Print a message relevant to the given DECL. */ |
4291d9c8 | 1297 | |
eb711c86 RK |
1298 | static void |
1299 | v_message_with_decl (decl, prefix, s, ap) | |
4291d9c8 | 1300 | tree decl; |
eb711c86 | 1301 | char *prefix; |
4291d9c8 | 1302 | char *s; |
eb711c86 | 1303 | va_list ap; |
4291d9c8 | 1304 | { |
a1d7ffe3 | 1305 | char *n, *p; |
4291d9c8 RS |
1306 | |
1307 | fprintf (stderr, "%s:%d: ", | |
1308 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
1309 | ||
eb711c86 RK |
1310 | if (prefix) |
1311 | fprintf (stderr, "%s: ", prefix); | |
1312 | ||
1313 | /* Do magic to get around lack of varargs support for insertion | |
1314 | of arguments into existing list. We know that the decl is first; | |
1315 | we ass_u_me that it will be printed with "%s". */ | |
1316 | ||
1317 | for (p = s; *p; ++p) | |
1318 | { | |
1319 | if (*p == '%') | |
1320 | { | |
1321 | if (*(p + 1) == '%') | |
1322 | ++p; | |
1323 | else | |
1324 | break; | |
1325 | } | |
1326 | } | |
1327 | ||
cb039f8a RK |
1328 | if (p > s) /* Print the left-hand substring. */ |
1329 | { | |
1330 | char fmt[sizeof "%.255s"]; | |
1331 | long width = p - s; | |
1332 | ||
1333 | if (width > 255L) width = 255L; /* arbitrary */ | |
1334 | sprintf (fmt, "%%.%lds", width); | |
1335 | fprintf (stderr, fmt, s); | |
1336 | } | |
eb711c86 | 1337 | |
cb039f8a | 1338 | if (*p == '%') /* Print the name. */ |
eb711c86 RK |
1339 | { |
1340 | char *n = (DECL_NAME (decl) | |
a1d7ffe3 | 1341 | ? (*decl_printable_name) (decl, 2) |
eb711c86 RK |
1342 | : "((anonymous))"); |
1343 | fputs (n, stderr); | |
1344 | while (*p) | |
1345 | { | |
1346 | ++p; | |
1347 | if (isalpha (*(p - 1) & 0xFF)) | |
1348 | break; | |
1349 | } | |
1350 | } | |
1351 | ||
cb039f8a | 1352 | if (*p) /* Print the rest of the message. */ |
eb711c86 RK |
1353 | vmessage ((char *)NULL, p, ap); |
1354 | ||
1355 | fputc ('\n', stderr); | |
4291d9c8 RS |
1356 | } |
1357 | ||
eb711c86 | 1358 | /* Figure file and line of the given INSN. */ |
4291d9c8 | 1359 | |
eb711c86 RK |
1360 | static void |
1361 | file_and_line_for_asm (insn, pfile, pline) | |
4291d9c8 | 1362 | rtx insn; |
eb711c86 RK |
1363 | char **pfile; |
1364 | int *pline; | |
4291d9c8 | 1365 | { |
4291d9c8 RS |
1366 | rtx body = PATTERN (insn); |
1367 | rtx asmop; | |
1368 | ||
1369 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
1370 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
1371 | asmop = SET_SRC (body); | |
1372 | else if (GET_CODE (body) == ASM_OPERANDS) | |
1373 | asmop = body; | |
1374 | else if (GET_CODE (body) == PARALLEL | |
1375 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
1376 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
1377 | else if (GET_CODE (body) == PARALLEL | |
1378 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
1379 | asmop = XVECEXP (body, 0, 0); | |
eb711c86 RK |
1380 | else |
1381 | asmop = NULL; | |
1382 | ||
1383 | if (asmop) | |
1384 | { | |
1385 | *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); | |
1386 | *pline = ASM_OPERANDS_SOURCE_LINE (asmop); | |
1387 | } | |
1388 | else | |
1389 | { | |
1390 | *pfile = input_filename; | |
1391 | *pline = lineno; | |
1392 | } | |
1393 | } | |
4291d9c8 | 1394 | |
eb711c86 | 1395 | /* Report an error at line LINE of file FILE. */ |
4291d9c8 | 1396 | |
eb711c86 RK |
1397 | static void |
1398 | v_error_with_file_and_line (file, line, s, ap) | |
1399 | char *file; | |
1400 | int line; | |
1401 | char *s; | |
1402 | va_list ap; | |
1403 | { | |
1404 | count_error (0); | |
1405 | report_error_function (file); | |
1406 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); | |
d78c6ad5 RK |
1407 | } |
1408 | ||
1409 | void | |
e0e2a8da | 1410 | error_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
d78c6ad5 | 1411 | { |
e0e2a8da | 1412 | #ifndef __STDC__ |
eb711c86 RK |
1413 | char *file; |
1414 | int line; | |
1415 | char *s; | |
e0e2a8da RK |
1416 | #endif |
1417 | va_list ap; | |
1418 | ||
1419 | VA_START (ap, s); | |
eb711c86 | 1420 | |
e0e2a8da | 1421 | #ifndef __STDC__ |
eb711c86 RK |
1422 | file = va_arg (ap, char *); |
1423 | line = va_arg (ap, int); | |
1424 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1425 | #endif |
1426 | ||
eb711c86 RK |
1427 | v_error_with_file_and_line (file, line, s, ap); |
1428 | va_end (ap); | |
4291d9c8 RS |
1429 | } |
1430 | ||
eb711c86 RK |
1431 | /* Report an error at the declaration DECL. |
1432 | S is a format string which uses %s to substitute the declaration | |
1433 | name; subsequent substitutions are a la printf. */ | |
1434 | ||
1435 | static void | |
1436 | v_error_with_decl (decl, s, ap) | |
1437 | tree decl; | |
1438 | char *s; | |
1439 | va_list ap; | |
1440 | { | |
1441 | count_error (0); | |
1442 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1443 | v_message_with_decl (decl, (char *)NULL, s, ap); | |
1444 | } | |
4291d9c8 RS |
1445 | |
1446 | void | |
e0e2a8da | 1447 | error_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1448 | { |
e0e2a8da | 1449 | #ifndef __STDC__ |
eb711c86 RK |
1450 | tree decl; |
1451 | char *s; | |
e0e2a8da RK |
1452 | #endif |
1453 | va_list ap; | |
eb711c86 | 1454 | |
e0e2a8da RK |
1455 | VA_START (ap, s); |
1456 | ||
1457 | #ifndef __STDC__ | |
eb711c86 RK |
1458 | decl = va_arg (ap, tree); |
1459 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1460 | #endif |
1461 | ||
eb711c86 RK |
1462 | v_error_with_decl (decl, s, ap); |
1463 | va_end (ap); | |
1464 | } | |
1465 | ||
1466 | /* Report an error at the line number of the insn INSN. | |
1467 | This is used only when INSN is an `asm' with operands, | |
1468 | and each ASM_OPERANDS records its own source file and line. */ | |
1469 | ||
1470 | static void | |
1471 | v_error_for_asm (insn, s, ap) | |
1472 | rtx insn; | |
4291d9c8 | 1473 | char *s; |
eb711c86 | 1474 | va_list ap; |
4291d9c8 | 1475 | { |
eb711c86 RK |
1476 | char *file; |
1477 | int line; | |
4291d9c8 | 1478 | |
eb711c86 RK |
1479 | count_error (0); |
1480 | file_and_line_for_asm (insn, &file, &line); | |
4291d9c8 | 1481 | report_error_function (file); |
eb711c86 RK |
1482 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); |
1483 | } | |
4291d9c8 | 1484 | |
eb711c86 | 1485 | void |
e0e2a8da | 1486 | error_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1487 | { |
e0e2a8da | 1488 | #ifndef __STDC__ |
eb711c86 RK |
1489 | rtx insn; |
1490 | char *s; | |
e0e2a8da RK |
1491 | #endif |
1492 | va_list ap; | |
eb711c86 | 1493 | |
e0e2a8da RK |
1494 | VA_START (ap, s); |
1495 | ||
1496 | #ifndef __STDC__ | |
eb711c86 RK |
1497 | insn = va_arg (ap, rtx); |
1498 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1499 | #endif |
1500 | ||
eb711c86 RK |
1501 | v_error_for_asm (insn, s, ap); |
1502 | va_end (ap); | |
4291d9c8 RS |
1503 | } |
1504 | ||
eb711c86 | 1505 | /* Report an error at the current line number. */ |
4291d9c8 | 1506 | |
eb711c86 RK |
1507 | static void |
1508 | verror (s, ap) | |
4291d9c8 | 1509 | char *s; |
eb711c86 | 1510 | va_list ap; |
4291d9c8 | 1511 | { |
eb711c86 | 1512 | v_error_with_file_and_line (input_filename, lineno, s, ap); |
4291d9c8 RS |
1513 | } |
1514 | ||
eb711c86 | 1515 | void |
e0e2a8da | 1516 | error VPROTO((char *s, ...)) |
eb711c86 | 1517 | { |
e0e2a8da | 1518 | #ifndef __STDC__ |
eb711c86 | 1519 | char *s; |
e0e2a8da RK |
1520 | #endif |
1521 | va_list ap; | |
1522 | ||
1523 | VA_START (ap, s); | |
eb711c86 | 1524 | |
e0e2a8da | 1525 | #ifndef __STDC__ |
eb711c86 | 1526 | s = va_arg (ap, char *); |
e0e2a8da RK |
1527 | #endif |
1528 | ||
eb711c86 RK |
1529 | verror (s, ap); |
1530 | va_end (ap); | |
1531 | } | |
1532 | ||
1533 | /* Report a fatal error at the current line number. */ | |
1534 | ||
1535 | static void | |
1536 | vfatal (s, ap) | |
1537 | char *s; | |
1538 | va_list ap; | |
1539 | { | |
1540 | verror (s, ap); | |
299846f2 | 1541 | exit (FATAL_EXIT_CODE); |
eb711c86 | 1542 | } |
4291d9c8 RS |
1543 | |
1544 | void | |
e0e2a8da | 1545 | fatal VPROTO((char *s, ...)) |
eb711c86 | 1546 | { |
e0e2a8da | 1547 | #ifndef __STDC__ |
eb711c86 | 1548 | char *s; |
e0e2a8da RK |
1549 | #endif |
1550 | va_list ap; | |
1551 | ||
1552 | VA_START (ap, s); | |
eb711c86 | 1553 | |
e0e2a8da | 1554 | #ifndef __STDC__ |
eb711c86 | 1555 | s = va_arg (ap, char *); |
e0e2a8da RK |
1556 | #endif |
1557 | ||
eb711c86 RK |
1558 | vfatal (s, ap); |
1559 | va_end (ap); | |
1560 | } | |
1561 | ||
1562 | /* Report a warning at line LINE of file FILE. */ | |
1563 | ||
1564 | static void | |
1565 | v_warning_with_file_and_line (file, line, s, ap) | |
1566 | char *file; | |
1567 | int line; | |
4291d9c8 | 1568 | char *s; |
eb711c86 | 1569 | va_list ap; |
4291d9c8 | 1570 | { |
eb711c86 RK |
1571 | if (count_error (1)) |
1572 | { | |
1573 | report_error_function (file); | |
1574 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1575 | } | |
1576 | } | |
4291d9c8 | 1577 | |
eb711c86 | 1578 | void |
e0e2a8da | 1579 | warning_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1580 | { |
e0e2a8da | 1581 | #ifndef __STDC__ |
eb711c86 RK |
1582 | char *file; |
1583 | int line; | |
1584 | char *s; | |
e0e2a8da RK |
1585 | #endif |
1586 | va_list ap; | |
1587 | ||
1588 | VA_START (ap, s); | |
eb711c86 | 1589 | |
e0e2a8da | 1590 | #ifndef __STDC__ |
eb711c86 RK |
1591 | file = va_arg (ap, char *); |
1592 | line = va_arg (ap, int); | |
1593 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1594 | #endif |
1595 | ||
eb711c86 RK |
1596 | v_warning_with_file_and_line (file, line, s, ap); |
1597 | va_end (ap); | |
1598 | } | |
4291d9c8 | 1599 | |
eb711c86 RK |
1600 | /* Report a warning at the declaration DECL. |
1601 | S is a format string which uses %s to substitute the declaration | |
1602 | name; subsequent substitutions are a la printf. */ | |
4291d9c8 | 1603 | |
eb711c86 RK |
1604 | static void |
1605 | v_warning_with_decl (decl, s, ap) | |
1606 | tree decl; | |
1607 | char *s; | |
1608 | va_list ap; | |
1609 | { | |
1610 | if (count_error (1)) | |
1611 | { | |
1612 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1613 | v_message_with_decl (decl, "warning", s, ap); | |
1614 | } | |
1615 | } | |
4291d9c8 | 1616 | |
eb711c86 | 1617 | void |
e0e2a8da | 1618 | warning_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1619 | { |
e0e2a8da | 1620 | #ifndef __STDC__ |
eb711c86 RK |
1621 | tree decl; |
1622 | char *s; | |
e0e2a8da RK |
1623 | #endif |
1624 | va_list ap; | |
eb711c86 | 1625 | |
e0e2a8da RK |
1626 | VA_START (ap, s); |
1627 | ||
1628 | #ifndef __STDC__ | |
eb711c86 RK |
1629 | decl = va_arg (ap, tree); |
1630 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1631 | #endif |
1632 | ||
eb711c86 RK |
1633 | v_warning_with_decl (decl, s, ap); |
1634 | va_end (ap); | |
4291d9c8 RS |
1635 | } |
1636 | ||
1637 | /* Report a warning at the line number of the insn INSN. | |
4291d9c8 RS |
1638 | This is used only when INSN is an `asm' with operands, |
1639 | and each ASM_OPERANDS records its own source file and line. */ | |
1640 | ||
eb711c86 RK |
1641 | static void |
1642 | v_warning_for_asm (insn, s, ap) | |
4291d9c8 RS |
1643 | rtx insn; |
1644 | char *s; | |
eb711c86 | 1645 | va_list ap; |
4291d9c8 | 1646 | { |
eb711c86 RK |
1647 | if (count_error (1)) |
1648 | { | |
1649 | char *file; | |
1650 | int line; | |
4291d9c8 | 1651 | |
eb711c86 RK |
1652 | file_and_line_for_asm (insn, &file, &line); |
1653 | report_error_function (file); | |
1654 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1655 | } | |
1656 | } | |
4291d9c8 | 1657 | |
eb711c86 | 1658 | void |
e0e2a8da | 1659 | warning_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1660 | { |
e0e2a8da | 1661 | #ifndef __STDC__ |
eb711c86 RK |
1662 | rtx insn; |
1663 | char *s; | |
e0e2a8da RK |
1664 | #endif |
1665 | va_list ap; | |
1666 | ||
1667 | VA_START (ap, s); | |
eb711c86 | 1668 | |
e0e2a8da | 1669 | #ifndef __STDC__ |
eb711c86 RK |
1670 | insn = va_arg (ap, rtx); |
1671 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1672 | #endif |
1673 | ||
eb711c86 RK |
1674 | v_warning_for_asm (insn, s, ap); |
1675 | va_end (ap); | |
1676 | } | |
4291d9c8 | 1677 | |
eb711c86 RK |
1678 | /* Report a warning at the current line number. */ |
1679 | ||
1680 | static void | |
1681 | vwarning (s, ap) | |
1682 | char *s; | |
1683 | va_list ap; | |
1684 | { | |
1685 | v_warning_with_file_and_line (input_filename, lineno, s, ap); | |
4291d9c8 | 1686 | } |
eb711c86 RK |
1687 | |
1688 | void | |
e0e2a8da | 1689 | warning VPROTO((char *s, ...)) |
eb711c86 | 1690 | { |
e0e2a8da | 1691 | #ifndef __STDC__ |
eb711c86 | 1692 | char *s; |
e0e2a8da RK |
1693 | #endif |
1694 | va_list ap; | |
1695 | ||
1696 | VA_START (ap, s); | |
eb711c86 | 1697 | |
e0e2a8da | 1698 | #ifndef __STDC__ |
eb711c86 | 1699 | s = va_arg (ap, char *); |
e0e2a8da RK |
1700 | #endif |
1701 | ||
eb711c86 RK |
1702 | vwarning (s, ap); |
1703 | va_end (ap); | |
1704 | } | |
1705 | ||
4291d9c8 RS |
1706 | /* These functions issue either warnings or errors depending on |
1707 | -pedantic-errors. */ | |
1708 | ||
eb711c86 RK |
1709 | static void |
1710 | vpedwarn (s, ap) | |
4291d9c8 | 1711 | char *s; |
eb711c86 | 1712 | va_list ap; |
4291d9c8 RS |
1713 | { |
1714 | if (flag_pedantic_errors) | |
eb711c86 | 1715 | verror (s, ap); |
4291d9c8 | 1716 | else |
eb711c86 | 1717 | vwarning (s, ap); |
4291d9c8 RS |
1718 | } |
1719 | ||
1720 | void | |
e0e2a8da | 1721 | pedwarn VPROTO((char *s, ...)) |
eb711c86 | 1722 | { |
e0e2a8da | 1723 | #ifndef __STDC__ |
eb711c86 | 1724 | char *s; |
e0e2a8da RK |
1725 | #endif |
1726 | va_list ap; | |
1727 | ||
1728 | VA_START (ap, s); | |
eb711c86 | 1729 | |
e0e2a8da | 1730 | #ifndef __STDC__ |
eb711c86 | 1731 | s = va_arg (ap, char *); |
e0e2a8da RK |
1732 | #endif |
1733 | ||
eb711c86 RK |
1734 | vpedwarn (s, ap); |
1735 | va_end (ap); | |
1736 | } | |
1737 | ||
1738 | static void | |
1739 | v_pedwarn_with_decl (decl, s, ap) | |
4291d9c8 RS |
1740 | tree decl; |
1741 | char *s; | |
eb711c86 | 1742 | va_list ap; |
4291d9c8 | 1743 | { |
1554cdf5 DE |
1744 | /* We don't want -pedantic-errors to cause the compilation to fail from |
1745 | "errors" in system header files. Sometimes fixincludes can't fix what's | |
1746 | broken (eg: unsigned char bitfields - fixing it may change the alignment | |
1747 | which will cause programs to mysteriously fail because the C library | |
22d74562 DE |
1748 | or kernel uses the original layout). There's no point in issuing a |
1749 | warning either, it's just unnecessary noise. */ | |
1554cdf5 | 1750 | |
22d74562 DE |
1751 | if (! DECL_IN_SYSTEM_HEADER (decl)) |
1752 | { | |
1753 | if (flag_pedantic_errors) | |
1754 | v_error_with_decl (decl, s, ap); | |
1755 | else | |
1756 | v_warning_with_decl (decl, s, ap); | |
1757 | } | |
4291d9c8 RS |
1758 | } |
1759 | ||
1760 | void | |
e0e2a8da | 1761 | pedwarn_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1762 | { |
e0e2a8da | 1763 | #ifndef __STDC__ |
eb711c86 RK |
1764 | tree decl; |
1765 | char *s; | |
e0e2a8da RK |
1766 | #endif |
1767 | va_list ap; | |
eb711c86 | 1768 | |
e0e2a8da RK |
1769 | VA_START (ap, s); |
1770 | ||
1771 | #ifndef __STDC__ | |
eb711c86 RK |
1772 | decl = va_arg (ap, tree); |
1773 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1774 | #endif |
1775 | ||
eb711c86 RK |
1776 | v_pedwarn_with_decl (decl, s, ap); |
1777 | va_end (ap); | |
1778 | } | |
1779 | ||
1780 | static void | |
1781 | v_pedwarn_with_file_and_line (file, line, s, ap) | |
4291d9c8 RS |
1782 | char *file; |
1783 | int line; | |
1784 | char *s; | |
eb711c86 | 1785 | va_list ap; |
4291d9c8 RS |
1786 | { |
1787 | if (flag_pedantic_errors) | |
eb711c86 | 1788 | v_error_with_file_and_line (file, line, s, ap); |
4291d9c8 | 1789 | else |
eb711c86 | 1790 | v_warning_with_file_and_line (file, line, s, ap); |
4291d9c8 RS |
1791 | } |
1792 | ||
4291d9c8 | 1793 | void |
e0e2a8da | 1794 | pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1795 | { |
e0e2a8da | 1796 | #ifndef __STDC__ |
eb711c86 RK |
1797 | char *file; |
1798 | int line; | |
1799 | char *s; | |
e0e2a8da RK |
1800 | #endif |
1801 | va_list ap; | |
eb711c86 | 1802 | |
e0e2a8da RK |
1803 | VA_START (ap, s); |
1804 | ||
1805 | #ifndef __STDC__ | |
eb711c86 RK |
1806 | file = va_arg (ap, char *); |
1807 | line = va_arg (ap, int); | |
1808 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1809 | #endif |
1810 | ||
eb711c86 RK |
1811 | v_pedwarn_with_file_and_line (file, line, s, ap); |
1812 | va_end (ap); | |
1813 | } | |
1814 | ||
1815 | /* Apologize for not implementing some feature. */ | |
1816 | ||
1817 | static void | |
1818 | vsorry (s, ap) | |
4291d9c8 | 1819 | char *s; |
eb711c86 | 1820 | va_list ap; |
4291d9c8 RS |
1821 | { |
1822 | sorrycount++; | |
1823 | if (input_filename) | |
1824 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1825 | else | |
1826 | fprintf (stderr, "%s: ", progname); | |
eb711c86 RK |
1827 | vmessage ("sorry, not implemented", s, ap); |
1828 | fputc ('\n', stderr); | |
1829 | } | |
4291d9c8 | 1830 | |
eb711c86 | 1831 | void |
e0e2a8da | 1832 | sorry VPROTO((char *s, ...)) |
eb711c86 | 1833 | { |
e0e2a8da | 1834 | #ifndef __STDC__ |
eb711c86 | 1835 | char *s; |
e0e2a8da RK |
1836 | #endif |
1837 | va_list ap; | |
1838 | ||
1839 | VA_START (ap, s); | |
eb711c86 | 1840 | |
e0e2a8da | 1841 | #ifndef __STDC__ |
eb711c86 | 1842 | s = va_arg (ap, char *); |
e0e2a8da RK |
1843 | #endif |
1844 | ||
eb711c86 RK |
1845 | vsorry (s, ap); |
1846 | va_end (ap); | |
4291d9c8 RS |
1847 | } |
1848 | ||
eb711c86 | 1849 | /* Apologize for not implementing some feature, then quit. */ |
4291d9c8 | 1850 | |
eb711c86 RK |
1851 | static void |
1852 | v_really_sorry (s, ap) | |
4291d9c8 | 1853 | char *s; |
eb711c86 | 1854 | va_list ap; |
4291d9c8 | 1855 | { |
eb711c86 | 1856 | sorrycount++; |
4291d9c8 RS |
1857 | if (input_filename) |
1858 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1859 | else | |
c10afc44 | 1860 | fprintf (stderr, "%s: ", progname); |
eb711c86 | 1861 | vmessage ("sorry, not implemented", s, ap); |
4291d9c8 RS |
1862 | fatal (" (fatal)\n"); |
1863 | } | |
eb711c86 RK |
1864 | |
1865 | void | |
e0e2a8da | 1866 | really_sorry VPROTO((char *s, ...)) |
eb711c86 | 1867 | { |
e0e2a8da | 1868 | #ifndef __STDC__ |
eb711c86 | 1869 | char *s; |
e0e2a8da RK |
1870 | #endif |
1871 | va_list ap; | |
1872 | ||
1873 | VA_START (ap, s); | |
eb711c86 | 1874 | |
e0e2a8da | 1875 | #ifndef __STDC__ |
eb711c86 | 1876 | s = va_arg (ap, char *); |
e0e2a8da RK |
1877 | #endif |
1878 | ||
eb711c86 RK |
1879 | v_really_sorry (s, ap); |
1880 | va_end (ap); | |
1881 | } | |
4291d9c8 RS |
1882 | \f |
1883 | /* More 'friendly' abort that prints the line and file. | |
1884 | config.h can #define abort fancy_abort if you like that sort of thing. | |
1885 | ||
1886 | I don't think this is actually a good idea. | |
1887 | Other sorts of crashes will look a certain way. | |
1888 | It is a good thing if crashes from calling abort look the same way. | |
1889 | -- RMS */ | |
1890 | ||
1891 | void | |
1892 | fancy_abort () | |
1893 | { | |
1894 | fatal ("internal gcc abort"); | |
1895 | } | |
1896 | ||
1897 | /* This calls abort and is used to avoid problems when abort if a macro. | |
1898 | It is used when we need to pass the address of abort. */ | |
1899 | ||
1900 | void | |
1901 | do_abort () | |
1902 | { | |
1903 | abort (); | |
1904 | } | |
1905 | ||
1906 | /* When `malloc.c' is compiled with `rcheck' defined, | |
1907 | it calls this function to report clobberage. */ | |
1908 | ||
1909 | void | |
1910 | botch (s) | |
1911 | { | |
1912 | abort (); | |
1913 | } | |
1914 | ||
1915 | /* Same as `malloc' but report error if no memory available. */ | |
1916 | ||
4b980e20 | 1917 | char * |
4291d9c8 RS |
1918 | xmalloc (size) |
1919 | unsigned size; | |
1920 | { | |
4b980e20 | 1921 | register char *value = (char *) malloc (size); |
809d135d | 1922 | if (value == 0 && size != 0) |
4291d9c8 RS |
1923 | fatal ("virtual memory exhausted"); |
1924 | return value; | |
1925 | } | |
1926 | ||
1927 | /* Same as `realloc' but report error if no memory available. */ | |
1928 | ||
4b980e20 | 1929 | char * |
4291d9c8 RS |
1930 | xrealloc (ptr, size) |
1931 | char *ptr; | |
1932 | int size; | |
1933 | { | |
4b980e20 | 1934 | char *result = (char *) realloc (ptr, size); |
4291d9c8 RS |
1935 | if (!result) |
1936 | fatal ("virtual memory exhausted"); | |
1937 | return result; | |
1938 | } | |
3e386b9e RK |
1939 | |
1940 | /* Same as `strdup' but report error if no memory available. */ | |
1941 | ||
1942 | char * | |
1943 | xstrdup (s) | |
1944 | register char *s; | |
1945 | { | |
1946 | register char *result = (char *) malloc (strlen (s) + 1); | |
1947 | ||
1948 | if (! result) | |
1949 | fatal ("virtual memory exhausted"); | |
1950 | strcpy (result, s); | |
1951 | return result; | |
1952 | } | |
4291d9c8 RS |
1953 | \f |
1954 | /* Return the logarithm of X, base 2, considering X unsigned, | |
37366632 RK |
1955 | if X is a power of 2. Otherwise, returns -1. |
1956 | ||
1957 | This should be used via the `exact_log2' macro. */ | |
4291d9c8 RS |
1958 | |
1959 | int | |
37366632 RK |
1960 | exact_log2_wide (x) |
1961 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
1962 | { |
1963 | register int log = 0; | |
1964 | /* Test for 0 or a power of 2. */ | |
1965 | if (x == 0 || x != (x & -x)) | |
1966 | return -1; | |
1967 | while ((x >>= 1) != 0) | |
1968 | log++; | |
1969 | return log; | |
1970 | } | |
1971 | ||
1972 | /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. | |
37366632 RK |
1973 | If X is 0, return -1. |
1974 | ||
1975 | This should be used via the floor_log2 macro. */ | |
4291d9c8 RS |
1976 | |
1977 | int | |
37366632 RK |
1978 | floor_log2_wide (x) |
1979 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
1980 | { |
1981 | register int log = -1; | |
1982 | while (x != 0) | |
1983 | log++, | |
1984 | x >>= 1; | |
1985 | return log; | |
1986 | } | |
1987 | ||
3bbfa296 | 1988 | static int float_handler_set; |
4291d9c8 RS |
1989 | int float_handled; |
1990 | jmp_buf float_handler; | |
1991 | ||
3bbfa296 RK |
1992 | /* Signals actually come here. */ |
1993 | ||
1994 | static void | |
1995 | float_signal (signo) | |
1996 | /* If this is missing, some compilers complain. */ | |
1997 | int signo; | |
1998 | { | |
1999 | if (float_handled == 0) | |
2000 | abort (); | |
2001 | #if defined (USG) || defined (hpux) | |
2002 | signal (SIGFPE, float_signal); /* re-enable the signal catcher */ | |
2003 | #endif | |
2004 | float_handled = 0; | |
2005 | signal (SIGFPE, float_signal); | |
2006 | longjmp (float_handler, 1); | |
2007 | } | |
2008 | ||
4291d9c8 RS |
2009 | /* Specify where to longjmp to when a floating arithmetic error happens. |
2010 | If HANDLER is 0, it means don't handle the errors any more. */ | |
2011 | ||
2012 | void | |
2013 | set_float_handler (handler) | |
2014 | jmp_buf handler; | |
2015 | { | |
2016 | float_handled = (handler != 0); | |
2017 | if (handler) | |
4c9a05bc | 2018 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
3bbfa296 RK |
2019 | |
2020 | if (float_handled && ! float_handler_set) | |
2021 | { | |
2022 | signal (SIGFPE, float_signal); | |
2023 | float_handler_set = 1; | |
2024 | } | |
4291d9c8 RS |
2025 | } |
2026 | ||
bff4b641 RS |
2027 | /* Specify, in HANDLER, where to longjmp to when a floating arithmetic |
2028 | error happens, pushing the previous specification into OLD_HANDLER. | |
2029 | Return an indication of whether there was a previous handler in effect. */ | |
2030 | ||
2031 | int | |
2032 | push_float_handler (handler, old_handler) | |
dc2b15dc | 2033 | jmp_buf handler, old_handler; |
bff4b641 RS |
2034 | { |
2035 | int was_handled = float_handled; | |
2036 | ||
2037 | float_handled = 1; | |
2038 | if (was_handled) | |
4c9a05bc RK |
2039 | bcopy ((char *) float_handler, (char *) old_handler, |
2040 | sizeof (float_handler)); | |
2041 | ||
2042 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
bff4b641 RS |
2043 | return was_handled; |
2044 | } | |
2045 | ||
2046 | /* Restore the previous specification of whether and where to longjmp to | |
2047 | when a floating arithmetic error happens. */ | |
2048 | ||
2049 | void | |
2050 | pop_float_handler (handled, handler) | |
2051 | int handled; | |
2052 | jmp_buf handler; | |
2053 | { | |
2054 | float_handled = handled; | |
2055 | if (handled) | |
4c9a05bc | 2056 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
bff4b641 RS |
2057 | } |
2058 | ||
4291d9c8 RS |
2059 | /* Handler for SIGPIPE. */ |
2060 | ||
2061 | static void | |
2062 | pipe_closed (signo) | |
2063 | /* If this is missing, some compilers complain. */ | |
2064 | int signo; | |
2065 | { | |
2066 | fatal ("output pipe has been closed"); | |
2067 | } | |
2068 | ||
2069 | /* Strip off a legitimate source ending from the input string NAME of | |
c62bdc79 RK |
2070 | length LEN. Rather than having to know the names used by all of |
2071 | our front ends, we strip off an ending of a period followed by one, | |
2072 | two, or three characters. */ | |
4291d9c8 RS |
2073 | |
2074 | void | |
2075 | strip_off_ending (name, len) | |
2076 | char *name; | |
2077 | int len; | |
2078 | { | |
c62bdc79 RK |
2079 | if (len > 2 && name[len - 2] == '.') |
2080 | name[len - 2] = '\0'; | |
2081 | else if (len > 3 && name[len - 3] == '.') | |
2082 | name[len - 3] = '\0'; | |
2083 | else if (len > 4 && name[len - 4] == '.') | |
2084 | name[len - 4] = '\0'; | |
4291d9c8 RS |
2085 | } |
2086 | ||
7dce5088 | 2087 | /* Output a quoted string. */ |
0f41302f | 2088 | |
7dce5088 PE |
2089 | void |
2090 | output_quoted_string (asm_file, string) | |
2091 | FILE *asm_file; | |
2092 | char *string; | |
2093 | { | |
2094 | char c; | |
2095 | ||
2096 | putc ('\"', asm_file); | |
2097 | while ((c = *string++) != 0) | |
2098 | { | |
2099 | if (c == '\"' || c == '\\') | |
2100 | putc ('\\', asm_file); | |
2101 | putc (c, asm_file); | |
2102 | } | |
2103 | putc ('\"', asm_file); | |
2104 | } | |
2105 | ||
4291d9c8 RS |
2106 | /* Output a file name in the form wanted by System V. */ |
2107 | ||
2108 | void | |
2109 | output_file_directive (asm_file, input_name) | |
2110 | FILE *asm_file; | |
2111 | char *input_name; | |
2112 | { | |
2113 | int len = strlen (input_name); | |
2114 | char *na = input_name + len; | |
2115 | ||
2116 | /* NA gets INPUT_NAME sans directory names. */ | |
2117 | while (na > input_name) | |
2118 | { | |
2119 | if (na[-1] == '/') | |
2120 | break; | |
2121 | na--; | |
2122 | } | |
2123 | ||
2124 | #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME | |
2125 | ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); | |
2126 | #else | |
2127 | #ifdef ASM_OUTPUT_SOURCE_FILENAME | |
2128 | ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); | |
2129 | #else | |
7dce5088 PE |
2130 | fprintf (asm_file, "\t.file\t"); |
2131 | output_quoted_string (asm_file, na); | |
2132 | fputc ('\n', asm_file); | |
4291d9c8 RS |
2133 | #endif |
2134 | #endif | |
2135 | } | |
2136 | \f | |
0f41302f MS |
2137 | /* Routine to build language identifier for object file. */ |
2138 | ||
d0d4af87 MS |
2139 | static void |
2140 | output_lang_identify (asm_out_file) | |
2141 | FILE *asm_out_file; | |
2142 | { | |
2143 | int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; | |
2144 | char *s = (char *) alloca (len); | |
2145 | sprintf (s, "__gnu_compiled_%s", lang_identify ()); | |
2146 | ASM_OUTPUT_LABEL (asm_out_file, s); | |
2147 | } | |
2148 | ||
dfe1a916 | 2149 | /* Routine to open a dump file. */ |
0f41302f | 2150 | |
dfe1a916 DE |
2151 | static FILE * |
2152 | open_dump_file (base_name, suffix) | |
2153 | char *base_name; | |
2154 | char *suffix; | |
2155 | { | |
2156 | FILE *f; | |
2157 | char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1); | |
2158 | ||
2159 | strcpy (dumpname, base_name); | |
2160 | strcat (dumpname, suffix); | |
2161 | f = fopen (dumpname, "w"); | |
2162 | if (f == 0) | |
2163 | pfatal_with_name (dumpname); | |
2164 | return f; | |
2165 | } | |
2166 | ||
4291d9c8 RS |
2167 | /* Compile an entire file of output from cpp, named NAME. |
2168 | Write a file of assembly output and various debugging dumps. */ | |
2169 | ||
2170 | static void | |
2171 | compile_file (name) | |
2172 | char *name; | |
2173 | { | |
2174 | tree globals; | |
2175 | int start_time; | |
4291d9c8 RS |
2176 | |
2177 | int name_specified = name != 0; | |
2178 | ||
2179 | if (dump_base_name == 0) | |
2180 | dump_base_name = name ? name : "gccdump"; | |
4291d9c8 RS |
2181 | |
2182 | parse_time = 0; | |
2183 | varconst_time = 0; | |
2184 | integration_time = 0; | |
2185 | jump_time = 0; | |
2186 | cse_time = 0; | |
2187 | loop_time = 0; | |
2188 | cse2_time = 0; | |
0d332add | 2189 | branch_prob_time = 0; |
4291d9c8 RS |
2190 | flow_time = 0; |
2191 | combine_time = 0; | |
8c660648 | 2192 | regmove_time = 0; |
4291d9c8 RS |
2193 | sched_time = 0; |
2194 | local_alloc_time = 0; | |
2195 | global_alloc_time = 0; | |
2196 | sched2_time = 0; | |
2197 | dbr_sched_time = 0; | |
2198 | shorten_branch_time = 0; | |
2199 | stack_reg_time = 0; | |
2200 | final_time = 0; | |
2201 | symout_time = 0; | |
2202 | dump_time = 0; | |
2203 | ||
e3d1fd32 | 2204 | #if !USE_CPPLIB |
4291d9c8 RS |
2205 | /* Open input file. */ |
2206 | ||
2207 | if (name == 0 || !strcmp (name, "-")) | |
2208 | { | |
2209 | finput = stdin; | |
2210 | name = "stdin"; | |
2211 | } | |
2212 | else | |
2213 | finput = fopen (name, "r"); | |
2214 | if (finput == 0) | |
2215 | pfatal_with_name (name); | |
2216 | ||
282ea52a | 2217 | #ifdef IO_BUFFER_SIZE |
d7cedf4b | 2218 | setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); |
282ea52a | 2219 | #endif |
e3d1fd32 | 2220 | #endif /* !USE_CPPLIB */ |
282ea52a | 2221 | |
4291d9c8 RS |
2222 | /* Initialize data in various passes. */ |
2223 | ||
2224 | init_obstacks (); | |
2225 | init_tree_codes (); | |
e3d1fd32 PB |
2226 | #if USE_CPPLIB |
2227 | init_parse (name); | |
2228 | #else | |
4291d9c8 | 2229 | init_lex (); |
e3d1fd32 | 2230 | #endif |
ca695ac9 JB |
2231 | /* Some of these really don't need to be called when generating bytecode, |
2232 | but the options would have to be parsed first to know that. -bson */ | |
4291d9c8 RS |
2233 | init_rtl (); |
2234 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
0d332add DE |
2235 | || debug_info_level == DINFO_LEVEL_VERBOSE |
2236 | || flag_test_coverage); | |
7f21d440 | 2237 | init_regs (); |
4291d9c8 RS |
2238 | init_decl_processing (); |
2239 | init_optabs (); | |
2240 | init_stmt (); | |
2241 | init_expmed (); | |
4fa52007 | 2242 | init_expr_once (); |
4291d9c8 RS |
2243 | init_loop (); |
2244 | init_reload (); | |
2245 | ||
2246 | if (flag_caller_saves) | |
2247 | init_caller_save (); | |
2248 | ||
f246a305 RS |
2249 | /* If auxiliary info generation is desired, open the output file. |
2250 | This goes in the same directory as the source file--unlike | |
2251 | all the other output files. */ | |
4291d9c8 RS |
2252 | if (flag_gen_aux_info) |
2253 | { | |
4291d9c8 RS |
2254 | aux_info_file = fopen (aux_info_file_name, "w"); |
2255 | if (aux_info_file == 0) | |
2256 | pfatal_with_name (aux_info_file_name); | |
2257 | } | |
2258 | ||
2259 | /* If rtl dump desired, open the output file. */ | |
2260 | if (rtl_dump) | |
dfe1a916 | 2261 | rtl_dump_file = open_dump_file (dump_base_name, ".rtl"); |
4291d9c8 RS |
2262 | |
2263 | /* If jump_opt dump desired, open the output file. */ | |
2264 | if (jump_opt_dump) | |
dfe1a916 | 2265 | jump_opt_dump_file = open_dump_file (dump_base_name, ".jump"); |
4291d9c8 RS |
2266 | |
2267 | /* If cse dump desired, open the output file. */ | |
2268 | if (cse_dump) | |
dfe1a916 | 2269 | cse_dump_file = open_dump_file (dump_base_name, ".cse"); |
4291d9c8 RS |
2270 | |
2271 | /* If loop dump desired, open the output file. */ | |
2272 | if (loop_dump) | |
dfe1a916 | 2273 | loop_dump_file = open_dump_file (dump_base_name, ".loop"); |
4291d9c8 RS |
2274 | |
2275 | /* If cse2 dump desired, open the output file. */ | |
2276 | if (cse2_dump) | |
dfe1a916 | 2277 | cse2_dump_file = open_dump_file (dump_base_name, ".cse2"); |
4291d9c8 | 2278 | |
0d332add DE |
2279 | /* If branch_prob dump desired, open the output file. */ |
2280 | if (branch_prob_dump) | |
2281 | branch_prob_dump_file = open_dump_file (dump_base_name, ".bp"); | |
2282 | ||
4291d9c8 RS |
2283 | /* If flow dump desired, open the output file. */ |
2284 | if (flow_dump) | |
dfe1a916 | 2285 | flow_dump_file = open_dump_file (dump_base_name, ".flow"); |
4291d9c8 RS |
2286 | |
2287 | /* If combine dump desired, open the output file. */ | |
2288 | if (combine_dump) | |
dfe1a916 | 2289 | combine_dump_file = open_dump_file (dump_base_name, ".combine"); |
4291d9c8 | 2290 | |
8c660648 JL |
2291 | /* If regmove dump desired, open the output file. */ |
2292 | if (regmove_dump) | |
2293 | regmove_dump_file = open_dump_file (dump_base_name, ".regmove"); | |
2294 | ||
4291d9c8 RS |
2295 | /* If scheduling dump desired, open the output file. */ |
2296 | if (sched_dump) | |
dfe1a916 | 2297 | sched_dump_file = open_dump_file (dump_base_name, ".sched"); |
4291d9c8 RS |
2298 | |
2299 | /* If local_reg dump desired, open the output file. */ | |
2300 | if (local_reg_dump) | |
dfe1a916 | 2301 | local_reg_dump_file = open_dump_file (dump_base_name, ".lreg"); |
4291d9c8 RS |
2302 | |
2303 | /* If global_reg dump desired, open the output file. */ | |
2304 | if (global_reg_dump) | |
dfe1a916 | 2305 | global_reg_dump_file = open_dump_file (dump_base_name, ".greg"); |
4291d9c8 RS |
2306 | |
2307 | /* If 2nd scheduling dump desired, open the output file. */ | |
2308 | if (sched2_dump) | |
dfe1a916 | 2309 | sched2_dump_file = open_dump_file (dump_base_name, ".sched2"); |
4291d9c8 RS |
2310 | |
2311 | /* If jump2_opt dump desired, open the output file. */ | |
2312 | if (jump2_opt_dump) | |
dfe1a916 | 2313 | jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2"); |
4291d9c8 RS |
2314 | |
2315 | /* If dbr_sched dump desired, open the output file. */ | |
2316 | if (dbr_sched_dump) | |
dfe1a916 | 2317 | dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr"); |
4291d9c8 RS |
2318 | |
2319 | #ifdef STACK_REGS | |
2320 | ||
2321 | /* If stack_reg dump desired, open the output file. */ | |
2322 | if (stack_reg_dump) | |
dfe1a916 | 2323 | stack_reg_dump_file = open_dump_file (dump_base_name, ".stack"); |
4291d9c8 RS |
2324 | |
2325 | #endif | |
2326 | ||
2327 | /* Open assembler code output file. */ | |
2328 | ||
2329 | if (! name_specified && asm_file_name == 0) | |
2330 | asm_out_file = stdout; | |
2331 | else | |
2332 | { | |
4291d9c8 | 2333 | int len = strlen (dump_base_name); |
dfe1a916 | 2334 | register char *dumpname = (char *) xmalloc (len + 6); |
4291d9c8 RS |
2335 | strcpy (dumpname, dump_base_name); |
2336 | strip_off_ending (dumpname, len); | |
2337 | strcat (dumpname, ".s"); | |
2338 | if (asm_file_name == 0) | |
2339 | { | |
2340 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
2341 | strcpy (asm_file_name, dumpname); | |
2342 | } | |
2343 | if (!strcmp (asm_file_name, "-")) | |
2344 | asm_out_file = stdout; | |
2345 | else | |
2346 | asm_out_file = fopen (asm_file_name, "w"); | |
2347 | if (asm_out_file == 0) | |
2348 | pfatal_with_name (asm_file_name); | |
2349 | } | |
2350 | ||
f246a305 | 2351 | #ifdef IO_BUFFER_SIZE |
d7cedf4b RS |
2352 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), |
2353 | _IOFBF, IO_BUFFER_SIZE); | |
f246a305 RS |
2354 | #endif |
2355 | ||
4291d9c8 RS |
2356 | input_filename = name; |
2357 | ||
18736654 RK |
2358 | /* Put an entry on the input file stack for the main input file. */ |
2359 | input_file_stack | |
2360 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2361 | input_file_stack->next = 0; | |
2362 | input_file_stack->name = input_filename; | |
2363 | ||
4291d9c8 RS |
2364 | /* Perform language-specific initialization. |
2365 | This may set main_input_filename. */ | |
2366 | lang_init (); | |
2367 | ||
2368 | /* If the input doesn't start with a #line, use the input name | |
2369 | as the official input file name. */ | |
2370 | if (main_input_filename == 0) | |
2371 | main_input_filename = name; | |
2372 | ||
ca695ac9 JB |
2373 | if (!output_bytecode) |
2374 | { | |
2375 | ASM_FILE_START (asm_out_file); | |
3d5cdd42 DE |
2376 | |
2377 | #ifdef ASM_COMMENT_START | |
2378 | if (flag_verbose_asm) | |
2379 | { | |
2380 | /* Print the list of options in effect. */ | |
3d5cdd42 DE |
2381 | print_version (asm_out_file, ASM_COMMENT_START); |
2382 | print_switch_values (asm_out_file, 0, MAX_LINE, | |
2383 | ASM_COMMENT_START, " ", "\n"); | |
2384 | /* Add a blank line here so it appears in assembler output but not | |
2385 | screen output. */ | |
2386 | fprintf (asm_out_file, "\n"); | |
2387 | } | |
2388 | #endif | |
ca695ac9 | 2389 | } |
4291d9c8 | 2390 | |
ca695ac9 | 2391 | /* Output something to inform GDB that this compilation was by GCC. Also |
0f41302f | 2392 | serves to tell GDB file consists of bytecodes. */ |
ca695ac9 JB |
2393 | if (output_bytecode) |
2394 | fprintf (asm_out_file, "bc_gcc2_compiled.:\n"); | |
2395 | else | |
2396 | { | |
4291d9c8 | 2397 | #ifndef ASM_IDENTIFY_GCC |
ca695ac9 | 2398 | fprintf (asm_out_file, "gcc2_compiled.:\n"); |
4291d9c8 | 2399 | #else |
ca695ac9 | 2400 | ASM_IDENTIFY_GCC (asm_out_file); |
4291d9c8 | 2401 | #endif |
ca695ac9 | 2402 | } |
d0d4af87 | 2403 | |
0f41302f | 2404 | /* Output something to identify which front-end produced this file. */ |
d0d4af87 MS |
2405 | #ifdef ASM_IDENTIFY_LANGUAGE |
2406 | ASM_IDENTIFY_LANGUAGE (asm_out_file); | |
2407 | #endif | |
2408 | ||
cf440348 JL |
2409 | #ifndef ASM_OUTPUT_SECTION_NAME |
2410 | if (flag_function_sections) | |
2411 | { | |
2412 | warning ("-ffunction-sections not supported for this target."); | |
2413 | flag_function_sections = 0; | |
2414 | } | |
2415 | #endif | |
2416 | ||
2417 | if (flag_function_sections | |
2418 | && (profile_flag || profile_block_flag)) | |
2419 | { | |
2420 | warning ("-ffunction-sections disabled; it makes profiling impossible."); | |
2421 | flag_function_sections = 0; | |
2422 | } | |
2423 | ||
2424 | if (flag_function_sections && write_symbols != NO_DEBUG) | |
2425 | warning ("-ffunction-sections may affect debugging on some targets."); | |
2426 | ||
ca695ac9 JB |
2427 | if (output_bytecode) |
2428 | { | |
2429 | if (profile_flag || profile_block_flag) | |
2430 | error ("profiling not supported in bytecode compilation"); | |
2431 | } | |
2432 | else | |
2433 | { | |
2434 | /* ??? Note: There used to be a conditional here | |
2435 | to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. | |
2436 | This was to guarantee separation between gcc_compiled. and | |
2437 | the first function, for the sake of dbx on Suns. | |
2438 | However, having the extra zero here confused the Emacs | |
2439 | code for unexec, and might confuse other programs too. | |
2440 | Therefore, I took out that change. | |
2441 | In future versions we should find another way to solve | |
2442 | that dbx problem. -- rms, 23 May 93. */ | |
2443 | ||
2444 | /* Don't let the first function fall at the same address | |
2445 | as gcc_compiled., if profiling. */ | |
2446 | if (profile_flag || profile_block_flag) | |
2447 | assemble_zeros (UNITS_PER_WORD); | |
2448 | } | |
4291d9c8 RS |
2449 | |
2450 | /* If dbx symbol table desired, initialize writing it | |
2451 | and output the predefined types. */ | |
f246a305 RS |
2452 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2453 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2454 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, |
2455 | getdecls ())); | |
2456 | #endif | |
2457 | #ifdef SDB_DEBUGGING_INFO | |
2458 | if (write_symbols == SDB_DEBUG) | |
2459 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
2460 | getdecls ())); | |
2461 | #endif | |
2462 | #ifdef DWARF_DEBUGGING_INFO | |
2463 | if (write_symbols == DWARF_DEBUG) | |
2464 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
2465 | #endif | |
9a666dda JM |
2466 | #ifdef DWARF2_DEBUGGING_INFO |
2467 | if (write_symbols == DWARF2_DEBUG) | |
2468 | TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename)); | |
2469 | #endif | |
4291d9c8 RS |
2470 | |
2471 | /* Initialize yet another pass. */ | |
2472 | ||
ca695ac9 JB |
2473 | if (!output_bytecode) |
2474 | init_final (main_input_filename); | |
0d332add | 2475 | init_branch_prob (dump_base_name); |
4291d9c8 RS |
2476 | |
2477 | start_time = get_run_time (); | |
2478 | ||
2479 | /* Call the parser, which parses the entire file | |
2480 | (calling rest_of_compilation for each function). */ | |
2481 | ||
2482 | if (yyparse () != 0) | |
453dfc78 JW |
2483 | { |
2484 | if (errorcount == 0) | |
2485 | fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); | |
2486 | ||
2487 | /* In case there were missing closebraces, | |
2488 | get us back to the global binding level. */ | |
2489 | while (! global_bindings_p ()) | |
2490 | poplevel (0, 0, 0); | |
2491 | } | |
4291d9c8 | 2492 | |
0d332add DE |
2493 | output_func_start_profiler (); |
2494 | ||
4291d9c8 RS |
2495 | /* Compilation is now finished except for writing |
2496 | what's left of the symbol table output. */ | |
2497 | ||
2498 | parse_time += get_run_time () - start_time; | |
2499 | ||
2500 | parse_time -= integration_time; | |
2501 | parse_time -= varconst_time; | |
2502 | ||
2503 | globals = getdecls (); | |
2504 | ||
2505 | /* Really define vars that have had only a tentative definition. | |
2506 | Really output inline functions that must actually be callable | |
2507 | and have not been output so far. */ | |
2508 | ||
2509 | { | |
2510 | int len = list_length (globals); | |
2511 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
2512 | int i; | |
2513 | tree decl; | |
2b6c54d6 | 2514 | int reconsider = 1; |
4291d9c8 RS |
2515 | |
2516 | /* Process the decls in reverse order--earliest first. | |
2517 | Put them into VEC from back to front, then take out from front. */ | |
2518 | ||
2519 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
2520 | vec[len - i - 1] = decl; | |
2521 | ||
2522 | for (i = 0; i < len; i++) | |
2523 | { | |
2524 | decl = vec[i]; | |
07af9d16 JM |
2525 | |
2526 | /* We're not deferring this any longer. */ | |
2527 | DECL_DEFER_OUTPUT (decl) = 0; | |
2528 | ||
488b1f4f RS |
2529 | if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 |
2530 | && incomplete_decl_finalize_hook != 0) | |
2b599527 | 2531 | (*incomplete_decl_finalize_hook) (decl); |
2b6c54d6 | 2532 | } |
2b599527 | 2533 | |
2b6c54d6 JM |
2534 | /* Now emit any global variables or functions that we have been putting |
2535 | off. We need to loop in case one of the things emitted here | |
2536 | references another one which comes earlier in the list. */ | |
2537 | while (reconsider) | |
2538 | { | |
2539 | reconsider = 0; | |
2540 | for (i = 0; i < len; i++) | |
4291d9c8 | 2541 | { |
2b6c54d6 JM |
2542 | decl = vec[i]; |
2543 | ||
2544 | if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) | |
2545 | continue; | |
2546 | ||
6b2bd61e PB |
2547 | /* Don't write out static consts, unless we still need them. |
2548 | ||
fbe912dd BK |
2549 | We also keep static consts if not optimizing (for debugging), |
2550 | unless the user specified -fno-keep-static-consts. | |
6b2bd61e PB |
2551 | ??? They might be better written into the debug information. |
2552 | This is possible when using DWARF. | |
2553 | ||
2554 | A language processor that wants static constants to be always | |
2555 | written out (even if it is not used) is responsible for | |
2556 | calling rest_of_decl_compilation itself. E.g. the C front-end | |
2557 | calls rest_of_decl_compilation from finish_decl. | |
2558 | One motivation for this is that is conventional in some | |
2559 | environments to write things like: | |
2560 | static const char rcsid[] = "... version string ..."; | |
2561 | intending to force the string to be in the executable. | |
2562 | ||
2563 | A language processor that would prefer to have unneeded | |
2564 | static constants "optimized away" would just defer writing | |
2565 | them out until here. E.g. C++ does this, because static | |
2566 | constants are often defined in header files. | |
2567 | ||
2568 | ??? A tempting alternative (for both C and C++) would be | |
2569 | to force a constant to be written if and only if it is | |
0f41302f | 2570 | defined in a main file, as opposed to an include file. */ |
6b2bd61e | 2571 | |
2b6c54d6 JM |
2572 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) |
2573 | && (! TREE_READONLY (decl) | |
2574 | || TREE_PUBLIC (decl) | |
fbe912dd | 2575 | || (!optimize && flag_keep_static_consts) |
2b6c54d6 JM |
2576 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
2577 | { | |
2578 | reconsider = 1; | |
2579 | rest_of_decl_compilation (decl, NULL_PTR, 1, 1); | |
2580 | } | |
2581 | ||
2582 | if (TREE_CODE (decl) == FUNCTION_DECL | |
2583 | && DECL_INITIAL (decl) != 0 | |
2584 | && DECL_SAVED_INSNS (decl) != 0 | |
2585 | && (flag_keep_inline_functions | |
2f8844a8 | 2586 | || TREE_PUBLIC (decl) |
2b6c54d6 JM |
2587 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
2588 | { | |
2589 | reconsider = 1; | |
2590 | temporary_allocation (); | |
2591 | output_inline_function (decl); | |
2592 | permanent_allocation (1); | |
2593 | } | |
4291d9c8 | 2594 | } |
2b6c54d6 | 2595 | } |
4291d9c8 | 2596 | |
3d195391 MS |
2597 | /* Now that all possible functions have been output, we can dump |
2598 | the exception table. */ | |
2599 | ||
2600 | if (exception_table_p ()) | |
2601 | output_exception_table (); | |
2602 | ||
2b6c54d6 JM |
2603 | for (i = 0; i < len; i++) |
2604 | { | |
2605 | decl = vec[i]; | |
2606 | ||
2607 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
2608 | && ! TREE_ASM_WRITTEN (decl)) | |
2609 | /* Cancel the RTL for this decl so that, if debugging info | |
2610 | output for global variables is still to come, | |
2611 | this one will be omitted. */ | |
2612 | DECL_RTL (decl) = NULL; | |
4291d9c8 | 2613 | |
ac266247 RS |
2614 | /* Warn about any function |
2615 | declared static but not defined. | |
2616 | We don't warn about variables, | |
2617 | because many programs have static variables | |
2618 | that exist only to get some text into the object file. */ | |
8c461ea1 JM |
2619 | if (TREE_CODE (decl) == FUNCTION_DECL |
2620 | && (warn_unused | |
2621 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | |
4291d9c8 | 2622 | && DECL_INITIAL (decl) == 0 |
216d5cdd | 2623 | && DECL_EXTERNAL (decl) |
d1b01681 | 2624 | && ! DECL_ARTIFICIAL (decl) |
4291d9c8 | 2625 | && ! TREE_PUBLIC (decl)) |
7d429c41 | 2626 | { |
8c461ea1 | 2627 | pedwarn_with_decl (decl, |
7d429c41 RS |
2628 | "`%s' declared `static' but never defined"); |
2629 | /* This symbol is effectively an "extern" declaration now. */ | |
2630 | TREE_PUBLIC (decl) = 1; | |
2631 | assemble_external (decl); | |
7d429c41 | 2632 | } |
8c461ea1 | 2633 | |
4291d9c8 | 2634 | /* Warn about static fns or vars defined but not used, |
7062b881 PB |
2635 | but not about inline functions or static consts |
2636 | since defining those in header files is normal practice. */ | |
4291d9c8 | 2637 | if (warn_unused |
7062b881 PB |
2638 | && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) |
2639 | || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) | |
0c20aabf | 2640 | && ! DECL_IN_SYSTEM_HEADER (decl) |
216d5cdd | 2641 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2642 | && ! TREE_PUBLIC (decl) |
2643 | && ! TREE_USED (decl) | |
f843649d | 2644 | && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) |
4291d9c8 RS |
2645 | /* The TREE_USED bit for file-scope decls |
2646 | is kept in the identifier, to handle multiple | |
2647 | external decls in different scopes. */ | |
2648 | && ! TREE_USED (DECL_NAME (decl))) | |
2649 | warning_with_decl (decl, "`%s' defined but not used"); | |
2650 | ||
2651 | #ifdef SDB_DEBUGGING_INFO | |
2652 | /* The COFF linker can move initialized global vars to the end. | |
2653 | And that can screw up the symbol ordering. | |
2654 | By putting the symbols in that order to begin with, | |
2655 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
2656 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
2657 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
7efad3f7 | 2658 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2659 | && DECL_RTL (decl) != 0) |
2660 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2661 | ||
2662 | /* Output COFF information for non-global | |
0f41302f | 2663 | file-scope initialized variables. */ |
4291d9c8 RS |
2664 | if (write_symbols == SDB_DEBUG |
2665 | && TREE_CODE (decl) == VAR_DECL | |
2666 | && DECL_INITIAL (decl) | |
7efad3f7 | 2667 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2668 | && DECL_RTL (decl) != 0 |
2669 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
2670 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
2671 | #endif /* SDB_DEBUGGING_INFO */ | |
2672 | #ifdef DWARF_DEBUGGING_INFO | |
6dc42e49 | 2673 | /* Output DWARF information for file-scope tentative data object |
4291d9c8 RS |
2674 | declarations, file-scope (extern) function declarations (which |
2675 | had no corresponding body) and file-scope tagged type declarations | |
2676 | and definitions which have not yet been forced out. */ | |
2677 | ||
2678 | if (write_symbols == DWARF_DEBUG | |
2679 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
2680 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
9a666dda JM |
2681 | #endif |
2682 | #ifdef DWARF2_DEBUGGING_INFO | |
2683 | /* Output DWARF2 information for file-scope tentative data object | |
2684 | declarations, file-scope (extern) function declarations (which | |
2685 | had no corresponding body) and file-scope tagged type declarations | |
2686 | and definitions which have not yet been forced out. */ | |
2687 | ||
2688 | if (write_symbols == DWARF2_DEBUG | |
2689 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
88dad228 | 2690 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
4291d9c8 RS |
2691 | #endif |
2692 | } | |
2693 | } | |
2694 | ||
4b8af8d9 JM |
2695 | /* Write out any pending weak symbol declarations. */ |
2696 | ||
2697 | weak_finish (); | |
2698 | ||
4291d9c8 | 2699 | /* Do dbx symbols */ |
f246a305 RS |
2700 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2701 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2702 | TIMEVAR (symout_time, |
2703 | { | |
2704 | dbxout_finish (asm_out_file, main_input_filename); | |
2705 | }); | |
2706 | #endif | |
2707 | ||
2708 | #ifdef DWARF_DEBUGGING_INFO | |
2709 | if (write_symbols == DWARF_DEBUG) | |
2710 | TIMEVAR (symout_time, | |
2711 | { | |
2712 | dwarfout_finish (); | |
2713 | }); | |
2714 | #endif | |
2715 | ||
9a666dda JM |
2716 | #ifdef DWARF2_DEBUGGING_INFO |
2717 | if (write_symbols == DWARF2_DEBUG) | |
2718 | TIMEVAR (symout_time, | |
2719 | { | |
2720 | dwarf2out_finish (); | |
2721 | }); | |
2722 | #endif | |
2723 | ||
4291d9c8 RS |
2724 | /* Output some stuff at end of file if nec. */ |
2725 | ||
ca695ac9 JB |
2726 | if (!output_bytecode) |
2727 | { | |
0d332add DE |
2728 | end_final (dump_base_name); |
2729 | end_branch_prob (branch_prob_dump_file); | |
4291d9c8 RS |
2730 | |
2731 | #ifdef ASM_FILE_END | |
ca695ac9 | 2732 | ASM_FILE_END (asm_out_file); |
4291d9c8 | 2733 | #endif |
ca695ac9 | 2734 | } |
4291d9c8 | 2735 | |
4291d9c8 RS |
2736 | /* Language-specific end of compilation actions. */ |
2737 | ||
2738 | lang_finish (); | |
2739 | ||
0207ea82 RK |
2740 | if (output_bytecode) |
2741 | bc_write_file (asm_out_file); | |
2742 | ||
4291d9c8 RS |
2743 | /* Close the dump files. */ |
2744 | ||
2745 | if (flag_gen_aux_info) | |
2746 | { | |
2747 | fclose (aux_info_file); | |
2748 | if (errorcount) | |
2749 | unlink (aux_info_file_name); | |
2750 | } | |
2751 | ||
2752 | if (rtl_dump) | |
2753 | fclose (rtl_dump_file); | |
2754 | ||
2755 | if (jump_opt_dump) | |
2756 | fclose (jump_opt_dump_file); | |
2757 | ||
2758 | if (cse_dump) | |
2759 | fclose (cse_dump_file); | |
2760 | ||
2761 | if (loop_dump) | |
2762 | fclose (loop_dump_file); | |
2763 | ||
2764 | if (cse2_dump) | |
2765 | fclose (cse2_dump_file); | |
2766 | ||
0d332add DE |
2767 | if (branch_prob_dump) |
2768 | fclose (branch_prob_dump_file); | |
2769 | ||
4291d9c8 RS |
2770 | if (flow_dump) |
2771 | fclose (flow_dump_file); | |
2772 | ||
2773 | if (combine_dump) | |
2774 | { | |
2775 | dump_combine_total_stats (combine_dump_file); | |
2776 | fclose (combine_dump_file); | |
2777 | } | |
2778 | ||
8c660648 JL |
2779 | if (regmove_dump) |
2780 | fclose (regmove_dump_file); | |
2781 | ||
4291d9c8 RS |
2782 | if (sched_dump) |
2783 | fclose (sched_dump_file); | |
2784 | ||
2785 | if (local_reg_dump) | |
2786 | fclose (local_reg_dump_file); | |
2787 | ||
2788 | if (global_reg_dump) | |
2789 | fclose (global_reg_dump_file); | |
2790 | ||
2791 | if (sched2_dump) | |
2792 | fclose (sched2_dump_file); | |
2793 | ||
2794 | if (jump2_opt_dump) | |
2795 | fclose (jump2_opt_dump_file); | |
2796 | ||
2797 | if (dbr_sched_dump) | |
2798 | fclose (dbr_sched_dump_file); | |
2799 | ||
2800 | #ifdef STACK_REGS | |
2801 | if (stack_reg_dump) | |
2802 | fclose (stack_reg_dump_file); | |
2803 | #endif | |
2804 | ||
2805 | /* Close non-debugging input and output files. Take special care to note | |
2806 | whether fclose returns an error, since the pages might still be on the | |
2807 | buffer chain while the file is open. */ | |
2808 | ||
e3d1fd32 PB |
2809 | #if USE_CPPLIB |
2810 | finish_parse (); | |
2811 | #else | |
4291d9c8 | 2812 | fclose (finput); |
e3d1fd32 | 2813 | #endif |
4291d9c8 RS |
2814 | if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) |
2815 | fatal_io_error (asm_file_name); | |
2816 | ||
2817 | /* Print the times. */ | |
2818 | ||
2819 | if (! quiet_flag) | |
2820 | { | |
2821 | fprintf (stderr,"\n"); | |
2822 | print_time ("parse", parse_time); | |
ca695ac9 JB |
2823 | |
2824 | if (!output_bytecode) | |
2825 | { | |
2826 | print_time ("integration", integration_time); | |
2827 | print_time ("jump", jump_time); | |
2828 | print_time ("cse", cse_time); | |
2829 | print_time ("loop", loop_time); | |
2830 | print_time ("cse2", cse2_time); | |
116758a7 | 2831 | print_time ("branch-prob", branch_prob_time); |
ca695ac9 JB |
2832 | print_time ("flow", flow_time); |
2833 | print_time ("combine", combine_time); | |
8c660648 | 2834 | print_time ("regmove", regmove_time); |
ca695ac9 JB |
2835 | print_time ("sched", sched_time); |
2836 | print_time ("local-alloc", local_alloc_time); | |
2837 | print_time ("global-alloc", global_alloc_time); | |
2838 | print_time ("sched2", sched2_time); | |
2839 | print_time ("dbranch", dbr_sched_time); | |
2840 | print_time ("shorten-branch", shorten_branch_time); | |
2841 | print_time ("stack-reg", stack_reg_time); | |
2842 | print_time ("final", final_time); | |
2843 | print_time ("varconst", varconst_time); | |
2844 | print_time ("symout", symout_time); | |
2845 | print_time ("dump", dump_time); | |
2846 | } | |
4291d9c8 RS |
2847 | } |
2848 | } | |
2849 | \f | |
2850 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
2851 | and TYPE_DECL nodes. | |
2852 | ||
2853 | This does nothing for local (non-static) variables. | |
2854 | Otherwise, it sets up the RTL and outputs any assembler code | |
2855 | (label definition, storage allocation and initialization). | |
2856 | ||
2857 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
2858 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
2859 | if this declaration is not within a function. */ | |
2860 | ||
2861 | void | |
2862 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
2863 | tree decl; | |
2864 | char *asmspec; | |
2865 | int top_level; | |
2866 | int at_end; | |
2867 | { | |
2868 | /* Declarations of variables, and of functions defined elsewhere. */ | |
2869 | ||
928eb380 RS |
2870 | /* The most obvious approach, to put an #ifndef around where |
2871 | this macro is used, doesn't work since it's inside a macro call. */ | |
2872 | #ifndef ASM_FINISH_DECLARE_OBJECT | |
2873 | #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) | |
2874 | #endif | |
2875 | ||
4291d9c8 RS |
2876 | /* Forward declarations for nested functions are not "external", |
2877 | but we need to treat them as if they were. */ | |
216d5cdd | 2878 | if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) |
4291d9c8 RS |
2879 | || TREE_CODE (decl) == FUNCTION_DECL) |
2880 | TIMEVAR (varconst_time, | |
2881 | { | |
2882 | make_decl_rtl (decl, asmspec, top_level); | |
9a9a9643 RS |
2883 | /* Initialized extern variable exists to be replaced |
2884 | with its value, or represents something that will be | |
2885 | output in another file. */ | |
6dbf678a | 2886 | if (! (TREE_CODE (decl) == VAR_DECL |
9a9a9643 RS |
2887 | && DECL_EXTERNAL (decl) && TREE_READONLY (decl) |
2888 | && DECL_INITIAL (decl) != 0 | |
5b272d50 | 2889 | && DECL_INITIAL (decl) != error_mark_node)) |
6dbf678a RS |
2890 | /* Don't output anything |
2891 | when a tentative file-scope definition is seen. | |
2892 | But at end of compilation, do output code for them. */ | |
2893 | if (! (! at_end && top_level | |
2894 | && (DECL_INITIAL (decl) == 0 | |
9a9a9643 | 2895 | || DECL_INITIAL (decl) == error_mark_node))) |
8380e2f2 | 2896 | assemble_variable (decl, top_level, at_end, 0); |
5b7540b6 DE |
2897 | if (!output_bytecode |
2898 | && decl == last_assemble_variable_decl) | |
5e10b3cc RS |
2899 | { |
2900 | ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
2901 | top_level, at_end); | |
2902 | } | |
4291d9c8 | 2903 | }); |
216d5cdd | 2904 | else if (DECL_REGISTER (decl) && asmspec != 0) |
4291d9c8 RS |
2905 | { |
2906 | if (decode_reg_name (asmspec) >= 0) | |
2907 | { | |
2908 | DECL_RTL (decl) = 0; | |
2909 | make_decl_rtl (decl, asmspec, top_level); | |
2910 | } | |
2911 | else | |
2912 | error ("invalid register name `%s' for register variable", asmspec); | |
2913 | } | |
f246a305 RS |
2914 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2915 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2916 | && TREE_CODE (decl) == TYPE_DECL) | |
4291d9c8 RS |
2917 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); |
2918 | #endif | |
2919 | #ifdef SDB_DEBUGGING_INFO | |
2920 | else if (write_symbols == SDB_DEBUG && top_level | |
2921 | && TREE_CODE (decl) == TYPE_DECL) | |
2922 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2923 | #endif | |
2924 | } | |
2925 | ||
2926 | /* Called after finishing a record, union or enumeral type. */ | |
2927 | ||
2928 | void | |
2929 | rest_of_type_compilation (type, toplev) | |
2930 | tree type; | |
2931 | int toplev; | |
2932 | { | |
f246a305 RS |
2933 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2934 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2935 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); |
2936 | #endif | |
2937 | #ifdef SDB_DEBUGGING_INFO | |
2938 | if (write_symbols == SDB_DEBUG) | |
2939 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
2940 | #endif | |
2941 | } | |
2942 | ||
2943 | /* This is called from finish_function (within yyparse) | |
2944 | after each top-level definition is parsed. | |
2945 | It is supposed to compile that function or variable | |
2946 | and output the assembler code for it. | |
2947 | After we return, the tree storage is freed. */ | |
2948 | ||
2949 | void | |
2950 | rest_of_compilation (decl) | |
2951 | tree decl; | |
2952 | { | |
2953 | register rtx insns; | |
2954 | int start_time = get_run_time (); | |
2955 | int tem; | |
2956 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
2957 | to be restored after we finish compiling the function | |
2958 | (for use when compiling inline calls to this function). */ | |
2959 | tree saved_block_tree = 0; | |
8a958768 RS |
2960 | /* Likewise, for DECL_ARGUMENTS. */ |
2961 | tree saved_arguments = 0; | |
ab40ad2b | 2962 | int failure = 0; |
4291d9c8 | 2963 | |
ca695ac9 JB |
2964 | if (output_bytecode) |
2965 | return; | |
2966 | ||
4291d9c8 RS |
2967 | /* If we are reconsidering an inline function |
2968 | at the end of compilation, skip the stuff for making it inline. */ | |
2969 | ||
2970 | if (DECL_SAVED_INSNS (decl) == 0) | |
2971 | { | |
9deaf1b1 | 2972 | int inlineable = 0; |
4291d9c8 RS |
2973 | char *lose; |
2974 | ||
2975 | /* If requested, consider whether to make this function inline. */ | |
9deaf1b1 | 2976 | if (DECL_INLINE (decl) || flag_inline_functions) |
4291d9c8 RS |
2977 | TIMEVAR (integration_time, |
2978 | { | |
2979 | lose = function_cannot_inline_p (decl); | |
caa0eccd | 2980 | if (lose || ! optimize) |
4291d9c8 | 2981 | { |
9deaf1b1 | 2982 | if (warn_inline && DECL_INLINE (decl)) |
4291d9c8 | 2983 | warning_with_decl (decl, lose); |
9548c538 | 2984 | DECL_ABSTRACT_ORIGIN (decl) = 0; |
46dbb914 RS |
2985 | /* Don't really compile an extern inline function. |
2986 | If we can't make it inline, pretend | |
2987 | it was only declared. */ | |
2988 | if (DECL_EXTERNAL (decl)) | |
27937f46 RS |
2989 | { |
2990 | DECL_INITIAL (decl) = 0; | |
2991 | goto exit_rest_of_compilation; | |
2992 | } | |
4291d9c8 RS |
2993 | } |
2994 | else | |
9deaf1b1 RK |
2995 | /* ??? Note that this has the effect of making it look |
2996 | like "inline" was specified for a function if we choose | |
2997 | to inline it. This isn't quite right, but it's | |
2998 | probably not worth the trouble to fix. */ | |
2999 | inlineable = DECL_INLINE (decl) = 1; | |
4291d9c8 RS |
3000 | }); |
3001 | ||
3002 | insns = get_insns (); | |
3003 | ||
3004 | /* Dump the rtl code if we are dumping rtl. */ | |
3005 | ||
3006 | if (rtl_dump) | |
3007 | TIMEVAR (dump_time, | |
3008 | { | |
3009 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3010 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3011 | if (DECL_SAVED_INSNS (decl)) |
3012 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
3013 | print_rtl (rtl_dump_file, insns); | |
3014 | fflush (rtl_dump_file); | |
3015 | }); | |
3016 | ||
3017 | /* If function is inline, and we don't yet know whether to | |
3018 | compile it by itself, defer decision till end of compilation. | |
3019 | finish_compilation will call rest_of_compilation again | |
16411ea6 | 3020 | for those functions that need to be output. Also defer those |
ec6c615d RK |
3021 | functions that we are supposed to defer. We cannot defer |
3022 | functions containing nested functions since the nested function | |
3023 | data is in our non-saved obstack. */ | |
3024 | ||
3025 | if (! current_function_contains_functions | |
3026 | && (DECL_DEFER_OUTPUT (decl) | |
9deaf1b1 | 3027 | || (DECL_INLINE (decl) |
ec6c615d RK |
3028 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) |
3029 | && ! flag_keep_inline_functions) | |
3030 | || DECL_EXTERNAL (decl))))) | |
4291d9c8 | 3031 | { |
951af26e JM |
3032 | DECL_DEFER_OUTPUT (decl) = 1; |
3033 | ||
3034 | /* If -Wreturn-type, we have to do a bit of compilation. */ | |
3035 | if (! warn_return_type) | |
937522b5 | 3036 | { |
951af26e JM |
3037 | #ifdef DWARF_DEBUGGING_INFO |
3038 | /* Generate the DWARF info for the "abstract" instance | |
3039 | of a function which we may later generate inlined and/or | |
3040 | out-of-line instances of. */ | |
3041 | if (write_symbols == DWARF_DEBUG) | |
3042 | { | |
3043 | set_decl_abstract_flags (decl, 1); | |
3044 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3045 | set_decl_abstract_flags (decl, 0); | |
3046 | } | |
9a666dda JM |
3047 | #endif |
3048 | #ifdef DWARF2_DEBUGGING_INFO | |
3049 | /* Generate the DWARF2 info for the "abstract" instance | |
3050 | of a function which we may later generate inlined and/or | |
3051 | out-of-line instances of. */ | |
3052 | if (write_symbols == DWARF2_DEBUG) | |
3053 | { | |
3054 | set_decl_abstract_flags (decl, 1); | |
88dad228 | 3055 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3056 | set_decl_abstract_flags (decl, 0); |
3057 | } | |
951af26e JM |
3058 | #endif |
3059 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
ac02eb62 | 3060 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable; |
951af26e | 3061 | goto exit_rest_of_compilation; |
937522b5 | 3062 | } |
4291d9c8 RS |
3063 | } |
3064 | ||
8a958768 | 3065 | /* If we have to compile the function now, save its rtl and subdecls |
4291d9c8 | 3066 | so that its compilation will not affect what others get. */ |
9deaf1b1 | 3067 | if (inlineable || DECL_DEFER_OUTPUT (decl)) |
4291d9c8 | 3068 | { |
937522b5 RS |
3069 | #ifdef DWARF_DEBUGGING_INFO |
3070 | /* Generate the DWARF info for the "abstract" instance of | |
3071 | a function which we will generate an out-of-line instance | |
3072 | of almost immediately (and which we may also later generate | |
3073 | various inlined instances of). */ | |
3074 | if (write_symbols == DWARF_DEBUG) | |
3075 | { | |
3076 | set_decl_abstract_flags (decl, 1); | |
3077 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3078 | set_decl_abstract_flags (decl, 0); | |
3079 | } | |
9a666dda JM |
3080 | #endif |
3081 | #ifdef DWARF2_DEBUGGING_INFO | |
3082 | /* Generate the DWARF2 info for the "abstract" instance of | |
3083 | a function which we will generate an out-of-line instance | |
3084 | of almost immediately (and which we may also later generate | |
3085 | various inlined instances of). */ | |
3086 | if (write_symbols == DWARF2_DEBUG) | |
3087 | { | |
3088 | set_decl_abstract_flags (decl, 1); | |
88dad228 | 3089 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3090 | set_decl_abstract_flags (decl, 0); |
3091 | } | |
937522b5 | 3092 | #endif |
4291d9c8 | 3093 | saved_block_tree = DECL_INITIAL (decl); |
8a958768 | 3094 | saved_arguments = DECL_ARGUMENTS (decl); |
4291d9c8 | 3095 | TIMEVAR (integration_time, save_for_inline_copying (decl)); |
912c4289 | 3096 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable; |
4291d9c8 | 3097 | } |
4291d9c8 | 3098 | |
b8471b65 RK |
3099 | /* If specified extern inline but we aren't inlining it, we are |
3100 | done. */ | |
9deaf1b1 | 3101 | if (DECL_INLINE (decl) && DECL_EXTERNAL (decl)) |
b8471b65 RK |
3102 | goto exit_rest_of_compilation; |
3103 | } | |
07af9d16 | 3104 | |
951af26e JM |
3105 | if (! DECL_DEFER_OUTPUT (decl)) |
3106 | TREE_ASM_WRITTEN (decl) = 1; | |
4291d9c8 RS |
3107 | |
3108 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
3109 | between the return value of this function and the return value of called | |
3110 | functions. */ | |
3111 | rtx_equal_function_value_matters = 0; | |
3112 | ||
32235b30 RS |
3113 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ |
3114 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
4291d9c8 RS |
3115 | { |
3116 | goto exit_rest_of_compilation; | |
3117 | } | |
3118 | ||
89418a92 BK |
3119 | /* Add an unwinder for exception handling, if needed. |
3120 | This must be done before we finalize PIC code. */ | |
3121 | emit_unwinder (); | |
4291d9c8 RS |
3122 | |
3123 | #ifdef FINALIZE_PIC | |
3124 | /* If we are doing position-independent code generation, now | |
3125 | is the time to output special prologues and epilogues. | |
3126 | We do not want to do this earlier, because it just clutters | |
3127 | up inline functions with meaningless insns. */ | |
3128 | if (flag_pic) | |
3129 | FINALIZE_PIC; | |
3130 | #endif | |
3131 | ||
89418a92 BK |
3132 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. |
3133 | Note that that may have been done above, in save_for_inline_copying. | |
3134 | The call to resume_temporary_allocation near the end of this function | |
3135 | goes back to the usual state of affairs. This must be done after | |
3136 | we've built up any unwinders for exception handling, and done | |
3137 | the FINALIZE_PIC work, if necessary. */ | |
3138 | ||
3139 | rtl_in_current_obstack (); | |
3d195391 | 3140 | |
4291d9c8 RS |
3141 | insns = get_insns (); |
3142 | ||
3143 | /* Copy any shared structure that should not be shared. */ | |
3144 | ||
3145 | unshare_all_rtl (insns); | |
3146 | ||
3147 | /* Instantiate all virtual registers. */ | |
3148 | ||
3149 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
3150 | ||
3151 | /* See if we have allocated stack slots that are not directly addressable. | |
3152 | If so, scan all the insns and create explicit address computation | |
3153 | for all references to such slots. */ | |
3154 | /* fixup_stack_slots (); */ | |
3155 | ||
3d195391 MS |
3156 | /* Find all the EH handlers. */ |
3157 | find_exception_handler_labels (); | |
3158 | ||
cc4e79d8 JL |
3159 | /* Always do one jump optimization pass to ensure that JUMP_LABEL fields |
3160 | are initialized and to compute whether control can drop off the end | |
3161 | of the function. */ | |
3162 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3163 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
4291d9c8 | 3164 | |
32235b30 | 3165 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ |
951af26e | 3166 | if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) |
32235b30 RS |
3167 | goto exit_rest_of_compilation; |
3168 | ||
4291d9c8 RS |
3169 | /* Dump rtl code after jump, if we are doing that. */ |
3170 | ||
3171 | if (jump_opt_dump) | |
3172 | TIMEVAR (dump_time, | |
3173 | { | |
3174 | fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3175 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3176 | print_rtl (jump_opt_dump_file, insns); |
3177 | fflush (jump_opt_dump_file); | |
3178 | }); | |
3179 | ||
3180 | /* Perform common subexpression elimination. | |
3181 | Nonzero value from `cse_main' means that jumps were simplified | |
3182 | and some code may now be unreachable, so do | |
3183 | jump optimization again. */ | |
3184 | ||
3185 | if (cse_dump) | |
3186 | TIMEVAR (dump_time, | |
3187 | { | |
3188 | fprintf (cse_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3189 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3190 | }); |
3191 | ||
3192 | if (optimize > 0) | |
3193 | { | |
3194 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); | |
3195 | ||
3196 | if (flag_thread_jumps) | |
3197 | /* Hacks by tiemann & kenner. */ | |
6f606d63 | 3198 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); |
4291d9c8 RS |
3199 | |
3200 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
3201 | 0, cse_dump_file)); | |
3202 | TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); | |
3203 | ||
534bfae4 | 3204 | if (tem || optimize > 1) |
4291d9c8 RS |
3205 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); |
3206 | } | |
3207 | ||
3208 | /* Dump rtl code after cse, if we are doing that. */ | |
3209 | ||
3210 | if (cse_dump) | |
3211 | TIMEVAR (dump_time, | |
3212 | { | |
3213 | print_rtl (cse_dump_file, insns); | |
3214 | fflush (cse_dump_file); | |
3215 | }); | |
3216 | ||
3217 | if (loop_dump) | |
3218 | TIMEVAR (dump_time, | |
3219 | { | |
3220 | fprintf (loop_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3221 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3222 | }); |
3223 | ||
3224 | /* Move constant computations out of loops. */ | |
3225 | ||
3226 | if (optimize > 0) | |
3227 | { | |
3228 | TIMEVAR (loop_time, | |
3229 | { | |
37366632 | 3230 | loop_optimize (insns, loop_dump_file); |
4291d9c8 RS |
3231 | }); |
3232 | } | |
3233 | ||
3234 | /* Dump rtl code after loop opt, if we are doing that. */ | |
3235 | ||
3236 | if (loop_dump) | |
3237 | TIMEVAR (dump_time, | |
3238 | { | |
3239 | print_rtl (loop_dump_file, insns); | |
3240 | fflush (loop_dump_file); | |
3241 | }); | |
3242 | ||
3243 | if (cse2_dump) | |
3244 | TIMEVAR (dump_time, | |
3245 | { | |
3246 | fprintf (cse2_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3247 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3248 | }); |
3249 | ||
3250 | if (optimize > 0 && flag_rerun_cse_after_loop) | |
3251 | { | |
44333223 JL |
3252 | /* Running another jump optimization pass before the second |
3253 | cse pass sometimes simplifies the RTL enough to allow | |
9e9b48a4 DE |
3254 | the second CSE pass to do a better job. Jump_optimize can change |
3255 | max_reg_num so we must rerun reg_scan afterwards. | |
3256 | ??? Rework to not call reg_scan so often. */ | |
3257 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
44333223 | 3258 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); |
4291d9c8 | 3259 | |
9e9b48a4 | 3260 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); |
4291d9c8 RS |
3261 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), |
3262 | 1, cse2_dump_file)); | |
3263 | if (tem) | |
3264 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
3265 | } | |
3266 | ||
3267 | if (optimize > 0 && flag_thread_jumps) | |
c2f006ec RK |
3268 | { |
3269 | /* This pass of jump threading straightens out code | |
3270 | that was kinked by loop optimization. */ | |
3271 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3272 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
3273 | } | |
4291d9c8 RS |
3274 | /* Dump rtl code after cse, if we are doing that. */ |
3275 | ||
3276 | if (cse2_dump) | |
3277 | TIMEVAR (dump_time, | |
3278 | { | |
3279 | print_rtl (cse2_dump_file, insns); | |
3280 | fflush (cse2_dump_file); | |
3281 | }); | |
3282 | ||
0d332add DE |
3283 | if (branch_prob_dump) |
3284 | TIMEVAR (dump_time, | |
3285 | { | |
3286 | fprintf (branch_prob_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3287 | (*decl_printable_name) (decl, 2)); |
0d332add DE |
3288 | }); |
3289 | ||
3290 | if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) | |
3291 | TIMEVAR (branch_prob_time, | |
3292 | { | |
3293 | branch_prob (insns, branch_prob_dump_file); | |
3294 | }); | |
3295 | ||
3296 | if (branch_prob_dump) | |
3297 | TIMEVAR (dump_time, | |
3298 | { | |
3299 | print_rtl (branch_prob_dump_file, insns); | |
3300 | fflush (branch_prob_dump_file); | |
3301 | }); | |
4291d9c8 RS |
3302 | /* We are no longer anticipating cse in this function, at least. */ |
3303 | ||
3304 | cse_not_expected = 1; | |
3305 | ||
3306 | /* Now we choose between stupid (pcc-like) register allocation | |
3307 | (if we got the -noreg switch and not -opt) | |
3308 | and smart register allocation. */ | |
3309 | ||
3310 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
3311 | obey_regdecls = 0; /* if optimizations being done. */ | |
3312 | ||
3313 | regclass_init (); | |
3314 | ||
3315 | /* Print function header into flow dump now | |
3316 | because doing the flow analysis makes some of the dump. */ | |
3317 | ||
3318 | if (flow_dump) | |
3319 | TIMEVAR (dump_time, | |
3320 | { | |
3321 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3322 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3323 | }); |
3324 | ||
3325 | if (obey_regdecls) | |
3326 | { | |
3327 | TIMEVAR (flow_time, | |
3328 | { | |
3329 | regclass (insns, max_reg_num ()); | |
3330 | stupid_life_analysis (insns, max_reg_num (), | |
3331 | flow_dump_file); | |
3332 | }); | |
3333 | } | |
3334 | else | |
3335 | { | |
3336 | /* Do control and data flow analysis, | |
3337 | and write some of the results to dump file. */ | |
3338 | ||
3339 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
3340 | flow_dump_file)); | |
3341 | if (warn_uninitialized) | |
3342 | { | |
3343 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
3344 | setjmp_args_warning (); | |
3345 | } | |
3346 | } | |
3347 | ||
3348 | /* Dump rtl after flow analysis. */ | |
3349 | ||
3350 | if (flow_dump) | |
3351 | TIMEVAR (dump_time, | |
3352 | { | |
3353 | print_rtl (flow_dump_file, insns); | |
3354 | fflush (flow_dump_file); | |
3355 | }); | |
3356 | ||
3357 | /* If -opt, try combining insns through substitution. */ | |
3358 | ||
3359 | if (optimize > 0) | |
3360 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
3361 | ||
3362 | /* Dump rtl code after insn combination. */ | |
3363 | ||
3364 | if (combine_dump) | |
3365 | TIMEVAR (dump_time, | |
3366 | { | |
3367 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3368 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3369 | dump_combine_stats (combine_dump_file); |
3370 | print_rtl (combine_dump_file, insns); | |
3371 | fflush (combine_dump_file); | |
3372 | }); | |
3373 | ||
8c660648 JL |
3374 | if (regmove_dump) |
3375 | TIMEVAR (dump_time, | |
3376 | { | |
3377 | fprintf (regmove_dump_file, "\n;; Function %s\n\n", | |
3378 | (*decl_printable_name) (decl, 2)); | |
3379 | }); | |
3380 | ||
3381 | /* Register allocation pre-pass, to reduce number of moves | |
3382 | necessary for two-address machines. */ | |
3383 | if (optimize > 0 && flag_regmove) | |
3384 | TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (), | |
3385 | regmove_dump_file)); | |
3386 | ||
3387 | if (regmove_dump) | |
3388 | TIMEVAR (dump_time, | |
3389 | { | |
3390 | print_rtl (regmove_dump_file, insns); | |
3391 | fflush (regmove_dump_file); | |
3392 | }); | |
3393 | ||
4291d9c8 RS |
3394 | /* Print function header into sched dump now |
3395 | because doing the sched analysis makes some of the dump. */ | |
3396 | ||
3397 | if (sched_dump) | |
3398 | TIMEVAR (dump_time, | |
3399 | { | |
3400 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3401 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3402 | }); |
3403 | ||
3404 | if (optimize > 0 && flag_schedule_insns) | |
3405 | { | |
3406 | /* Do control and data sched analysis, | |
3407 | and write some of the results to dump file. */ | |
3408 | ||
3409 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
3410 | } | |
3411 | ||
3412 | /* Dump rtl after instruction scheduling. */ | |
3413 | ||
3414 | if (sched_dump) | |
3415 | TIMEVAR (dump_time, | |
3416 | { | |
3417 | print_rtl (sched_dump_file, insns); | |
3418 | fflush (sched_dump_file); | |
3419 | }); | |
3420 | ||
3421 | /* Unless we did stupid register allocation, | |
3422 | allocate pseudo-regs that are used only within 1 basic block. */ | |
3423 | ||
3424 | if (!obey_regdecls) | |
3425 | TIMEVAR (local_alloc_time, | |
3426 | { | |
3427 | regclass (insns, max_reg_num ()); | |
3428 | local_alloc (); | |
3429 | }); | |
3430 | ||
3431 | /* Dump rtl code after allocating regs within basic blocks. */ | |
3432 | ||
3433 | if (local_reg_dump) | |
3434 | TIMEVAR (dump_time, | |
3435 | { | |
3436 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3437 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3438 | dump_flow_info (local_reg_dump_file); |
3439 | dump_local_alloc (local_reg_dump_file); | |
3440 | print_rtl (local_reg_dump_file, insns); | |
3441 | fflush (local_reg_dump_file); | |
3442 | }); | |
3443 | ||
3444 | if (global_reg_dump) | |
3445 | TIMEVAR (dump_time, | |
3446 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3447 | (*decl_printable_name) (decl, 2))); |
4291d9c8 | 3448 | |
bf8b4985 RK |
3449 | /* Save the last label number used so far, so reorg can tell |
3450 | when it's safe to kill spill regs. */ | |
3451 | max_label_num_after_reload = max_label_num (); | |
3452 | ||
4291d9c8 RS |
3453 | /* Unless we did stupid register allocation, |
3454 | allocate remaining pseudo-regs, then do the reload pass | |
3455 | fixing up any insns that are invalid. */ | |
3456 | ||
3457 | TIMEVAR (global_alloc_time, | |
3458 | { | |
3459 | if (!obey_regdecls) | |
37366632 | 3460 | failure = global_alloc (global_reg_dump_file); |
4291d9c8 | 3461 | else |
37366632 | 3462 | failure = reload (insns, 0, global_reg_dump_file); |
4291d9c8 RS |
3463 | }); |
3464 | ||
3465 | if (global_reg_dump) | |
3466 | TIMEVAR (dump_time, | |
3467 | { | |
3468 | dump_global_regs (global_reg_dump_file); | |
3469 | print_rtl (global_reg_dump_file, insns); | |
3470 | fflush (global_reg_dump_file); | |
3471 | }); | |
3472 | ||
ab40ad2b RS |
3473 | if (failure) |
3474 | goto exit_rest_of_compilation; | |
3475 | ||
4291d9c8 RS |
3476 | reload_completed = 1; |
3477 | ||
c8ed219d RK |
3478 | /* Do a very simple CSE pass over just the hard registers. */ |
3479 | if (optimize > 0) | |
3480 | reload_cse_regs (insns); | |
3481 | ||
bdac5f58 TW |
3482 | /* On some machines, the prologue and epilogue code, or parts thereof, |
3483 | can be represented as RTL. Doing so lets us schedule insns between | |
3484 | it and the rest of the code and also allows delayed branch | |
3485 | scheduling to operate in the epilogue. */ | |
3486 | ||
3487 | thread_prologue_and_epilogue_insns (insns); | |
3488 | ||
4291d9c8 RS |
3489 | if (optimize > 0 && flag_schedule_insns_after_reload) |
3490 | { | |
3491 | if (sched2_dump) | |
3492 | TIMEVAR (dump_time, | |
3493 | { | |
3494 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3495 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3496 | }); |
3497 | ||
3498 | /* Do control and data sched analysis again, | |
3499 | and write some more of the results to dump file. */ | |
3500 | ||
3501 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
3502 | ||
3503 | /* Dump rtl after post-reorder instruction scheduling. */ | |
3504 | ||
3505 | if (sched2_dump) | |
3506 | TIMEVAR (dump_time, | |
3507 | { | |
3508 | print_rtl (sched2_dump_file, insns); | |
3509 | fflush (sched2_dump_file); | |
3510 | }); | |
3511 | } | |
3512 | ||
3513 | #ifdef LEAF_REGISTERS | |
3514 | leaf_function = 0; | |
3515 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 3516 | leaf_function = 1; |
4291d9c8 RS |
3517 | #endif |
3518 | ||
3519 | /* One more attempt to remove jumps to .+1 | |
3520 | left by dead-store-elimination. | |
3521 | Also do cross-jumping this time | |
3522 | and delete no-op move insns. */ | |
3523 | ||
3524 | if (optimize > 0) | |
3525 | { | |
3526 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
3527 | } | |
3528 | ||
3529 | /* Dump rtl code after jump, if we are doing that. */ | |
3530 | ||
3531 | if (jump2_opt_dump) | |
3532 | TIMEVAR (dump_time, | |
3533 | { | |
3534 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3535 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3536 | print_rtl (jump2_opt_dump_file, insns); |
3537 | fflush (jump2_opt_dump_file); | |
3538 | }); | |
3539 | ||
2c65021a RK |
3540 | /* If a machine dependent reorganization is needed, call it. */ |
3541 | #ifdef MACHINE_DEPENDENT_REORG | |
3542 | MACHINE_DEPENDENT_REORG (insns); | |
3543 | #endif | |
3544 | ||
4291d9c8 | 3545 | /* If a scheduling pass for delayed branches is to be done, |
0f41302f | 3546 | call the scheduling code. */ |
4291d9c8 RS |
3547 | |
3548 | #ifdef DELAY_SLOTS | |
3549 | if (optimize > 0 && flag_delayed_branch) | |
3550 | { | |
3551 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
3552 | if (dbr_sched_dump) | |
3553 | { | |
3554 | TIMEVAR (dump_time, | |
3555 | { | |
3556 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3557 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3558 | print_rtl (dbr_sched_dump_file, insns); |
3559 | fflush (dbr_sched_dump_file); | |
3560 | }); | |
3561 | } | |
3562 | } | |
3563 | #endif | |
3564 | ||
d0c874f6 TG |
3565 | /* Shorten branches. */ |
3566 | TIMEVAR (shorten_branch_time, | |
3567 | { | |
3568 | shorten_branches (get_insns ()); | |
3569 | }); | |
4291d9c8 RS |
3570 | |
3571 | #ifdef STACK_REGS | |
3572 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
3573 | if (stack_reg_dump) | |
3574 | { | |
3575 | TIMEVAR (dump_time, | |
3576 | { | |
3577 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3578 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3579 | print_rtl (stack_reg_dump_file, insns); |
3580 | fflush (stack_reg_dump_file); | |
3581 | }); | |
3582 | } | |
3583 | #endif | |
3584 | ||
3585 | /* Now turn the rtl into assembler code. */ | |
3586 | ||
3587 | TIMEVAR (final_time, | |
3588 | { | |
3589 | rtx x; | |
3590 | char *fnname; | |
3591 | ||
3592 | /* Get the function's name, as described by its RTL. | |
3593 | This may be different from the DECL_NAME name used | |
3594 | in the source file. */ | |
3595 | ||
3596 | x = DECL_RTL (decl); | |
3597 | if (GET_CODE (x) != MEM) | |
3598 | abort (); | |
3599 | x = XEXP (x, 0); | |
3600 | if (GET_CODE (x) != SYMBOL_REF) | |
3601 | abort (); | |
3602 | fnname = XSTR (x, 0); | |
3603 | ||
3604 | assemble_start_function (decl, fnname); | |
3605 | final_start_function (insns, asm_out_file, optimize); | |
3606 | final (insns, asm_out_file, optimize, 0); | |
3607 | final_end_function (insns, asm_out_file, optimize); | |
3608 | assemble_end_function (decl, fnname); | |
3609 | fflush (asm_out_file); | |
9ddca353 RK |
3610 | |
3611 | /* Release all memory held by regsets now */ | |
3612 | regset_release_memory (); | |
4291d9c8 RS |
3613 | }); |
3614 | ||
3615 | /* Write DBX symbols if requested */ | |
3616 | ||
3617 | /* Note that for those inline functions where we don't initially | |
3618 | know for certain that we will be generating an out-of-line copy, | |
3619 | the first invocation of this routine (rest_of_compilation) will | |
3620 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
3621 | Later on, finish_compilation will call rest_of_compilation again | |
3622 | for those inline functions that need to have out-of-line copies | |
3623 | generated. During that call, we *will* be routed past here. */ | |
3624 | ||
3625 | #ifdef DBX_DEBUGGING_INFO | |
3626 | if (write_symbols == DBX_DEBUG) | |
3627 | TIMEVAR (symout_time, dbxout_function (decl)); | |
3628 | #endif | |
3629 | ||
3630 | #ifdef DWARF_DEBUGGING_INFO | |
3631 | if (write_symbols == DWARF_DEBUG) | |
3632 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3633 | #endif | |
3634 | ||
9a666dda JM |
3635 | #ifdef DWARF2_DEBUGGING_INFO |
3636 | if (write_symbols == DWARF2_DEBUG) | |
88dad228 | 3637 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3638 | #endif |
3639 | ||
4291d9c8 RS |
3640 | exit_rest_of_compilation: |
3641 | ||
f246a305 RS |
3642 | /* In case the function was not output, |
3643 | don't leave any temporary anonymous types | |
3644 | queued up for sdb output. */ | |
3645 | #ifdef SDB_DEBUGGING_INFO | |
3646 | if (write_symbols == SDB_DEBUG) | |
37366632 | 3647 | sdbout_types (NULL_TREE); |
f246a305 RS |
3648 | #endif |
3649 | ||
8a958768 RS |
3650 | /* Put back the tree of subblocks and list of arguments |
3651 | from before we copied them. | |
4291d9c8 RS |
3652 | Code generation and the output of debugging info may have modified |
3653 | the copy, but the original is unchanged. */ | |
3654 | ||
3655 | if (saved_block_tree != 0) | |
fb19c456 JM |
3656 | { |
3657 | DECL_INITIAL (decl) = saved_block_tree; | |
3658 | DECL_ARGUMENTS (decl) = saved_arguments; | |
3659 | DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
3660 | } | |
4291d9c8 RS |
3661 | |
3662 | reload_completed = 0; | |
3663 | ||
9fe320d7 RK |
3664 | /* Clear out the insn_length contents now that they are no longer valid. */ |
3665 | init_insn_lengths (); | |
3666 | ||
4291d9c8 RS |
3667 | /* Clear out the real_constant_chain before some of the rtx's |
3668 | it runs through become garbage. */ | |
3669 | ||
3670 | clear_const_double_mem (); | |
3671 | ||
3672 | /* Cancel the effect of rtl_in_current_obstack. */ | |
3673 | ||
3674 | resume_temporary_allocation (); | |
3675 | ||
adcd38c9 RK |
3676 | /* Show no temporary slots allocated. */ |
3677 | ||
3678 | init_temp_slots (); | |
3679 | ||
4291d9c8 RS |
3680 | /* The parsing time is all the time spent in yyparse |
3681 | *except* what is spent in this function. */ | |
3682 | ||
3683 | parse_time -= get_run_time () - start_time; | |
3684 | } | |
3685 | \f | |
3686 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
3687 | Exit code is 35 if can't open files, 34 if fatal error, | |
3688 | 33 if had nonfatal errors, else success. */ | |
3689 | ||
3690 | int | |
3691 | main (argc, argv, envp) | |
3692 | int argc; | |
3693 | char **argv; | |
3694 | char **envp; | |
3695 | { | |
3696 | register int i; | |
3697 | char *filename = 0; | |
3698 | int flag_print_mem = 0; | |
3699 | int version_flag = 0; | |
3700 | char *p; | |
3701 | ||
3702 | /* save in case md file wants to emit args as a comment. */ | |
3703 | save_argc = argc; | |
3704 | save_argv = argv; | |
3705 | ||
3706 | p = argv[0] + strlen (argv[0]); | |
128373ac RK |
3707 | while (p != argv[0] && p[-1] != '/' |
3708 | #ifdef DIR_SEPARATOR | |
3709 | && p[-1] != DIR_SEPARATOR | |
3710 | #endif | |
3711 | ) | |
3712 | --p; | |
4291d9c8 RS |
3713 | progname = p; |
3714 | ||
3715 | #ifdef RLIMIT_STACK | |
3716 | /* Get rid of any avoidable limit on stack size. */ | |
3717 | { | |
3718 | struct rlimit rlim; | |
3719 | ||
0f41302f | 3720 | /* Set the stack limit huge so that alloca does not fail. */ |
4291d9c8 RS |
3721 | getrlimit (RLIMIT_STACK, &rlim); |
3722 | rlim.rlim_cur = rlim.rlim_max; | |
3723 | setrlimit (RLIMIT_STACK, &rlim); | |
3724 | } | |
3725 | #endif /* RLIMIT_STACK */ | |
3726 | ||
3727 | signal (SIGFPE, float_signal); | |
3728 | ||
935d4b07 | 3729 | #ifdef SIGPIPE |
4291d9c8 | 3730 | signal (SIGPIPE, pipe_closed); |
935d4b07 | 3731 | #endif |
4291d9c8 RS |
3732 | |
3733 | decl_printable_name = decl_name; | |
3734 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
3735 | ||
3736 | /* Initialize whether `char' is signed. */ | |
3737 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
3738 | #ifdef DEFAULT_SHORT_ENUMS | |
3739 | /* Initialize how much space enums occupy, by default. */ | |
3740 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
3741 | #endif | |
3742 | ||
3743 | /* Scan to see what optimization level has been specified. That will | |
3744 | determine the default value of many flags. */ | |
3745 | for (i = 1; i < argc; i++) | |
3746 | { | |
3747 | if (!strcmp (argv[i], "-O")) | |
3748 | { | |
3749 | optimize = 1; | |
3750 | } | |
3751 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
3752 | { | |
3753 | /* Handle -O2, -O3, -O69, ... */ | |
3754 | char *p = &argv[i][2]; | |
3755 | int c; | |
3756 | ||
3757 | while (c = *p++) | |
3758 | if (! (c >= '0' && c <= '9')) | |
3759 | break; | |
3760 | if (c == 0) | |
3761 | optimize = atoi (&argv[i][2]); | |
3762 | } | |
3763 | } | |
3764 | ||
3765 | obey_regdecls = (optimize == 0); | |
4291d9c8 RS |
3766 | |
3767 | if (optimize >= 1) | |
3768 | { | |
6731a3e3 | 3769 | flag_defer_pop = 1; |
4291d9c8 RS |
3770 | flag_thread_jumps = 1; |
3771 | #ifdef DELAY_SLOTS | |
3772 | flag_delayed_branch = 1; | |
7e89c3a3 RK |
3773 | #endif |
3774 | #ifdef CAN_DEBUG_WITHOUT_FP | |
3775 | flag_omit_frame_pointer = 1; | |
4291d9c8 | 3776 | #endif |
9ae8ffe7 | 3777 | flag_alias_check = 1; |
4291d9c8 RS |
3778 | } |
3779 | ||
3780 | if (optimize >= 2) | |
3781 | { | |
3782 | flag_cse_follow_jumps = 1; | |
8b3686ed | 3783 | flag_cse_skip_blocks = 1; |
4291d9c8 RS |
3784 | flag_expensive_optimizations = 1; |
3785 | flag_strength_reduce = 1; | |
3786 | flag_rerun_cse_after_loop = 1; | |
ac266247 | 3787 | flag_caller_saves = 1; |
4ac8e06e | 3788 | flag_force_mem = 1; |
4291d9c8 RS |
3789 | #ifdef INSN_SCHEDULING |
3790 | flag_schedule_insns = 1; | |
3791 | flag_schedule_insns_after_reload = 1; | |
3792 | #endif | |
8c660648 | 3793 | flag_regmove = 1; |
4291d9c8 RS |
3794 | } |
3795 | ||
7e89c3a3 RK |
3796 | if (optimize >= 3) |
3797 | { | |
3798 | flag_inline_functions = 1; | |
3799 | } | |
3800 | ||
c1da383f DE |
3801 | /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can |
3802 | modify it. */ | |
3803 | target_flags = 0; | |
3804 | set_target_switch (""); | |
3805 | ||
4291d9c8 RS |
3806 | #ifdef OPTIMIZATION_OPTIONS |
3807 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
3808 | OPTIMIZATION_OPTIONS (optimize); | |
3809 | #endif | |
3810 | ||
3811 | /* Initialize register usage now so switches may override. */ | |
3812 | init_reg_sets (); | |
3813 | ||
4291d9c8 RS |
3814 | for (i = 1; i < argc; i++) |
3815 | { | |
b99933c7 RS |
3816 | int j; |
3817 | /* If this is a language-specific option, | |
3818 | decode it in a language-specific way. */ | |
3819 | for (j = 0; lang_options[j] != 0; j++) | |
7e6c0864 RK |
3820 | if (!strncmp (argv[i], lang_options[j], |
3821 | strlen (lang_options[j]))) | |
b99933c7 RS |
3822 | break; |
3823 | if (lang_options[j] != 0) | |
3824 | /* If the option is valid for *some* language, | |
3825 | treat it as valid even if this language doesn't understand it. */ | |
3826 | lang_decode_option (argv[i]); | |
3827 | else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4291d9c8 RS |
3828 | { |
3829 | register char *str = argv[i] + 1; | |
3830 | if (str[0] == 'Y') | |
3831 | str++; | |
3832 | ||
3833 | if (str[0] == 'm') | |
3834 | set_target_switch (&str[1]); | |
3835 | else if (!strcmp (str, "dumpbase")) | |
3836 | { | |
3837 | dump_base_name = argv[++i]; | |
3838 | } | |
3839 | else if (str[0] == 'd') | |
3840 | { | |
3841 | register char *p = &str[1]; | |
3842 | while (*p) | |
3843 | switch (*p++) | |
3844 | { | |
3845 | case 'a': | |
0d332add | 3846 | branch_prob_dump = 1; |
4291d9c8 RS |
3847 | combine_dump = 1; |
3848 | dbr_sched_dump = 1; | |
3849 | flow_dump = 1; | |
3850 | global_reg_dump = 1; | |
3851 | jump_opt_dump = 1; | |
3852 | jump2_opt_dump = 1; | |
3853 | local_reg_dump = 1; | |
3854 | loop_dump = 1; | |
8c660648 | 3855 | regmove_dump = 1; |
4291d9c8 RS |
3856 | rtl_dump = 1; |
3857 | cse_dump = 1, cse2_dump = 1; | |
3858 | sched_dump = 1; | |
3859 | sched2_dump = 1; | |
3860 | stack_reg_dump = 1; | |
3861 | break; | |
0d332add DE |
3862 | case 'b': |
3863 | branch_prob_dump = 1; | |
3864 | break; | |
4291d9c8 RS |
3865 | case 'k': |
3866 | stack_reg_dump = 1; | |
3867 | break; | |
3868 | case 'c': | |
3869 | combine_dump = 1; | |
3870 | break; | |
3871 | case 'd': | |
3872 | dbr_sched_dump = 1; | |
3873 | break; | |
3874 | case 'f': | |
3875 | flow_dump = 1; | |
3876 | break; | |
3877 | case 'g': | |
3878 | global_reg_dump = 1; | |
3879 | break; | |
3880 | case 'j': | |
3881 | jump_opt_dump = 1; | |
3882 | break; | |
3883 | case 'J': | |
3884 | jump2_opt_dump = 1; | |
3885 | break; | |
3886 | case 'l': | |
3887 | local_reg_dump = 1; | |
3888 | break; | |
3889 | case 'L': | |
3890 | loop_dump = 1; | |
3891 | break; | |
3892 | case 'm': | |
3893 | flag_print_mem = 1; | |
3894 | break; | |
3895 | case 'p': | |
3896 | flag_print_asm_name = 1; | |
3897 | break; | |
3898 | case 'r': | |
3899 | rtl_dump = 1; | |
3900 | break; | |
3901 | case 's': | |
3902 | cse_dump = 1; | |
3903 | break; | |
3904 | case 't': | |
3905 | cse2_dump = 1; | |
3906 | break; | |
8c660648 JL |
3907 | case 'N': |
3908 | regmove_dump = 1; | |
3909 | break; | |
4291d9c8 RS |
3910 | case 'S': |
3911 | sched_dump = 1; | |
3912 | break; | |
3913 | case 'R': | |
3914 | sched2_dump = 1; | |
3915 | break; | |
3916 | case 'y': | |
3917 | set_yydebug (1); | |
3918 | break; | |
4291d9c8 RS |
3919 | case 'x': |
3920 | rtl_dump_and_exit = 1; | |
3921 | break; | |
3d5cdd42 DE |
3922 | case 'A': |
3923 | flag_debug_asm = 1; | |
3924 | break; | |
4291d9c8 RS |
3925 | } |
3926 | } | |
3927 | else if (str[0] == 'f') | |
3928 | { | |
4291d9c8 RS |
3929 | register char *p = &str[1]; |
3930 | int found = 0; | |
3931 | ||
3932 | /* Some kind of -f option. | |
3933 | P's value is the option sans `-f'. | |
3934 | Search for it in the table of options. */ | |
3935 | ||
3936 | for (j = 0; | |
3937 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
3938 | j++) | |
3939 | { | |
3940 | if (!strcmp (p, f_options[j].string)) | |
3941 | { | |
3942 | *f_options[j].variable = f_options[j].on_value; | |
3943 | /* A goto here would be cleaner, | |
3944 | but breaks the vax pcc. */ | |
3945 | found = 1; | |
3946 | } | |
3947 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
3948 | && ! strcmp (p+3, f_options[j].string)) | |
3949 | { | |
3950 | *f_options[j].variable = ! f_options[j].on_value; | |
3951 | found = 1; | |
3952 | } | |
3953 | } | |
3954 | ||
3955 | if (found) | |
3956 | ; | |
8c660648 JL |
3957 | #ifdef HAIFA |
3958 | #ifdef INSN_SCHEDULING | |
3959 | else if (!strncmp (p, "sched-verbose-",14)) | |
3960 | fix_sched_param("verbose",&p[14]); | |
3961 | else if (!strncmp (p, "sched-max-",10)) | |
3962 | fix_sched_param("max",&p[10]); | |
3963 | else if (!strncmp (p, "sched-inter-max-b-",18)) | |
3964 | fix_sched_param("interblock-max-blocks",&p[18]); | |
3965 | else if (!strncmp (p, "sched-inter-max-i-",18)) | |
3966 | fix_sched_param("interblock-max-insns",&p[18]); | |
3967 | #endif | |
3968 | #endif /* HAIFA */ | |
4291d9c8 RS |
3969 | else if (!strncmp (p, "fixed-", 6)) |
3970 | fix_register (&p[6], 1, 1); | |
3971 | else if (!strncmp (p, "call-used-", 10)) | |
3972 | fix_register (&p[10], 0, 1); | |
3973 | else if (!strncmp (p, "call-saved-", 11)) | |
3974 | fix_register (&p[11], 0, 0); | |
b99933c7 | 3975 | else |
4291d9c8 RS |
3976 | error ("Invalid option `%s'", argv[i]); |
3977 | } | |
3978 | else if (str[0] == 'O') | |
3979 | { | |
3980 | register char *p = str+1; | |
3981 | while (*p && *p >= '0' && *p <= '9') | |
3982 | p++; | |
3983 | if (*p == '\0') | |
3984 | ; | |
3985 | else | |
3986 | error ("Invalid option `%s'", argv[i]); | |
3987 | } | |
3988 | else if (!strcmp (str, "pedantic")) | |
3989 | pedantic = 1; | |
3990 | else if (!strcmp (str, "pedantic-errors")) | |
3991 | flag_pedantic_errors = pedantic = 1; | |
4291d9c8 RS |
3992 | else if (!strcmp (str, "quiet")) |
3993 | quiet_flag = 1; | |
3994 | else if (!strcmp (str, "version")) | |
3995 | version_flag = 1; | |
3996 | else if (!strcmp (str, "w")) | |
3997 | inhibit_warnings = 1; | |
3998 | else if (!strcmp (str, "W")) | |
3999 | { | |
4000 | extra_warnings = 1; | |
fa1a4543 RS |
4001 | /* We save the value of warn_uninitialized, since if they put |
4002 | -Wuninitialized on the command line, we need to generate a | |
4003 | warning about not using it without also specifying -O. */ | |
4004 | if (warn_uninitialized != 1) | |
4005 | warn_uninitialized = 2; | |
4291d9c8 RS |
4006 | } |
4007 | else if (str[0] == 'W') | |
4008 | { | |
4291d9c8 RS |
4009 | register char *p = &str[1]; |
4010 | int found = 0; | |
4011 | ||
4012 | /* Some kind of -W option. | |
4013 | P's value is the option sans `-W'. | |
4014 | Search for it in the table of options. */ | |
4015 | ||
4016 | for (j = 0; | |
4017 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
4018 | j++) | |
4019 | { | |
4020 | if (!strcmp (p, W_options[j].string)) | |
4021 | { | |
4022 | *W_options[j].variable = W_options[j].on_value; | |
4023 | /* A goto here would be cleaner, | |
4024 | but breaks the vax pcc. */ | |
4025 | found = 1; | |
4026 | } | |
4027 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4028 | && ! strcmp (p+3, W_options[j].string)) | |
4029 | { | |
4030 | *W_options[j].variable = ! W_options[j].on_value; | |
4031 | found = 1; | |
4032 | } | |
4033 | } | |
4034 | ||
4035 | if (found) | |
4036 | ; | |
4037 | else if (!strncmp (p, "id-clash-", 9)) | |
4038 | { | |
4039 | char *endp = p + 9; | |
4040 | ||
4041 | while (*endp) | |
4042 | { | |
4043 | if (*endp >= '0' && *endp <= '9') | |
4044 | endp++; | |
4045 | else | |
7085b873 RS |
4046 | { |
4047 | error ("Invalid option `%s'", argv[i]); | |
4048 | goto id_clash_lose; | |
4049 | } | |
4291d9c8 RS |
4050 | } |
4051 | warn_id_clash = 1; | |
4052 | id_clash_len = atoi (str + 10); | |
7085b873 | 4053 | id_clash_lose: ; |
4291d9c8 | 4054 | } |
b51e9c62 RK |
4055 | else if (!strncmp (p, "larger-than-", 12)) |
4056 | { | |
4057 | char *endp = p + 12; | |
4058 | ||
4059 | while (*endp) | |
4060 | { | |
4061 | if (*endp >= '0' && *endp <= '9') | |
4062 | endp++; | |
4063 | else | |
4064 | { | |
4065 | error ("Invalid option `%s'", argv[i]); | |
4066 | goto larger_than_lose; | |
4067 | } | |
4068 | } | |
4069 | warn_larger_than = 1; | |
4070 | larger_than_size = atoi (str + 13); | |
4071 | larger_than_lose: ; | |
4072 | } | |
4291d9c8 RS |
4073 | else |
4074 | error ("Invalid option `%s'", argv[i]); | |
4075 | } | |
4076 | else if (!strcmp (str, "p")) | |
ca695ac9 | 4077 | { |
c2d12c8b | 4078 | profile_flag = 1; |
ca695ac9 | 4079 | } |
4291d9c8 RS |
4080 | else if (!strcmp (str, "a")) |
4081 | { | |
4082 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4083 | warning ("`-a' option (basic block profile) not supported"); | |
4084 | #else | |
ec6c615d RK |
4085 | profile_block_flag = (profile_block_flag < 2) ? 1 : 3; |
4086 | #endif | |
4087 | } | |
4088 | else if (!strcmp (str, "ax")) | |
4089 | { | |
4090 | #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4091 | warning ("`-ax' option (jump profiling) not supported"); | |
4092 | #else | |
4093 | profile_block_flag = (!profile_block_flag | |
4094 | || profile_block_flag == 2) ? 2 : 3; | |
4291d9c8 RS |
4095 | #endif |
4096 | } | |
4097 | else if (str[0] == 'g') | |
4098 | { | |
4291d9c8 RS |
4099 | unsigned len; |
4100 | unsigned level; | |
ff482cef DE |
4101 | /* A lot of code assumes write_symbols == NO_DEBUG if the |
4102 | debugging level is 0 (thus -gstabs1 -gstabs0 would lose track | |
4103 | of what debugging type has been selected). This records the | |
4104 | selected type. It is an error to specify more than one | |
4105 | debugging type. */ | |
4106 | static enum debug_info_type selected_debug_type = NO_DEBUG; | |
4107 | /* Non-zero if debugging format has been explicitly set. | |
4108 | -g and -ggdb don't explicitly set the debugging format so | |
4109 | -gdwarf -g3 is equivalent to -gdwarf3. */ | |
4110 | static int type_explicitly_set_p = 0; | |
4111 | /* Table of supported debugging formats. */ | |
4112 | static struct { | |
4113 | char *arg; | |
4114 | /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a | |
4115 | constant expression, we use NO_DEBUG in its place. */ | |
4116 | enum debug_info_type debug_type; | |
4117 | int use_extensions_p; | |
4118 | } *da, debug_args[] = { | |
4119 | { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS }, | |
4120 | { "ggdb", NO_DEBUG, 1 }, | |
4121 | #ifdef DBX_DEBUGGING_INFO | |
4122 | { "gstabs", DBX_DEBUG, 0 }, | |
4123 | { "gstabs+", DBX_DEBUG, 1 }, | |
4124 | #endif | |
4125 | #ifdef DWARF_DEBUGGING_INFO | |
4126 | { "gdwarf", DWARF_DEBUG, 0 }, | |
4127 | { "gdwarf+", DWARF_DEBUG, 1 }, | |
9a666dda | 4128 | #endif |
a94dbf2c JM |
4129 | #ifdef DWARF2_DEBUGGING_INFO |
4130 | { "gdwarf-2", DWARF2_DEBUG, 0 }, | |
ff482cef DE |
4131 | #endif |
4132 | #ifdef XCOFF_DEBUGGING_INFO | |
4133 | { "gxcoff", XCOFF_DEBUG, 0 }, | |
4134 | { "gxcoff+", XCOFF_DEBUG, 1 }, | |
4135 | #endif | |
4136 | #ifdef SDB_DEBUGGING_INFO | |
4137 | { "gcoff", SDB_DEBUG, 0 }, | |
4138 | #endif | |
4139 | { 0, 0, 0 } | |
4140 | }; | |
4141 | /* Indexed by enum debug_info_type. */ | |
4142 | static char *debug_type_names[] = { | |
9a666dda | 4143 | "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff" |
ff482cef | 4144 | }; |
4291d9c8 | 4145 | |
ff482cef DE |
4146 | /* Look up STR in the table. */ |
4147 | for (da = debug_args; da->arg; da++) | |
4148 | { | |
9a666dda | 4149 | if (! strncmp (str, da->arg, strlen (da->arg))) |
ff482cef DE |
4150 | { |
4151 | enum debug_info_type type = da->debug_type; | |
9a666dda JM |
4152 | char *p, *q; |
4153 | ||
4154 | p = str + strlen (da->arg); | |
4155 | if (*p && (*p < '0' || *p > '9')) | |
4156 | continue; | |
4157 | q = p; | |
5d38efae | 4158 | len = p - str; |
9a666dda JM |
4159 | while (*q && (*q >= '0' && *q <= '9')) |
4160 | q++; | |
4161 | if (*p) | |
4162 | level = atoi (p); | |
4163 | else | |
4164 | level = 2; /* default debugging info level */ | |
4165 | if (*q || level > 3) | |
4166 | { | |
4167 | warning ("invalid debug level specification in option: `-%s'", | |
4168 | str); | |
4169 | /* ??? This error message is incorrect in the case of | |
4170 | -g4 -g. */ | |
4171 | warning ("no debugging information will be generated"); | |
4172 | level = 0; | |
4173 | } | |
4174 | ||
ff482cef | 4175 | if (type == NO_DEBUG) |
fe0986b4 JM |
4176 | { |
4177 | type = PREFERRED_DEBUGGING_TYPE; | |
4178 | if (len > 1 && strncmp (str, "ggdb", len) == 0) | |
4179 | { | |
4180 | #ifdef DWARF2_DEBUGGING_INFO | |
4181 | type = DWARF2_DEBUG; | |
417b0fa2 JW |
4182 | #else |
4183 | #ifdef DBX_DEBUGGING_INFO | |
fe0986b4 | 4184 | type = DBX_DEBUG; |
417b0fa2 | 4185 | #endif |
fe0986b4 JM |
4186 | #endif |
4187 | } | |
4188 | } | |
ff482cef | 4189 | |
e38eaffd RK |
4190 | if (type == NO_DEBUG) |
4191 | warning ("`-%s' not supported by this configuration of GCC", | |
4192 | str); | |
4193 | ||
ff482cef DE |
4194 | /* Does it conflict with an already selected type? */ |
4195 | if (type_explicitly_set_p | |
4196 | /* -g/-ggdb don't conflict with anything */ | |
4197 | && da->debug_type != NO_DEBUG | |
4198 | && type != selected_debug_type) | |
4199 | warning ("`-%s' ignored, conflicts with `-g%s'", | |
4200 | str, debug_type_names[(int) selected_debug_type]); | |
4201 | else | |
4202 | { | |
4203 | /* If the format has already been set, -g/-ggdb | |
4204 | only change the debug level. */ | |
4205 | if (type_explicitly_set_p | |
4206 | && da->debug_type == NO_DEBUG) | |
4207 | ; /* don't change debugging type */ | |
4208 | else | |
4209 | { | |
4210 | selected_debug_type = type; | |
4211 | type_explicitly_set_p = da->debug_type != NO_DEBUG; | |
4212 | } | |
4213 | write_symbols = (level == 0 | |
4214 | ? NO_DEBUG | |
4215 | : selected_debug_type); | |
4216 | use_gnu_debug_info_extensions = da->use_extensions_p; | |
4217 | debug_info_level = (enum debug_info_level) level; | |
4218 | } | |
4219 | break; | |
4220 | } | |
4221 | } | |
4222 | if (! da->arg) | |
7276e85d RK |
4223 | warning ("`-%s' not supported by this configuration of GCC", |
4224 | str); | |
4291d9c8 RS |
4225 | } |
4226 | else if (!strcmp (str, "o")) | |
4227 | { | |
4228 | asm_file_name = argv[++i]; | |
4229 | } | |
4230 | else if (str[0] == 'G') | |
4231 | { | |
4232 | g_switch_set = TRUE; | |
4233 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
4234 | } | |
f246a305 RS |
4235 | else if (!strncmp (str, "aux-info", 8)) |
4236 | { | |
4237 | flag_gen_aux_info = 1; | |
4238 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
4239 | } | |
4291d9c8 RS |
4240 | else |
4241 | error ("Invalid option `%s'", argv[i]); | |
4242 | } | |
4243 | else if (argv[i][0] == '+') | |
b99933c7 | 4244 | error ("Invalid option `%s'", argv[i]); |
4291d9c8 RS |
4245 | else |
4246 | filename = argv[i]; | |
4247 | } | |
4248 | ||
f602c208 RK |
4249 | /* Checker uses the frame pointer. */ |
4250 | if (flag_check_memory_usage) | |
4251 | flag_omit_frame_pointer = 0; | |
4252 | ||
ca695ac9 | 4253 | /* Initialize for bytecode output. A good idea to do this as soon as |
0f41302f | 4254 | possible after the "-f" options have been parsed. */ |
ca695ac9 JB |
4255 | if (output_bytecode) |
4256 | { | |
4257 | #ifndef TARGET_SUPPORTS_BYTECODE | |
4258 | /* Just die with a fatal error if not supported */ | |
40e6003c | 4259 | fatal ("-fbytecode not supported for this target"); |
ca695ac9 JB |
4260 | #else |
4261 | bc_initialize (); | |
4262 | #endif | |
4263 | } | |
4264 | ||
f246a305 RS |
4265 | if (optimize == 0) |
4266 | { | |
a2468e45 BK |
4267 | /* Inlining does not work if not optimizing, |
4268 | so force it not to be done. */ | |
f246a305 RS |
4269 | flag_no_inline = 1; |
4270 | warn_inline = 0; | |
a2468e45 BK |
4271 | |
4272 | /* The c_decode_option and lang_decode_option functions set | |
4273 | this to `2' if -Wall is used, so we can avoid giving out | |
4274 | lots of errors for people who don't realize what -Wall does. */ | |
4275 | if (warn_uninitialized == 1) | |
4276 | warning ("-Wuninitialized is not supported without -O"); | |
f246a305 RS |
4277 | } |
4278 | ||
4291d9c8 RS |
4279 | #ifdef OVERRIDE_OPTIONS |
4280 | /* Some machines may reject certain combinations of options. */ | |
4281 | OVERRIDE_OPTIONS; | |
4282 | #endif | |
4283 | ||
ec6c615d RK |
4284 | if (profile_block_flag == 3) |
4285 | { | |
4286 | warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); | |
4287 | profile_block_flag = 2; | |
4288 | } | |
4289 | ||
4291d9c8 RS |
4290 | /* Unrolling all loops implies that standard loop unrolling must also |
4291 | be done. */ | |
4292 | if (flag_unroll_all_loops) | |
4293 | flag_unroll_loops = 1; | |
4294 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
4295 | turn on strength reduction here if it isn't already on. Also, the loop | |
4296 | unrolling code assumes that cse will be run after loop, so that must | |
4297 | be turned on also. */ | |
4298 | if (flag_unroll_loops) | |
4299 | { | |
4300 | flag_strength_reduce = 1; | |
4301 | flag_rerun_cse_after_loop = 1; | |
4302 | } | |
4303 | ||
4304 | /* Warn about options that are not supported on this machine. */ | |
4305 | #ifndef INSN_SCHEDULING | |
4306 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
4307 | warning ("instruction scheduling not supported on this target machine"); | |
4308 | #endif | |
4309 | #ifndef DELAY_SLOTS | |
4310 | if (flag_delayed_branch) | |
4311 | warning ("this target machine does not have delayed branches"); | |
4312 | #endif | |
4313 | ||
4314 | /* If we are in verbose mode, write out the version and maybe all the | |
4315 | option flags in use. */ | |
4316 | if (version_flag) | |
4317 | { | |
3d5cdd42 | 4318 | print_version (stderr, ""); |
4291d9c8 | 4319 | if (! quiet_flag) |
3d5cdd42 | 4320 | print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n"); |
4291d9c8 RS |
4321 | } |
4322 | ||
4291d9c8 RS |
4323 | compile_file (filename); |
4324 | ||
876ac40d | 4325 | #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__)) |
4291d9c8 RS |
4326 | if (flag_print_mem) |
4327 | { | |
4328 | char *lim = (char *) sbrk (0); | |
4329 | ||
4330 | fprintf (stderr, "Data size %d.\n", | |
b61b1c91 | 4331 | lim - (char *) &environ); |
4291d9c8 RS |
4332 | fflush (stderr); |
4333 | ||
4334 | #ifdef USG | |
4335 | system ("ps -l 1>&2"); | |
4336 | #else /* not USG */ | |
4337 | system ("ps v"); | |
4338 | #endif /* not USG */ | |
4339 | } | |
876ac40d | 4340 | #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */ |
4291d9c8 RS |
4341 | |
4342 | if (errorcount) | |
4343 | exit (FATAL_EXIT_CODE); | |
4344 | if (sorrycount) | |
4345 | exit (FATAL_EXIT_CODE); | |
4346 | exit (SUCCESS_EXIT_CODE); | |
299846f2 | 4347 | return 0; |
4291d9c8 RS |
4348 | } |
4349 | \f | |
4350 | /* Decode -m switches. */ | |
4351 | ||
4352 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
4353 | and which bits in `target_switches' it should set or clear. | |
4354 | If VALUE is positive, it is bits to set. | |
4355 | If VALUE is negative, -VALUE is bits to clear. | |
4356 | (The sign bit is not used so there is no confusion.) */ | |
4357 | ||
4358 | struct {char *name; int value;} target_switches [] | |
4359 | = TARGET_SWITCHES; | |
4360 | ||
4361 | /* This table is similar, but allows the switch to have a value. */ | |
4362 | ||
4363 | #ifdef TARGET_OPTIONS | |
4364 | struct {char *prefix; char ** variable;} target_options [] | |
4365 | = TARGET_OPTIONS; | |
4366 | #endif | |
4367 | ||
4368 | /* Decode the switch -mNAME. */ | |
4369 | ||
4370 | void | |
4371 | set_target_switch (name) | |
4372 | char *name; | |
4373 | { | |
4374 | register int j; | |
4375 | int valid = 0; | |
4376 | ||
4377 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
4378 | if (!strcmp (target_switches[j].name, name)) | |
4379 | { | |
4380 | if (target_switches[j].value < 0) | |
4381 | target_flags &= ~-target_switches[j].value; | |
4382 | else | |
4383 | target_flags |= target_switches[j].value; | |
4384 | valid = 1; | |
4385 | } | |
4386 | ||
4387 | #ifdef TARGET_OPTIONS | |
4388 | if (!valid) | |
4389 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4390 | { | |
4391 | int len = strlen (target_options[j].prefix); | |
4392 | if (!strncmp (target_options[j].prefix, name, len)) | |
4393 | { | |
4394 | *target_options[j].variable = name + len; | |
4395 | valid = 1; | |
4396 | } | |
4397 | } | |
4398 | #endif | |
4399 | ||
4400 | if (!valid) | |
4401 | error ("Invalid option `%s'", name); | |
4402 | } | |
4403 | \f | |
3d5cdd42 DE |
4404 | /* Print version information to FILE. |
4405 | Each line begins with INDENT (for the case where FILE is the | |
4406 | assembler output file). */ | |
4291d9c8 | 4407 | |
3d5cdd42 DE |
4408 | void |
4409 | print_version (file, indent) | |
4410 | FILE *file; | |
4411 | char *indent; | |
4291d9c8 | 4412 | { |
3d5cdd42 DE |
4413 | fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "", |
4414 | language_string, version_string); | |
4415 | fprintf (file, " (%s)", TARGET_NAME); | |
4416 | #ifdef __GNUC__ | |
4417 | #ifndef __VERSION__ | |
4418 | #define __VERSION__ "[unknown]" | |
4419 | #endif | |
4420 | fprintf (file, " compiled by GNU C version %s.\n", __VERSION__); | |
4421 | #else | |
4422 | fprintf (file, " compiled by CC.\n"); | |
4423 | #endif | |
4424 | } | |
4291d9c8 | 4425 | |
3d5cdd42 | 4426 | /* Print an option value and return the adjusted position in the line. |
309a8875 DE |
4427 | ??? We don't handle error returns from fprintf (disk full); presumably |
4428 | other code will catch a disk full though. */ | |
4291d9c8 | 4429 | |
3d5cdd42 DE |
4430 | int |
4431 | print_single_switch (file, pos, max, indent, sep, term, type, name) | |
4432 | FILE *file; | |
4433 | int pos, max; | |
4434 | char *indent, *sep, *term, *type, *name; | |
4435 | { | |
309a8875 DE |
4436 | /* The ultrix fprintf returns 0 on success, so compute the result we want |
4437 | here since we need it for the following test. */ | |
4438 | int len = strlen (sep) + strlen (type) + strlen (name); | |
4439 | ||
3d5cdd42 | 4440 | if (pos != 0 |
309a8875 | 4441 | && pos + len > max) |
4291d9c8 | 4442 | { |
3d5cdd42 DE |
4443 | fprintf (file, "%s", term); |
4444 | pos = 0; | |
4291d9c8 | 4445 | } |
3d5cdd42 DE |
4446 | if (pos == 0) |
4447 | { | |
309a8875 DE |
4448 | fprintf (file, "%s", indent); |
4449 | pos = strlen (indent); | |
3d5cdd42 | 4450 | } |
309a8875 DE |
4451 | fprintf (file, "%s%s%s", sep, type, name); |
4452 | pos += len; | |
3d5cdd42 | 4453 | return pos; |
4291d9c8 RS |
4454 | } |
4455 | ||
3d5cdd42 DE |
4456 | /* Print active target switches to FILE. |
4457 | POS is the current cursor position and MAX is the size of a "line". | |
4458 | Each line begins with INDENT and ends with TERM. | |
4459 | Each switch is separated from the next by SEP. */ | |
4291d9c8 | 4460 | |
3d5cdd42 DE |
4461 | void |
4462 | print_switch_values (file, pos, max, indent, sep, term) | |
4463 | FILE *file; | |
4464 | int pos, max; | |
4465 | char *indent, *sep, *term; | |
4291d9c8 | 4466 | { |
3d5cdd42 DE |
4467 | int j, flags; |
4468 | char **p; | |
4469 | ||
4470 | /* Print the options as passed. */ | |
4291d9c8 | 4471 | |
3d5cdd42 DE |
4472 | pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term, |
4473 | "options passed: ", ""); | |
4474 | ||
520e7ff5 | 4475 | for (p = &save_argv[1]; *p != NULL; p++) |
3d5cdd42 DE |
4476 | if (**p == '-') |
4477 | { | |
4478 | /* Ignore these. */ | |
520e7ff5 DE |
4479 | if (strcmp (*p, "-o") == 0) |
4480 | { | |
4481 | if (p[1] != NULL) | |
4482 | p++; | |
4483 | continue; | |
4484 | } | |
3d5cdd42 DE |
4485 | if (strcmp (*p, "-quiet") == 0) |
4486 | continue; | |
4487 | if (strcmp (*p, "-version") == 0) | |
4488 | continue; | |
4489 | if ((*p)[1] == 'd') | |
4490 | continue; | |
4491 | ||
4492 | pos = print_single_switch (file, pos, max, indent, sep, term, *p, ""); | |
4493 | } | |
4494 | if (pos > 0) | |
4495 | fprintf (file, "%s", term); | |
4496 | ||
4497 | /* Print the -f and -m options that have been enabled. | |
4498 | We don't handle language specific options but printing argv | |
4499 | should suffice. */ | |
4500 | ||
4501 | pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, | |
4502 | "options enabled: ", ""); | |
4291d9c8 RS |
4503 | |
4504 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
4505 | if (*f_options[j].variable == f_options[j].on_value) | |
3d5cdd42 DE |
4506 | pos = print_single_switch (file, pos, max, indent, sep, term, |
4507 | "-f", f_options[j].string); | |
4291d9c8 | 4508 | |
3d5cdd42 | 4509 | /* Print target specific options. */ |
4291d9c8 | 4510 | |
3d5cdd42 | 4511 | flags = target_flags; |
4291d9c8 RS |
4512 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) |
4513 | if (target_switches[j].name[0] != '\0' | |
4514 | && target_switches[j].value > 0 | |
4515 | && ((target_switches[j].value & target_flags) | |
4516 | == target_switches[j].value)) | |
3d5cdd42 DE |
4517 | { |
4518 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4519 | "-m", target_switches[j].name); | |
4520 | flags &= ~ target_switches[j].value; | |
4521 | } | |
4522 | ||
4523 | #ifdef TARGET_OPTIONS | |
4524 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4525 | if (*target_options[j].variable != NULL) | |
4526 | { | |
4527 | char prefix[256]; | |
4528 | sprintf (prefix, "-m%s", target_options[j].prefix); | |
4529 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4530 | prefix, *target_options[j].variable); | |
4531 | } | |
4532 | #endif | |
4291d9c8 | 4533 | |
3d5cdd42 | 4534 | fprintf (file, "%s", term); |
4291d9c8 | 4535 | } |
9a666dda JM |
4536 | |
4537 | /* Record the beginning of a new source file, named FILENAME. */ | |
4538 | ||
4539 | void | |
4540 | debug_start_source_file (filename) | |
4541 | register char *filename; | |
4542 | { | |
4543 | #ifdef DBX_DEBUGGING_INFO | |
4544 | if (write_symbols == DBX_DEBUG) | |
4545 | dbxout_start_new_source_file (filename); | |
4546 | #endif | |
4547 | #ifdef DWARF_DEBUGGING_INFO | |
4548 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4549 | && write_symbols == DWARF_DEBUG) | |
4550 | dwarfout_start_new_source_file (filename); | |
4551 | #endif /* DWARF_DEBUGGING_INFO */ | |
4552 | #ifdef DWARF2_DEBUGGING_INFO | |
4553 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4554 | && write_symbols == DWARF2_DEBUG) | |
4555 | dwarf2out_start_source_file (filename); | |
4556 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
4557 | #ifdef SDB_DEBUGGING_INFO |
4558 | if (write_symbols == SDB_DEBUG) | |
4559 | sdbout_start_new_source_file (filename); | |
4560 | #endif | |
9a666dda JM |
4561 | } |
4562 | ||
4563 | /* Record the resumption of a source file. LINENO is the line number in | |
4564 | the source file we are returning to. */ | |
4565 | ||
4566 | void | |
4567 | debug_end_source_file (lineno) | |
4568 | register unsigned lineno; | |
4569 | { | |
4570 | #ifdef DBX_DEBUGGING_INFO | |
4571 | if (write_symbols == DBX_DEBUG) | |
4572 | dbxout_resume_previous_source_file (); | |
4573 | #endif | |
4574 | #ifdef DWARF_DEBUGGING_INFO | |
4575 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4576 | && write_symbols == DWARF_DEBUG) | |
4577 | dwarfout_resume_previous_source_file (lineno); | |
4578 | #endif /* DWARF_DEBUGGING_INFO */ | |
4579 | #ifdef DWARF2_DEBUGGING_INFO | |
4580 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4581 | && write_symbols == DWARF2_DEBUG) | |
4582 | dwarf2out_end_source_file (); | |
4583 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
4584 | #ifdef SDB_DEBUGGING_INFO |
4585 | if (write_symbols == SDB_DEBUG) | |
4586 | sdbout_resume_previous_source_file (); | |
4587 | #endif | |
9a666dda JM |
4588 | } |
4589 | ||
4590 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4591 | the tail part of the directive line, i.e. the part which is past the | |
4592 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4593 | ||
4594 | void | |
4595 | debug_define (lineno, buffer) | |
4596 | register unsigned lineno; | |
4597 | register char *buffer; | |
4598 | { | |
4599 | #ifdef DWARF_DEBUGGING_INFO | |
4600 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4601 | && write_symbols == DWARF_DEBUG) | |
4602 | dwarfout_define (lineno, buffer); | |
4603 | #endif /* DWARF_DEBUGGING_INFO */ | |
4604 | #ifdef DWARF2_DEBUGGING_INFO | |
4605 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4606 | && write_symbols == DWARF2_DEBUG) | |
4607 | dwarf2out_define (lineno, buffer); | |
4608 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4609 | } | |
4610 | ||
4611 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4612 | the tail part of the directive line, i.e. the part which is past the | |
4613 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4614 | ||
4615 | void | |
4616 | debug_undef (lineno, buffer) | |
4617 | register unsigned lineno; | |
4618 | register char *buffer; | |
4619 | { | |
4620 | #ifdef DWARF_DEBUGGING_INFO | |
4621 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4622 | && write_symbols == DWARF_DEBUG) | |
4623 | dwarfout_undef (lineno, buffer); | |
4624 | #endif /* DWARF_DEBUGGING_INFO */ | |
4625 | #ifdef DWARF2_DEBUGGING_INFO | |
4626 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4627 | && write_symbols == DWARF2_DEBUG) | |
4628 | dwarf2out_undef (lineno, buffer); | |
4629 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4630 | } |