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