]>
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; | |
ea466196 | 1022 | #if defined (_WIN32) && !defined (__CYGWIN32__) |
15f00097 RK |
1023 | if (clock() < 0) |
1024 | return 0; | |
1025 | else | |
1026 | return (clock() * 1000); | |
9580b583 | 1027 | #else /* not _WIN32 */ |
4291d9c8 RS |
1028 | #ifdef USG |
1029 | times (&tms); | |
1030 | return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); | |
1031 | #else | |
1032 | #ifndef VMS | |
1033 | getrusage (0, &rusage); | |
1034 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
1035 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
1036 | #else /* VMS */ | |
1037 | times (&vms_times); | |
1038 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
1039 | #endif | |
1040 | #endif | |
eb910b5a | 1041 | #endif |
4291d9c8 RS |
1042 | } |
1043 | ||
1044 | #define TIMEVAR(VAR, BODY) \ | |
1045 | do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) | |
1046 | ||
1047 | void | |
1048 | print_time (str, total) | |
1049 | char *str; | |
1050 | int total; | |
1051 | { | |
1052 | fprintf (stderr, | |
1053 | "time in %s: %d.%06d\n", | |
1054 | str, total / 1000000, total % 1000000); | |
1055 | } | |
1056 | ||
1057 | /* Count an error or warning. Return 1 if the message should be printed. */ | |
1058 | ||
1059 | int | |
1060 | count_error (warningp) | |
1061 | int warningp; | |
1062 | { | |
1063 | if (warningp && inhibit_warnings) | |
1064 | return 0; | |
1065 | ||
1066 | if (warningp && !warnings_are_errors) | |
1067 | warningcount++; | |
1068 | else | |
1069 | { | |
1070 | static int warning_message = 0; | |
1071 | ||
1072 | if (warningp && !warning_message) | |
1073 | { | |
1074 | fprintf (stderr, "%s: warnings being treated as errors\n", progname); | |
1075 | warning_message = 1; | |
1076 | } | |
1077 | errorcount++; | |
1078 | } | |
1079 | ||
1080 | return 1; | |
1081 | } | |
1082 | ||
1083 | /* Print a fatal error message. NAME is the text. | |
1084 | Also include a system error message based on `errno'. */ | |
1085 | ||
1086 | void | |
1087 | pfatal_with_name (name) | |
1088 | char *name; | |
1089 | { | |
1090 | fprintf (stderr, "%s: ", progname); | |
1091 | perror (name); | |
299846f2 | 1092 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1093 | } |
1094 | ||
1095 | void | |
1096 | fatal_io_error (name) | |
1097 | char *name; | |
1098 | { | |
1099 | fprintf (stderr, "%s: %s: I/O error\n", progname, name); | |
299846f2 | 1100 | exit (FATAL_EXIT_CODE); |
4291d9c8 RS |
1101 | } |
1102 | ||
a89b2cc4 MM |
1103 | /* Called to give a better error message for a bad insn rather than |
1104 | just calling abort(). */ | |
4291d9c8 RS |
1105 | |
1106 | void | |
a89b2cc4 MM |
1107 | fatal_insn (message, insn) |
1108 | char *message; | |
4291d9c8 RS |
1109 | rtx insn; |
1110 | { | |
ca695ac9 JB |
1111 | if (!output_bytecode) |
1112 | { | |
a89b2cc4 | 1113 | error (message); |
ca695ac9 JB |
1114 | debug_rtx (insn); |
1115 | } | |
4291d9c8 RS |
1116 | if (asm_out_file) |
1117 | fflush (asm_out_file); | |
1118 | if (aux_info_file) | |
1119 | fflush (aux_info_file); | |
1120 | if (rtl_dump_file) | |
1121 | fflush (rtl_dump_file); | |
1122 | if (jump_opt_dump_file) | |
1123 | fflush (jump_opt_dump_file); | |
e9a25f70 JL |
1124 | if (addressof_dump_file) |
1125 | fflush (addressof_dump_file); | |
4291d9c8 RS |
1126 | if (cse_dump_file) |
1127 | fflush (cse_dump_file); | |
1128 | if (loop_dump_file) | |
1129 | fflush (loop_dump_file); | |
1130 | if (cse2_dump_file) | |
1131 | fflush (cse2_dump_file); | |
1132 | if (flow_dump_file) | |
1133 | fflush (flow_dump_file); | |
1134 | if (combine_dump_file) | |
1135 | fflush (combine_dump_file); | |
8c660648 JL |
1136 | if (regmove_dump_file) |
1137 | fflush (regmove_dump_file); | |
4291d9c8 RS |
1138 | if (sched_dump_file) |
1139 | fflush (sched_dump_file); | |
1140 | if (local_reg_dump_file) | |
1141 | fflush (local_reg_dump_file); | |
1142 | if (global_reg_dump_file) | |
1143 | fflush (global_reg_dump_file); | |
1144 | if (sched2_dump_file) | |
1145 | fflush (sched2_dump_file); | |
1146 | if (jump2_opt_dump_file) | |
1147 | fflush (jump2_opt_dump_file); | |
1148 | if (dbr_sched_dump_file) | |
1149 | fflush (dbr_sched_dump_file); | |
1150 | if (stack_reg_dump_file) | |
1151 | fflush (stack_reg_dump_file); | |
1902f7fd MM |
1152 | fflush (stdout); |
1153 | fflush (stderr); | |
4291d9c8 RS |
1154 | abort (); |
1155 | } | |
1156 | ||
a89b2cc4 MM |
1157 | /* Called to give a better error message when we don't have an insn to match |
1158 | what we are looking for or if the insn's constraints aren't satisfied, | |
1159 | rather than just calling abort(). */ | |
1160 | ||
1161 | void | |
1162 | fatal_insn_not_found (insn) | |
1163 | rtx insn; | |
1164 | { | |
1165 | if (INSN_CODE (insn) < 0) | |
1166 | fatal_insn ("internal error--unrecognizable insn:", insn); | |
1167 | else | |
1168 | fatal_insn ("internal error--insn does not satisfy its constraints:", insn); | |
1169 | } | |
1170 | ||
4291d9c8 RS |
1171 | /* This is the default decl_printable_name function. */ |
1172 | ||
1173 | static char * | |
a1d7ffe3 | 1174 | decl_name (decl, verbosity) |
4291d9c8 | 1175 | tree decl; |
a1d7ffe3 | 1176 | int verbosity; |
4291d9c8 RS |
1177 | { |
1178 | return IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1179 | } | |
1180 | \f | |
1181 | static int need_error_newline; | |
1182 | ||
1183 | /* Function of last error message; | |
1184 | more generally, function such that if next error message is in it | |
1185 | then we don't have to mention the function name. */ | |
1186 | static tree last_error_function = NULL; | |
1187 | ||
1188 | /* Used to detect when input_file_stack has changed since last described. */ | |
1189 | static int last_error_tick; | |
1190 | ||
1191 | /* Called when the start of a function definition is parsed, | |
1192 | this function prints on stderr the name of the function. */ | |
1193 | ||
1194 | void | |
1195 | announce_function (decl) | |
1196 | tree decl; | |
1197 | { | |
1198 | if (! quiet_flag) | |
1199 | { | |
4291d9c8 RS |
1200 | if (rtl_dump_and_exit) |
1201 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
1202 | else | |
a1d7ffe3 | 1203 | fprintf (stderr, " %s", (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
1204 | fflush (stderr); |
1205 | need_error_newline = 1; | |
1206 | last_error_function = current_function_decl; | |
1207 | } | |
1208 | } | |
1209 | ||
b64e9948 PB |
1210 | /* The default function to print out name of current function that caused |
1211 | an error. */ | |
4291d9c8 RS |
1212 | |
1213 | void | |
b64e9948 | 1214 | default_print_error_function (file) |
4291d9c8 RS |
1215 | char *file; |
1216 | { | |
4291d9c8 RS |
1217 | if (last_error_function != current_function_decl) |
1218 | { | |
1219 | char *kind = "function"; | |
1220 | if (current_function_decl != 0 | |
1221 | && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) | |
1222 | kind = "method"; | |
1223 | ||
1224 | if (file) | |
1225 | fprintf (stderr, "%s: ", file); | |
1226 | ||
1227 | if (current_function_decl == NULL) | |
1228 | fprintf (stderr, "At top level:\n"); | |
1229 | else | |
1230 | { | |
a1d7ffe3 | 1231 | char *name = (*decl_printable_name) (current_function_decl, 2); |
4291d9c8 RS |
1232 | fprintf (stderr, "In %s `%s':\n", kind, name); |
1233 | } | |
1234 | ||
1235 | last_error_function = current_function_decl; | |
1236 | } | |
b64e9948 PB |
1237 | } |
1238 | ||
1239 | /* Called by report_error_function to print out function name. | |
0f41302f | 1240 | * Default may be overridden by language front-ends. */ |
b64e9948 | 1241 | |
0f41302f | 1242 | void (*print_error_function) PROTO((char *)) = default_print_error_function; |
b64e9948 PB |
1243 | |
1244 | /* Prints out, if necessary, the name of the current function | |
1245 | that caused an error. Called from all error and warning functions. */ | |
1246 | ||
1247 | void | |
1248 | report_error_function (file) | |
1249 | char *file; | |
1250 | { | |
1251 | struct file_stack *p; | |
1252 | ||
1253 | if (need_error_newline) | |
1254 | { | |
1255 | fprintf (stderr, "\n"); | |
1256 | need_error_newline = 0; | |
1257 | } | |
1258 | ||
1259 | (*print_error_function) (file); | |
1260 | ||
4291d9c8 | 1261 | if (input_file_stack && input_file_stack->next != 0 |
2efc92ed RK |
1262 | && input_file_stack_tick != last_error_tick |
1263 | && file == input_filename) | |
4291d9c8 RS |
1264 | { |
1265 | fprintf (stderr, "In file included"); | |
1266 | for (p = input_file_stack->next; p; p = p->next) | |
1267 | { | |
1268 | fprintf (stderr, " from %s:%d", p->name, p->line); | |
1269 | if (p->next) | |
e5301904 | 1270 | fprintf (stderr, ",\n "); |
4291d9c8 RS |
1271 | } |
1272 | fprintf (stderr, ":\n"); | |
1273 | last_error_tick = input_file_stack_tick; | |
1274 | } | |
1275 | } | |
eb711c86 RK |
1276 | \f |
1277 | /* Print a message. */ | |
4291d9c8 | 1278 | |
eb711c86 RK |
1279 | static void |
1280 | vmessage (prefix, s, ap) | |
1281 | char *prefix; | |
4291d9c8 | 1282 | char *s; |
eb711c86 | 1283 | va_list ap; |
4291d9c8 | 1284 | { |
eb711c86 RK |
1285 | if (prefix) |
1286 | fprintf (stderr, "%s: ", prefix); | |
1287 | ||
1288 | #ifdef HAVE_VPRINTF | |
1289 | vfprintf (stderr, s, ap); | |
1290 | #else | |
1291 | { | |
1292 | HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT); | |
1293 | HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT); | |
1294 | HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT); | |
a4326b4d RK |
1295 | HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT); |
1296 | fprintf (stderr, s, v1, v2, v3, v4); | |
eb711c86 RK |
1297 | } |
1298 | #endif | |
4291d9c8 RS |
1299 | } |
1300 | ||
eb711c86 | 1301 | /* Print a message relevant to line LINE of file FILE. */ |
4291d9c8 | 1302 | |
eb711c86 RK |
1303 | static void |
1304 | v_message_with_file_and_line (file, line, prefix, s, ap) | |
4291d9c8 RS |
1305 | char *file; |
1306 | int line; | |
eb711c86 | 1307 | char *prefix; |
4291d9c8 | 1308 | char *s; |
eb711c86 | 1309 | va_list ap; |
4291d9c8 | 1310 | { |
4291d9c8 RS |
1311 | if (file) |
1312 | fprintf (stderr, "%s:%d: ", file, line); | |
1313 | else | |
1314 | fprintf (stderr, "%s: ", progname); | |
d78c6ad5 | 1315 | |
eb711c86 RK |
1316 | vmessage (prefix, s, ap); |
1317 | fputc ('\n', stderr); | |
4291d9c8 RS |
1318 | } |
1319 | ||
eb711c86 | 1320 | /* Print a message relevant to the given DECL. */ |
4291d9c8 | 1321 | |
eb711c86 RK |
1322 | static void |
1323 | v_message_with_decl (decl, prefix, s, ap) | |
4291d9c8 | 1324 | tree decl; |
eb711c86 | 1325 | char *prefix; |
4291d9c8 | 1326 | char *s; |
eb711c86 | 1327 | va_list ap; |
4291d9c8 | 1328 | { |
a1d7ffe3 | 1329 | char *n, *p; |
4291d9c8 RS |
1330 | |
1331 | fprintf (stderr, "%s:%d: ", | |
1332 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
1333 | ||
eb711c86 RK |
1334 | if (prefix) |
1335 | fprintf (stderr, "%s: ", prefix); | |
1336 | ||
1337 | /* Do magic to get around lack of varargs support for insertion | |
1338 | of arguments into existing list. We know that the decl is first; | |
1339 | we ass_u_me that it will be printed with "%s". */ | |
1340 | ||
1341 | for (p = s; *p; ++p) | |
1342 | { | |
1343 | if (*p == '%') | |
1344 | { | |
1345 | if (*(p + 1) == '%') | |
1346 | ++p; | |
1347 | else | |
1348 | break; | |
1349 | } | |
1350 | } | |
1351 | ||
cb039f8a RK |
1352 | if (p > s) /* Print the left-hand substring. */ |
1353 | { | |
1354 | char fmt[sizeof "%.255s"]; | |
1355 | long width = p - s; | |
1356 | ||
1357 | if (width > 255L) width = 255L; /* arbitrary */ | |
1358 | sprintf (fmt, "%%.%lds", width); | |
1359 | fprintf (stderr, fmt, s); | |
1360 | } | |
eb711c86 | 1361 | |
cb039f8a | 1362 | if (*p == '%') /* Print the name. */ |
eb711c86 RK |
1363 | { |
1364 | char *n = (DECL_NAME (decl) | |
a1d7ffe3 | 1365 | ? (*decl_printable_name) (decl, 2) |
eb711c86 RK |
1366 | : "((anonymous))"); |
1367 | fputs (n, stderr); | |
1368 | while (*p) | |
1369 | { | |
1370 | ++p; | |
1371 | if (isalpha (*(p - 1) & 0xFF)) | |
1372 | break; | |
1373 | } | |
1374 | } | |
1375 | ||
cb039f8a | 1376 | if (*p) /* Print the rest of the message. */ |
eb711c86 RK |
1377 | vmessage ((char *)NULL, p, ap); |
1378 | ||
1379 | fputc ('\n', stderr); | |
4291d9c8 RS |
1380 | } |
1381 | ||
eb711c86 | 1382 | /* Figure file and line of the given INSN. */ |
4291d9c8 | 1383 | |
eb711c86 RK |
1384 | static void |
1385 | file_and_line_for_asm (insn, pfile, pline) | |
4291d9c8 | 1386 | rtx insn; |
eb711c86 RK |
1387 | char **pfile; |
1388 | int *pline; | |
4291d9c8 | 1389 | { |
4291d9c8 RS |
1390 | rtx body = PATTERN (insn); |
1391 | rtx asmop; | |
1392 | ||
1393 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ | |
1394 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
1395 | asmop = SET_SRC (body); | |
1396 | else if (GET_CODE (body) == ASM_OPERANDS) | |
1397 | asmop = body; | |
1398 | else if (GET_CODE (body) == PARALLEL | |
1399 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
1400 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
1401 | else if (GET_CODE (body) == PARALLEL | |
1402 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
1403 | asmop = XVECEXP (body, 0, 0); | |
eb711c86 RK |
1404 | else |
1405 | asmop = NULL; | |
1406 | ||
1407 | if (asmop) | |
1408 | { | |
1409 | *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); | |
1410 | *pline = ASM_OPERANDS_SOURCE_LINE (asmop); | |
1411 | } | |
1412 | else | |
1413 | { | |
1414 | *pfile = input_filename; | |
1415 | *pline = lineno; | |
1416 | } | |
1417 | } | |
4291d9c8 | 1418 | |
eb711c86 | 1419 | /* Report an error at line LINE of file FILE. */ |
4291d9c8 | 1420 | |
eb711c86 RK |
1421 | static void |
1422 | v_error_with_file_and_line (file, line, s, ap) | |
1423 | char *file; | |
1424 | int line; | |
1425 | char *s; | |
1426 | va_list ap; | |
1427 | { | |
1428 | count_error (0); | |
1429 | report_error_function (file); | |
1430 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); | |
d78c6ad5 RK |
1431 | } |
1432 | ||
1433 | void | |
e0e2a8da | 1434 | error_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
d78c6ad5 | 1435 | { |
e0e2a8da | 1436 | #ifndef __STDC__ |
eb711c86 RK |
1437 | char *file; |
1438 | int line; | |
1439 | char *s; | |
e0e2a8da RK |
1440 | #endif |
1441 | va_list ap; | |
1442 | ||
1443 | VA_START (ap, s); | |
eb711c86 | 1444 | |
e0e2a8da | 1445 | #ifndef __STDC__ |
eb711c86 RK |
1446 | file = va_arg (ap, char *); |
1447 | line = va_arg (ap, int); | |
1448 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1449 | #endif |
1450 | ||
eb711c86 RK |
1451 | v_error_with_file_and_line (file, line, s, ap); |
1452 | va_end (ap); | |
4291d9c8 RS |
1453 | } |
1454 | ||
eb711c86 RK |
1455 | /* Report an error at the declaration DECL. |
1456 | S is a format string which uses %s to substitute the declaration | |
1457 | name; subsequent substitutions are a la printf. */ | |
1458 | ||
1459 | static void | |
1460 | v_error_with_decl (decl, s, ap) | |
1461 | tree decl; | |
1462 | char *s; | |
1463 | va_list ap; | |
1464 | { | |
1465 | count_error (0); | |
1466 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1467 | v_message_with_decl (decl, (char *)NULL, s, ap); | |
1468 | } | |
4291d9c8 RS |
1469 | |
1470 | void | |
e0e2a8da | 1471 | error_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1472 | { |
e0e2a8da | 1473 | #ifndef __STDC__ |
eb711c86 RK |
1474 | tree decl; |
1475 | char *s; | |
e0e2a8da RK |
1476 | #endif |
1477 | va_list ap; | |
eb711c86 | 1478 | |
e0e2a8da RK |
1479 | VA_START (ap, s); |
1480 | ||
1481 | #ifndef __STDC__ | |
eb711c86 RK |
1482 | decl = va_arg (ap, tree); |
1483 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1484 | #endif |
1485 | ||
eb711c86 RK |
1486 | v_error_with_decl (decl, s, ap); |
1487 | va_end (ap); | |
1488 | } | |
1489 | ||
1490 | /* Report an error at the line number of the insn INSN. | |
1491 | This is used only when INSN is an `asm' with operands, | |
1492 | and each ASM_OPERANDS records its own source file and line. */ | |
1493 | ||
1494 | static void | |
1495 | v_error_for_asm (insn, s, ap) | |
1496 | rtx insn; | |
4291d9c8 | 1497 | char *s; |
eb711c86 | 1498 | va_list ap; |
4291d9c8 | 1499 | { |
eb711c86 RK |
1500 | char *file; |
1501 | int line; | |
4291d9c8 | 1502 | |
eb711c86 RK |
1503 | count_error (0); |
1504 | file_and_line_for_asm (insn, &file, &line); | |
4291d9c8 | 1505 | report_error_function (file); |
eb711c86 RK |
1506 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); |
1507 | } | |
4291d9c8 | 1508 | |
eb711c86 | 1509 | void |
e0e2a8da | 1510 | error_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1511 | { |
e0e2a8da | 1512 | #ifndef __STDC__ |
eb711c86 RK |
1513 | rtx insn; |
1514 | char *s; | |
e0e2a8da RK |
1515 | #endif |
1516 | va_list ap; | |
eb711c86 | 1517 | |
e0e2a8da RK |
1518 | VA_START (ap, s); |
1519 | ||
1520 | #ifndef __STDC__ | |
eb711c86 RK |
1521 | insn = va_arg (ap, rtx); |
1522 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1523 | #endif |
1524 | ||
eb711c86 RK |
1525 | v_error_for_asm (insn, s, ap); |
1526 | va_end (ap); | |
4291d9c8 RS |
1527 | } |
1528 | ||
eb711c86 | 1529 | /* Report an error at the current line number. */ |
4291d9c8 | 1530 | |
eb711c86 RK |
1531 | static void |
1532 | verror (s, ap) | |
4291d9c8 | 1533 | char *s; |
eb711c86 | 1534 | va_list ap; |
4291d9c8 | 1535 | { |
eb711c86 | 1536 | v_error_with_file_and_line (input_filename, lineno, s, ap); |
4291d9c8 RS |
1537 | } |
1538 | ||
eb711c86 | 1539 | void |
e0e2a8da | 1540 | error VPROTO((char *s, ...)) |
eb711c86 | 1541 | { |
e0e2a8da | 1542 | #ifndef __STDC__ |
eb711c86 | 1543 | char *s; |
e0e2a8da RK |
1544 | #endif |
1545 | va_list ap; | |
1546 | ||
1547 | VA_START (ap, s); | |
eb711c86 | 1548 | |
e0e2a8da | 1549 | #ifndef __STDC__ |
eb711c86 | 1550 | s = va_arg (ap, char *); |
e0e2a8da RK |
1551 | #endif |
1552 | ||
eb711c86 RK |
1553 | verror (s, ap); |
1554 | va_end (ap); | |
1555 | } | |
1556 | ||
1557 | /* Report a fatal error at the current line number. */ | |
1558 | ||
1559 | static void | |
1560 | vfatal (s, ap) | |
1561 | char *s; | |
1562 | va_list ap; | |
1563 | { | |
1564 | verror (s, ap); | |
299846f2 | 1565 | exit (FATAL_EXIT_CODE); |
eb711c86 | 1566 | } |
4291d9c8 RS |
1567 | |
1568 | void | |
e0e2a8da | 1569 | fatal VPROTO((char *s, ...)) |
eb711c86 | 1570 | { |
e0e2a8da | 1571 | #ifndef __STDC__ |
eb711c86 | 1572 | char *s; |
e0e2a8da RK |
1573 | #endif |
1574 | va_list ap; | |
1575 | ||
1576 | VA_START (ap, s); | |
eb711c86 | 1577 | |
e0e2a8da | 1578 | #ifndef __STDC__ |
eb711c86 | 1579 | s = va_arg (ap, char *); |
e0e2a8da RK |
1580 | #endif |
1581 | ||
eb711c86 RK |
1582 | vfatal (s, ap); |
1583 | va_end (ap); | |
1584 | } | |
1585 | ||
1586 | /* Report a warning at line LINE of file FILE. */ | |
1587 | ||
1588 | static void | |
1589 | v_warning_with_file_and_line (file, line, s, ap) | |
1590 | char *file; | |
1591 | int line; | |
4291d9c8 | 1592 | char *s; |
eb711c86 | 1593 | va_list ap; |
4291d9c8 | 1594 | { |
eb711c86 RK |
1595 | if (count_error (1)) |
1596 | { | |
1597 | report_error_function (file); | |
1598 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1599 | } | |
1600 | } | |
4291d9c8 | 1601 | |
eb711c86 | 1602 | void |
e0e2a8da | 1603 | warning_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1604 | { |
e0e2a8da | 1605 | #ifndef __STDC__ |
eb711c86 RK |
1606 | char *file; |
1607 | int line; | |
1608 | char *s; | |
e0e2a8da RK |
1609 | #endif |
1610 | va_list ap; | |
1611 | ||
1612 | VA_START (ap, s); | |
eb711c86 | 1613 | |
e0e2a8da | 1614 | #ifndef __STDC__ |
eb711c86 RK |
1615 | file = va_arg (ap, char *); |
1616 | line = va_arg (ap, int); | |
1617 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1618 | #endif |
1619 | ||
eb711c86 RK |
1620 | v_warning_with_file_and_line (file, line, s, ap); |
1621 | va_end (ap); | |
1622 | } | |
4291d9c8 | 1623 | |
eb711c86 RK |
1624 | /* Report a warning at the declaration DECL. |
1625 | S is a format string which uses %s to substitute the declaration | |
1626 | name; subsequent substitutions are a la printf. */ | |
4291d9c8 | 1627 | |
eb711c86 RK |
1628 | static void |
1629 | v_warning_with_decl (decl, s, ap) | |
1630 | tree decl; | |
1631 | char *s; | |
1632 | va_list ap; | |
1633 | { | |
1634 | if (count_error (1)) | |
1635 | { | |
1636 | report_error_function (DECL_SOURCE_FILE (decl)); | |
1637 | v_message_with_decl (decl, "warning", s, ap); | |
1638 | } | |
1639 | } | |
4291d9c8 | 1640 | |
eb711c86 | 1641 | void |
e0e2a8da | 1642 | warning_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1643 | { |
e0e2a8da | 1644 | #ifndef __STDC__ |
eb711c86 RK |
1645 | tree decl; |
1646 | char *s; | |
e0e2a8da RK |
1647 | #endif |
1648 | va_list ap; | |
eb711c86 | 1649 | |
e0e2a8da RK |
1650 | VA_START (ap, s); |
1651 | ||
1652 | #ifndef __STDC__ | |
eb711c86 RK |
1653 | decl = va_arg (ap, tree); |
1654 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1655 | #endif |
1656 | ||
eb711c86 RK |
1657 | v_warning_with_decl (decl, s, ap); |
1658 | va_end (ap); | |
4291d9c8 RS |
1659 | } |
1660 | ||
1661 | /* Report a warning at the line number of the insn INSN. | |
4291d9c8 RS |
1662 | This is used only when INSN is an `asm' with operands, |
1663 | and each ASM_OPERANDS records its own source file and line. */ | |
1664 | ||
eb711c86 RK |
1665 | static void |
1666 | v_warning_for_asm (insn, s, ap) | |
4291d9c8 RS |
1667 | rtx insn; |
1668 | char *s; | |
eb711c86 | 1669 | va_list ap; |
4291d9c8 | 1670 | { |
eb711c86 RK |
1671 | if (count_error (1)) |
1672 | { | |
1673 | char *file; | |
1674 | int line; | |
4291d9c8 | 1675 | |
eb711c86 RK |
1676 | file_and_line_for_asm (insn, &file, &line); |
1677 | report_error_function (file); | |
1678 | v_message_with_file_and_line (file, line, "warning", s, ap); | |
1679 | } | |
1680 | } | |
4291d9c8 | 1681 | |
eb711c86 | 1682 | void |
e0e2a8da | 1683 | warning_for_asm VPROTO((rtx insn, char *s, ...)) |
eb711c86 | 1684 | { |
e0e2a8da | 1685 | #ifndef __STDC__ |
eb711c86 RK |
1686 | rtx insn; |
1687 | char *s; | |
e0e2a8da RK |
1688 | #endif |
1689 | va_list ap; | |
1690 | ||
1691 | VA_START (ap, s); | |
eb711c86 | 1692 | |
e0e2a8da | 1693 | #ifndef __STDC__ |
eb711c86 RK |
1694 | insn = va_arg (ap, rtx); |
1695 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1696 | #endif |
1697 | ||
eb711c86 RK |
1698 | v_warning_for_asm (insn, s, ap); |
1699 | va_end (ap); | |
1700 | } | |
4291d9c8 | 1701 | |
eb711c86 RK |
1702 | /* Report a warning at the current line number. */ |
1703 | ||
1704 | static void | |
1705 | vwarning (s, ap) | |
1706 | char *s; | |
1707 | va_list ap; | |
1708 | { | |
1709 | v_warning_with_file_and_line (input_filename, lineno, s, ap); | |
4291d9c8 | 1710 | } |
eb711c86 RK |
1711 | |
1712 | void | |
e0e2a8da | 1713 | warning VPROTO((char *s, ...)) |
eb711c86 | 1714 | { |
e0e2a8da | 1715 | #ifndef __STDC__ |
eb711c86 | 1716 | char *s; |
e0e2a8da RK |
1717 | #endif |
1718 | va_list ap; | |
1719 | ||
1720 | VA_START (ap, s); | |
eb711c86 | 1721 | |
e0e2a8da | 1722 | #ifndef __STDC__ |
eb711c86 | 1723 | s = va_arg (ap, char *); |
e0e2a8da RK |
1724 | #endif |
1725 | ||
eb711c86 RK |
1726 | vwarning (s, ap); |
1727 | va_end (ap); | |
1728 | } | |
1729 | ||
4291d9c8 RS |
1730 | /* These functions issue either warnings or errors depending on |
1731 | -pedantic-errors. */ | |
1732 | ||
eb711c86 RK |
1733 | static void |
1734 | vpedwarn (s, ap) | |
4291d9c8 | 1735 | char *s; |
eb711c86 | 1736 | va_list ap; |
4291d9c8 RS |
1737 | { |
1738 | if (flag_pedantic_errors) | |
eb711c86 | 1739 | verror (s, ap); |
4291d9c8 | 1740 | else |
eb711c86 | 1741 | vwarning (s, ap); |
4291d9c8 RS |
1742 | } |
1743 | ||
1744 | void | |
e0e2a8da | 1745 | pedwarn VPROTO((char *s, ...)) |
eb711c86 | 1746 | { |
e0e2a8da | 1747 | #ifndef __STDC__ |
eb711c86 | 1748 | char *s; |
e0e2a8da RK |
1749 | #endif |
1750 | va_list ap; | |
1751 | ||
1752 | VA_START (ap, s); | |
eb711c86 | 1753 | |
e0e2a8da | 1754 | #ifndef __STDC__ |
eb711c86 | 1755 | s = va_arg (ap, char *); |
e0e2a8da RK |
1756 | #endif |
1757 | ||
eb711c86 RK |
1758 | vpedwarn (s, ap); |
1759 | va_end (ap); | |
1760 | } | |
1761 | ||
1762 | static void | |
1763 | v_pedwarn_with_decl (decl, s, ap) | |
4291d9c8 RS |
1764 | tree decl; |
1765 | char *s; | |
eb711c86 | 1766 | va_list ap; |
4291d9c8 | 1767 | { |
1554cdf5 DE |
1768 | /* We don't want -pedantic-errors to cause the compilation to fail from |
1769 | "errors" in system header files. Sometimes fixincludes can't fix what's | |
1770 | broken (eg: unsigned char bitfields - fixing it may change the alignment | |
1771 | which will cause programs to mysteriously fail because the C library | |
22d74562 DE |
1772 | or kernel uses the original layout). There's no point in issuing a |
1773 | warning either, it's just unnecessary noise. */ | |
1554cdf5 | 1774 | |
22d74562 DE |
1775 | if (! DECL_IN_SYSTEM_HEADER (decl)) |
1776 | { | |
1777 | if (flag_pedantic_errors) | |
1778 | v_error_with_decl (decl, s, ap); | |
1779 | else | |
1780 | v_warning_with_decl (decl, s, ap); | |
1781 | } | |
4291d9c8 RS |
1782 | } |
1783 | ||
1784 | void | |
e0e2a8da | 1785 | pedwarn_with_decl VPROTO((tree decl, char *s, ...)) |
eb711c86 | 1786 | { |
e0e2a8da | 1787 | #ifndef __STDC__ |
eb711c86 RK |
1788 | tree decl; |
1789 | char *s; | |
e0e2a8da RK |
1790 | #endif |
1791 | va_list ap; | |
eb711c86 | 1792 | |
e0e2a8da RK |
1793 | VA_START (ap, s); |
1794 | ||
1795 | #ifndef __STDC__ | |
eb711c86 RK |
1796 | decl = va_arg (ap, tree); |
1797 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1798 | #endif |
1799 | ||
eb711c86 RK |
1800 | v_pedwarn_with_decl (decl, s, ap); |
1801 | va_end (ap); | |
1802 | } | |
1803 | ||
1804 | static void | |
1805 | v_pedwarn_with_file_and_line (file, line, s, ap) | |
4291d9c8 RS |
1806 | char *file; |
1807 | int line; | |
1808 | char *s; | |
eb711c86 | 1809 | va_list ap; |
4291d9c8 RS |
1810 | { |
1811 | if (flag_pedantic_errors) | |
eb711c86 | 1812 | v_error_with_file_and_line (file, line, s, ap); |
4291d9c8 | 1813 | else |
eb711c86 | 1814 | v_warning_with_file_and_line (file, line, s, ap); |
4291d9c8 RS |
1815 | } |
1816 | ||
4291d9c8 | 1817 | void |
e0e2a8da | 1818 | pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...)) |
eb711c86 | 1819 | { |
e0e2a8da | 1820 | #ifndef __STDC__ |
eb711c86 RK |
1821 | char *file; |
1822 | int line; | |
1823 | char *s; | |
e0e2a8da RK |
1824 | #endif |
1825 | va_list ap; | |
eb711c86 | 1826 | |
e0e2a8da RK |
1827 | VA_START (ap, s); |
1828 | ||
1829 | #ifndef __STDC__ | |
eb711c86 RK |
1830 | file = va_arg (ap, char *); |
1831 | line = va_arg (ap, int); | |
1832 | s = va_arg (ap, char *); | |
e0e2a8da RK |
1833 | #endif |
1834 | ||
eb711c86 RK |
1835 | v_pedwarn_with_file_and_line (file, line, s, ap); |
1836 | va_end (ap); | |
1837 | } | |
1838 | ||
1839 | /* Apologize for not implementing some feature. */ | |
1840 | ||
1841 | static void | |
1842 | vsorry (s, ap) | |
4291d9c8 | 1843 | char *s; |
eb711c86 | 1844 | va_list ap; |
4291d9c8 RS |
1845 | { |
1846 | sorrycount++; | |
1847 | if (input_filename) | |
1848 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1849 | else | |
1850 | fprintf (stderr, "%s: ", progname); | |
eb711c86 RK |
1851 | vmessage ("sorry, not implemented", s, ap); |
1852 | fputc ('\n', stderr); | |
1853 | } | |
4291d9c8 | 1854 | |
eb711c86 | 1855 | void |
e0e2a8da | 1856 | sorry VPROTO((char *s, ...)) |
eb711c86 | 1857 | { |
e0e2a8da | 1858 | #ifndef __STDC__ |
eb711c86 | 1859 | char *s; |
e0e2a8da RK |
1860 | #endif |
1861 | va_list ap; | |
1862 | ||
1863 | VA_START (ap, s); | |
eb711c86 | 1864 | |
e0e2a8da | 1865 | #ifndef __STDC__ |
eb711c86 | 1866 | s = va_arg (ap, char *); |
e0e2a8da RK |
1867 | #endif |
1868 | ||
eb711c86 RK |
1869 | vsorry (s, ap); |
1870 | va_end (ap); | |
4291d9c8 RS |
1871 | } |
1872 | ||
eb711c86 | 1873 | /* Apologize for not implementing some feature, then quit. */ |
4291d9c8 | 1874 | |
eb711c86 RK |
1875 | static void |
1876 | v_really_sorry (s, ap) | |
4291d9c8 | 1877 | char *s; |
eb711c86 | 1878 | va_list ap; |
4291d9c8 | 1879 | { |
eb711c86 | 1880 | sorrycount++; |
4291d9c8 RS |
1881 | if (input_filename) |
1882 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1883 | else | |
c10afc44 | 1884 | fprintf (stderr, "%s: ", progname); |
eb711c86 | 1885 | vmessage ("sorry, not implemented", s, ap); |
4291d9c8 RS |
1886 | fatal (" (fatal)\n"); |
1887 | } | |
eb711c86 RK |
1888 | |
1889 | void | |
e0e2a8da | 1890 | really_sorry VPROTO((char *s, ...)) |
eb711c86 | 1891 | { |
e0e2a8da | 1892 | #ifndef __STDC__ |
eb711c86 | 1893 | char *s; |
e0e2a8da RK |
1894 | #endif |
1895 | va_list ap; | |
1896 | ||
1897 | VA_START (ap, s); | |
eb711c86 | 1898 | |
e0e2a8da | 1899 | #ifndef __STDC__ |
eb711c86 | 1900 | s = va_arg (ap, char *); |
e0e2a8da RK |
1901 | #endif |
1902 | ||
eb711c86 RK |
1903 | v_really_sorry (s, ap); |
1904 | va_end (ap); | |
1905 | } | |
4291d9c8 RS |
1906 | \f |
1907 | /* More 'friendly' abort that prints the line and file. | |
1908 | config.h can #define abort fancy_abort if you like that sort of thing. | |
1909 | ||
1910 | I don't think this is actually a good idea. | |
1911 | Other sorts of crashes will look a certain way. | |
1912 | It is a good thing if crashes from calling abort look the same way. | |
1913 | -- RMS */ | |
1914 | ||
1915 | void | |
1916 | fancy_abort () | |
1917 | { | |
1918 | fatal ("internal gcc abort"); | |
1919 | } | |
1920 | ||
1921 | /* This calls abort and is used to avoid problems when abort if a macro. | |
1922 | It is used when we need to pass the address of abort. */ | |
1923 | ||
1924 | void | |
1925 | do_abort () | |
1926 | { | |
1927 | abort (); | |
1928 | } | |
1929 | ||
1930 | /* When `malloc.c' is compiled with `rcheck' defined, | |
1931 | it calls this function to report clobberage. */ | |
1932 | ||
1933 | void | |
1934 | botch (s) | |
1935 | { | |
1936 | abort (); | |
1937 | } | |
1938 | ||
1939 | /* Same as `malloc' but report error if no memory available. */ | |
1940 | ||
4b980e20 | 1941 | char * |
4291d9c8 RS |
1942 | xmalloc (size) |
1943 | unsigned size; | |
1944 | { | |
4b980e20 | 1945 | register char *value = (char *) malloc (size); |
809d135d | 1946 | if (value == 0 && size != 0) |
4291d9c8 RS |
1947 | fatal ("virtual memory exhausted"); |
1948 | return value; | |
1949 | } | |
1950 | ||
e9a25f70 JL |
1951 | /* Same as `realloc' but report error if no memory available. |
1952 | Also handle null PTR even if the vendor realloc gets it wrong. */ | |
4291d9c8 | 1953 | |
4b980e20 | 1954 | char * |
4291d9c8 RS |
1955 | xrealloc (ptr, size) |
1956 | char *ptr; | |
1957 | int size; | |
1958 | { | |
e9a25f70 JL |
1959 | char *result = (ptr |
1960 | ? (char *) realloc (ptr, size) | |
1961 | : (char *) malloc (size)); | |
4291d9c8 RS |
1962 | if (!result) |
1963 | fatal ("virtual memory exhausted"); | |
1964 | return result; | |
1965 | } | |
3e386b9e RK |
1966 | |
1967 | /* Same as `strdup' but report error if no memory available. */ | |
1968 | ||
1969 | char * | |
1970 | xstrdup (s) | |
1971 | register char *s; | |
1972 | { | |
1973 | register char *result = (char *) malloc (strlen (s) + 1); | |
1974 | ||
1975 | if (! result) | |
1976 | fatal ("virtual memory exhausted"); | |
1977 | strcpy (result, s); | |
1978 | return result; | |
1979 | } | |
4291d9c8 RS |
1980 | \f |
1981 | /* Return the logarithm of X, base 2, considering X unsigned, | |
37366632 RK |
1982 | if X is a power of 2. Otherwise, returns -1. |
1983 | ||
1984 | This should be used via the `exact_log2' macro. */ | |
4291d9c8 RS |
1985 | |
1986 | int | |
37366632 RK |
1987 | exact_log2_wide (x) |
1988 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
1989 | { |
1990 | register int log = 0; | |
1991 | /* Test for 0 or a power of 2. */ | |
1992 | if (x == 0 || x != (x & -x)) | |
1993 | return -1; | |
1994 | while ((x >>= 1) != 0) | |
1995 | log++; | |
1996 | return log; | |
1997 | } | |
1998 | ||
1999 | /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. | |
37366632 RK |
2000 | If X is 0, return -1. |
2001 | ||
2002 | This should be used via the floor_log2 macro. */ | |
4291d9c8 RS |
2003 | |
2004 | int | |
37366632 RK |
2005 | floor_log2_wide (x) |
2006 | register unsigned HOST_WIDE_INT x; | |
4291d9c8 RS |
2007 | { |
2008 | register int log = -1; | |
2009 | while (x != 0) | |
2010 | log++, | |
2011 | x >>= 1; | |
2012 | return log; | |
2013 | } | |
2014 | ||
3bbfa296 | 2015 | static int float_handler_set; |
4291d9c8 RS |
2016 | int float_handled; |
2017 | jmp_buf float_handler; | |
2018 | ||
3bbfa296 RK |
2019 | /* Signals actually come here. */ |
2020 | ||
2021 | static void | |
2022 | float_signal (signo) | |
2023 | /* If this is missing, some compilers complain. */ | |
2024 | int signo; | |
2025 | { | |
2026 | if (float_handled == 0) | |
2027 | abort (); | |
2028 | #if defined (USG) || defined (hpux) | |
2029 | signal (SIGFPE, float_signal); /* re-enable the signal catcher */ | |
2030 | #endif | |
2031 | float_handled = 0; | |
2032 | signal (SIGFPE, float_signal); | |
2033 | longjmp (float_handler, 1); | |
2034 | } | |
2035 | ||
4291d9c8 RS |
2036 | /* Specify where to longjmp to when a floating arithmetic error happens. |
2037 | If HANDLER is 0, it means don't handle the errors any more. */ | |
2038 | ||
2039 | void | |
2040 | set_float_handler (handler) | |
2041 | jmp_buf handler; | |
2042 | { | |
2043 | float_handled = (handler != 0); | |
2044 | if (handler) | |
4c9a05bc | 2045 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
3bbfa296 RK |
2046 | |
2047 | if (float_handled && ! float_handler_set) | |
2048 | { | |
2049 | signal (SIGFPE, float_signal); | |
2050 | float_handler_set = 1; | |
2051 | } | |
4291d9c8 RS |
2052 | } |
2053 | ||
bff4b641 RS |
2054 | /* Specify, in HANDLER, where to longjmp to when a floating arithmetic |
2055 | error happens, pushing the previous specification into OLD_HANDLER. | |
2056 | Return an indication of whether there was a previous handler in effect. */ | |
2057 | ||
2058 | int | |
2059 | push_float_handler (handler, old_handler) | |
dc2b15dc | 2060 | jmp_buf handler, old_handler; |
bff4b641 RS |
2061 | { |
2062 | int was_handled = float_handled; | |
2063 | ||
2064 | float_handled = 1; | |
2065 | if (was_handled) | |
4c9a05bc RK |
2066 | bcopy ((char *) float_handler, (char *) old_handler, |
2067 | sizeof (float_handler)); | |
2068 | ||
2069 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
bff4b641 RS |
2070 | return was_handled; |
2071 | } | |
2072 | ||
2073 | /* Restore the previous specification of whether and where to longjmp to | |
2074 | when a floating arithmetic error happens. */ | |
2075 | ||
2076 | void | |
2077 | pop_float_handler (handled, handler) | |
2078 | int handled; | |
2079 | jmp_buf handler; | |
2080 | { | |
2081 | float_handled = handled; | |
2082 | if (handled) | |
4c9a05bc | 2083 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); |
bff4b641 RS |
2084 | } |
2085 | ||
4291d9c8 RS |
2086 | /* Handler for SIGPIPE. */ |
2087 | ||
2088 | static void | |
2089 | pipe_closed (signo) | |
2090 | /* If this is missing, some compilers complain. */ | |
2091 | int signo; | |
2092 | { | |
2093 | fatal ("output pipe has been closed"); | |
2094 | } | |
2095 | ||
2096 | /* Strip off a legitimate source ending from the input string NAME of | |
c62bdc79 RK |
2097 | length LEN. Rather than having to know the names used by all of |
2098 | our front ends, we strip off an ending of a period followed by one, | |
2099 | two, or three characters. */ | |
4291d9c8 RS |
2100 | |
2101 | void | |
2102 | strip_off_ending (name, len) | |
2103 | char *name; | |
2104 | int len; | |
2105 | { | |
c62bdc79 RK |
2106 | if (len > 2 && name[len - 2] == '.') |
2107 | name[len - 2] = '\0'; | |
2108 | else if (len > 3 && name[len - 3] == '.') | |
2109 | name[len - 3] = '\0'; | |
2110 | else if (len > 4 && name[len - 4] == '.') | |
2111 | name[len - 4] = '\0'; | |
4291d9c8 RS |
2112 | } |
2113 | ||
7dce5088 | 2114 | /* Output a quoted string. */ |
0f41302f | 2115 | |
7dce5088 PE |
2116 | void |
2117 | output_quoted_string (asm_file, string) | |
2118 | FILE *asm_file; | |
2119 | char *string; | |
2120 | { | |
e9a25f70 JL |
2121 | #ifdef OUTPUT_QUOTED_STRING |
2122 | OUTPUT_QUOTED_STRING (asm_file, string); | |
2123 | #else | |
7dce5088 PE |
2124 | char c; |
2125 | ||
2126 | putc ('\"', asm_file); | |
2127 | while ((c = *string++) != 0) | |
2128 | { | |
2129 | if (c == '\"' || c == '\\') | |
2130 | putc ('\\', asm_file); | |
2131 | putc (c, asm_file); | |
2132 | } | |
2133 | putc ('\"', asm_file); | |
e9a25f70 | 2134 | #endif |
7dce5088 PE |
2135 | } |
2136 | ||
4291d9c8 RS |
2137 | /* Output a file name in the form wanted by System V. */ |
2138 | ||
2139 | void | |
2140 | output_file_directive (asm_file, input_name) | |
2141 | FILE *asm_file; | |
2142 | char *input_name; | |
2143 | { | |
2144 | int len = strlen (input_name); | |
2145 | char *na = input_name + len; | |
2146 | ||
2147 | /* NA gets INPUT_NAME sans directory names. */ | |
2148 | while (na > input_name) | |
2149 | { | |
2150 | if (na[-1] == '/') | |
2151 | break; | |
2152 | na--; | |
2153 | } | |
2154 | ||
2155 | #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME | |
2156 | ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); | |
2157 | #else | |
2158 | #ifdef ASM_OUTPUT_SOURCE_FILENAME | |
2159 | ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); | |
2160 | #else | |
7dce5088 PE |
2161 | fprintf (asm_file, "\t.file\t"); |
2162 | output_quoted_string (asm_file, na); | |
2163 | fputc ('\n', asm_file); | |
4291d9c8 RS |
2164 | #endif |
2165 | #endif | |
2166 | } | |
2167 | \f | |
0f41302f MS |
2168 | /* Routine to build language identifier for object file. */ |
2169 | ||
d0d4af87 MS |
2170 | static void |
2171 | output_lang_identify (asm_out_file) | |
2172 | FILE *asm_out_file; | |
2173 | { | |
2174 | int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; | |
2175 | char *s = (char *) alloca (len); | |
2176 | sprintf (s, "__gnu_compiled_%s", lang_identify ()); | |
2177 | ASM_OUTPUT_LABEL (asm_out_file, s); | |
2178 | } | |
2179 | ||
dfe1a916 | 2180 | /* Routine to open a dump file. */ |
0f41302f | 2181 | |
dfe1a916 DE |
2182 | static FILE * |
2183 | open_dump_file (base_name, suffix) | |
2184 | char *base_name; | |
2185 | char *suffix; | |
2186 | { | |
2187 | FILE *f; | |
2188 | char *dumpname = (char *) alloca (strlen (base_name) + strlen (suffix) + 1); | |
2189 | ||
2190 | strcpy (dumpname, base_name); | |
2191 | strcat (dumpname, suffix); | |
2192 | f = fopen (dumpname, "w"); | |
2193 | if (f == 0) | |
2194 | pfatal_with_name (dumpname); | |
2195 | return f; | |
2196 | } | |
2197 | ||
4291d9c8 RS |
2198 | /* Compile an entire file of output from cpp, named NAME. |
2199 | Write a file of assembly output and various debugging dumps. */ | |
2200 | ||
2201 | static void | |
2202 | compile_file (name) | |
2203 | char *name; | |
2204 | { | |
2205 | tree globals; | |
2206 | int start_time; | |
4291d9c8 RS |
2207 | |
2208 | int name_specified = name != 0; | |
2209 | ||
2210 | if (dump_base_name == 0) | |
2211 | dump_base_name = name ? name : "gccdump"; | |
4291d9c8 RS |
2212 | |
2213 | parse_time = 0; | |
2214 | varconst_time = 0; | |
2215 | integration_time = 0; | |
2216 | jump_time = 0; | |
2217 | cse_time = 0; | |
2218 | loop_time = 0; | |
2219 | cse2_time = 0; | |
0d332add | 2220 | branch_prob_time = 0; |
4291d9c8 RS |
2221 | flow_time = 0; |
2222 | combine_time = 0; | |
8c660648 | 2223 | regmove_time = 0; |
4291d9c8 RS |
2224 | sched_time = 0; |
2225 | local_alloc_time = 0; | |
2226 | global_alloc_time = 0; | |
2227 | sched2_time = 0; | |
2228 | dbr_sched_time = 0; | |
2229 | shorten_branch_time = 0; | |
2230 | stack_reg_time = 0; | |
2231 | final_time = 0; | |
2232 | symout_time = 0; | |
2233 | dump_time = 0; | |
2234 | ||
e3d1fd32 | 2235 | #if !USE_CPPLIB |
4291d9c8 RS |
2236 | /* Open input file. */ |
2237 | ||
2238 | if (name == 0 || !strcmp (name, "-")) | |
2239 | { | |
2240 | finput = stdin; | |
2241 | name = "stdin"; | |
2242 | } | |
2243 | else | |
2244 | finput = fopen (name, "r"); | |
2245 | if (finput == 0) | |
2246 | pfatal_with_name (name); | |
2247 | ||
282ea52a | 2248 | #ifdef IO_BUFFER_SIZE |
d7cedf4b | 2249 | setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); |
282ea52a | 2250 | #endif |
e3d1fd32 | 2251 | #endif /* !USE_CPPLIB */ |
282ea52a | 2252 | |
4291d9c8 RS |
2253 | /* Initialize data in various passes. */ |
2254 | ||
2255 | init_obstacks (); | |
2256 | init_tree_codes (); | |
e3d1fd32 PB |
2257 | #if USE_CPPLIB |
2258 | init_parse (name); | |
2259 | #else | |
4291d9c8 | 2260 | init_lex (); |
e3d1fd32 | 2261 | #endif |
ca695ac9 JB |
2262 | /* Some of these really don't need to be called when generating bytecode, |
2263 | but the options would have to be parsed first to know that. -bson */ | |
4291d9c8 RS |
2264 | init_rtl (); |
2265 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
0d332add DE |
2266 | || debug_info_level == DINFO_LEVEL_VERBOSE |
2267 | || flag_test_coverage); | |
7f21d440 | 2268 | init_regs (); |
4291d9c8 RS |
2269 | init_decl_processing (); |
2270 | init_optabs (); | |
2271 | init_stmt (); | |
2272 | init_expmed (); | |
4fa52007 | 2273 | init_expr_once (); |
4291d9c8 RS |
2274 | init_loop (); |
2275 | init_reload (); | |
2276 | ||
2277 | if (flag_caller_saves) | |
2278 | init_caller_save (); | |
2279 | ||
f246a305 RS |
2280 | /* If auxiliary info generation is desired, open the output file. |
2281 | This goes in the same directory as the source file--unlike | |
2282 | all the other output files. */ | |
4291d9c8 RS |
2283 | if (flag_gen_aux_info) |
2284 | { | |
4291d9c8 RS |
2285 | aux_info_file = fopen (aux_info_file_name, "w"); |
2286 | if (aux_info_file == 0) | |
2287 | pfatal_with_name (aux_info_file_name); | |
2288 | } | |
2289 | ||
2290 | /* If rtl dump desired, open the output file. */ | |
2291 | if (rtl_dump) | |
dfe1a916 | 2292 | rtl_dump_file = open_dump_file (dump_base_name, ".rtl"); |
4291d9c8 RS |
2293 | |
2294 | /* If jump_opt dump desired, open the output file. */ | |
2295 | if (jump_opt_dump) | |
dfe1a916 | 2296 | jump_opt_dump_file = open_dump_file (dump_base_name, ".jump"); |
4291d9c8 | 2297 | |
e9a25f70 JL |
2298 | /* If addressof dump desired, open the output file. */ |
2299 | if (addressof_dump) | |
2300 | addressof_dump_file = open_dump_file (dump_base_name, ".addressof"); | |
2301 | ||
4291d9c8 RS |
2302 | /* If cse dump desired, open the output file. */ |
2303 | if (cse_dump) | |
dfe1a916 | 2304 | cse_dump_file = open_dump_file (dump_base_name, ".cse"); |
4291d9c8 RS |
2305 | |
2306 | /* If loop dump desired, open the output file. */ | |
2307 | if (loop_dump) | |
dfe1a916 | 2308 | loop_dump_file = open_dump_file (dump_base_name, ".loop"); |
4291d9c8 RS |
2309 | |
2310 | /* If cse2 dump desired, open the output file. */ | |
2311 | if (cse2_dump) | |
dfe1a916 | 2312 | cse2_dump_file = open_dump_file (dump_base_name, ".cse2"); |
4291d9c8 | 2313 | |
0d332add DE |
2314 | /* If branch_prob dump desired, open the output file. */ |
2315 | if (branch_prob_dump) | |
2316 | branch_prob_dump_file = open_dump_file (dump_base_name, ".bp"); | |
2317 | ||
4291d9c8 RS |
2318 | /* If flow dump desired, open the output file. */ |
2319 | if (flow_dump) | |
dfe1a916 | 2320 | flow_dump_file = open_dump_file (dump_base_name, ".flow"); |
4291d9c8 RS |
2321 | |
2322 | /* If combine dump desired, open the output file. */ | |
2323 | if (combine_dump) | |
dfe1a916 | 2324 | combine_dump_file = open_dump_file (dump_base_name, ".combine"); |
4291d9c8 | 2325 | |
8c660648 JL |
2326 | /* If regmove dump desired, open the output file. */ |
2327 | if (regmove_dump) | |
2328 | regmove_dump_file = open_dump_file (dump_base_name, ".regmove"); | |
2329 | ||
4291d9c8 RS |
2330 | /* If scheduling dump desired, open the output file. */ |
2331 | if (sched_dump) | |
dfe1a916 | 2332 | sched_dump_file = open_dump_file (dump_base_name, ".sched"); |
4291d9c8 RS |
2333 | |
2334 | /* If local_reg dump desired, open the output file. */ | |
2335 | if (local_reg_dump) | |
dfe1a916 | 2336 | local_reg_dump_file = open_dump_file (dump_base_name, ".lreg"); |
4291d9c8 RS |
2337 | |
2338 | /* If global_reg dump desired, open the output file. */ | |
2339 | if (global_reg_dump) | |
dfe1a916 | 2340 | global_reg_dump_file = open_dump_file (dump_base_name, ".greg"); |
4291d9c8 RS |
2341 | |
2342 | /* If 2nd scheduling dump desired, open the output file. */ | |
2343 | if (sched2_dump) | |
dfe1a916 | 2344 | sched2_dump_file = open_dump_file (dump_base_name, ".sched2"); |
4291d9c8 RS |
2345 | |
2346 | /* If jump2_opt dump desired, open the output file. */ | |
2347 | if (jump2_opt_dump) | |
dfe1a916 | 2348 | jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2"); |
4291d9c8 RS |
2349 | |
2350 | /* If dbr_sched dump desired, open the output file. */ | |
2351 | if (dbr_sched_dump) | |
dfe1a916 | 2352 | dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr"); |
4291d9c8 RS |
2353 | |
2354 | #ifdef STACK_REGS | |
2355 | ||
2356 | /* If stack_reg dump desired, open the output file. */ | |
2357 | if (stack_reg_dump) | |
dfe1a916 | 2358 | stack_reg_dump_file = open_dump_file (dump_base_name, ".stack"); |
4291d9c8 RS |
2359 | |
2360 | #endif | |
2361 | ||
2362 | /* Open assembler code output file. */ | |
2363 | ||
2364 | if (! name_specified && asm_file_name == 0) | |
2365 | asm_out_file = stdout; | |
2366 | else | |
2367 | { | |
4291d9c8 | 2368 | int len = strlen (dump_base_name); |
dfe1a916 | 2369 | register char *dumpname = (char *) xmalloc (len + 6); |
4291d9c8 RS |
2370 | strcpy (dumpname, dump_base_name); |
2371 | strip_off_ending (dumpname, len); | |
2372 | strcat (dumpname, ".s"); | |
2373 | if (asm_file_name == 0) | |
2374 | { | |
2375 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
2376 | strcpy (asm_file_name, dumpname); | |
2377 | } | |
2378 | if (!strcmp (asm_file_name, "-")) | |
2379 | asm_out_file = stdout; | |
2380 | else | |
2381 | asm_out_file = fopen (asm_file_name, "w"); | |
2382 | if (asm_out_file == 0) | |
2383 | pfatal_with_name (asm_file_name); | |
2384 | } | |
2385 | ||
f246a305 | 2386 | #ifdef IO_BUFFER_SIZE |
d7cedf4b RS |
2387 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), |
2388 | _IOFBF, IO_BUFFER_SIZE); | |
f246a305 RS |
2389 | #endif |
2390 | ||
4291d9c8 RS |
2391 | input_filename = name; |
2392 | ||
18736654 RK |
2393 | /* Put an entry on the input file stack for the main input file. */ |
2394 | input_file_stack | |
2395 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2396 | input_file_stack->next = 0; | |
2397 | input_file_stack->name = input_filename; | |
2398 | ||
56bf1fd9 JL |
2399 | /* Gross. Gross. lang_init is (I think) the first callback into |
2400 | the language front end, and is thus the first opportunity to | |
2401 | have the selected language override the default value for any | |
2402 | -f option. | |
2403 | ||
2404 | So the default value for flag_exceptions is 2 (uninitialized). | |
2405 | If we encounter -fno-exceptions or -fexceptions, then flag_exceptions | |
2406 | will be set to zero or one respectively. | |
2407 | ||
2408 | flag_exceptions can also be set by lang_init to something other | |
2409 | than the default "uninitialized" value of 2. | |
2410 | ||
2411 | After lang_init, if the value is still 2, then we default to | |
2412 | -fno-exceptions (value will be reset to zero). | |
2413 | ||
2414 | When our EH mechanism is low enough overhead that we can enable | |
2415 | it by default for languages other than C++, then all this braindamage | |
2416 | will go away. */ | |
2417 | ||
4291d9c8 RS |
2418 | /* Perform language-specific initialization. |
2419 | This may set main_input_filename. */ | |
2420 | lang_init (); | |
2421 | ||
56bf1fd9 JL |
2422 | if (flag_exceptions == 2) |
2423 | flag_exceptions = 0; | |
2424 | ||
4291d9c8 RS |
2425 | /* If the input doesn't start with a #line, use the input name |
2426 | as the official input file name. */ | |
2427 | if (main_input_filename == 0) | |
2428 | main_input_filename = name; | |
2429 | ||
ca695ac9 JB |
2430 | if (!output_bytecode) |
2431 | { | |
2432 | ASM_FILE_START (asm_out_file); | |
3d5cdd42 DE |
2433 | |
2434 | #ifdef ASM_COMMENT_START | |
2435 | if (flag_verbose_asm) | |
2436 | { | |
2437 | /* Print the list of options in effect. */ | |
3d5cdd42 DE |
2438 | print_version (asm_out_file, ASM_COMMENT_START); |
2439 | print_switch_values (asm_out_file, 0, MAX_LINE, | |
2440 | ASM_COMMENT_START, " ", "\n"); | |
2441 | /* Add a blank line here so it appears in assembler output but not | |
2442 | screen output. */ | |
2443 | fprintf (asm_out_file, "\n"); | |
2444 | } | |
2445 | #endif | |
ca695ac9 | 2446 | } |
4291d9c8 | 2447 | |
ca695ac9 | 2448 | /* Output something to inform GDB that this compilation was by GCC. Also |
0f41302f | 2449 | serves to tell GDB file consists of bytecodes. */ |
ca695ac9 JB |
2450 | if (output_bytecode) |
2451 | fprintf (asm_out_file, "bc_gcc2_compiled.:\n"); | |
2452 | else | |
2453 | { | |
4291d9c8 | 2454 | #ifndef ASM_IDENTIFY_GCC |
ca695ac9 | 2455 | fprintf (asm_out_file, "gcc2_compiled.:\n"); |
4291d9c8 | 2456 | #else |
ca695ac9 | 2457 | ASM_IDENTIFY_GCC (asm_out_file); |
4291d9c8 | 2458 | #endif |
ca695ac9 | 2459 | } |
d0d4af87 | 2460 | |
0f41302f | 2461 | /* Output something to identify which front-end produced this file. */ |
d0d4af87 MS |
2462 | #ifdef ASM_IDENTIFY_LANGUAGE |
2463 | ASM_IDENTIFY_LANGUAGE (asm_out_file); | |
2464 | #endif | |
2465 | ||
cf440348 JL |
2466 | #ifndef ASM_OUTPUT_SECTION_NAME |
2467 | if (flag_function_sections) | |
2468 | { | |
2469 | warning ("-ffunction-sections not supported for this target."); | |
2470 | flag_function_sections = 0; | |
2471 | } | |
2472 | #endif | |
2473 | ||
2474 | if (flag_function_sections | |
2475 | && (profile_flag || profile_block_flag)) | |
2476 | { | |
2477 | warning ("-ffunction-sections disabled; it makes profiling impossible."); | |
2478 | flag_function_sections = 0; | |
2479 | } | |
2480 | ||
2481 | if (flag_function_sections && write_symbols != NO_DEBUG) | |
2482 | warning ("-ffunction-sections may affect debugging on some targets."); | |
2483 | ||
ca695ac9 JB |
2484 | if (output_bytecode) |
2485 | { | |
2486 | if (profile_flag || profile_block_flag) | |
2487 | error ("profiling not supported in bytecode compilation"); | |
2488 | } | |
2489 | else | |
2490 | { | |
2491 | /* ??? Note: There used to be a conditional here | |
2492 | to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. | |
2493 | This was to guarantee separation between gcc_compiled. and | |
2494 | the first function, for the sake of dbx on Suns. | |
2495 | However, having the extra zero here confused the Emacs | |
2496 | code for unexec, and might confuse other programs too. | |
2497 | Therefore, I took out that change. | |
2498 | In future versions we should find another way to solve | |
2499 | that dbx problem. -- rms, 23 May 93. */ | |
2500 | ||
2501 | /* Don't let the first function fall at the same address | |
2502 | as gcc_compiled., if profiling. */ | |
2503 | if (profile_flag || profile_block_flag) | |
2504 | assemble_zeros (UNITS_PER_WORD); | |
2505 | } | |
4291d9c8 RS |
2506 | |
2507 | /* If dbx symbol table desired, initialize writing it | |
2508 | and output the predefined types. */ | |
f246a305 RS |
2509 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2510 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2511 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, |
2512 | getdecls ())); | |
2513 | #endif | |
2514 | #ifdef SDB_DEBUGGING_INFO | |
2515 | if (write_symbols == SDB_DEBUG) | |
2516 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
2517 | getdecls ())); | |
2518 | #endif | |
2519 | #ifdef DWARF_DEBUGGING_INFO | |
2520 | if (write_symbols == DWARF_DEBUG) | |
2521 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
2522 | #endif | |
0021b564 JM |
2523 | #ifdef DWARF2_UNWIND_INFO |
2524 | if (dwarf2out_do_frame ()) | |
2525 | dwarf2out_frame_init (); | |
2526 | #endif | |
9a666dda JM |
2527 | #ifdef DWARF2_DEBUGGING_INFO |
2528 | if (write_symbols == DWARF2_DEBUG) | |
2529 | TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename)); | |
2530 | #endif | |
4291d9c8 RS |
2531 | |
2532 | /* Initialize yet another pass. */ | |
2533 | ||
ca695ac9 JB |
2534 | if (!output_bytecode) |
2535 | init_final (main_input_filename); | |
0d332add | 2536 | init_branch_prob (dump_base_name); |
4291d9c8 RS |
2537 | |
2538 | start_time = get_run_time (); | |
2539 | ||
2540 | /* Call the parser, which parses the entire file | |
2541 | (calling rest_of_compilation for each function). */ | |
2542 | ||
2543 | if (yyparse () != 0) | |
453dfc78 JW |
2544 | { |
2545 | if (errorcount == 0) | |
2546 | fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); | |
2547 | ||
2548 | /* In case there were missing closebraces, | |
2549 | get us back to the global binding level. */ | |
2550 | while (! global_bindings_p ()) | |
2551 | poplevel (0, 0, 0); | |
2552 | } | |
4291d9c8 | 2553 | |
0d332add DE |
2554 | output_func_start_profiler (); |
2555 | ||
4291d9c8 RS |
2556 | /* Compilation is now finished except for writing |
2557 | what's left of the symbol table output. */ | |
2558 | ||
2559 | parse_time += get_run_time () - start_time; | |
2560 | ||
2561 | parse_time -= integration_time; | |
2562 | parse_time -= varconst_time; | |
2563 | ||
2564 | globals = getdecls (); | |
2565 | ||
2566 | /* Really define vars that have had only a tentative definition. | |
2567 | Really output inline functions that must actually be callable | |
2568 | and have not been output so far. */ | |
2569 | ||
2570 | { | |
2571 | int len = list_length (globals); | |
2572 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
2573 | int i; | |
2574 | tree decl; | |
2b6c54d6 | 2575 | int reconsider = 1; |
4291d9c8 RS |
2576 | |
2577 | /* Process the decls in reverse order--earliest first. | |
2578 | Put them into VEC from back to front, then take out from front. */ | |
2579 | ||
2580 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
2581 | vec[len - i - 1] = decl; | |
2582 | ||
2583 | for (i = 0; i < len; i++) | |
2584 | { | |
2585 | decl = vec[i]; | |
07af9d16 JM |
2586 | |
2587 | /* We're not deferring this any longer. */ | |
2588 | DECL_DEFER_OUTPUT (decl) = 0; | |
2589 | ||
488b1f4f RS |
2590 | if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 |
2591 | && incomplete_decl_finalize_hook != 0) | |
2b599527 | 2592 | (*incomplete_decl_finalize_hook) (decl); |
2b6c54d6 | 2593 | } |
2b599527 | 2594 | |
2b6c54d6 JM |
2595 | /* Now emit any global variables or functions that we have been putting |
2596 | off. We need to loop in case one of the things emitted here | |
2597 | references another one which comes earlier in the list. */ | |
2598 | while (reconsider) | |
2599 | { | |
2600 | reconsider = 0; | |
2601 | for (i = 0; i < len; i++) | |
4291d9c8 | 2602 | { |
2b6c54d6 JM |
2603 | decl = vec[i]; |
2604 | ||
2605 | if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) | |
2606 | continue; | |
2607 | ||
6b2bd61e PB |
2608 | /* Don't write out static consts, unless we still need them. |
2609 | ||
fbe912dd BK |
2610 | We also keep static consts if not optimizing (for debugging), |
2611 | unless the user specified -fno-keep-static-consts. | |
6b2bd61e PB |
2612 | ??? They might be better written into the debug information. |
2613 | This is possible when using DWARF. | |
2614 | ||
2615 | A language processor that wants static constants to be always | |
2616 | written out (even if it is not used) is responsible for | |
2617 | calling rest_of_decl_compilation itself. E.g. the C front-end | |
2618 | calls rest_of_decl_compilation from finish_decl. | |
2619 | One motivation for this is that is conventional in some | |
2620 | environments to write things like: | |
2621 | static const char rcsid[] = "... version string ..."; | |
2622 | intending to force the string to be in the executable. | |
2623 | ||
2624 | A language processor that would prefer to have unneeded | |
2625 | static constants "optimized away" would just defer writing | |
2626 | them out until here. E.g. C++ does this, because static | |
2627 | constants are often defined in header files. | |
2628 | ||
2629 | ??? A tempting alternative (for both C and C++) would be | |
2630 | to force a constant to be written if and only if it is | |
0f41302f | 2631 | defined in a main file, as opposed to an include file. */ |
6b2bd61e | 2632 | |
2b6c54d6 JM |
2633 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) |
2634 | && (! TREE_READONLY (decl) | |
2635 | || TREE_PUBLIC (decl) | |
fbe912dd | 2636 | || (!optimize && flag_keep_static_consts) |
2b6c54d6 JM |
2637 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
2638 | { | |
2639 | reconsider = 1; | |
2640 | rest_of_decl_compilation (decl, NULL_PTR, 1, 1); | |
2641 | } | |
2642 | ||
2643 | if (TREE_CODE (decl) == FUNCTION_DECL | |
2644 | && DECL_INITIAL (decl) != 0 | |
2645 | && DECL_SAVED_INSNS (decl) != 0 | |
2646 | && (flag_keep_inline_functions | |
2f8844a8 | 2647 | || TREE_PUBLIC (decl) |
2b6c54d6 JM |
2648 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) |
2649 | { | |
2650 | reconsider = 1; | |
2651 | temporary_allocation (); | |
2652 | output_inline_function (decl); | |
2653 | permanent_allocation (1); | |
2654 | } | |
4291d9c8 | 2655 | } |
2b6c54d6 | 2656 | } |
4291d9c8 | 2657 | |
3d195391 MS |
2658 | /* Now that all possible functions have been output, we can dump |
2659 | the exception table. */ | |
2660 | ||
0021b564 | 2661 | output_exception_table (); |
3d195391 | 2662 | |
2b6c54d6 JM |
2663 | for (i = 0; i < len; i++) |
2664 | { | |
2665 | decl = vec[i]; | |
2666 | ||
2667 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
2668 | && ! TREE_ASM_WRITTEN (decl)) | |
2669 | /* Cancel the RTL for this decl so that, if debugging info | |
2670 | output for global variables is still to come, | |
2671 | this one will be omitted. */ | |
2672 | DECL_RTL (decl) = NULL; | |
4291d9c8 | 2673 | |
ac266247 RS |
2674 | /* Warn about any function |
2675 | declared static but not defined. | |
2676 | We don't warn about variables, | |
2677 | because many programs have static variables | |
2678 | that exist only to get some text into the object file. */ | |
8c461ea1 JM |
2679 | if (TREE_CODE (decl) == FUNCTION_DECL |
2680 | && (warn_unused | |
2681 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | |
4291d9c8 | 2682 | && DECL_INITIAL (decl) == 0 |
216d5cdd | 2683 | && DECL_EXTERNAL (decl) |
d1b01681 | 2684 | && ! DECL_ARTIFICIAL (decl) |
4291d9c8 | 2685 | && ! TREE_PUBLIC (decl)) |
7d429c41 | 2686 | { |
8c461ea1 | 2687 | pedwarn_with_decl (decl, |
7d429c41 RS |
2688 | "`%s' declared `static' but never defined"); |
2689 | /* This symbol is effectively an "extern" declaration now. */ | |
2690 | TREE_PUBLIC (decl) = 1; | |
2691 | assemble_external (decl); | |
7d429c41 | 2692 | } |
8c461ea1 | 2693 | |
4291d9c8 | 2694 | /* Warn about static fns or vars defined but not used, |
7062b881 PB |
2695 | but not about inline functions or static consts |
2696 | since defining those in header files is normal practice. */ | |
4291d9c8 | 2697 | if (warn_unused |
7062b881 PB |
2698 | && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) |
2699 | || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) | |
0c20aabf | 2700 | && ! DECL_IN_SYSTEM_HEADER (decl) |
216d5cdd | 2701 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2702 | && ! TREE_PUBLIC (decl) |
2703 | && ! TREE_USED (decl) | |
f843649d | 2704 | && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) |
4291d9c8 RS |
2705 | /* The TREE_USED bit for file-scope decls |
2706 | is kept in the identifier, to handle multiple | |
2707 | external decls in different scopes. */ | |
2708 | && ! TREE_USED (DECL_NAME (decl))) | |
2709 | warning_with_decl (decl, "`%s' defined but not used"); | |
2710 | ||
2711 | #ifdef SDB_DEBUGGING_INFO | |
2712 | /* The COFF linker can move initialized global vars to the end. | |
2713 | And that can screw up the symbol ordering. | |
2714 | By putting the symbols in that order to begin with, | |
2715 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
2716 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
2717 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
7efad3f7 | 2718 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2719 | && DECL_RTL (decl) != 0) |
2720 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2721 | ||
2722 | /* Output COFF information for non-global | |
0f41302f | 2723 | file-scope initialized variables. */ |
4291d9c8 RS |
2724 | if (write_symbols == SDB_DEBUG |
2725 | && TREE_CODE (decl) == VAR_DECL | |
2726 | && DECL_INITIAL (decl) | |
7efad3f7 | 2727 | && ! DECL_EXTERNAL (decl) |
4291d9c8 RS |
2728 | && DECL_RTL (decl) != 0 |
2729 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
2730 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
2731 | #endif /* SDB_DEBUGGING_INFO */ | |
2732 | #ifdef DWARF_DEBUGGING_INFO | |
6dc42e49 | 2733 | /* Output DWARF information for file-scope tentative data object |
4291d9c8 RS |
2734 | declarations, file-scope (extern) function declarations (which |
2735 | had no corresponding body) and file-scope tagged type declarations | |
2736 | and definitions which have not yet been forced out. */ | |
2737 | ||
2738 | if (write_symbols == DWARF_DEBUG | |
2739 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
2740 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
9a666dda JM |
2741 | #endif |
2742 | #ifdef DWARF2_DEBUGGING_INFO | |
2743 | /* Output DWARF2 information for file-scope tentative data object | |
2744 | declarations, file-scope (extern) function declarations (which | |
2745 | had no corresponding body) and file-scope tagged type declarations | |
2746 | and definitions which have not yet been forced out. */ | |
2747 | ||
2748 | if (write_symbols == DWARF2_DEBUG | |
2749 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
88dad228 | 2750 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
4291d9c8 RS |
2751 | #endif |
2752 | } | |
2753 | } | |
2754 | ||
4b8af8d9 JM |
2755 | /* Write out any pending weak symbol declarations. */ |
2756 | ||
2757 | weak_finish (); | |
2758 | ||
4291d9c8 | 2759 | /* Do dbx symbols */ |
f246a305 RS |
2760 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2761 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
2762 | TIMEVAR (symout_time, |
2763 | { | |
2764 | dbxout_finish (asm_out_file, main_input_filename); | |
2765 | }); | |
2766 | #endif | |
2767 | ||
2768 | #ifdef DWARF_DEBUGGING_INFO | |
2769 | if (write_symbols == DWARF_DEBUG) | |
2770 | TIMEVAR (symout_time, | |
2771 | { | |
2772 | dwarfout_finish (); | |
2773 | }); | |
2774 | #endif | |
2775 | ||
0021b564 JM |
2776 | #ifdef DWARF2_UNWIND_INFO |
2777 | if (dwarf2out_do_frame ()) | |
2778 | dwarf2out_frame_finish (); | |
2779 | #endif | |
2780 | ||
9a666dda JM |
2781 | #ifdef DWARF2_DEBUGGING_INFO |
2782 | if (write_symbols == DWARF2_DEBUG) | |
2783 | TIMEVAR (symout_time, | |
2784 | { | |
2785 | dwarf2out_finish (); | |
2786 | }); | |
2787 | #endif | |
2788 | ||
4291d9c8 RS |
2789 | /* Output some stuff at end of file if nec. */ |
2790 | ||
ca695ac9 JB |
2791 | if (!output_bytecode) |
2792 | { | |
0d332add DE |
2793 | end_final (dump_base_name); |
2794 | end_branch_prob (branch_prob_dump_file); | |
4291d9c8 RS |
2795 | |
2796 | #ifdef ASM_FILE_END | |
ca695ac9 | 2797 | ASM_FILE_END (asm_out_file); |
4291d9c8 | 2798 | #endif |
ca695ac9 | 2799 | } |
4291d9c8 | 2800 | |
4291d9c8 RS |
2801 | /* Language-specific end of compilation actions. */ |
2802 | ||
2803 | lang_finish (); | |
2804 | ||
0207ea82 RK |
2805 | if (output_bytecode) |
2806 | bc_write_file (asm_out_file); | |
2807 | ||
4291d9c8 RS |
2808 | /* Close the dump files. */ |
2809 | ||
2810 | if (flag_gen_aux_info) | |
2811 | { | |
2812 | fclose (aux_info_file); | |
2813 | if (errorcount) | |
2814 | unlink (aux_info_file_name); | |
2815 | } | |
2816 | ||
2817 | if (rtl_dump) | |
2818 | fclose (rtl_dump_file); | |
2819 | ||
2820 | if (jump_opt_dump) | |
2821 | fclose (jump_opt_dump_file); | |
2822 | ||
e9a25f70 JL |
2823 | if (addressof_dump) |
2824 | fclose (addressof_dump_file); | |
2825 | ||
4291d9c8 RS |
2826 | if (cse_dump) |
2827 | fclose (cse_dump_file); | |
2828 | ||
2829 | if (loop_dump) | |
2830 | fclose (loop_dump_file); | |
2831 | ||
2832 | if (cse2_dump) | |
2833 | fclose (cse2_dump_file); | |
2834 | ||
0d332add DE |
2835 | if (branch_prob_dump) |
2836 | fclose (branch_prob_dump_file); | |
2837 | ||
4291d9c8 RS |
2838 | if (flow_dump) |
2839 | fclose (flow_dump_file); | |
2840 | ||
2841 | if (combine_dump) | |
2842 | { | |
2843 | dump_combine_total_stats (combine_dump_file); | |
2844 | fclose (combine_dump_file); | |
2845 | } | |
2846 | ||
8c660648 JL |
2847 | if (regmove_dump) |
2848 | fclose (regmove_dump_file); | |
2849 | ||
4291d9c8 RS |
2850 | if (sched_dump) |
2851 | fclose (sched_dump_file); | |
2852 | ||
2853 | if (local_reg_dump) | |
2854 | fclose (local_reg_dump_file); | |
2855 | ||
2856 | if (global_reg_dump) | |
2857 | fclose (global_reg_dump_file); | |
2858 | ||
2859 | if (sched2_dump) | |
2860 | fclose (sched2_dump_file); | |
2861 | ||
2862 | if (jump2_opt_dump) | |
2863 | fclose (jump2_opt_dump_file); | |
2864 | ||
2865 | if (dbr_sched_dump) | |
2866 | fclose (dbr_sched_dump_file); | |
2867 | ||
2868 | #ifdef STACK_REGS | |
2869 | if (stack_reg_dump) | |
2870 | fclose (stack_reg_dump_file); | |
2871 | #endif | |
2872 | ||
2873 | /* Close non-debugging input and output files. Take special care to note | |
2874 | whether fclose returns an error, since the pages might still be on the | |
2875 | buffer chain while the file is open. */ | |
2876 | ||
e3d1fd32 PB |
2877 | #if USE_CPPLIB |
2878 | finish_parse (); | |
2879 | #else | |
4291d9c8 | 2880 | fclose (finput); |
e3d1fd32 | 2881 | #endif |
4291d9c8 RS |
2882 | if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) |
2883 | fatal_io_error (asm_file_name); | |
2884 | ||
2885 | /* Print the times. */ | |
2886 | ||
2887 | if (! quiet_flag) | |
2888 | { | |
2889 | fprintf (stderr,"\n"); | |
2890 | print_time ("parse", parse_time); | |
ca695ac9 JB |
2891 | |
2892 | if (!output_bytecode) | |
2893 | { | |
2894 | print_time ("integration", integration_time); | |
2895 | print_time ("jump", jump_time); | |
2896 | print_time ("cse", cse_time); | |
2897 | print_time ("loop", loop_time); | |
2898 | print_time ("cse2", cse2_time); | |
116758a7 | 2899 | print_time ("branch-prob", branch_prob_time); |
ca695ac9 JB |
2900 | print_time ("flow", flow_time); |
2901 | print_time ("combine", combine_time); | |
8c660648 | 2902 | print_time ("regmove", regmove_time); |
ca695ac9 JB |
2903 | print_time ("sched", sched_time); |
2904 | print_time ("local-alloc", local_alloc_time); | |
2905 | print_time ("global-alloc", global_alloc_time); | |
2906 | print_time ("sched2", sched2_time); | |
2907 | print_time ("dbranch", dbr_sched_time); | |
2908 | print_time ("shorten-branch", shorten_branch_time); | |
2909 | print_time ("stack-reg", stack_reg_time); | |
2910 | print_time ("final", final_time); | |
2911 | print_time ("varconst", varconst_time); | |
2912 | print_time ("symout", symout_time); | |
2913 | print_time ("dump", dump_time); | |
2914 | } | |
4291d9c8 RS |
2915 | } |
2916 | } | |
2917 | \f | |
2918 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
2919 | and TYPE_DECL nodes. | |
2920 | ||
2921 | This does nothing for local (non-static) variables. | |
2922 | Otherwise, it sets up the RTL and outputs any assembler code | |
2923 | (label definition, storage allocation and initialization). | |
2924 | ||
2925 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
2926 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
2927 | if this declaration is not within a function. */ | |
2928 | ||
2929 | void | |
2930 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
2931 | tree decl; | |
2932 | char *asmspec; | |
2933 | int top_level; | |
2934 | int at_end; | |
2935 | { | |
2936 | /* Declarations of variables, and of functions defined elsewhere. */ | |
2937 | ||
928eb380 RS |
2938 | /* The most obvious approach, to put an #ifndef around where |
2939 | this macro is used, doesn't work since it's inside a macro call. */ | |
2940 | #ifndef ASM_FINISH_DECLARE_OBJECT | |
2941 | #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) | |
2942 | #endif | |
2943 | ||
4291d9c8 RS |
2944 | /* Forward declarations for nested functions are not "external", |
2945 | but we need to treat them as if they were. */ | |
216d5cdd | 2946 | if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) |
4291d9c8 RS |
2947 | || TREE_CODE (decl) == FUNCTION_DECL) |
2948 | TIMEVAR (varconst_time, | |
2949 | { | |
2950 | make_decl_rtl (decl, asmspec, top_level); | |
9a9a9643 RS |
2951 | /* Initialized extern variable exists to be replaced |
2952 | with its value, or represents something that will be | |
2953 | output in another file. */ | |
6dbf678a | 2954 | if (! (TREE_CODE (decl) == VAR_DECL |
9a9a9643 RS |
2955 | && DECL_EXTERNAL (decl) && TREE_READONLY (decl) |
2956 | && DECL_INITIAL (decl) != 0 | |
5b272d50 | 2957 | && DECL_INITIAL (decl) != error_mark_node)) |
6dbf678a RS |
2958 | /* Don't output anything |
2959 | when a tentative file-scope definition is seen. | |
2960 | But at end of compilation, do output code for them. */ | |
2961 | if (! (! at_end && top_level | |
2962 | && (DECL_INITIAL (decl) == 0 | |
9a9a9643 | 2963 | || DECL_INITIAL (decl) == error_mark_node))) |
8380e2f2 | 2964 | assemble_variable (decl, top_level, at_end, 0); |
5b7540b6 DE |
2965 | if (!output_bytecode |
2966 | && decl == last_assemble_variable_decl) | |
5e10b3cc RS |
2967 | { |
2968 | ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
2969 | top_level, at_end); | |
2970 | } | |
4291d9c8 | 2971 | }); |
216d5cdd | 2972 | else if (DECL_REGISTER (decl) && asmspec != 0) |
4291d9c8 RS |
2973 | { |
2974 | if (decode_reg_name (asmspec) >= 0) | |
2975 | { | |
2976 | DECL_RTL (decl) = 0; | |
2977 | make_decl_rtl (decl, asmspec, top_level); | |
2978 | } | |
2979 | else | |
2980 | error ("invalid register name `%s' for register variable", asmspec); | |
2981 | } | |
f246a305 RS |
2982 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
2983 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2984 | && TREE_CODE (decl) == TYPE_DECL) | |
4291d9c8 RS |
2985 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); |
2986 | #endif | |
2987 | #ifdef SDB_DEBUGGING_INFO | |
2988 | else if (write_symbols == SDB_DEBUG && top_level | |
2989 | && TREE_CODE (decl) == TYPE_DECL) | |
2990 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2991 | #endif | |
2992 | } | |
2993 | ||
2994 | /* Called after finishing a record, union or enumeral type. */ | |
2995 | ||
2996 | void | |
2997 | rest_of_type_compilation (type, toplev) | |
2998 | tree type; | |
2999 | int toplev; | |
3000 | { | |
f246a305 RS |
3001 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
3002 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
4291d9c8 RS |
3003 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); |
3004 | #endif | |
3005 | #ifdef SDB_DEBUGGING_INFO | |
3006 | if (write_symbols == SDB_DEBUG) | |
3007 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
3008 | #endif | |
3009 | } | |
3010 | ||
3011 | /* This is called from finish_function (within yyparse) | |
3012 | after each top-level definition is parsed. | |
3013 | It is supposed to compile that function or variable | |
3014 | and output the assembler code for it. | |
3015 | After we return, the tree storage is freed. */ | |
3016 | ||
3017 | void | |
3018 | rest_of_compilation (decl) | |
3019 | tree decl; | |
3020 | { | |
3021 | register rtx insns; | |
3022 | int start_time = get_run_time (); | |
3023 | int tem; | |
3024 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
3025 | to be restored after we finish compiling the function | |
3026 | (for use when compiling inline calls to this function). */ | |
3027 | tree saved_block_tree = 0; | |
8a958768 RS |
3028 | /* Likewise, for DECL_ARGUMENTS. */ |
3029 | tree saved_arguments = 0; | |
ab40ad2b | 3030 | int failure = 0; |
4291d9c8 | 3031 | |
ca695ac9 JB |
3032 | if (output_bytecode) |
3033 | return; | |
3034 | ||
4291d9c8 RS |
3035 | /* If we are reconsidering an inline function |
3036 | at the end of compilation, skip the stuff for making it inline. */ | |
3037 | ||
3038 | if (DECL_SAVED_INSNS (decl) == 0) | |
3039 | { | |
956d6950 | 3040 | int inlinable = 0; |
4291d9c8 RS |
3041 | char *lose; |
3042 | ||
3043 | /* If requested, consider whether to make this function inline. */ | |
9deaf1b1 | 3044 | if (DECL_INLINE (decl) || flag_inline_functions) |
4291d9c8 RS |
3045 | TIMEVAR (integration_time, |
3046 | { | |
3047 | lose = function_cannot_inline_p (decl); | |
caa0eccd | 3048 | if (lose || ! optimize) |
4291d9c8 | 3049 | { |
9deaf1b1 | 3050 | if (warn_inline && DECL_INLINE (decl)) |
4291d9c8 | 3051 | warning_with_decl (decl, lose); |
9548c538 | 3052 | DECL_ABSTRACT_ORIGIN (decl) = 0; |
46dbb914 RS |
3053 | /* Don't really compile an extern inline function. |
3054 | If we can't make it inline, pretend | |
3055 | it was only declared. */ | |
3056 | if (DECL_EXTERNAL (decl)) | |
27937f46 RS |
3057 | { |
3058 | DECL_INITIAL (decl) = 0; | |
3059 | goto exit_rest_of_compilation; | |
3060 | } | |
4291d9c8 RS |
3061 | } |
3062 | else | |
9deaf1b1 RK |
3063 | /* ??? Note that this has the effect of making it look |
3064 | like "inline" was specified for a function if we choose | |
3065 | to inline it. This isn't quite right, but it's | |
3066 | probably not worth the trouble to fix. */ | |
956d6950 | 3067 | inlinable = DECL_INLINE (decl) = 1; |
4291d9c8 RS |
3068 | }); |
3069 | ||
3070 | insns = get_insns (); | |
3071 | ||
3072 | /* Dump the rtl code if we are dumping rtl. */ | |
3073 | ||
3074 | if (rtl_dump) | |
3075 | TIMEVAR (dump_time, | |
3076 | { | |
3077 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3078 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3079 | if (DECL_SAVED_INSNS (decl)) |
3080 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
3081 | print_rtl (rtl_dump_file, insns); | |
3082 | fflush (rtl_dump_file); | |
3083 | }); | |
3084 | ||
c0da11c4 JM |
3085 | /* If we can, defer compiling inlines until EOF. |
3086 | save_for_inline_copying can be extremely expensive. */ | |
956d6950 | 3087 | if (inlinable && ! decl_function_context (decl)) |
c0da11c4 JM |
3088 | DECL_DEFER_OUTPUT (decl) = 1; |
3089 | ||
4291d9c8 RS |
3090 | /* If function is inline, and we don't yet know whether to |
3091 | compile it by itself, defer decision till end of compilation. | |
3092 | finish_compilation will call rest_of_compilation again | |
16411ea6 | 3093 | for those functions that need to be output. Also defer those |
ec6c615d RK |
3094 | functions that we are supposed to defer. We cannot defer |
3095 | functions containing nested functions since the nested function | |
3096 | data is in our non-saved obstack. */ | |
3097 | ||
e9a25f70 JL |
3098 | /* If this is a nested inline, remove ADDRESSOF now so we can |
3099 | finish compiling ourselves. Otherwise, wait until EOF. | |
3100 | We have to do this because the purge_addressof transformation | |
3101 | changes the DECL_RTL for many variables, which confuses integrate. */ | |
956d6950 | 3102 | if (inlinable) |
e9a25f70 JL |
3103 | { |
3104 | if (decl_function_context (decl)) | |
3105 | purge_addressof (insns); | |
3106 | else | |
3107 | DECL_DEFER_OUTPUT (decl) = 1; | |
3108 | } | |
3109 | ||
ec6c615d RK |
3110 | if (! current_function_contains_functions |
3111 | && (DECL_DEFER_OUTPUT (decl) | |
9deaf1b1 | 3112 | || (DECL_INLINE (decl) |
ec6c615d RK |
3113 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) |
3114 | && ! flag_keep_inline_functions) | |
3115 | || DECL_EXTERNAL (decl))))) | |
4291d9c8 | 3116 | { |
951af26e JM |
3117 | DECL_DEFER_OUTPUT (decl) = 1; |
3118 | ||
3119 | /* If -Wreturn-type, we have to do a bit of compilation. */ | |
3120 | if (! warn_return_type) | |
937522b5 | 3121 | { |
951af26e JM |
3122 | #ifdef DWARF_DEBUGGING_INFO |
3123 | /* Generate the DWARF info for the "abstract" instance | |
3124 | of a function which we may later generate inlined and/or | |
3125 | out-of-line instances of. */ | |
3126 | if (write_symbols == DWARF_DEBUG) | |
3127 | { | |
3128 | set_decl_abstract_flags (decl, 1); | |
3129 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3130 | set_decl_abstract_flags (decl, 0); | |
3131 | } | |
9a666dda JM |
3132 | #endif |
3133 | #ifdef DWARF2_DEBUGGING_INFO | |
3134 | /* Generate the DWARF2 info for the "abstract" instance | |
3135 | of a function which we may later generate inlined and/or | |
3136 | out-of-line instances of. */ | |
3137 | if (write_symbols == DWARF2_DEBUG) | |
3138 | { | |
3139 | set_decl_abstract_flags (decl, 1); | |
88dad228 | 3140 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3141 | set_decl_abstract_flags (decl, 0); |
3142 | } | |
951af26e JM |
3143 | #endif |
3144 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
956d6950 | 3145 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; |
951af26e | 3146 | goto exit_rest_of_compilation; |
937522b5 | 3147 | } |
4291d9c8 RS |
3148 | } |
3149 | ||
8a958768 | 3150 | /* If we have to compile the function now, save its rtl and subdecls |
4291d9c8 | 3151 | so that its compilation will not affect what others get. */ |
956d6950 | 3152 | if (inlinable || DECL_DEFER_OUTPUT (decl)) |
4291d9c8 | 3153 | { |
937522b5 RS |
3154 | #ifdef DWARF_DEBUGGING_INFO |
3155 | /* Generate the DWARF info for the "abstract" instance of | |
3156 | a function which we will generate an out-of-line instance | |
3157 | of almost immediately (and which we may also later generate | |
3158 | various inlined instances of). */ | |
3159 | if (write_symbols == DWARF_DEBUG) | |
3160 | { | |
3161 | set_decl_abstract_flags (decl, 1); | |
3162 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3163 | set_decl_abstract_flags (decl, 0); | |
3164 | } | |
9a666dda JM |
3165 | #endif |
3166 | #ifdef DWARF2_DEBUGGING_INFO | |
3167 | /* Generate the DWARF2 info for the "abstract" instance of | |
3168 | a function which we will generate an out-of-line instance | |
3169 | of almost immediately (and which we may also later generate | |
3170 | various inlined instances of). */ | |
3171 | if (write_symbols == DWARF2_DEBUG) | |
3172 | { | |
3173 | set_decl_abstract_flags (decl, 1); | |
88dad228 | 3174 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3175 | set_decl_abstract_flags (decl, 0); |
3176 | } | |
937522b5 | 3177 | #endif |
4291d9c8 | 3178 | saved_block_tree = DECL_INITIAL (decl); |
8a958768 | 3179 | saved_arguments = DECL_ARGUMENTS (decl); |
4291d9c8 | 3180 | TIMEVAR (integration_time, save_for_inline_copying (decl)); |
956d6950 | 3181 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; |
4291d9c8 | 3182 | } |
4291d9c8 | 3183 | |
b8471b65 RK |
3184 | /* If specified extern inline but we aren't inlining it, we are |
3185 | done. */ | |
9deaf1b1 | 3186 | if (DECL_INLINE (decl) && DECL_EXTERNAL (decl)) |
b8471b65 RK |
3187 | goto exit_rest_of_compilation; |
3188 | } | |
07af9d16 | 3189 | |
951af26e JM |
3190 | if (! DECL_DEFER_OUTPUT (decl)) |
3191 | TREE_ASM_WRITTEN (decl) = 1; | |
4291d9c8 RS |
3192 | |
3193 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
3194 | between the return value of this function and the return value of called | |
3195 | functions. */ | |
3196 | rtx_equal_function_value_matters = 0; | |
3197 | ||
32235b30 RS |
3198 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ |
3199 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
4291d9c8 RS |
3200 | { |
3201 | goto exit_rest_of_compilation; | |
3202 | } | |
3203 | ||
89418a92 BK |
3204 | /* Add an unwinder for exception handling, if needed. |
3205 | This must be done before we finalize PIC code. */ | |
3206 | emit_unwinder (); | |
4291d9c8 RS |
3207 | |
3208 | #ifdef FINALIZE_PIC | |
3209 | /* If we are doing position-independent code generation, now | |
3210 | is the time to output special prologues and epilogues. | |
3211 | We do not want to do this earlier, because it just clutters | |
3212 | up inline functions with meaningless insns. */ | |
3213 | if (flag_pic) | |
3214 | FINALIZE_PIC; | |
3215 | #endif | |
3216 | ||
89418a92 BK |
3217 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. |
3218 | Note that that may have been done above, in save_for_inline_copying. | |
3219 | The call to resume_temporary_allocation near the end of this function | |
3220 | goes back to the usual state of affairs. This must be done after | |
3221 | we've built up any unwinders for exception handling, and done | |
3222 | the FINALIZE_PIC work, if necessary. */ | |
3223 | ||
3224 | rtl_in_current_obstack (); | |
3d195391 | 3225 | |
4291d9c8 RS |
3226 | insns = get_insns (); |
3227 | ||
3228 | /* Copy any shared structure that should not be shared. */ | |
3229 | ||
3230 | unshare_all_rtl (insns); | |
3231 | ||
3232 | /* Instantiate all virtual registers. */ | |
3233 | ||
3234 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
3235 | ||
3236 | /* See if we have allocated stack slots that are not directly addressable. | |
3237 | If so, scan all the insns and create explicit address computation | |
3238 | for all references to such slots. */ | |
3239 | /* fixup_stack_slots (); */ | |
3240 | ||
3d195391 MS |
3241 | /* Find all the EH handlers. */ |
3242 | find_exception_handler_labels (); | |
3243 | ||
cc4e79d8 JL |
3244 | /* Always do one jump optimization pass to ensure that JUMP_LABEL fields |
3245 | are initialized and to compute whether control can drop off the end | |
3246 | of the function. */ | |
3247 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3248 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
4291d9c8 | 3249 | |
32235b30 | 3250 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ |
951af26e | 3251 | if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) |
32235b30 RS |
3252 | goto exit_rest_of_compilation; |
3253 | ||
4291d9c8 RS |
3254 | /* Dump rtl code after jump, if we are doing that. */ |
3255 | ||
3256 | if (jump_opt_dump) | |
3257 | TIMEVAR (dump_time, | |
3258 | { | |
3259 | fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3260 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3261 | print_rtl (jump_opt_dump_file, insns); |
3262 | fflush (jump_opt_dump_file); | |
3263 | }); | |
3264 | ||
3265 | /* Perform common subexpression elimination. | |
3266 | Nonzero value from `cse_main' means that jumps were simplified | |
3267 | and some code may now be unreachable, so do | |
3268 | jump optimization again. */ | |
3269 | ||
3270 | if (cse_dump) | |
3271 | TIMEVAR (dump_time, | |
3272 | { | |
3273 | fprintf (cse_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3274 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3275 | }); |
3276 | ||
3277 | if (optimize > 0) | |
3278 | { | |
3279 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); | |
3280 | ||
3281 | if (flag_thread_jumps) | |
3282 | /* Hacks by tiemann & kenner. */ | |
6f606d63 | 3283 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); |
4291d9c8 RS |
3284 | |
3285 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
3286 | 0, cse_dump_file)); | |
3287 | TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); | |
3288 | ||
534bfae4 | 3289 | if (tem || optimize > 1) |
4291d9c8 RS |
3290 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); |
3291 | } | |
3292 | ||
3293 | /* Dump rtl code after cse, if we are doing that. */ | |
3294 | ||
3295 | if (cse_dump) | |
3296 | TIMEVAR (dump_time, | |
3297 | { | |
3298 | print_rtl (cse_dump_file, insns); | |
3299 | fflush (cse_dump_file); | |
3300 | }); | |
3301 | ||
e9a25f70 JL |
3302 | purge_addressof (insns); |
3303 | reg_scan (insns, max_reg_num (), 1); | |
3304 | ||
3305 | if (addressof_dump) | |
3306 | TIMEVAR (dump_time, | |
3307 | { | |
3308 | fprintf (addressof_dump_file, "\n;; Function %s\n\n", | |
3309 | (*decl_printable_name) (decl, 2)); | |
3310 | print_rtl (addressof_dump_file, insns); | |
3311 | fflush (addressof_dump_file); | |
3312 | }); | |
3313 | ||
4291d9c8 RS |
3314 | if (loop_dump) |
3315 | TIMEVAR (dump_time, | |
3316 | { | |
3317 | fprintf (loop_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3318 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3319 | }); |
3320 | ||
3321 | /* Move constant computations out of loops. */ | |
3322 | ||
3323 | if (optimize > 0) | |
3324 | { | |
3325 | TIMEVAR (loop_time, | |
3326 | { | |
6d6d0fa0 JL |
3327 | if (flag_rerun_loop_opt) |
3328 | { | |
3329 | /* We only want to perform unrolling once. */ | |
6d6d0fa0 | 3330 | |
81797aba | 3331 | loop_optimize (insns, loop_dump_file, 0); |
6d6d0fa0 JL |
3332 | |
3333 | /* The regscan pass may not be necessary, but let's | |
3334 | be safe until we can prove otherwise. */ | |
3335 | reg_scan (insns, max_reg_num (), 1); | |
6d6d0fa0 | 3336 | } |
81797aba | 3337 | loop_optimize (insns, loop_dump_file, flag_unroll_loops); |
4291d9c8 RS |
3338 | }); |
3339 | } | |
3340 | ||
3341 | /* Dump rtl code after loop opt, if we are doing that. */ | |
3342 | ||
3343 | if (loop_dump) | |
3344 | TIMEVAR (dump_time, | |
3345 | { | |
3346 | print_rtl (loop_dump_file, insns); | |
3347 | fflush (loop_dump_file); | |
3348 | }); | |
3349 | ||
3350 | if (cse2_dump) | |
3351 | TIMEVAR (dump_time, | |
3352 | { | |
3353 | fprintf (cse2_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3354 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3355 | }); |
3356 | ||
3357 | if (optimize > 0 && flag_rerun_cse_after_loop) | |
3358 | { | |
44333223 JL |
3359 | /* Running another jump optimization pass before the second |
3360 | cse pass sometimes simplifies the RTL enough to allow | |
9e9b48a4 DE |
3361 | the second CSE pass to do a better job. Jump_optimize can change |
3362 | max_reg_num so we must rerun reg_scan afterwards. | |
3363 | ??? Rework to not call reg_scan so often. */ | |
3364 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
44333223 | 3365 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); |
4291d9c8 | 3366 | |
9e9b48a4 | 3367 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); |
4291d9c8 RS |
3368 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), |
3369 | 1, cse2_dump_file)); | |
3370 | if (tem) | |
3371 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
3372 | } | |
3373 | ||
3374 | if (optimize > 0 && flag_thread_jumps) | |
c2f006ec RK |
3375 | { |
3376 | /* This pass of jump threading straightens out code | |
3377 | that was kinked by loop optimization. */ | |
3378 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3379 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
3380 | } | |
4291d9c8 RS |
3381 | /* Dump rtl code after cse, if we are doing that. */ |
3382 | ||
3383 | if (cse2_dump) | |
3384 | TIMEVAR (dump_time, | |
3385 | { | |
3386 | print_rtl (cse2_dump_file, insns); | |
3387 | fflush (cse2_dump_file); | |
3388 | }); | |
3389 | ||
0d332add DE |
3390 | if (branch_prob_dump) |
3391 | TIMEVAR (dump_time, | |
3392 | { | |
3393 | fprintf (branch_prob_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3394 | (*decl_printable_name) (decl, 2)); |
0d332add DE |
3395 | }); |
3396 | ||
3397 | if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) | |
3398 | TIMEVAR (branch_prob_time, | |
3399 | { | |
3400 | branch_prob (insns, branch_prob_dump_file); | |
3401 | }); | |
3402 | ||
3403 | if (branch_prob_dump) | |
3404 | TIMEVAR (dump_time, | |
3405 | { | |
3406 | print_rtl (branch_prob_dump_file, insns); | |
3407 | fflush (branch_prob_dump_file); | |
3408 | }); | |
4291d9c8 RS |
3409 | /* We are no longer anticipating cse in this function, at least. */ |
3410 | ||
3411 | cse_not_expected = 1; | |
3412 | ||
3413 | /* Now we choose between stupid (pcc-like) register allocation | |
3414 | (if we got the -noreg switch and not -opt) | |
3415 | and smart register allocation. */ | |
3416 | ||
3417 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
3418 | obey_regdecls = 0; /* if optimizations being done. */ | |
3419 | ||
3420 | regclass_init (); | |
3421 | ||
3422 | /* Print function header into flow dump now | |
3423 | because doing the flow analysis makes some of the dump. */ | |
3424 | ||
3425 | if (flow_dump) | |
3426 | TIMEVAR (dump_time, | |
3427 | { | |
3428 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3429 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3430 | }); |
3431 | ||
3432 | if (obey_regdecls) | |
3433 | { | |
3434 | TIMEVAR (flow_time, | |
3435 | { | |
3436 | regclass (insns, max_reg_num ()); | |
3437 | stupid_life_analysis (insns, max_reg_num (), | |
3438 | flow_dump_file); | |
3439 | }); | |
3440 | } | |
3441 | else | |
3442 | { | |
3443 | /* Do control and data flow analysis, | |
3444 | and write some of the results to dump file. */ | |
3445 | ||
3446 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
3447 | flow_dump_file)); | |
3448 | if (warn_uninitialized) | |
3449 | { | |
3450 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
3451 | setjmp_args_warning (); | |
3452 | } | |
3453 | } | |
3454 | ||
3455 | /* Dump rtl after flow analysis. */ | |
3456 | ||
3457 | if (flow_dump) | |
3458 | TIMEVAR (dump_time, | |
3459 | { | |
3e28fe44 | 3460 | print_rtl_with_bb (flow_dump_file, insns); |
4291d9c8 RS |
3461 | fflush (flow_dump_file); |
3462 | }); | |
3463 | ||
3464 | /* If -opt, try combining insns through substitution. */ | |
3465 | ||
3466 | if (optimize > 0) | |
3467 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
3468 | ||
3469 | /* Dump rtl code after insn combination. */ | |
3470 | ||
3471 | if (combine_dump) | |
3472 | TIMEVAR (dump_time, | |
3473 | { | |
3474 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3475 | (*decl_printable_name) (decl, 2)); |
4291d9c8 | 3476 | dump_combine_stats (combine_dump_file); |
3e28fe44 | 3477 | print_rtl_with_bb (combine_dump_file, insns); |
4291d9c8 RS |
3478 | fflush (combine_dump_file); |
3479 | }); | |
3480 | ||
8c660648 JL |
3481 | if (regmove_dump) |
3482 | TIMEVAR (dump_time, | |
3483 | { | |
3484 | fprintf (regmove_dump_file, "\n;; Function %s\n\n", | |
3485 | (*decl_printable_name) (decl, 2)); | |
3486 | }); | |
3487 | ||
3488 | /* Register allocation pre-pass, to reduce number of moves | |
3489 | necessary for two-address machines. */ | |
3490 | if (optimize > 0 && flag_regmove) | |
3491 | TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (), | |
3492 | regmove_dump_file)); | |
3493 | ||
3494 | if (regmove_dump) | |
3495 | TIMEVAR (dump_time, | |
3496 | { | |
3e28fe44 | 3497 | print_rtl_with_bb (regmove_dump_file, insns); |
8c660648 JL |
3498 | fflush (regmove_dump_file); |
3499 | }); | |
3500 | ||
4291d9c8 RS |
3501 | /* Print function header into sched dump now |
3502 | because doing the sched analysis makes some of the dump. */ | |
3503 | ||
3504 | if (sched_dump) | |
3505 | TIMEVAR (dump_time, | |
3506 | { | |
3507 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3508 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3509 | }); |
3510 | ||
3511 | if (optimize > 0 && flag_schedule_insns) | |
3512 | { | |
3513 | /* Do control and data sched analysis, | |
3514 | and write some of the results to dump file. */ | |
3515 | ||
3516 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
3517 | } | |
3518 | ||
3519 | /* Dump rtl after instruction scheduling. */ | |
3520 | ||
3521 | if (sched_dump) | |
3522 | TIMEVAR (dump_time, | |
3523 | { | |
3e28fe44 | 3524 | print_rtl_with_bb (sched_dump_file, insns); |
4291d9c8 RS |
3525 | fflush (sched_dump_file); |
3526 | }); | |
3527 | ||
3528 | /* Unless we did stupid register allocation, | |
3529 | allocate pseudo-regs that are used only within 1 basic block. */ | |
3530 | ||
3531 | if (!obey_regdecls) | |
3532 | TIMEVAR (local_alloc_time, | |
3533 | { | |
3534 | regclass (insns, max_reg_num ()); | |
3535 | local_alloc (); | |
3536 | }); | |
3537 | ||
3538 | /* Dump rtl code after allocating regs within basic blocks. */ | |
3539 | ||
3540 | if (local_reg_dump) | |
3541 | TIMEVAR (dump_time, | |
3542 | { | |
3543 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3544 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3545 | dump_flow_info (local_reg_dump_file); |
3546 | dump_local_alloc (local_reg_dump_file); | |
3e28fe44 | 3547 | print_rtl_with_bb (local_reg_dump_file, insns); |
4291d9c8 RS |
3548 | fflush (local_reg_dump_file); |
3549 | }); | |
3550 | ||
3551 | if (global_reg_dump) | |
3552 | TIMEVAR (dump_time, | |
3553 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3554 | (*decl_printable_name) (decl, 2))); |
4291d9c8 | 3555 | |
bf8b4985 RK |
3556 | /* Save the last label number used so far, so reorg can tell |
3557 | when it's safe to kill spill regs. */ | |
3558 | max_label_num_after_reload = max_label_num (); | |
3559 | ||
4291d9c8 RS |
3560 | /* Unless we did stupid register allocation, |
3561 | allocate remaining pseudo-regs, then do the reload pass | |
3562 | fixing up any insns that are invalid. */ | |
3563 | ||
3564 | TIMEVAR (global_alloc_time, | |
3565 | { | |
3566 | if (!obey_regdecls) | |
37366632 | 3567 | failure = global_alloc (global_reg_dump_file); |
4291d9c8 | 3568 | else |
37366632 | 3569 | failure = reload (insns, 0, global_reg_dump_file); |
4291d9c8 RS |
3570 | }); |
3571 | ||
3572 | if (global_reg_dump) | |
3573 | TIMEVAR (dump_time, | |
3574 | { | |
3575 | dump_global_regs (global_reg_dump_file); | |
3e28fe44 | 3576 | print_rtl_with_bb (global_reg_dump_file, insns); |
4291d9c8 RS |
3577 | fflush (global_reg_dump_file); |
3578 | }); | |
3579 | ||
ab40ad2b RS |
3580 | if (failure) |
3581 | goto exit_rest_of_compilation; | |
3582 | ||
4291d9c8 RS |
3583 | reload_completed = 1; |
3584 | ||
c8ed219d RK |
3585 | /* Do a very simple CSE pass over just the hard registers. */ |
3586 | if (optimize > 0) | |
3587 | reload_cse_regs (insns); | |
3588 | ||
bdac5f58 TW |
3589 | /* On some machines, the prologue and epilogue code, or parts thereof, |
3590 | can be represented as RTL. Doing so lets us schedule insns between | |
3591 | it and the rest of the code and also allows delayed branch | |
3592 | scheduling to operate in the epilogue. */ | |
3593 | ||
3594 | thread_prologue_and_epilogue_insns (insns); | |
3595 | ||
4291d9c8 RS |
3596 | if (optimize > 0 && flag_schedule_insns_after_reload) |
3597 | { | |
3598 | if (sched2_dump) | |
3599 | TIMEVAR (dump_time, | |
3600 | { | |
3601 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3602 | (*decl_printable_name) (decl, 2)); |
4291d9c8 RS |
3603 | }); |
3604 | ||
3605 | /* Do control and data sched analysis again, | |
3606 | and write some more of the results to dump file. */ | |
3607 | ||
3608 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
3609 | ||
3610 | /* Dump rtl after post-reorder instruction scheduling. */ | |
3611 | ||
3612 | if (sched2_dump) | |
3613 | TIMEVAR (dump_time, | |
3614 | { | |
3e28fe44 | 3615 | print_rtl_with_bb (sched2_dump_file, insns); |
4291d9c8 RS |
3616 | fflush (sched2_dump_file); |
3617 | }); | |
3618 | } | |
3619 | ||
3620 | #ifdef LEAF_REGISTERS | |
3621 | leaf_function = 0; | |
3622 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
ab40ad2b | 3623 | leaf_function = 1; |
4291d9c8 RS |
3624 | #endif |
3625 | ||
3626 | /* One more attempt to remove jumps to .+1 | |
3627 | left by dead-store-elimination. | |
3628 | Also do cross-jumping this time | |
3629 | and delete no-op move insns. */ | |
3630 | ||
3631 | if (optimize > 0) | |
3632 | { | |
3633 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
3634 | } | |
3635 | ||
3636 | /* Dump rtl code after jump, if we are doing that. */ | |
3637 | ||
3638 | if (jump2_opt_dump) | |
3639 | TIMEVAR (dump_time, | |
3640 | { | |
3641 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3642 | (*decl_printable_name) (decl, 2)); |
3e28fe44 | 3643 | print_rtl_with_bb (jump2_opt_dump_file, insns); |
4291d9c8 RS |
3644 | fflush (jump2_opt_dump_file); |
3645 | }); | |
3646 | ||
2c65021a RK |
3647 | /* If a machine dependent reorganization is needed, call it. */ |
3648 | #ifdef MACHINE_DEPENDENT_REORG | |
3649 | MACHINE_DEPENDENT_REORG (insns); | |
3650 | #endif | |
3651 | ||
4291d9c8 | 3652 | /* If a scheduling pass for delayed branches is to be done, |
0f41302f | 3653 | call the scheduling code. */ |
4291d9c8 RS |
3654 | |
3655 | #ifdef DELAY_SLOTS | |
3656 | if (optimize > 0 && flag_delayed_branch) | |
3657 | { | |
3658 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
3659 | if (dbr_sched_dump) | |
3660 | { | |
3661 | TIMEVAR (dump_time, | |
3662 | { | |
3663 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3664 | (*decl_printable_name) (decl, 2)); |
3e28fe44 | 3665 | print_rtl_with_bb (dbr_sched_dump_file, insns); |
4291d9c8 RS |
3666 | fflush (dbr_sched_dump_file); |
3667 | }); | |
3668 | } | |
3669 | } | |
3670 | #endif | |
3671 | ||
d0c874f6 TG |
3672 | /* Shorten branches. */ |
3673 | TIMEVAR (shorten_branch_time, | |
3674 | { | |
3675 | shorten_branches (get_insns ()); | |
3676 | }); | |
4291d9c8 RS |
3677 | |
3678 | #ifdef STACK_REGS | |
3679 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
3680 | if (stack_reg_dump) | |
3681 | { | |
3682 | TIMEVAR (dump_time, | |
3683 | { | |
3684 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
2f8844a8 | 3685 | (*decl_printable_name) (decl, 2)); |
3e28fe44 | 3686 | print_rtl_with_bb (stack_reg_dump_file, insns); |
4291d9c8 RS |
3687 | fflush (stack_reg_dump_file); |
3688 | }); | |
3689 | } | |
3690 | #endif | |
3691 | ||
3692 | /* Now turn the rtl into assembler code. */ | |
3693 | ||
3694 | TIMEVAR (final_time, | |
3695 | { | |
3696 | rtx x; | |
3697 | char *fnname; | |
3698 | ||
3699 | /* Get the function's name, as described by its RTL. | |
3700 | This may be different from the DECL_NAME name used | |
3701 | in the source file. */ | |
3702 | ||
3703 | x = DECL_RTL (decl); | |
3704 | if (GET_CODE (x) != MEM) | |
3705 | abort (); | |
3706 | x = XEXP (x, 0); | |
3707 | if (GET_CODE (x) != SYMBOL_REF) | |
3708 | abort (); | |
3709 | fnname = XSTR (x, 0); | |
3710 | ||
3711 | assemble_start_function (decl, fnname); | |
3712 | final_start_function (insns, asm_out_file, optimize); | |
3713 | final (insns, asm_out_file, optimize, 0); | |
3714 | final_end_function (insns, asm_out_file, optimize); | |
3715 | assemble_end_function (decl, fnname); | |
3716 | fflush (asm_out_file); | |
9ddca353 RK |
3717 | |
3718 | /* Release all memory held by regsets now */ | |
3719 | regset_release_memory (); | |
4291d9c8 RS |
3720 | }); |
3721 | ||
3722 | /* Write DBX symbols if requested */ | |
3723 | ||
3724 | /* Note that for those inline functions where we don't initially | |
3725 | know for certain that we will be generating an out-of-line copy, | |
3726 | the first invocation of this routine (rest_of_compilation) will | |
3727 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
3728 | Later on, finish_compilation will call rest_of_compilation again | |
3729 | for those inline functions that need to have out-of-line copies | |
3730 | generated. During that call, we *will* be routed past here. */ | |
3731 | ||
3732 | #ifdef DBX_DEBUGGING_INFO | |
3733 | if (write_symbols == DBX_DEBUG) | |
3734 | TIMEVAR (symout_time, dbxout_function (decl)); | |
3735 | #endif | |
3736 | ||
3737 | #ifdef DWARF_DEBUGGING_INFO | |
3738 | if (write_symbols == DWARF_DEBUG) | |
3739 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3740 | #endif | |
3741 | ||
9a666dda JM |
3742 | #ifdef DWARF2_DEBUGGING_INFO |
3743 | if (write_symbols == DWARF2_DEBUG) | |
88dad228 | 3744 | TIMEVAR (symout_time, dwarf2out_decl (decl)); |
9a666dda JM |
3745 | #endif |
3746 | ||
4291d9c8 RS |
3747 | exit_rest_of_compilation: |
3748 | ||
f246a305 RS |
3749 | /* In case the function was not output, |
3750 | don't leave any temporary anonymous types | |
3751 | queued up for sdb output. */ | |
3752 | #ifdef SDB_DEBUGGING_INFO | |
3753 | if (write_symbols == SDB_DEBUG) | |
37366632 | 3754 | sdbout_types (NULL_TREE); |
f246a305 RS |
3755 | #endif |
3756 | ||
8a958768 RS |
3757 | /* Put back the tree of subblocks and list of arguments |
3758 | from before we copied them. | |
4291d9c8 RS |
3759 | Code generation and the output of debugging info may have modified |
3760 | the copy, but the original is unchanged. */ | |
3761 | ||
3762 | if (saved_block_tree != 0) | |
fb19c456 JM |
3763 | { |
3764 | DECL_INITIAL (decl) = saved_block_tree; | |
3765 | DECL_ARGUMENTS (decl) = saved_arguments; | |
3766 | DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
3767 | } | |
4291d9c8 RS |
3768 | |
3769 | reload_completed = 0; | |
3770 | ||
9fe320d7 RK |
3771 | /* Clear out the insn_length contents now that they are no longer valid. */ |
3772 | init_insn_lengths (); | |
3773 | ||
4291d9c8 RS |
3774 | /* Clear out the real_constant_chain before some of the rtx's |
3775 | it runs through become garbage. */ | |
3776 | ||
3777 | clear_const_double_mem (); | |
3778 | ||
3779 | /* Cancel the effect of rtl_in_current_obstack. */ | |
3780 | ||
3781 | resume_temporary_allocation (); | |
3782 | ||
adcd38c9 RK |
3783 | /* Show no temporary slots allocated. */ |
3784 | ||
3785 | init_temp_slots (); | |
3786 | ||
4291d9c8 RS |
3787 | /* The parsing time is all the time spent in yyparse |
3788 | *except* what is spent in this function. */ | |
3789 | ||
3790 | parse_time -= get_run_time () - start_time; | |
3791 | } | |
3792 | \f | |
3793 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
3794 | Exit code is 35 if can't open files, 34 if fatal error, | |
3795 | 33 if had nonfatal errors, else success. */ | |
3796 | ||
3797 | int | |
3798 | main (argc, argv, envp) | |
3799 | int argc; | |
3800 | char **argv; | |
3801 | char **envp; | |
3802 | { | |
3803 | register int i; | |
3804 | char *filename = 0; | |
3805 | int flag_print_mem = 0; | |
3806 | int version_flag = 0; | |
3807 | char *p; | |
3808 | ||
3809 | /* save in case md file wants to emit args as a comment. */ | |
3810 | save_argc = argc; | |
3811 | save_argv = argv; | |
3812 | ||
3813 | p = argv[0] + strlen (argv[0]); | |
128373ac RK |
3814 | while (p != argv[0] && p[-1] != '/' |
3815 | #ifdef DIR_SEPARATOR | |
3816 | && p[-1] != DIR_SEPARATOR | |
3817 | #endif | |
3818 | ) | |
3819 | --p; | |
4291d9c8 RS |
3820 | progname = p; |
3821 | ||
3822 | #ifdef RLIMIT_STACK | |
3823 | /* Get rid of any avoidable limit on stack size. */ | |
3824 | { | |
3825 | struct rlimit rlim; | |
3826 | ||
0f41302f | 3827 | /* Set the stack limit huge so that alloca does not fail. */ |
4291d9c8 RS |
3828 | getrlimit (RLIMIT_STACK, &rlim); |
3829 | rlim.rlim_cur = rlim.rlim_max; | |
3830 | setrlimit (RLIMIT_STACK, &rlim); | |
3831 | } | |
3832 | #endif /* RLIMIT_STACK */ | |
3833 | ||
3834 | signal (SIGFPE, float_signal); | |
3835 | ||
935d4b07 | 3836 | #ifdef SIGPIPE |
4291d9c8 | 3837 | signal (SIGPIPE, pipe_closed); |
935d4b07 | 3838 | #endif |
4291d9c8 RS |
3839 | |
3840 | decl_printable_name = decl_name; | |
3841 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
3842 | ||
3843 | /* Initialize whether `char' is signed. */ | |
3844 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
3845 | #ifdef DEFAULT_SHORT_ENUMS | |
3846 | /* Initialize how much space enums occupy, by default. */ | |
3847 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
3848 | #endif | |
3849 | ||
3850 | /* Scan to see what optimization level has been specified. That will | |
3851 | determine the default value of many flags. */ | |
3852 | for (i = 1; i < argc; i++) | |
3853 | { | |
3854 | if (!strcmp (argv[i], "-O")) | |
3855 | { | |
3856 | optimize = 1; | |
3857 | } | |
3858 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
3859 | { | |
3860 | /* Handle -O2, -O3, -O69, ... */ | |
3861 | char *p = &argv[i][2]; | |
3862 | int c; | |
3863 | ||
3864 | while (c = *p++) | |
3865 | if (! (c >= '0' && c <= '9')) | |
3866 | break; | |
3867 | if (c == 0) | |
3868 | optimize = atoi (&argv[i][2]); | |
3869 | } | |
3870 | } | |
3871 | ||
3872 | obey_regdecls = (optimize == 0); | |
4291d9c8 RS |
3873 | |
3874 | if (optimize >= 1) | |
3875 | { | |
6731a3e3 | 3876 | flag_defer_pop = 1; |
4291d9c8 RS |
3877 | flag_thread_jumps = 1; |
3878 | #ifdef DELAY_SLOTS | |
3879 | flag_delayed_branch = 1; | |
7e89c3a3 RK |
3880 | #endif |
3881 | #ifdef CAN_DEBUG_WITHOUT_FP | |
3882 | flag_omit_frame_pointer = 1; | |
4291d9c8 | 3883 | #endif |
9ae8ffe7 | 3884 | flag_alias_check = 1; |
4291d9c8 RS |
3885 | } |
3886 | ||
3887 | if (optimize >= 2) | |
3888 | { | |
3889 | flag_cse_follow_jumps = 1; | |
8b3686ed | 3890 | flag_cse_skip_blocks = 1; |
4291d9c8 RS |
3891 | flag_expensive_optimizations = 1; |
3892 | flag_strength_reduce = 1; | |
3893 | flag_rerun_cse_after_loop = 1; | |
6d6d0fa0 | 3894 | flag_rerun_loop_opt = 1; |
ac266247 | 3895 | flag_caller_saves = 1; |
4ac8e06e | 3896 | flag_force_mem = 1; |
4291d9c8 RS |
3897 | #ifdef INSN_SCHEDULING |
3898 | flag_schedule_insns = 1; | |
3899 | flag_schedule_insns_after_reload = 1; | |
3900 | #endif | |
8c660648 | 3901 | flag_regmove = 1; |
4291d9c8 RS |
3902 | } |
3903 | ||
7e89c3a3 RK |
3904 | if (optimize >= 3) |
3905 | { | |
3906 | flag_inline_functions = 1; | |
3907 | } | |
3908 | ||
c1da383f DE |
3909 | /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can |
3910 | modify it. */ | |
3911 | target_flags = 0; | |
3912 | set_target_switch (""); | |
3913 | ||
4291d9c8 RS |
3914 | #ifdef OPTIMIZATION_OPTIONS |
3915 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
3916 | OPTIMIZATION_OPTIONS (optimize); | |
3917 | #endif | |
3918 | ||
3919 | /* Initialize register usage now so switches may override. */ | |
3920 | init_reg_sets (); | |
3921 | ||
4291d9c8 RS |
3922 | for (i = 1; i < argc; i++) |
3923 | { | |
b99933c7 RS |
3924 | int j; |
3925 | /* If this is a language-specific option, | |
3926 | decode it in a language-specific way. */ | |
3927 | for (j = 0; lang_options[j] != 0; j++) | |
7e6c0864 RK |
3928 | if (!strncmp (argv[i], lang_options[j], |
3929 | strlen (lang_options[j]))) | |
b99933c7 RS |
3930 | break; |
3931 | if (lang_options[j] != 0) | |
3932 | /* If the option is valid for *some* language, | |
3933 | treat it as valid even if this language doesn't understand it. */ | |
3934 | lang_decode_option (argv[i]); | |
3935 | else if (argv[i][0] == '-' && argv[i][1] != 0) | |
4291d9c8 RS |
3936 | { |
3937 | register char *str = argv[i] + 1; | |
3938 | if (str[0] == 'Y') | |
3939 | str++; | |
3940 | ||
3941 | if (str[0] == 'm') | |
3942 | set_target_switch (&str[1]); | |
3943 | else if (!strcmp (str, "dumpbase")) | |
3944 | { | |
3945 | dump_base_name = argv[++i]; | |
3946 | } | |
3947 | else if (str[0] == 'd') | |
3948 | { | |
3949 | register char *p = &str[1]; | |
3950 | while (*p) | |
3951 | switch (*p++) | |
3952 | { | |
3953 | case 'a': | |
0d332add | 3954 | branch_prob_dump = 1; |
4291d9c8 RS |
3955 | combine_dump = 1; |
3956 | dbr_sched_dump = 1; | |
3957 | flow_dump = 1; | |
3958 | global_reg_dump = 1; | |
3959 | jump_opt_dump = 1; | |
e9a25f70 | 3960 | addressof_dump = 1; |
4291d9c8 RS |
3961 | jump2_opt_dump = 1; |
3962 | local_reg_dump = 1; | |
3963 | loop_dump = 1; | |
8c660648 | 3964 | regmove_dump = 1; |
4291d9c8 RS |
3965 | rtl_dump = 1; |
3966 | cse_dump = 1, cse2_dump = 1; | |
3967 | sched_dump = 1; | |
3968 | sched2_dump = 1; | |
3969 | stack_reg_dump = 1; | |
3970 | break; | |
0d332add DE |
3971 | case 'b': |
3972 | branch_prob_dump = 1; | |
3973 | break; | |
4291d9c8 RS |
3974 | case 'k': |
3975 | stack_reg_dump = 1; | |
3976 | break; | |
3977 | case 'c': | |
3978 | combine_dump = 1; | |
3979 | break; | |
3980 | case 'd': | |
3981 | dbr_sched_dump = 1; | |
3982 | break; | |
3983 | case 'f': | |
3984 | flow_dump = 1; | |
3985 | break; | |
3986 | case 'g': | |
3987 | global_reg_dump = 1; | |
3988 | break; | |
3989 | case 'j': | |
3990 | jump_opt_dump = 1; | |
3991 | break; | |
e9a25f70 JL |
3992 | case 'D': |
3993 | addressof_dump = 1; | |
3994 | break; | |
4291d9c8 RS |
3995 | case 'J': |
3996 | jump2_opt_dump = 1; | |
3997 | break; | |
3998 | case 'l': | |
3999 | local_reg_dump = 1; | |
4000 | break; | |
4001 | case 'L': | |
4002 | loop_dump = 1; | |
4003 | break; | |
4004 | case 'm': | |
4005 | flag_print_mem = 1; | |
4006 | break; | |
4007 | case 'p': | |
4008 | flag_print_asm_name = 1; | |
4009 | break; | |
4010 | case 'r': | |
4011 | rtl_dump = 1; | |
4012 | break; | |
4013 | case 's': | |
4014 | cse_dump = 1; | |
4015 | break; | |
4016 | case 't': | |
4017 | cse2_dump = 1; | |
4018 | break; | |
8c660648 JL |
4019 | case 'N': |
4020 | regmove_dump = 1; | |
4021 | break; | |
4291d9c8 RS |
4022 | case 'S': |
4023 | sched_dump = 1; | |
4024 | break; | |
4025 | case 'R': | |
4026 | sched2_dump = 1; | |
4027 | break; | |
4028 | case 'y': | |
4029 | set_yydebug (1); | |
4030 | break; | |
4291d9c8 RS |
4031 | case 'x': |
4032 | rtl_dump_and_exit = 1; | |
4033 | break; | |
3d5cdd42 DE |
4034 | case 'A': |
4035 | flag_debug_asm = 1; | |
4036 | break; | |
4291d9c8 RS |
4037 | } |
4038 | } | |
4039 | else if (str[0] == 'f') | |
4040 | { | |
4291d9c8 RS |
4041 | register char *p = &str[1]; |
4042 | int found = 0; | |
4043 | ||
4044 | /* Some kind of -f option. | |
4045 | P's value is the option sans `-f'. | |
4046 | Search for it in the table of options. */ | |
4047 | ||
4048 | for (j = 0; | |
4049 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
4050 | j++) | |
4051 | { | |
4052 | if (!strcmp (p, f_options[j].string)) | |
4053 | { | |
4054 | *f_options[j].variable = f_options[j].on_value; | |
4055 | /* A goto here would be cleaner, | |
4056 | but breaks the vax pcc. */ | |
4057 | found = 1; | |
4058 | } | |
4059 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4060 | && ! strcmp (p+3, f_options[j].string)) | |
4061 | { | |
4062 | *f_options[j].variable = ! f_options[j].on_value; | |
4063 | found = 1; | |
4064 | } | |
4065 | } | |
4066 | ||
4067 | if (found) | |
4068 | ; | |
8c660648 JL |
4069 | #ifdef HAIFA |
4070 | #ifdef INSN_SCHEDULING | |
4071 | else if (!strncmp (p, "sched-verbose-",14)) | |
4072 | fix_sched_param("verbose",&p[14]); | |
4073 | else if (!strncmp (p, "sched-max-",10)) | |
4074 | fix_sched_param("max",&p[10]); | |
4075 | else if (!strncmp (p, "sched-inter-max-b-",18)) | |
4076 | fix_sched_param("interblock-max-blocks",&p[18]); | |
4077 | else if (!strncmp (p, "sched-inter-max-i-",18)) | |
4078 | fix_sched_param("interblock-max-insns",&p[18]); | |
4079 | #endif | |
4080 | #endif /* HAIFA */ | |
4291d9c8 RS |
4081 | else if (!strncmp (p, "fixed-", 6)) |
4082 | fix_register (&p[6], 1, 1); | |
4083 | else if (!strncmp (p, "call-used-", 10)) | |
4084 | fix_register (&p[10], 0, 1); | |
4085 | else if (!strncmp (p, "call-saved-", 11)) | |
4086 | fix_register (&p[11], 0, 0); | |
b99933c7 | 4087 | else |
4291d9c8 RS |
4088 | error ("Invalid option `%s'", argv[i]); |
4089 | } | |
4090 | else if (str[0] == 'O') | |
4091 | { | |
4092 | register char *p = str+1; | |
4093 | while (*p && *p >= '0' && *p <= '9') | |
4094 | p++; | |
4095 | if (*p == '\0') | |
4096 | ; | |
4097 | else | |
4098 | error ("Invalid option `%s'", argv[i]); | |
4099 | } | |
4100 | else if (!strcmp (str, "pedantic")) | |
4101 | pedantic = 1; | |
4102 | else if (!strcmp (str, "pedantic-errors")) | |
4103 | flag_pedantic_errors = pedantic = 1; | |
4291d9c8 RS |
4104 | else if (!strcmp (str, "quiet")) |
4105 | quiet_flag = 1; | |
4106 | else if (!strcmp (str, "version")) | |
4107 | version_flag = 1; | |
4108 | else if (!strcmp (str, "w")) | |
4109 | inhibit_warnings = 1; | |
4110 | else if (!strcmp (str, "W")) | |
4111 | { | |
4112 | extra_warnings = 1; | |
fa1a4543 RS |
4113 | /* We save the value of warn_uninitialized, since if they put |
4114 | -Wuninitialized on the command line, we need to generate a | |
4115 | warning about not using it without also specifying -O. */ | |
4116 | if (warn_uninitialized != 1) | |
4117 | warn_uninitialized = 2; | |
4291d9c8 RS |
4118 | } |
4119 | else if (str[0] == 'W') | |
4120 | { | |
4291d9c8 RS |
4121 | register char *p = &str[1]; |
4122 | int found = 0; | |
4123 | ||
4124 | /* Some kind of -W option. | |
4125 | P's value is the option sans `-W'. | |
4126 | Search for it in the table of options. */ | |
4127 | ||
4128 | for (j = 0; | |
4129 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
4130 | j++) | |
4131 | { | |
4132 | if (!strcmp (p, W_options[j].string)) | |
4133 | { | |
4134 | *W_options[j].variable = W_options[j].on_value; | |
4135 | /* A goto here would be cleaner, | |
4136 | but breaks the vax pcc. */ | |
4137 | found = 1; | |
4138 | } | |
4139 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4140 | && ! strcmp (p+3, W_options[j].string)) | |
4141 | { | |
4142 | *W_options[j].variable = ! W_options[j].on_value; | |
4143 | found = 1; | |
4144 | } | |
4145 | } | |
4146 | ||
4147 | if (found) | |
4148 | ; | |
4149 | else if (!strncmp (p, "id-clash-", 9)) | |
4150 | { | |
4151 | char *endp = p + 9; | |
4152 | ||
4153 | while (*endp) | |
4154 | { | |
4155 | if (*endp >= '0' && *endp <= '9') | |
4156 | endp++; | |
4157 | else | |
7085b873 RS |
4158 | { |
4159 | error ("Invalid option `%s'", argv[i]); | |
4160 | goto id_clash_lose; | |
4161 | } | |
4291d9c8 RS |
4162 | } |
4163 | warn_id_clash = 1; | |
4164 | id_clash_len = atoi (str + 10); | |
7085b873 | 4165 | id_clash_lose: ; |
4291d9c8 | 4166 | } |
b51e9c62 RK |
4167 | else if (!strncmp (p, "larger-than-", 12)) |
4168 | { | |
4169 | char *endp = p + 12; | |
4170 | ||
4171 | while (*endp) | |
4172 | { | |
4173 | if (*endp >= '0' && *endp <= '9') | |
4174 | endp++; | |
4175 | else | |
4176 | { | |
4177 | error ("Invalid option `%s'", argv[i]); | |
4178 | goto larger_than_lose; | |
4179 | } | |
4180 | } | |
4181 | warn_larger_than = 1; | |
4182 | larger_than_size = atoi (str + 13); | |
4183 | larger_than_lose: ; | |
4184 | } | |
4291d9c8 RS |
4185 | else |
4186 | error ("Invalid option `%s'", argv[i]); | |
4187 | } | |
4188 | else if (!strcmp (str, "p")) | |
ca695ac9 | 4189 | { |
c2d12c8b | 4190 | profile_flag = 1; |
ca695ac9 | 4191 | } |
4291d9c8 RS |
4192 | else if (!strcmp (str, "a")) |
4193 | { | |
4194 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4195 | warning ("`-a' option (basic block profile) not supported"); | |
4196 | #else | |
ec6c615d RK |
4197 | profile_block_flag = (profile_block_flag < 2) ? 1 : 3; |
4198 | #endif | |
4199 | } | |
4200 | else if (!strcmp (str, "ax")) | |
4201 | { | |
4202 | #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4203 | warning ("`-ax' option (jump profiling) not supported"); | |
4204 | #else | |
4205 | profile_block_flag = (!profile_block_flag | |
4206 | || profile_block_flag == 2) ? 2 : 3; | |
4291d9c8 RS |
4207 | #endif |
4208 | } | |
4209 | else if (str[0] == 'g') | |
4210 | { | |
4291d9c8 RS |
4211 | unsigned len; |
4212 | unsigned level; | |
ff482cef DE |
4213 | /* A lot of code assumes write_symbols == NO_DEBUG if the |
4214 | debugging level is 0 (thus -gstabs1 -gstabs0 would lose track | |
4215 | of what debugging type has been selected). This records the | |
4216 | selected type. It is an error to specify more than one | |
4217 | debugging type. */ | |
4218 | static enum debug_info_type selected_debug_type = NO_DEBUG; | |
4219 | /* Non-zero if debugging format has been explicitly set. | |
4220 | -g and -ggdb don't explicitly set the debugging format so | |
4221 | -gdwarf -g3 is equivalent to -gdwarf3. */ | |
4222 | static int type_explicitly_set_p = 0; | |
4223 | /* Table of supported debugging formats. */ | |
4224 | static struct { | |
4225 | char *arg; | |
4226 | /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a | |
4227 | constant expression, we use NO_DEBUG in its place. */ | |
4228 | enum debug_info_type debug_type; | |
4229 | int use_extensions_p; | |
4230 | } *da, debug_args[] = { | |
4231 | { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS }, | |
4232 | { "ggdb", NO_DEBUG, 1 }, | |
4233 | #ifdef DBX_DEBUGGING_INFO | |
4234 | { "gstabs", DBX_DEBUG, 0 }, | |
4235 | { "gstabs+", DBX_DEBUG, 1 }, | |
4236 | #endif | |
4237 | #ifdef DWARF_DEBUGGING_INFO | |
4238 | { "gdwarf", DWARF_DEBUG, 0 }, | |
4239 | { "gdwarf+", DWARF_DEBUG, 1 }, | |
9a666dda | 4240 | #endif |
a94dbf2c JM |
4241 | #ifdef DWARF2_DEBUGGING_INFO |
4242 | { "gdwarf-2", DWARF2_DEBUG, 0 }, | |
ff482cef DE |
4243 | #endif |
4244 | #ifdef XCOFF_DEBUGGING_INFO | |
4245 | { "gxcoff", XCOFF_DEBUG, 0 }, | |
4246 | { "gxcoff+", XCOFF_DEBUG, 1 }, | |
4247 | #endif | |
4248 | #ifdef SDB_DEBUGGING_INFO | |
4249 | { "gcoff", SDB_DEBUG, 0 }, | |
4250 | #endif | |
4251 | { 0, 0, 0 } | |
4252 | }; | |
4253 | /* Indexed by enum debug_info_type. */ | |
4254 | static char *debug_type_names[] = { | |
9a666dda | 4255 | "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff" |
ff482cef | 4256 | }; |
4291d9c8 | 4257 | |
ff482cef DE |
4258 | /* Look up STR in the table. */ |
4259 | for (da = debug_args; da->arg; da++) | |
4260 | { | |
9a666dda | 4261 | if (! strncmp (str, da->arg, strlen (da->arg))) |
ff482cef DE |
4262 | { |
4263 | enum debug_info_type type = da->debug_type; | |
9a666dda JM |
4264 | char *p, *q; |
4265 | ||
4266 | p = str + strlen (da->arg); | |
4267 | if (*p && (*p < '0' || *p > '9')) | |
4268 | continue; | |
5d38efae | 4269 | len = p - str; |
e9a25f70 | 4270 | q = p; |
9a666dda JM |
4271 | while (*q && (*q >= '0' && *q <= '9')) |
4272 | q++; | |
4273 | if (*p) | |
33e5c8c3 JM |
4274 | { |
4275 | level = atoi (p); | |
4276 | if (len > 1 && !strncmp (str, "gdwarf", len)) | |
4277 | { | |
4278 | error ("use -gdwarf -g%d for DWARF v1, level %d", | |
4279 | level, level); | |
4280 | if (level == 2) | |
4281 | error ("use -gdwarf-2 for DWARF v2"); | |
4282 | } | |
4283 | } | |
9a666dda JM |
4284 | else |
4285 | level = 2; /* default debugging info level */ | |
4286 | if (*q || level > 3) | |
4287 | { | |
4288 | warning ("invalid debug level specification in option: `-%s'", | |
4289 | str); | |
4290 | /* ??? This error message is incorrect in the case of | |
4291 | -g4 -g. */ | |
4292 | warning ("no debugging information will be generated"); | |
4293 | level = 0; | |
4294 | } | |
4295 | ||
ff482cef | 4296 | if (type == NO_DEBUG) |
fe0986b4 JM |
4297 | { |
4298 | type = PREFERRED_DEBUGGING_TYPE; | |
4299 | if (len > 1 && strncmp (str, "ggdb", len) == 0) | |
4300 | { | |
4301 | #ifdef DWARF2_DEBUGGING_INFO | |
4302 | type = DWARF2_DEBUG; | |
417b0fa2 JW |
4303 | #else |
4304 | #ifdef DBX_DEBUGGING_INFO | |
fe0986b4 | 4305 | type = DBX_DEBUG; |
417b0fa2 | 4306 | #endif |
fe0986b4 JM |
4307 | #endif |
4308 | } | |
4309 | } | |
ff482cef | 4310 | |
e38eaffd RK |
4311 | if (type == NO_DEBUG) |
4312 | warning ("`-%s' not supported by this configuration of GCC", | |
4313 | str); | |
4314 | ||
ff482cef DE |
4315 | /* Does it conflict with an already selected type? */ |
4316 | if (type_explicitly_set_p | |
4317 | /* -g/-ggdb don't conflict with anything */ | |
4318 | && da->debug_type != NO_DEBUG | |
4319 | && type != selected_debug_type) | |
4320 | warning ("`-%s' ignored, conflicts with `-g%s'", | |
4321 | str, debug_type_names[(int) selected_debug_type]); | |
4322 | else | |
4323 | { | |
4324 | /* If the format has already been set, -g/-ggdb | |
4325 | only change the debug level. */ | |
4326 | if (type_explicitly_set_p | |
4327 | && da->debug_type == NO_DEBUG) | |
4328 | ; /* don't change debugging type */ | |
4329 | else | |
4330 | { | |
4331 | selected_debug_type = type; | |
4332 | type_explicitly_set_p = da->debug_type != NO_DEBUG; | |
4333 | } | |
4334 | write_symbols = (level == 0 | |
4335 | ? NO_DEBUG | |
4336 | : selected_debug_type); | |
4337 | use_gnu_debug_info_extensions = da->use_extensions_p; | |
4338 | debug_info_level = (enum debug_info_level) level; | |
4339 | } | |
4340 | break; | |
4341 | } | |
4342 | } | |
4343 | if (! da->arg) | |
7276e85d RK |
4344 | warning ("`-%s' not supported by this configuration of GCC", |
4345 | str); | |
4291d9c8 RS |
4346 | } |
4347 | else if (!strcmp (str, "o")) | |
4348 | { | |
4349 | asm_file_name = argv[++i]; | |
4350 | } | |
4351 | else if (str[0] == 'G') | |
4352 | { | |
4353 | g_switch_set = TRUE; | |
4354 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
4355 | } | |
f246a305 RS |
4356 | else if (!strncmp (str, "aux-info", 8)) |
4357 | { | |
4358 | flag_gen_aux_info = 1; | |
4359 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
4360 | } | |
4291d9c8 RS |
4361 | else |
4362 | error ("Invalid option `%s'", argv[i]); | |
4363 | } | |
4364 | else if (argv[i][0] == '+') | |
b99933c7 | 4365 | error ("Invalid option `%s'", argv[i]); |
4291d9c8 RS |
4366 | else |
4367 | filename = argv[i]; | |
4368 | } | |
4369 | ||
f602c208 RK |
4370 | /* Checker uses the frame pointer. */ |
4371 | if (flag_check_memory_usage) | |
4372 | flag_omit_frame_pointer = 0; | |
4373 | ||
ca695ac9 | 4374 | /* Initialize for bytecode output. A good idea to do this as soon as |
0f41302f | 4375 | possible after the "-f" options have been parsed. */ |
ca695ac9 JB |
4376 | if (output_bytecode) |
4377 | { | |
4378 | #ifndef TARGET_SUPPORTS_BYTECODE | |
4379 | /* Just die with a fatal error if not supported */ | |
40e6003c | 4380 | fatal ("-fbytecode not supported for this target"); |
ca695ac9 JB |
4381 | #else |
4382 | bc_initialize (); | |
4383 | #endif | |
4384 | } | |
4385 | ||
f246a305 RS |
4386 | if (optimize == 0) |
4387 | { | |
a2468e45 BK |
4388 | /* Inlining does not work if not optimizing, |
4389 | so force it not to be done. */ | |
f246a305 RS |
4390 | flag_no_inline = 1; |
4391 | warn_inline = 0; | |
a2468e45 BK |
4392 | |
4393 | /* The c_decode_option and lang_decode_option functions set | |
4394 | this to `2' if -Wall is used, so we can avoid giving out | |
4395 | lots of errors for people who don't realize what -Wall does. */ | |
4396 | if (warn_uninitialized == 1) | |
4397 | warning ("-Wuninitialized is not supported without -O"); | |
f246a305 RS |
4398 | } |
4399 | ||
4291d9c8 RS |
4400 | #ifdef OVERRIDE_OPTIONS |
4401 | /* Some machines may reject certain combinations of options. */ | |
4402 | OVERRIDE_OPTIONS; | |
4403 | #endif | |
4404 | ||
d1485032 JM |
4405 | if (exceptions_via_longjmp == 2) |
4406 | { | |
4407 | #ifdef DWARF2_UNWIND_INFO | |
4408 | exceptions_via_longjmp = ! DWARF2_UNWIND_INFO; | |
4409 | #else | |
4410 | exceptions_via_longjmp = 1; | |
4411 | #endif | |
4412 | } | |
4413 | ||
ec6c615d RK |
4414 | if (profile_block_flag == 3) |
4415 | { | |
4416 | warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); | |
4417 | profile_block_flag = 2; | |
4418 | } | |
4419 | ||
4291d9c8 RS |
4420 | /* Unrolling all loops implies that standard loop unrolling must also |
4421 | be done. */ | |
4422 | if (flag_unroll_all_loops) | |
4423 | flag_unroll_loops = 1; | |
4424 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
4425 | turn on strength reduction here if it isn't already on. Also, the loop | |
4426 | unrolling code assumes that cse will be run after loop, so that must | |
4427 | be turned on also. */ | |
4428 | if (flag_unroll_loops) | |
4429 | { | |
4430 | flag_strength_reduce = 1; | |
4431 | flag_rerun_cse_after_loop = 1; | |
4432 | } | |
4433 | ||
4434 | /* Warn about options that are not supported on this machine. */ | |
4435 | #ifndef INSN_SCHEDULING | |
4436 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
4437 | warning ("instruction scheduling not supported on this target machine"); | |
4438 | #endif | |
4439 | #ifndef DELAY_SLOTS | |
4440 | if (flag_delayed_branch) | |
4441 | warning ("this target machine does not have delayed branches"); | |
4442 | #endif | |
4443 | ||
4444 | /* If we are in verbose mode, write out the version and maybe all the | |
4445 | option flags in use. */ | |
4446 | if (version_flag) | |
4447 | { | |
3d5cdd42 | 4448 | print_version (stderr, ""); |
4291d9c8 | 4449 | if (! quiet_flag) |
3d5cdd42 | 4450 | print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n"); |
4291d9c8 RS |
4451 | } |
4452 | ||
4291d9c8 RS |
4453 | compile_file (filename); |
4454 | ||
876ac40d | 4455 | #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__)) |
4291d9c8 RS |
4456 | if (flag_print_mem) |
4457 | { | |
4458 | char *lim = (char *) sbrk (0); | |
4459 | ||
4460 | fprintf (stderr, "Data size %d.\n", | |
b61b1c91 | 4461 | lim - (char *) &environ); |
4291d9c8 RS |
4462 | fflush (stderr); |
4463 | ||
e9a25f70 | 4464 | #ifndef __MSDOS__ |
4291d9c8 RS |
4465 | #ifdef USG |
4466 | system ("ps -l 1>&2"); | |
4467 | #else /* not USG */ | |
4468 | system ("ps v"); | |
4469 | #endif /* not USG */ | |
e9a25f70 | 4470 | #endif |
4291d9c8 | 4471 | } |
876ac40d | 4472 | #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */ |
4291d9c8 RS |
4473 | |
4474 | if (errorcount) | |
4475 | exit (FATAL_EXIT_CODE); | |
4476 | if (sorrycount) | |
4477 | exit (FATAL_EXIT_CODE); | |
4478 | exit (SUCCESS_EXIT_CODE); | |
299846f2 | 4479 | return 0; |
4291d9c8 RS |
4480 | } |
4481 | \f | |
4482 | /* Decode -m switches. */ | |
4483 | ||
4484 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
4485 | and which bits in `target_switches' it should set or clear. | |
4486 | If VALUE is positive, it is bits to set. | |
4487 | If VALUE is negative, -VALUE is bits to clear. | |
4488 | (The sign bit is not used so there is no confusion.) */ | |
4489 | ||
4490 | struct {char *name; int value;} target_switches [] | |
4491 | = TARGET_SWITCHES; | |
4492 | ||
4493 | /* This table is similar, but allows the switch to have a value. */ | |
4494 | ||
4495 | #ifdef TARGET_OPTIONS | |
4496 | struct {char *prefix; char ** variable;} target_options [] | |
4497 | = TARGET_OPTIONS; | |
4498 | #endif | |
4499 | ||
4500 | /* Decode the switch -mNAME. */ | |
4501 | ||
4502 | void | |
4503 | set_target_switch (name) | |
4504 | char *name; | |
4505 | { | |
4506 | register int j; | |
4507 | int valid = 0; | |
4508 | ||
4509 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
4510 | if (!strcmp (target_switches[j].name, name)) | |
4511 | { | |
4512 | if (target_switches[j].value < 0) | |
4513 | target_flags &= ~-target_switches[j].value; | |
4514 | else | |
4515 | target_flags |= target_switches[j].value; | |
4516 | valid = 1; | |
4517 | } | |
4518 | ||
4519 | #ifdef TARGET_OPTIONS | |
4520 | if (!valid) | |
4521 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4522 | { | |
4523 | int len = strlen (target_options[j].prefix); | |
4524 | if (!strncmp (target_options[j].prefix, name, len)) | |
4525 | { | |
4526 | *target_options[j].variable = name + len; | |
4527 | valid = 1; | |
4528 | } | |
4529 | } | |
4530 | #endif | |
4531 | ||
4532 | if (!valid) | |
4533 | error ("Invalid option `%s'", name); | |
4534 | } | |
4535 | \f | |
3d5cdd42 DE |
4536 | /* Print version information to FILE. |
4537 | Each line begins with INDENT (for the case where FILE is the | |
4538 | assembler output file). */ | |
4291d9c8 | 4539 | |
3d5cdd42 DE |
4540 | void |
4541 | print_version (file, indent) | |
4542 | FILE *file; | |
4543 | char *indent; | |
4291d9c8 | 4544 | { |
3d5cdd42 DE |
4545 | fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "", |
4546 | language_string, version_string); | |
4547 | fprintf (file, " (%s)", TARGET_NAME); | |
4548 | #ifdef __GNUC__ | |
4549 | #ifndef __VERSION__ | |
4550 | #define __VERSION__ "[unknown]" | |
4551 | #endif | |
4552 | fprintf (file, " compiled by GNU C version %s.\n", __VERSION__); | |
4553 | #else | |
4554 | fprintf (file, " compiled by CC.\n"); | |
4555 | #endif | |
4556 | } | |
4291d9c8 | 4557 | |
3d5cdd42 | 4558 | /* Print an option value and return the adjusted position in the line. |
309a8875 DE |
4559 | ??? We don't handle error returns from fprintf (disk full); presumably |
4560 | other code will catch a disk full though. */ | |
4291d9c8 | 4561 | |
3d5cdd42 DE |
4562 | int |
4563 | print_single_switch (file, pos, max, indent, sep, term, type, name) | |
4564 | FILE *file; | |
4565 | int pos, max; | |
4566 | char *indent, *sep, *term, *type, *name; | |
4567 | { | |
309a8875 DE |
4568 | /* The ultrix fprintf returns 0 on success, so compute the result we want |
4569 | here since we need it for the following test. */ | |
4570 | int len = strlen (sep) + strlen (type) + strlen (name); | |
4571 | ||
3d5cdd42 | 4572 | if (pos != 0 |
309a8875 | 4573 | && pos + len > max) |
4291d9c8 | 4574 | { |
3d5cdd42 DE |
4575 | fprintf (file, "%s", term); |
4576 | pos = 0; | |
4291d9c8 | 4577 | } |
3d5cdd42 DE |
4578 | if (pos == 0) |
4579 | { | |
309a8875 DE |
4580 | fprintf (file, "%s", indent); |
4581 | pos = strlen (indent); | |
3d5cdd42 | 4582 | } |
309a8875 DE |
4583 | fprintf (file, "%s%s%s", sep, type, name); |
4584 | pos += len; | |
3d5cdd42 | 4585 | return pos; |
4291d9c8 RS |
4586 | } |
4587 | ||
3d5cdd42 DE |
4588 | /* Print active target switches to FILE. |
4589 | POS is the current cursor position and MAX is the size of a "line". | |
4590 | Each line begins with INDENT and ends with TERM. | |
4591 | Each switch is separated from the next by SEP. */ | |
4291d9c8 | 4592 | |
3d5cdd42 DE |
4593 | void |
4594 | print_switch_values (file, pos, max, indent, sep, term) | |
4595 | FILE *file; | |
4596 | int pos, max; | |
4597 | char *indent, *sep, *term; | |
4291d9c8 | 4598 | { |
3d5cdd42 DE |
4599 | int j, flags; |
4600 | char **p; | |
4601 | ||
4602 | /* Print the options as passed. */ | |
4291d9c8 | 4603 | |
3d5cdd42 DE |
4604 | pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term, |
4605 | "options passed: ", ""); | |
4606 | ||
520e7ff5 | 4607 | for (p = &save_argv[1]; *p != NULL; p++) |
3d5cdd42 DE |
4608 | if (**p == '-') |
4609 | { | |
4610 | /* Ignore these. */ | |
520e7ff5 DE |
4611 | if (strcmp (*p, "-o") == 0) |
4612 | { | |
4613 | if (p[1] != NULL) | |
4614 | p++; | |
4615 | continue; | |
4616 | } | |
3d5cdd42 DE |
4617 | if (strcmp (*p, "-quiet") == 0) |
4618 | continue; | |
4619 | if (strcmp (*p, "-version") == 0) | |
4620 | continue; | |
4621 | if ((*p)[1] == 'd') | |
4622 | continue; | |
4623 | ||
4624 | pos = print_single_switch (file, pos, max, indent, sep, term, *p, ""); | |
4625 | } | |
4626 | if (pos > 0) | |
4627 | fprintf (file, "%s", term); | |
4628 | ||
4629 | /* Print the -f and -m options that have been enabled. | |
4630 | We don't handle language specific options but printing argv | |
4631 | should suffice. */ | |
4632 | ||
4633 | pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, | |
4634 | "options enabled: ", ""); | |
4291d9c8 RS |
4635 | |
4636 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
4637 | if (*f_options[j].variable == f_options[j].on_value) | |
3d5cdd42 DE |
4638 | pos = print_single_switch (file, pos, max, indent, sep, term, |
4639 | "-f", f_options[j].string); | |
4291d9c8 | 4640 | |
3d5cdd42 | 4641 | /* Print target specific options. */ |
4291d9c8 | 4642 | |
3d5cdd42 | 4643 | flags = target_flags; |
4291d9c8 RS |
4644 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) |
4645 | if (target_switches[j].name[0] != '\0' | |
4646 | && target_switches[j].value > 0 | |
4647 | && ((target_switches[j].value & target_flags) | |
4648 | == target_switches[j].value)) | |
3d5cdd42 DE |
4649 | { |
4650 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4651 | "-m", target_switches[j].name); | |
4652 | flags &= ~ target_switches[j].value; | |
4653 | } | |
4654 | ||
4655 | #ifdef TARGET_OPTIONS | |
4656 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4657 | if (*target_options[j].variable != NULL) | |
4658 | { | |
4659 | char prefix[256]; | |
4660 | sprintf (prefix, "-m%s", target_options[j].prefix); | |
4661 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4662 | prefix, *target_options[j].variable); | |
4663 | } | |
4664 | #endif | |
4291d9c8 | 4665 | |
3d5cdd42 | 4666 | fprintf (file, "%s", term); |
4291d9c8 | 4667 | } |
9a666dda JM |
4668 | |
4669 | /* Record the beginning of a new source file, named FILENAME. */ | |
4670 | ||
4671 | void | |
4672 | debug_start_source_file (filename) | |
4673 | register char *filename; | |
4674 | { | |
4675 | #ifdef DBX_DEBUGGING_INFO | |
4676 | if (write_symbols == DBX_DEBUG) | |
4677 | dbxout_start_new_source_file (filename); | |
4678 | #endif | |
4679 | #ifdef DWARF_DEBUGGING_INFO | |
4680 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4681 | && write_symbols == DWARF_DEBUG) | |
4682 | dwarfout_start_new_source_file (filename); | |
4683 | #endif /* DWARF_DEBUGGING_INFO */ | |
4684 | #ifdef DWARF2_DEBUGGING_INFO | |
4685 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4686 | && write_symbols == DWARF2_DEBUG) | |
4687 | dwarf2out_start_source_file (filename); | |
4688 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
4689 | #ifdef SDB_DEBUGGING_INFO |
4690 | if (write_symbols == SDB_DEBUG) | |
4691 | sdbout_start_new_source_file (filename); | |
4692 | #endif | |
9a666dda JM |
4693 | } |
4694 | ||
4695 | /* Record the resumption of a source file. LINENO is the line number in | |
4696 | the source file we are returning to. */ | |
4697 | ||
4698 | void | |
4699 | debug_end_source_file (lineno) | |
4700 | register unsigned lineno; | |
4701 | { | |
4702 | #ifdef DBX_DEBUGGING_INFO | |
4703 | if (write_symbols == DBX_DEBUG) | |
4704 | dbxout_resume_previous_source_file (); | |
4705 | #endif | |
4706 | #ifdef DWARF_DEBUGGING_INFO | |
4707 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4708 | && write_symbols == DWARF_DEBUG) | |
4709 | dwarfout_resume_previous_source_file (lineno); | |
4710 | #endif /* DWARF_DEBUGGING_INFO */ | |
4711 | #ifdef DWARF2_DEBUGGING_INFO | |
4712 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4713 | && write_symbols == DWARF2_DEBUG) | |
4714 | dwarf2out_end_source_file (); | |
4715 | #endif /* DWARF2_DEBUGGING_INFO */ | |
cc694a81 DE |
4716 | #ifdef SDB_DEBUGGING_INFO |
4717 | if (write_symbols == SDB_DEBUG) | |
4718 | sdbout_resume_previous_source_file (); | |
4719 | #endif | |
9a666dda JM |
4720 | } |
4721 | ||
4722 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4723 | the tail part of the directive line, i.e. the part which is past the | |
4724 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4725 | ||
4726 | void | |
4727 | debug_define (lineno, buffer) | |
4728 | register unsigned lineno; | |
4729 | register char *buffer; | |
4730 | { | |
4731 | #ifdef DWARF_DEBUGGING_INFO | |
4732 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4733 | && write_symbols == DWARF_DEBUG) | |
4734 | dwarfout_define (lineno, buffer); | |
4735 | #endif /* DWARF_DEBUGGING_INFO */ | |
4736 | #ifdef DWARF2_DEBUGGING_INFO | |
4737 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4738 | && write_symbols == DWARF2_DEBUG) | |
4739 | dwarf2out_define (lineno, buffer); | |
4740 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4741 | } | |
4742 | ||
4743 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4744 | the tail part of the directive line, i.e. the part which is past the | |
4745 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4746 | ||
4747 | void | |
4748 | debug_undef (lineno, buffer) | |
4749 | register unsigned lineno; | |
4750 | register char *buffer; | |
4751 | { | |
4752 | #ifdef DWARF_DEBUGGING_INFO | |
4753 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4754 | && write_symbols == DWARF_DEBUG) | |
4755 | dwarfout_undef (lineno, buffer); | |
4756 | #endif /* DWARF_DEBUGGING_INFO */ | |
4757 | #ifdef DWARF2_DEBUGGING_INFO | |
4758 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4759 | && write_symbols == DWARF2_DEBUG) | |
4760 | dwarf2out_undef (lineno, buffer); | |
4761 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4762 | } |