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