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