]>
Commit | Line | Data |
---|---|---|
1 | /* Top level of GNU C compiler | |
2 | Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc. | |
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 | |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
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" | |
27 | #ifdef __STDC__ | |
28 | #include <stdarg.h> | |
29 | #else | |
30 | #include <varargs.h> | |
31 | #endif | |
32 | #include <stdio.h> | |
33 | #include <signal.h> | |
34 | #include <setjmp.h> | |
35 | #include <sys/types.h> | |
36 | #include <ctype.h> | |
37 | #include <sys/stat.h> | |
38 | #undef FLOAT | |
39 | #ifdef HAVE_SYS_PARAM_H | |
40 | #include <sys/param.h> | |
41 | #endif | |
42 | ||
43 | #undef FLOAT /* This is for hpux. They should change hpux. */ | |
44 | #undef FFS /* Some systems define this in param.h. */ | |
45 | ||
46 | #ifdef TIME_WITH_SYS_TIME | |
47 | # include <sys/time.h> | |
48 | # include <time.h> | |
49 | #else | |
50 | # if HAVE_SYS_TIME_H | |
51 | # include <sys/time.h> | |
52 | # else | |
53 | # include <time.h> | |
54 | #endif | |
55 | #endif | |
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> | |
63 | #endif | |
64 | ||
65 | #include "input.h" | |
66 | #include "tree.h" | |
67 | #include "rtl.h" | |
68 | #include "flags.h" | |
69 | #include "insn-attr.h" | |
70 | #include "defaults.h" | |
71 | #include "output.h" | |
72 | #include "bytecode.h" | |
73 | #include "bc-emit.h" | |
74 | #include "except.h" | |
75 | ||
76 | #ifdef XCOFF_DEBUGGING_INFO | |
77 | #include "xcoffout.h" | |
78 | #endif | |
79 | \f | |
80 | #ifdef VMS | |
81 | /* The extra parameters substantially improve the I/O performance. */ | |
82 | static FILE * | |
83 | vms_fopen (fname, type) | |
84 | char * fname; | |
85 | char * type; | |
86 | { | |
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"); | |
97 | } | |
98 | #define fopen vms_fopen | |
99 | #endif /* VMS */ | |
100 | ||
101 | #ifndef DEFAULT_GDB_EXTENSIONS | |
102 | #define DEFAULT_GDB_EXTENSIONS 1 | |
103 | #endif | |
104 | ||
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. */ | |
109 | #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) | |
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 | |
124 | #ifdef DWARF2_DEBUGGING_INFO | |
125 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG | |
126 | #endif | |
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 | ||
138 | extern int rtx_equal_function_value_matters; | |
139 | ||
140 | #if ! (defined (VMS) || defined (OS2)) | |
141 | extern char **environ; | |
142 | #endif | |
143 | extern char *version_string, *language_string; | |
144 | ||
145 | /* Carry information from ASM_DECLARE_OBJECT_NAME | |
146 | to ASM_FINISH_DECLARE_OBJECT. */ | |
147 | ||
148 | extern int size_directive_output; | |
149 | extern tree last_assemble_variable_decl; | |
150 | ||
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 (); | |
156 | extern void init_regs (); | |
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 (); | |
163 | extern void regset_release_memory (); | |
164 | ||
165 | void rest_of_decl_compilation (); | |
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, ...)); | |
180 | void fancy_abort (); | |
181 | #ifndef abort | |
182 | void abort (); | |
183 | #endif | |
184 | void set_target_switch (); | |
185 | static char *decl_name (); | |
186 | ||
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 | ||
193 | #ifdef __alpha | |
194 | extern char *sbrk (); | |
195 | #endif | |
196 | ||
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 | ||
216 | #if !USE_CPPLIB | |
217 | /* Stream for reading from the input file. */ | |
218 | FILE *finput; | |
219 | #endif | |
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; | |
251 | int addressof_dump = 0; | |
252 | int cse_dump = 0; | |
253 | int loop_dump = 0; | |
254 | int cse2_dump = 0; | |
255 | int branch_prob_dump = 0; | |
256 | int flow_dump = 0; | |
257 | int combine_dump = 0; | |
258 | int regmove_dump = 0; | |
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 | ||
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; | |
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 | ||
306 | /* Flag to output bytecode instead of native assembler */ | |
307 | int output_bytecode = 0; | |
308 | ||
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++. */ | |
316 | ||
317 | char *(*decl_printable_name) (/* tree decl, int verbosity */); | |
318 | ||
319 | /* Pointer to function to compute rtl for a language-specific tree code. */ | |
320 | ||
321 | struct rtx_def *(*lang_expand_expr) (); | |
322 | ||
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 | ||
328 | /* Highest label number used at the end of reload. */ | |
329 | ||
330 | int max_label_num_after_reload; | |
331 | ||
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 | ||
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 | ||
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 | ||
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 | ||
401 | /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ | |
402 | ||
403 | int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; | |
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 | ||
418 | int flag_defer_pop = 0; | |
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 | ||
430 | /* Nonzero for -fcse-skip-blocks: | |
431 | have cse follow a branch around a block. */ | |
432 | int flag_cse_skip_blocks; | |
433 | ||
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 | ||
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 | ||
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 | ||
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 | ||
490 | /* Nonzero to inhibit use of define_optimization peephole opts. */ | |
491 | ||
492 | int flag_no_peephole = 0; | |
493 | ||
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 | |
497 | faster code for sqrt to be generated. */ | |
498 | ||
499 | int flag_fast_math = 0; | |
500 | ||
501 | /* Nonzero means all references through pointers are volatile. */ | |
502 | ||
503 | int flag_volatile; | |
504 | ||
505 | /* Nonzero means treat all global and extern variables as global. */ | |
506 | ||
507 | int flag_volatile_global; | |
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 | ||
518 | /* Nonzero means to run loop optimizations twice. */ | |
519 | ||
520 | int flag_rerun_loop_opt; | |
521 | ||
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 | |
528 | go inline everywhere, keep its definition around for debugging | |
529 | purposes. */ | |
530 | ||
531 | int flag_keep_inline_functions; | |
532 | ||
533 | /* Nonzero means that functions will not be inlined. */ | |
534 | ||
535 | int flag_no_inline; | |
536 | ||
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 | ||
542 | /* Nonzero means we should be saving declaration info into a .X file. */ | |
543 | ||
544 | int flag_gen_aux_info = 0; | |
545 | ||
546 | /* Specified name of aux-info file. */ | |
547 | ||
548 | static char *aux_info_file_name; | |
549 | ||
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 | ||
565 | /* Nonzero means generate extra code for exception handling and enable | |
566 | exception handling. */ | |
567 | ||
568 | int flag_exceptions = 2; | |
569 | ||
570 | /* Nonzero means don't place uninitialized global data in common storage | |
571 | by default. */ | |
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 | ||
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 | ||
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 | ||
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 | |
632 | generated assembly code (perhaps while debugging the compiler itself). | |
633 | -fno-verbose-asm, the default, causes the extra information | |
634 | to be omitted and is useful when comparing two assembler files. */ | |
635 | ||
636 | int flag_verbose_asm = 0; | |
637 | ||
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; | |
646 | ||
647 | /* -fgnu-linker specifies use of the GNU linker for initializations. | |
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 | |
653 | int flag_gnu_linker = 1; | |
654 | #endif | |
655 | ||
656 | /* Tag all structures with __attribute__(packed) */ | |
657 | int flag_pack_struct = 0; | |
658 | ||
659 | /* Emit code to check for stack overflow; also may cause large objects | |
660 | to be allocated dynamically. */ | |
661 | int flag_stack_check; | |
662 | ||
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 | ||
673 | int flag_regmove = 0; | |
674 | ||
675 | /* 0 if pointer arguments may alias each other. True in C. | |
676 | 1 if pointer arguments may not alias each other but may alias | |
677 | global variables. | |
678 | 2 if pointer arguments may not alias each other and may not | |
679 | alias global variables. True in Fortran. | |
680 | This defaults to 0 for C. */ | |
681 | int flag_argument_noalias = 0; | |
682 | ||
683 | /* Table of language-independent -f options. | |
684 | STRING is the option name. VARIABLE is the address of the variable. | |
685 | ON_VALUE is the value to store in VARIABLE | |
686 | if `-fSTRING' is seen as an option. | |
687 | (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ | |
688 | ||
689 | struct { char *string; int *variable; int on_value;} f_options[] = | |
690 | { | |
691 | {"float-store", &flag_float_store, 1}, | |
692 | {"volatile", &flag_volatile, 1}, | |
693 | {"volatile-global", &flag_volatile_global, 1}, | |
694 | {"defer-pop", &flag_defer_pop, 1}, | |
695 | {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, | |
696 | {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, | |
697 | {"cse-skip-blocks", &flag_cse_skip_blocks, 1}, | |
698 | {"expensive-optimizations", &flag_expensive_optimizations, 1}, | |
699 | {"thread-jumps", &flag_thread_jumps, 1}, | |
700 | {"strength-reduce", &flag_strength_reduce, 1}, | |
701 | {"unroll-loops", &flag_unroll_loops, 1}, | |
702 | {"unroll-all-loops", &flag_unroll_all_loops, 1}, | |
703 | {"move-all-movables", &flag_move_all_movables, 1}, | |
704 | {"reduce-all-givs", &flag_reduce_all_givs, 1}, | |
705 | {"writable-strings", &flag_writable_strings, 1}, | |
706 | {"peephole", &flag_no_peephole, 0}, | |
707 | {"force-mem", &flag_force_mem, 1}, | |
708 | {"force-addr", &flag_force_addr, 1}, | |
709 | {"function-cse", &flag_no_function_cse, 0}, | |
710 | {"inline-functions", &flag_inline_functions, 1}, | |
711 | {"keep-inline-functions", &flag_keep_inline_functions, 1}, | |
712 | {"inline", &flag_no_inline, 0}, | |
713 | {"keep-static-consts", &flag_keep_static_consts, 1}, | |
714 | {"syntax-only", &flag_syntax_only, 1}, | |
715 | {"shared-data", &flag_shared_data, 1}, | |
716 | {"caller-saves", &flag_caller_saves, 1}, | |
717 | {"pcc-struct-return", &flag_pcc_struct_return, 1}, | |
718 | {"reg-struct-return", &flag_pcc_struct_return, 0}, | |
719 | {"delayed-branch", &flag_delayed_branch, 1}, | |
720 | {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1}, | |
721 | {"rerun-loop-opt", &flag_rerun_loop_opt, 1}, | |
722 | {"pretend-float", &flag_pretend_float, 1}, | |
723 | {"schedule-insns", &flag_schedule_insns, 1}, | |
724 | {"schedule-insns2", &flag_schedule_insns_after_reload, 1}, | |
725 | #ifdef HAIFA | |
726 | {"sched-interblock",&flag_schedule_interblock, 1}, | |
727 | {"sched-spec",&flag_schedule_speculative, 1}, | |
728 | {"sched-spec-load",&flag_schedule_speculative_load, 1}, | |
729 | {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1}, | |
730 | {"sched-reverse-S",&flag_schedule_reverse_before_reload, 1}, | |
731 | {"sched-reverse-R",&flag_schedule_reverse_after_reload, 1}, | |
732 | {"branch-count-reg",&flag_branch_on_count_reg, 1}, | |
733 | #endif /* HAIFA */ | |
734 | {"pic", &flag_pic, 1}, | |
735 | {"PIC", &flag_pic, 2}, | |
736 | {"exceptions", &flag_exceptions, 1}, | |
737 | {"sjlj-exceptions", &exceptions_via_longjmp, 1}, | |
738 | {"asynchronous-exceptions", &asynchronous_exceptions, 1}, | |
739 | {"profile-arcs", &profile_arc_flag, 1}, | |
740 | {"test-coverage", &flag_test_coverage, 1}, | |
741 | {"branch-probabilities", &flag_branch_probabilities, 1}, | |
742 | {"fast-math", &flag_fast_math, 1}, | |
743 | {"common", &flag_no_common, 0}, | |
744 | {"inhibit-size-directive", &flag_inhibit_size_directive, 1}, | |
745 | {"function-sections", &flag_function_sections, 1}, | |
746 | {"verbose-asm", &flag_verbose_asm, 1}, | |
747 | {"gnu-linker", &flag_gnu_linker, 1}, | |
748 | {"regmove", &flag_regmove, 1}, | |
749 | {"pack-struct", &flag_pack_struct, 1}, | |
750 | {"stack-check", &flag_stack_check, 1}, | |
751 | {"bytecode", &output_bytecode, 1}, | |
752 | {"argument-alias", &flag_argument_noalias, 0}, | |
753 | {"argument-noalias", &flag_argument_noalias, 1}, | |
754 | {"argument-noalias-global", &flag_argument_noalias, 2}, | |
755 | {"check-memory-usage", &flag_check_memory_usage, 1}, | |
756 | {"prefix-function-name", &flag_prefix_function_name, 1} | |
757 | }; | |
758 | ||
759 | /* Table of language-specific options. */ | |
760 | ||
761 | char *lang_options[] = | |
762 | { | |
763 | "-ansi", | |
764 | "-fallow-single-precision", | |
765 | ||
766 | "-fsigned-bitfields", | |
767 | "-funsigned-bitfields", | |
768 | "-fno-signed-bitfields", | |
769 | "-fno-unsigned-bitfields", | |
770 | "-fsigned-char", | |
771 | "-funsigned-char", | |
772 | "-fno-signed-char", | |
773 | "-fno-unsigned-char", | |
774 | ||
775 | "-ftraditional", | |
776 | "-traditional", | |
777 | "-fnotraditional", | |
778 | "-fno-traditional", | |
779 | ||
780 | "-fasm", | |
781 | "-fno-asm", | |
782 | "-fbuiltin", | |
783 | "-fno-builtin", | |
784 | "-fhosted", | |
785 | "-fno-hosted", | |
786 | "-ffreestanding", | |
787 | "-fno-freestanding", | |
788 | "-fcond-mismatch", | |
789 | "-fno-cond-mismatch", | |
790 | "-fdollars-in-identifiers", | |
791 | "-fno-dollars-in-identifiers", | |
792 | "-fident", | |
793 | "-fno-ident", | |
794 | "-fshort-double", | |
795 | "-fno-short-double", | |
796 | "-fshort-enums", | |
797 | "-fno-short-enums", | |
798 | ||
799 | "-Wall", | |
800 | "-Wbad-function-cast", | |
801 | "-Wno-bad-function-cast", | |
802 | "-Wcast-qual", | |
803 | "-Wno-cast-qual", | |
804 | "-Wchar-subscripts", | |
805 | "-Wno-char-subscripts", | |
806 | "-Wcomment", | |
807 | "-Wno-comment", | |
808 | "-Wcomments", | |
809 | "-Wno-comments", | |
810 | "-Wconversion", | |
811 | "-Wno-conversion", | |
812 | "-Wformat", | |
813 | "-Wno-format", | |
814 | "-Wimport", | |
815 | "-Wno-import", | |
816 | "-Wimplicit-function-declaration", | |
817 | "-Wno-implicit-function-declaration", | |
818 | "-Werror-implicit-function-declaration", | |
819 | "-Wimplicit-int", | |
820 | "-Wno-implicit-int", | |
821 | "-Wimplicit", | |
822 | "-Wno-implicit", | |
823 | "-Wmain", | |
824 | "-Wno-main", | |
825 | "-Wmissing-braces", | |
826 | "-Wno-missing-braces", | |
827 | "-Wmissing-declarations", | |
828 | "-Wno-missing-declarations", | |
829 | "-Wmissing-prototypes", | |
830 | "-Wno-missing-prototypes", | |
831 | "-Wnested-externs", | |
832 | "-Wno-nested-externs", | |
833 | "-Wparentheses", | |
834 | "-Wno-parentheses", | |
835 | "-Wpointer-arith", | |
836 | "-Wno-pointer-arith", | |
837 | "-Wredundant-decls", | |
838 | "-Wno-redundant-decls", | |
839 | "-Wsign-compare", | |
840 | "-Wno-sign-compare", | |
841 | "-Wstrict-prototypes", | |
842 | "-Wno-strict-prototypes", | |
843 | "-Wtraditional", | |
844 | "-Wno-traditional", | |
845 | "-Wtrigraphs", | |
846 | "-Wno-trigraphs", | |
847 | "-Wundef", | |
848 | "-Wno-undef", | |
849 | "-Wwrite-strings", | |
850 | "-Wno-write-strings", | |
851 | ||
852 | /* these are for obj c */ | |
853 | "-lang-objc", | |
854 | "-gen-decls", | |
855 | "-fgnu-runtime", | |
856 | "-fno-gnu-runtime", | |
857 | "-fnext-runtime", | |
858 | "-fno-next-runtime", | |
859 | "-Wselector", | |
860 | "-Wno-selector", | |
861 | "-Wprotocol", | |
862 | "-Wno-protocol", | |
863 | "-print-objc-runtime-info", | |
864 | ||
865 | #include "options.h" | |
866 | 0 | |
867 | }; | |
868 | \f | |
869 | /* Options controlling warnings */ | |
870 | ||
871 | /* Don't print warning messages. -w. */ | |
872 | ||
873 | int inhibit_warnings = 0; | |
874 | ||
875 | /* Print various extra warnings. -W. */ | |
876 | ||
877 | int extra_warnings = 0; | |
878 | ||
879 | /* Treat warnings as errors. -Werror. */ | |
880 | ||
881 | int warnings_are_errors = 0; | |
882 | ||
883 | /* Nonzero to warn about unused local variables. */ | |
884 | ||
885 | int warn_unused; | |
886 | ||
887 | /* Nonzero to warn about variables used before they are initialized. */ | |
888 | ||
889 | int warn_uninitialized; | |
890 | ||
891 | /* Nonzero means warn about all declarations which shadow others. */ | |
892 | ||
893 | int warn_shadow; | |
894 | ||
895 | /* Warn if a switch on an enum fails to have a case for every enum value. */ | |
896 | ||
897 | int warn_switch; | |
898 | ||
899 | /* Nonzero means warn about function definitions that default the return type | |
900 | or that use a null return and have a return-type other than void. */ | |
901 | ||
902 | int warn_return_type; | |
903 | ||
904 | /* Nonzero means warn about pointer casts that increase the required | |
905 | alignment of the target type (and might therefore lead to a crash | |
906 | due to a misaligned access). */ | |
907 | ||
908 | int warn_cast_align; | |
909 | ||
910 | /* Nonzero means warn about any identifiers that match in the first N | |
911 | characters. The value N is in `id_clash_len'. */ | |
912 | ||
913 | int warn_id_clash; | |
914 | unsigned id_clash_len; | |
915 | ||
916 | /* Nonzero means warn about any objects definitions whose size is larger | |
917 | than N bytes. Also want about function definitions whose returned | |
918 | values are larger than N bytes. The value N is in `larger_than_size'. */ | |
919 | ||
920 | int warn_larger_than; | |
921 | unsigned larger_than_size; | |
922 | ||
923 | /* Nonzero means warn if inline function is too large. */ | |
924 | ||
925 | int warn_inline; | |
926 | ||
927 | /* Warn if a function returns an aggregate, | |
928 | since there are often incompatible calling conventions for doing this. */ | |
929 | ||
930 | int warn_aggregate_return; | |
931 | ||
932 | /* Likewise for -W. */ | |
933 | ||
934 | struct { char *string; int *variable; int on_value;} W_options[] = | |
935 | { | |
936 | {"unused", &warn_unused, 1}, | |
937 | {"error", &warnings_are_errors, 1}, | |
938 | {"shadow", &warn_shadow, 1}, | |
939 | {"switch", &warn_switch, 1}, | |
940 | {"aggregate-return", &warn_aggregate_return, 1}, | |
941 | {"cast-align", &warn_cast_align, 1}, | |
942 | {"uninitialized", &warn_uninitialized, 1}, | |
943 | {"inline", &warn_inline, 1} | |
944 | }; | |
945 | \f | |
946 | /* Output files for assembler code (real compiler output) | |
947 | and debugging dumps. */ | |
948 | ||
949 | FILE *asm_out_file; | |
950 | FILE *aux_info_file; | |
951 | FILE *rtl_dump_file; | |
952 | FILE *jump_opt_dump_file; | |
953 | FILE *addressof_dump_file; | |
954 | FILE *cse_dump_file; | |
955 | FILE *loop_dump_file; | |
956 | FILE *cse2_dump_file; | |
957 | FILE *branch_prob_dump_file; | |
958 | FILE *flow_dump_file; | |
959 | FILE *combine_dump_file; | |
960 | FILE *regmove_dump_file; | |
961 | FILE *sched_dump_file; | |
962 | FILE *local_reg_dump_file; | |
963 | FILE *global_reg_dump_file; | |
964 | FILE *sched2_dump_file; | |
965 | FILE *jump2_opt_dump_file; | |
966 | FILE *dbr_sched_dump_file; | |
967 | FILE *stack_reg_dump_file; | |
968 | ||
969 | /* Time accumulators, to count the total time spent in various passes. */ | |
970 | ||
971 | int parse_time; | |
972 | int varconst_time; | |
973 | int integration_time; | |
974 | int jump_time; | |
975 | int cse_time; | |
976 | int loop_time; | |
977 | int cse2_time; | |
978 | int branch_prob_time; | |
979 | int flow_time; | |
980 | int combine_time; | |
981 | int regmove_time; | |
982 | int sched_time; | |
983 | int local_alloc_time; | |
984 | int global_alloc_time; | |
985 | int sched2_time; | |
986 | int dbr_sched_time; | |
987 | int shorten_branch_time; | |
988 | int stack_reg_time; | |
989 | int final_time; | |
990 | int symout_time; | |
991 | int dump_time; | |
992 | \f | |
993 | /* Return time used so far, in microseconds. */ | |
994 | ||
995 | int | |
996 | get_run_time () | |
997 | { | |
998 | #if !defined (_WIN32) || defined (__CYGWIN32__) | |
999 | #ifdef USG | |
1000 | struct tms tms; | |
1001 | #else | |
1002 | #ifndef VMS | |
1003 | struct rusage rusage; | |
1004 | #else | |
1005 | struct | |
1006 | { | |
1007 | int proc_user_time; | |
1008 | int proc_system_time; | |
1009 | int child_user_time; | |
1010 | int child_system_time; | |
1011 | } vms_times; | |
1012 | #endif | |
1013 | #endif | |
1014 | #endif | |
1015 | ||
1016 | if (quiet_flag) | |
1017 | return 0; | |
1018 | #ifdef __BEOS__ | |
1019 | return 0; | |
1020 | #else /* not BeOS */ | |
1021 | #if defined (_WIN32) && !defined (__CYGWIN32__) | |
1022 | if (clock() < 0) | |
1023 | return 0; | |
1024 | else | |
1025 | return (clock() * 1000); | |
1026 | #else /* not _WIN32 */ | |
1027 | #ifdef USG | |
1028 | times (&tms); | |
1029 | return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); | |
1030 | #else | |
1031 | #ifndef VMS | |
1032 | getrusage (0, &rusage); | |
1033 | return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec | |
1034 | + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); | |
1035 | #else /* VMS */ | |
1036 | times ((void *) &vms_times); | |
1037 | return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; | |
1038 | #endif /* VMS */ | |
1039 | #endif /* USG */ | |
1040 | #endif /* _WIN32 */ | |
1041 | #endif /* __BEOS__ */ | |
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); | |
1092 | exit (FATAL_EXIT_CODE); | |
1093 | } | |
1094 | ||
1095 | void | |
1096 | fatal_io_error (name) | |
1097 | char *name; | |
1098 | { | |
1099 | fprintf (stderr, "%s: %s: I/O error\n", progname, name); | |
1100 | exit (FATAL_EXIT_CODE); | |
1101 | } | |
1102 | ||
1103 | /* Called to give a better error message for a bad insn rather than | |
1104 | just calling abort(). */ | |
1105 | ||
1106 | void | |
1107 | fatal_insn (message, insn) | |
1108 | char *message; | |
1109 | rtx insn; | |
1110 | { | |
1111 | if (!output_bytecode) | |
1112 | { | |
1113 | error (message); | |
1114 | debug_rtx (insn); | |
1115 | } | |
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); | |
1124 | if (addressof_dump_file) | |
1125 | fflush (addressof_dump_file); | |
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); | |
1136 | if (regmove_dump_file) | |
1137 | fflush (regmove_dump_file); | |
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); | |
1152 | fflush (stdout); | |
1153 | fflush (stderr); | |
1154 | abort (); | |
1155 | } | |
1156 | ||
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 | ||
1171 | /* This is the default decl_printable_name function. */ | |
1172 | ||
1173 | static char * | |
1174 | decl_name (decl, verbosity) | |
1175 | tree decl; | |
1176 | int verbosity; | |
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 | { | |
1200 | if (rtl_dump_and_exit) | |
1201 | fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); | |
1202 | else | |
1203 | fprintf (stderr, " %s", (*decl_printable_name) (decl, 2)); | |
1204 | fflush (stderr); | |
1205 | need_error_newline = 1; | |
1206 | last_error_function = current_function_decl; | |
1207 | } | |
1208 | } | |
1209 | ||
1210 | /* The default function to print out name of current function that caused | |
1211 | an error. */ | |
1212 | ||
1213 | void | |
1214 | default_print_error_function (file) | |
1215 | char *file; | |
1216 | { | |
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 | { | |
1231 | char *name = (*decl_printable_name) (current_function_decl, 2); | |
1232 | fprintf (stderr, "In %s `%s':\n", kind, name); | |
1233 | } | |
1234 | ||
1235 | last_error_function = current_function_decl; | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | /* Called by report_error_function to print out function name. | |
1240 | * Default may be overridden by language front-ends. */ | |
1241 | ||
1242 | void (*print_error_function) PROTO((char *)) = default_print_error_function; | |
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 | ||
1261 | if (input_file_stack && input_file_stack->next != 0 | |
1262 | && input_file_stack_tick != last_error_tick | |
1263 | && file == input_filename) | |
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) | |
1270 | fprintf (stderr, ",\n "); | |
1271 | } | |
1272 | fprintf (stderr, ":\n"); | |
1273 | last_error_tick = input_file_stack_tick; | |
1274 | } | |
1275 | } | |
1276 | \f | |
1277 | /* Print a message. */ | |
1278 | ||
1279 | static void | |
1280 | vmessage (prefix, s, ap) | |
1281 | char *prefix; | |
1282 | char *s; | |
1283 | va_list ap; | |
1284 | { | |
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); | |
1295 | HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT); | |
1296 | fprintf (stderr, s, v1, v2, v3, v4); | |
1297 | } | |
1298 | #endif | |
1299 | } | |
1300 | ||
1301 | /* Print a message relevant to line LINE of file FILE. */ | |
1302 | ||
1303 | static void | |
1304 | v_message_with_file_and_line (file, line, prefix, s, ap) | |
1305 | char *file; | |
1306 | int line; | |
1307 | char *prefix; | |
1308 | char *s; | |
1309 | va_list ap; | |
1310 | { | |
1311 | if (file) | |
1312 | fprintf (stderr, "%s:%d: ", file, line); | |
1313 | else | |
1314 | fprintf (stderr, "%s: ", progname); | |
1315 | ||
1316 | vmessage (prefix, s, ap); | |
1317 | fputc ('\n', stderr); | |
1318 | } | |
1319 | ||
1320 | /* Print a message relevant to the given DECL. */ | |
1321 | ||
1322 | static void | |
1323 | v_message_with_decl (decl, prefix, s, ap) | |
1324 | tree decl; | |
1325 | char *prefix; | |
1326 | char *s; | |
1327 | va_list ap; | |
1328 | { | |
1329 | char *n, *p; | |
1330 | ||
1331 | fprintf (stderr, "%s:%d: ", | |
1332 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
1333 | ||
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 | ||
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 | } | |
1361 | ||
1362 | if (*p == '%') /* Print the name. */ | |
1363 | { | |
1364 | char *n = (DECL_NAME (decl) | |
1365 | ? (*decl_printable_name) (decl, 2) | |
1366 | : "((anonymous))"); | |
1367 | fputs (n, stderr); | |
1368 | while (*p) | |
1369 | { | |
1370 | ++p; | |
1371 | if (isalpha (*(p - 1) & 0xFF)) | |
1372 | break; | |
1373 | } | |
1374 | } | |
1375 | ||
1376 | if (*p) /* Print the rest of the message. */ | |
1377 | vmessage ((char *)NULL, p, ap); | |
1378 | ||
1379 | fputc ('\n', stderr); | |
1380 | } | |
1381 | ||
1382 | /* Figure file and line of the given INSN. */ | |
1383 | ||
1384 | static void | |
1385 | file_and_line_for_asm (insn, pfile, pline) | |
1386 | rtx insn; | |
1387 | char **pfile; | |
1388 | int *pline; | |
1389 | { | |
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); | |
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 | } | |
1418 | ||
1419 | /* Report an error at line LINE of file FILE. */ | |
1420 | ||
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); | |
1431 | } | |
1432 | ||
1433 | void | |
1434 | error_with_file_and_line VPROTO((char *file, int line, char *s, ...)) | |
1435 | { | |
1436 | #ifndef __STDC__ | |
1437 | char *file; | |
1438 | int line; | |
1439 | char *s; | |
1440 | #endif | |
1441 | va_list ap; | |
1442 | ||
1443 | VA_START (ap, s); | |
1444 | ||
1445 | #ifndef __STDC__ | |
1446 | file = va_arg (ap, char *); | |
1447 | line = va_arg (ap, int); | |
1448 | s = va_arg (ap, char *); | |
1449 | #endif | |
1450 | ||
1451 | v_error_with_file_and_line (file, line, s, ap); | |
1452 | va_end (ap); | |
1453 | } | |
1454 | ||
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 | } | |
1469 | ||
1470 | void | |
1471 | error_with_decl VPROTO((tree decl, char *s, ...)) | |
1472 | { | |
1473 | #ifndef __STDC__ | |
1474 | tree decl; | |
1475 | char *s; | |
1476 | #endif | |
1477 | va_list ap; | |
1478 | ||
1479 | VA_START (ap, s); | |
1480 | ||
1481 | #ifndef __STDC__ | |
1482 | decl = va_arg (ap, tree); | |
1483 | s = va_arg (ap, char *); | |
1484 | #endif | |
1485 | ||
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; | |
1497 | char *s; | |
1498 | va_list ap; | |
1499 | { | |
1500 | char *file; | |
1501 | int line; | |
1502 | ||
1503 | count_error (0); | |
1504 | file_and_line_for_asm (insn, &file, &line); | |
1505 | report_error_function (file); | |
1506 | v_message_with_file_and_line (file, line, (char *)NULL, s, ap); | |
1507 | } | |
1508 | ||
1509 | void | |
1510 | error_for_asm VPROTO((rtx insn, char *s, ...)) | |
1511 | { | |
1512 | #ifndef __STDC__ | |
1513 | rtx insn; | |
1514 | char *s; | |
1515 | #endif | |
1516 | va_list ap; | |
1517 | ||
1518 | VA_START (ap, s); | |
1519 | ||
1520 | #ifndef __STDC__ | |
1521 | insn = va_arg (ap, rtx); | |
1522 | s = va_arg (ap, char *); | |
1523 | #endif | |
1524 | ||
1525 | v_error_for_asm (insn, s, ap); | |
1526 | va_end (ap); | |
1527 | } | |
1528 | ||
1529 | /* Report an error at the current line number. */ | |
1530 | ||
1531 | static void | |
1532 | verror (s, ap) | |
1533 | char *s; | |
1534 | va_list ap; | |
1535 | { | |
1536 | v_error_with_file_and_line (input_filename, lineno, s, ap); | |
1537 | } | |
1538 | ||
1539 | void | |
1540 | error VPROTO((char *s, ...)) | |
1541 | { | |
1542 | #ifndef __STDC__ | |
1543 | char *s; | |
1544 | #endif | |
1545 | va_list ap; | |
1546 | ||
1547 | VA_START (ap, s); | |
1548 | ||
1549 | #ifndef __STDC__ | |
1550 | s = va_arg (ap, char *); | |
1551 | #endif | |
1552 | ||
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); | |
1565 | exit (FATAL_EXIT_CODE); | |
1566 | } | |
1567 | ||
1568 | void | |
1569 | fatal VPROTO((char *s, ...)) | |
1570 | { | |
1571 | #ifndef __STDC__ | |
1572 | char *s; | |
1573 | #endif | |
1574 | va_list ap; | |
1575 | ||
1576 | VA_START (ap, s); | |
1577 | ||
1578 | #ifndef __STDC__ | |
1579 | s = va_arg (ap, char *); | |
1580 | #endif | |
1581 | ||
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; | |
1592 | char *s; | |
1593 | va_list ap; | |
1594 | { | |
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 | } | |
1601 | ||
1602 | void | |
1603 | warning_with_file_and_line VPROTO((char *file, int line, char *s, ...)) | |
1604 | { | |
1605 | #ifndef __STDC__ | |
1606 | char *file; | |
1607 | int line; | |
1608 | char *s; | |
1609 | #endif | |
1610 | va_list ap; | |
1611 | ||
1612 | VA_START (ap, s); | |
1613 | ||
1614 | #ifndef __STDC__ | |
1615 | file = va_arg (ap, char *); | |
1616 | line = va_arg (ap, int); | |
1617 | s = va_arg (ap, char *); | |
1618 | #endif | |
1619 | ||
1620 | v_warning_with_file_and_line (file, line, s, ap); | |
1621 | va_end (ap); | |
1622 | } | |
1623 | ||
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. */ | |
1627 | ||
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 | } | |
1640 | ||
1641 | void | |
1642 | warning_with_decl VPROTO((tree decl, char *s, ...)) | |
1643 | { | |
1644 | #ifndef __STDC__ | |
1645 | tree decl; | |
1646 | char *s; | |
1647 | #endif | |
1648 | va_list ap; | |
1649 | ||
1650 | VA_START (ap, s); | |
1651 | ||
1652 | #ifndef __STDC__ | |
1653 | decl = va_arg (ap, tree); | |
1654 | s = va_arg (ap, char *); | |
1655 | #endif | |
1656 | ||
1657 | v_warning_with_decl (decl, s, ap); | |
1658 | va_end (ap); | |
1659 | } | |
1660 | ||
1661 | /* Report a warning at the line number of the insn INSN. | |
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 | ||
1665 | static void | |
1666 | v_warning_for_asm (insn, s, ap) | |
1667 | rtx insn; | |
1668 | char *s; | |
1669 | va_list ap; | |
1670 | { | |
1671 | if (count_error (1)) | |
1672 | { | |
1673 | char *file; | |
1674 | int line; | |
1675 | ||
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 | } | |
1681 | ||
1682 | void | |
1683 | warning_for_asm VPROTO((rtx insn, char *s, ...)) | |
1684 | { | |
1685 | #ifndef __STDC__ | |
1686 | rtx insn; | |
1687 | char *s; | |
1688 | #endif | |
1689 | va_list ap; | |
1690 | ||
1691 | VA_START (ap, s); | |
1692 | ||
1693 | #ifndef __STDC__ | |
1694 | insn = va_arg (ap, rtx); | |
1695 | s = va_arg (ap, char *); | |
1696 | #endif | |
1697 | ||
1698 | v_warning_for_asm (insn, s, ap); | |
1699 | va_end (ap); | |
1700 | } | |
1701 | ||
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); | |
1710 | } | |
1711 | ||
1712 | void | |
1713 | warning VPROTO((char *s, ...)) | |
1714 | { | |
1715 | #ifndef __STDC__ | |
1716 | char *s; | |
1717 | #endif | |
1718 | va_list ap; | |
1719 | ||
1720 | VA_START (ap, s); | |
1721 | ||
1722 | #ifndef __STDC__ | |
1723 | s = va_arg (ap, char *); | |
1724 | #endif | |
1725 | ||
1726 | vwarning (s, ap); | |
1727 | va_end (ap); | |
1728 | } | |
1729 | ||
1730 | /* These functions issue either warnings or errors depending on | |
1731 | -pedantic-errors. */ | |
1732 | ||
1733 | static void | |
1734 | vpedwarn (s, ap) | |
1735 | char *s; | |
1736 | va_list ap; | |
1737 | { | |
1738 | if (flag_pedantic_errors) | |
1739 | verror (s, ap); | |
1740 | else | |
1741 | vwarning (s, ap); | |
1742 | } | |
1743 | ||
1744 | void | |
1745 | pedwarn VPROTO((char *s, ...)) | |
1746 | { | |
1747 | #ifndef __STDC__ | |
1748 | char *s; | |
1749 | #endif | |
1750 | va_list ap; | |
1751 | ||
1752 | VA_START (ap, s); | |
1753 | ||
1754 | #ifndef __STDC__ | |
1755 | s = va_arg (ap, char *); | |
1756 | #endif | |
1757 | ||
1758 | vpedwarn (s, ap); | |
1759 | va_end (ap); | |
1760 | } | |
1761 | ||
1762 | static void | |
1763 | v_pedwarn_with_decl (decl, s, ap) | |
1764 | tree decl; | |
1765 | char *s; | |
1766 | va_list ap; | |
1767 | { | |
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 | |
1772 | or kernel uses the original layout). There's no point in issuing a | |
1773 | warning either, it's just unnecessary noise. */ | |
1774 | ||
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 | } | |
1782 | } | |
1783 | ||
1784 | void | |
1785 | pedwarn_with_decl VPROTO((tree decl, char *s, ...)) | |
1786 | { | |
1787 | #ifndef __STDC__ | |
1788 | tree decl; | |
1789 | char *s; | |
1790 | #endif | |
1791 | va_list ap; | |
1792 | ||
1793 | VA_START (ap, s); | |
1794 | ||
1795 | #ifndef __STDC__ | |
1796 | decl = va_arg (ap, tree); | |
1797 | s = va_arg (ap, char *); | |
1798 | #endif | |
1799 | ||
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) | |
1806 | char *file; | |
1807 | int line; | |
1808 | char *s; | |
1809 | va_list ap; | |
1810 | { | |
1811 | if (flag_pedantic_errors) | |
1812 | v_error_with_file_and_line (file, line, s, ap); | |
1813 | else | |
1814 | v_warning_with_file_and_line (file, line, s, ap); | |
1815 | } | |
1816 | ||
1817 | void | |
1818 | pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...)) | |
1819 | { | |
1820 | #ifndef __STDC__ | |
1821 | char *file; | |
1822 | int line; | |
1823 | char *s; | |
1824 | #endif | |
1825 | va_list ap; | |
1826 | ||
1827 | VA_START (ap, s); | |
1828 | ||
1829 | #ifndef __STDC__ | |
1830 | file = va_arg (ap, char *); | |
1831 | line = va_arg (ap, int); | |
1832 | s = va_arg (ap, char *); | |
1833 | #endif | |
1834 | ||
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) | |
1843 | char *s; | |
1844 | va_list ap; | |
1845 | { | |
1846 | sorrycount++; | |
1847 | if (input_filename) | |
1848 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1849 | else | |
1850 | fprintf (stderr, "%s: ", progname); | |
1851 | vmessage ("sorry, not implemented", s, ap); | |
1852 | fputc ('\n', stderr); | |
1853 | } | |
1854 | ||
1855 | void | |
1856 | sorry VPROTO((char *s, ...)) | |
1857 | { | |
1858 | #ifndef __STDC__ | |
1859 | char *s; | |
1860 | #endif | |
1861 | va_list ap; | |
1862 | ||
1863 | VA_START (ap, s); | |
1864 | ||
1865 | #ifndef __STDC__ | |
1866 | s = va_arg (ap, char *); | |
1867 | #endif | |
1868 | ||
1869 | vsorry (s, ap); | |
1870 | va_end (ap); | |
1871 | } | |
1872 | ||
1873 | /* Apologize for not implementing some feature, then quit. */ | |
1874 | ||
1875 | static void | |
1876 | v_really_sorry (s, ap) | |
1877 | char *s; | |
1878 | va_list ap; | |
1879 | { | |
1880 | sorrycount++; | |
1881 | if (input_filename) | |
1882 | fprintf (stderr, "%s:%d: ", input_filename, lineno); | |
1883 | else | |
1884 | fprintf (stderr, "%s: ", progname); | |
1885 | vmessage ("sorry, not implemented", s, ap); | |
1886 | fatal (" (fatal)\n"); | |
1887 | } | |
1888 | ||
1889 | void | |
1890 | really_sorry VPROTO((char *s, ...)) | |
1891 | { | |
1892 | #ifndef __STDC__ | |
1893 | char *s; | |
1894 | #endif | |
1895 | va_list ap; | |
1896 | ||
1897 | VA_START (ap, s); | |
1898 | ||
1899 | #ifndef __STDC__ | |
1900 | s = va_arg (ap, char *); | |
1901 | #endif | |
1902 | ||
1903 | v_really_sorry (s, ap); | |
1904 | va_end (ap); | |
1905 | } | |
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 | ||
1941 | char * | |
1942 | xmalloc (size) | |
1943 | unsigned size; | |
1944 | { | |
1945 | register char *value = (char *) malloc (size); | |
1946 | if (value == 0 && size != 0) | |
1947 | fatal ("virtual memory exhausted"); | |
1948 | return value; | |
1949 | } | |
1950 | ||
1951 | /* Same as `realloc' but report error if no memory available. | |
1952 | Also handle null PTR even if the vendor realloc gets it wrong. */ | |
1953 | ||
1954 | char * | |
1955 | xrealloc (ptr, size) | |
1956 | char *ptr; | |
1957 | int size; | |
1958 | { | |
1959 | char *result = (ptr | |
1960 | ? (char *) realloc (ptr, size) | |
1961 | : (char *) malloc (size)); | |
1962 | if (!result) | |
1963 | fatal ("virtual memory exhausted"); | |
1964 | return result; | |
1965 | } | |
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 | } | |
1980 | \f | |
1981 | /* Return the logarithm of X, base 2, considering X unsigned, | |
1982 | if X is a power of 2. Otherwise, returns -1. | |
1983 | ||
1984 | This should be used via the `exact_log2' macro. */ | |
1985 | ||
1986 | int | |
1987 | exact_log2_wide (x) | |
1988 | register unsigned HOST_WIDE_INT x; | |
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. | |
2000 | If X is 0, return -1. | |
2001 | ||
2002 | This should be used via the floor_log2 macro. */ | |
2003 | ||
2004 | int | |
2005 | floor_log2_wide (x) | |
2006 | register unsigned HOST_WIDE_INT x; | |
2007 | { | |
2008 | register int log = -1; | |
2009 | while (x != 0) | |
2010 | log++, | |
2011 | x >>= 1; | |
2012 | return log; | |
2013 | } | |
2014 | ||
2015 | static int float_handler_set; | |
2016 | int float_handled; | |
2017 | jmp_buf float_handler; | |
2018 | ||
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 | ||
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) | |
2045 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
2046 | ||
2047 | if (float_handled && ! float_handler_set) | |
2048 | { | |
2049 | signal (SIGFPE, float_signal); | |
2050 | float_handler_set = 1; | |
2051 | } | |
2052 | } | |
2053 | ||
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) | |
2060 | jmp_buf handler, old_handler; | |
2061 | { | |
2062 | int was_handled = float_handled; | |
2063 | ||
2064 | float_handled = 1; | |
2065 | if (was_handled) | |
2066 | bcopy ((char *) float_handler, (char *) old_handler, | |
2067 | sizeof (float_handler)); | |
2068 | ||
2069 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
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) | |
2083 | bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); | |
2084 | } | |
2085 | ||
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 | |
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. */ | |
2100 | ||
2101 | void | |
2102 | strip_off_ending (name, len) | |
2103 | char *name; | |
2104 | int len; | |
2105 | { | |
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'; | |
2112 | } | |
2113 | ||
2114 | /* Output a quoted string. */ | |
2115 | ||
2116 | void | |
2117 | output_quoted_string (asm_file, string) | |
2118 | FILE *asm_file; | |
2119 | char *string; | |
2120 | { | |
2121 | #ifdef OUTPUT_QUOTED_STRING | |
2122 | OUTPUT_QUOTED_STRING (asm_file, string); | |
2123 | #else | |
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); | |
2134 | #endif | |
2135 | } | |
2136 | ||
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 | |
2161 | fprintf (asm_file, "\t.file\t"); | |
2162 | output_quoted_string (asm_file, na); | |
2163 | fputc ('\n', asm_file); | |
2164 | #endif | |
2165 | #endif | |
2166 | } | |
2167 | \f | |
2168 | /* Routine to build language identifier for object file. */ | |
2169 | ||
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 | ||
2180 | /* Routine to open a dump file. */ | |
2181 | ||
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 | ||
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; | |
2207 | ||
2208 | int name_specified = name != 0; | |
2209 | ||
2210 | if (dump_base_name == 0) | |
2211 | dump_base_name = name ? name : "gccdump"; | |
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; | |
2220 | branch_prob_time = 0; | |
2221 | flow_time = 0; | |
2222 | combine_time = 0; | |
2223 | regmove_time = 0; | |
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 | ||
2235 | #if !USE_CPPLIB | |
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 | ||
2248 | #ifdef IO_BUFFER_SIZE | |
2249 | setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); | |
2250 | #endif | |
2251 | #endif /* !USE_CPPLIB */ | |
2252 | ||
2253 | /* Initialize data in various passes. */ | |
2254 | ||
2255 | init_obstacks (); | |
2256 | init_tree_codes (); | |
2257 | #if USE_CPPLIB | |
2258 | init_parse (name); | |
2259 | #else | |
2260 | init_lex (); | |
2261 | #endif | |
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 */ | |
2264 | init_rtl (); | |
2265 | init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL | |
2266 | || debug_info_level == DINFO_LEVEL_VERBOSE | |
2267 | || flag_test_coverage); | |
2268 | init_regs (); | |
2269 | init_decl_processing (); | |
2270 | init_optabs (); | |
2271 | init_stmt (); | |
2272 | init_expmed (); | |
2273 | init_expr_once (); | |
2274 | init_loop (); | |
2275 | init_reload (); | |
2276 | init_alias_once (); | |
2277 | ||
2278 | if (flag_caller_saves) | |
2279 | init_caller_save (); | |
2280 | ||
2281 | /* If auxiliary info generation is desired, open the output file. | |
2282 | This goes in the same directory as the source file--unlike | |
2283 | all the other output files. */ | |
2284 | if (flag_gen_aux_info) | |
2285 | { | |
2286 | aux_info_file = fopen (aux_info_file_name, "w"); | |
2287 | if (aux_info_file == 0) | |
2288 | pfatal_with_name (aux_info_file_name); | |
2289 | } | |
2290 | ||
2291 | /* If rtl dump desired, open the output file. */ | |
2292 | if (rtl_dump) | |
2293 | rtl_dump_file = open_dump_file (dump_base_name, ".rtl"); | |
2294 | ||
2295 | /* If jump_opt dump desired, open the output file. */ | |
2296 | if (jump_opt_dump) | |
2297 | jump_opt_dump_file = open_dump_file (dump_base_name, ".jump"); | |
2298 | ||
2299 | /* If addressof dump desired, open the output file. */ | |
2300 | if (addressof_dump) | |
2301 | addressof_dump_file = open_dump_file (dump_base_name, ".addressof"); | |
2302 | ||
2303 | /* If cse dump desired, open the output file. */ | |
2304 | if (cse_dump) | |
2305 | cse_dump_file = open_dump_file (dump_base_name, ".cse"); | |
2306 | ||
2307 | /* If loop dump desired, open the output file. */ | |
2308 | if (loop_dump) | |
2309 | loop_dump_file = open_dump_file (dump_base_name, ".loop"); | |
2310 | ||
2311 | /* If cse2 dump desired, open the output file. */ | |
2312 | if (cse2_dump) | |
2313 | cse2_dump_file = open_dump_file (dump_base_name, ".cse2"); | |
2314 | ||
2315 | /* If branch_prob dump desired, open the output file. */ | |
2316 | if (branch_prob_dump) | |
2317 | branch_prob_dump_file = open_dump_file (dump_base_name, ".bp"); | |
2318 | ||
2319 | /* If flow dump desired, open the output file. */ | |
2320 | if (flow_dump) | |
2321 | flow_dump_file = open_dump_file (dump_base_name, ".flow"); | |
2322 | ||
2323 | /* If combine dump desired, open the output file. */ | |
2324 | if (combine_dump) | |
2325 | combine_dump_file = open_dump_file (dump_base_name, ".combine"); | |
2326 | ||
2327 | /* If regmove dump desired, open the output file. */ | |
2328 | if (regmove_dump) | |
2329 | regmove_dump_file = open_dump_file (dump_base_name, ".regmove"); | |
2330 | ||
2331 | /* If scheduling dump desired, open the output file. */ | |
2332 | if (sched_dump) | |
2333 | sched_dump_file = open_dump_file (dump_base_name, ".sched"); | |
2334 | ||
2335 | /* If local_reg dump desired, open the output file. */ | |
2336 | if (local_reg_dump) | |
2337 | local_reg_dump_file = open_dump_file (dump_base_name, ".lreg"); | |
2338 | ||
2339 | /* If global_reg dump desired, open the output file. */ | |
2340 | if (global_reg_dump) | |
2341 | global_reg_dump_file = open_dump_file (dump_base_name, ".greg"); | |
2342 | ||
2343 | /* If 2nd scheduling dump desired, open the output file. */ | |
2344 | if (sched2_dump) | |
2345 | sched2_dump_file = open_dump_file (dump_base_name, ".sched2"); | |
2346 | ||
2347 | /* If jump2_opt dump desired, open the output file. */ | |
2348 | if (jump2_opt_dump) | |
2349 | jump2_opt_dump_file = open_dump_file (dump_base_name, ".jump2"); | |
2350 | ||
2351 | /* If dbr_sched dump desired, open the output file. */ | |
2352 | if (dbr_sched_dump) | |
2353 | dbr_sched_dump_file = open_dump_file (dump_base_name, ".dbr"); | |
2354 | ||
2355 | #ifdef STACK_REGS | |
2356 | ||
2357 | /* If stack_reg dump desired, open the output file. */ | |
2358 | if (stack_reg_dump) | |
2359 | stack_reg_dump_file = open_dump_file (dump_base_name, ".stack"); | |
2360 | ||
2361 | #endif | |
2362 | ||
2363 | /* Open assembler code output file. */ | |
2364 | ||
2365 | if (! name_specified && asm_file_name == 0) | |
2366 | asm_out_file = stdout; | |
2367 | else | |
2368 | { | |
2369 | int len = strlen (dump_base_name); | |
2370 | register char *dumpname = (char *) xmalloc (len + 6); | |
2371 | strcpy (dumpname, dump_base_name); | |
2372 | strip_off_ending (dumpname, len); | |
2373 | strcat (dumpname, ".s"); | |
2374 | if (asm_file_name == 0) | |
2375 | { | |
2376 | asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); | |
2377 | strcpy (asm_file_name, dumpname); | |
2378 | } | |
2379 | if (!strcmp (asm_file_name, "-")) | |
2380 | asm_out_file = stdout; | |
2381 | else | |
2382 | asm_out_file = fopen (asm_file_name, "w"); | |
2383 | if (asm_out_file == 0) | |
2384 | pfatal_with_name (asm_file_name); | |
2385 | } | |
2386 | ||
2387 | #ifdef IO_BUFFER_SIZE | |
2388 | setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), | |
2389 | _IOFBF, IO_BUFFER_SIZE); | |
2390 | #endif | |
2391 | ||
2392 | input_filename = name; | |
2393 | ||
2394 | /* Put an entry on the input file stack for the main input file. */ | |
2395 | input_file_stack | |
2396 | = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2397 | input_file_stack->next = 0; | |
2398 | input_file_stack->name = input_filename; | |
2399 | ||
2400 | /* Gross. Gross. lang_init is (I think) the first callback into | |
2401 | the language front end, and is thus the first opportunity to | |
2402 | have the selected language override the default value for any | |
2403 | -f option. | |
2404 | ||
2405 | So the default value for flag_exceptions is 2 (uninitialized). | |
2406 | If we encounter -fno-exceptions or -fexceptions, then flag_exceptions | |
2407 | will be set to zero or one respectively. | |
2408 | ||
2409 | flag_exceptions can also be set by lang_init to something other | |
2410 | than the default "uninitialized" value of 2. | |
2411 | ||
2412 | After lang_init, if the value is still 2, then we default to | |
2413 | -fno-exceptions (value will be reset to zero). | |
2414 | ||
2415 | When our EH mechanism is low enough overhead that we can enable | |
2416 | it by default for languages other than C++, then all this braindamage | |
2417 | will go away. */ | |
2418 | ||
2419 | /* Perform language-specific initialization. | |
2420 | This may set main_input_filename. */ | |
2421 | lang_init (); | |
2422 | ||
2423 | if (flag_exceptions == 2) | |
2424 | flag_exceptions = 0; | |
2425 | ||
2426 | /* If the input doesn't start with a #line, use the input name | |
2427 | as the official input file name. */ | |
2428 | if (main_input_filename == 0) | |
2429 | main_input_filename = name; | |
2430 | ||
2431 | if (!output_bytecode) | |
2432 | { | |
2433 | ASM_FILE_START (asm_out_file); | |
2434 | ||
2435 | #ifdef ASM_COMMENT_START | |
2436 | if (flag_verbose_asm) | |
2437 | { | |
2438 | /* Print the list of options in effect. */ | |
2439 | print_version (asm_out_file, ASM_COMMENT_START); | |
2440 | print_switch_values (asm_out_file, 0, MAX_LINE, | |
2441 | ASM_COMMENT_START, " ", "\n"); | |
2442 | /* Add a blank line here so it appears in assembler output but not | |
2443 | screen output. */ | |
2444 | fprintf (asm_out_file, "\n"); | |
2445 | } | |
2446 | #endif | |
2447 | } | |
2448 | ||
2449 | /* Output something to inform GDB that this compilation was by GCC. Also | |
2450 | serves to tell GDB file consists of bytecodes. */ | |
2451 | if (output_bytecode) | |
2452 | fprintf (asm_out_file, "bc_gcc2_compiled.:\n"); | |
2453 | else | |
2454 | { | |
2455 | #ifndef ASM_IDENTIFY_GCC | |
2456 | fprintf (asm_out_file, "gcc2_compiled.:\n"); | |
2457 | #else | |
2458 | ASM_IDENTIFY_GCC (asm_out_file); | |
2459 | #endif | |
2460 | } | |
2461 | ||
2462 | /* Output something to identify which front-end produced this file. */ | |
2463 | #ifdef ASM_IDENTIFY_LANGUAGE | |
2464 | ASM_IDENTIFY_LANGUAGE (asm_out_file); | |
2465 | #endif | |
2466 | ||
2467 | #ifndef ASM_OUTPUT_SECTION_NAME | |
2468 | if (flag_function_sections) | |
2469 | { | |
2470 | warning ("-ffunction-sections not supported for this target."); | |
2471 | flag_function_sections = 0; | |
2472 | } | |
2473 | #endif | |
2474 | ||
2475 | if (flag_function_sections | |
2476 | && (profile_flag || profile_block_flag)) | |
2477 | { | |
2478 | warning ("-ffunction-sections disabled; it makes profiling impossible."); | |
2479 | flag_function_sections = 0; | |
2480 | } | |
2481 | ||
2482 | if (flag_function_sections && write_symbols != NO_DEBUG) | |
2483 | warning ("-ffunction-sections may affect debugging on some targets."); | |
2484 | ||
2485 | if (output_bytecode) | |
2486 | { | |
2487 | if (profile_flag || profile_block_flag) | |
2488 | error ("profiling not supported in bytecode compilation"); | |
2489 | } | |
2490 | else | |
2491 | { | |
2492 | /* ??? Note: There used to be a conditional here | |
2493 | to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. | |
2494 | This was to guarantee separation between gcc_compiled. and | |
2495 | the first function, for the sake of dbx on Suns. | |
2496 | However, having the extra zero here confused the Emacs | |
2497 | code for unexec, and might confuse other programs too. | |
2498 | Therefore, I took out that change. | |
2499 | In future versions we should find another way to solve | |
2500 | that dbx problem. -- rms, 23 May 93. */ | |
2501 | ||
2502 | /* Don't let the first function fall at the same address | |
2503 | as gcc_compiled., if profiling. */ | |
2504 | if (profile_flag || profile_block_flag) | |
2505 | assemble_zeros (UNITS_PER_WORD); | |
2506 | } | |
2507 | ||
2508 | /* If dbx symbol table desired, initialize writing it | |
2509 | and output the predefined types. */ | |
2510 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
2511 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2512 | TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, | |
2513 | getdecls ())); | |
2514 | #endif | |
2515 | #ifdef SDB_DEBUGGING_INFO | |
2516 | if (write_symbols == SDB_DEBUG) | |
2517 | TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, | |
2518 | getdecls ())); | |
2519 | #endif | |
2520 | #ifdef DWARF_DEBUGGING_INFO | |
2521 | if (write_symbols == DWARF_DEBUG) | |
2522 | TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); | |
2523 | #endif | |
2524 | #ifdef DWARF2_UNWIND_INFO | |
2525 | if (dwarf2out_do_frame ()) | |
2526 | dwarf2out_frame_init (); | |
2527 | #endif | |
2528 | #ifdef DWARF2_DEBUGGING_INFO | |
2529 | if (write_symbols == DWARF2_DEBUG) | |
2530 | TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename)); | |
2531 | #endif | |
2532 | ||
2533 | /* Initialize yet another pass. */ | |
2534 | ||
2535 | if (!output_bytecode) | |
2536 | init_final (main_input_filename); | |
2537 | init_branch_prob (dump_base_name); | |
2538 | ||
2539 | start_time = get_run_time (); | |
2540 | ||
2541 | /* Call the parser, which parses the entire file | |
2542 | (calling rest_of_compilation for each function). */ | |
2543 | ||
2544 | if (yyparse () != 0) | |
2545 | { | |
2546 | if (errorcount == 0) | |
2547 | fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); | |
2548 | ||
2549 | /* In case there were missing closebraces, | |
2550 | get us back to the global binding level. */ | |
2551 | while (! global_bindings_p ()) | |
2552 | poplevel (0, 0, 0); | |
2553 | } | |
2554 | ||
2555 | output_func_start_profiler (); | |
2556 | ||
2557 | /* Compilation is now finished except for writing | |
2558 | what's left of the symbol table output. */ | |
2559 | ||
2560 | parse_time += get_run_time () - start_time; | |
2561 | ||
2562 | parse_time -= integration_time; | |
2563 | parse_time -= varconst_time; | |
2564 | ||
2565 | globals = getdecls (); | |
2566 | ||
2567 | /* Really define vars that have had only a tentative definition. | |
2568 | Really output inline functions that must actually be callable | |
2569 | and have not been output so far. */ | |
2570 | ||
2571 | { | |
2572 | int len = list_length (globals); | |
2573 | tree *vec = (tree *) alloca (sizeof (tree) * len); | |
2574 | int i; | |
2575 | tree decl; | |
2576 | int reconsider = 1; | |
2577 | ||
2578 | /* Process the decls in reverse order--earliest first. | |
2579 | Put them into VEC from back to front, then take out from front. */ | |
2580 | ||
2581 | for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | |
2582 | vec[len - i - 1] = decl; | |
2583 | ||
2584 | for (i = 0; i < len; i++) | |
2585 | { | |
2586 | decl = vec[i]; | |
2587 | ||
2588 | /* We're not deferring this any longer. */ | |
2589 | DECL_DEFER_OUTPUT (decl) = 0; | |
2590 | ||
2591 | if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 | |
2592 | && incomplete_decl_finalize_hook != 0) | |
2593 | (*incomplete_decl_finalize_hook) (decl); | |
2594 | } | |
2595 | ||
2596 | /* Now emit any global variables or functions that we have been putting | |
2597 | off. We need to loop in case one of the things emitted here | |
2598 | references another one which comes earlier in the list. */ | |
2599 | while (reconsider) | |
2600 | { | |
2601 | reconsider = 0; | |
2602 | for (i = 0; i < len; i++) | |
2603 | { | |
2604 | decl = vec[i]; | |
2605 | ||
2606 | if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) | |
2607 | continue; | |
2608 | ||
2609 | /* Don't write out static consts, unless we still need them. | |
2610 | ||
2611 | We also keep static consts if not optimizing (for debugging), | |
2612 | unless the user specified -fno-keep-static-consts. | |
2613 | ??? They might be better written into the debug information. | |
2614 | This is possible when using DWARF. | |
2615 | ||
2616 | A language processor that wants static constants to be always | |
2617 | written out (even if it is not used) is responsible for | |
2618 | calling rest_of_decl_compilation itself. E.g. the C front-end | |
2619 | calls rest_of_decl_compilation from finish_decl. | |
2620 | One motivation for this is that is conventional in some | |
2621 | environments to write things like: | |
2622 | static const char rcsid[] = "... version string ..."; | |
2623 | intending to force the string to be in the executable. | |
2624 | ||
2625 | A language processor that would prefer to have unneeded | |
2626 | static constants "optimized away" would just defer writing | |
2627 | them out until here. E.g. C++ does this, because static | |
2628 | constants are often defined in header files. | |
2629 | ||
2630 | ??? A tempting alternative (for both C and C++) would be | |
2631 | to force a constant to be written if and only if it is | |
2632 | defined in a main file, as opposed to an include file. */ | |
2633 | ||
2634 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
2635 | && (! TREE_READONLY (decl) | |
2636 | || TREE_PUBLIC (decl) | |
2637 | || (!optimize && flag_keep_static_consts) | |
2638 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) | |
2639 | { | |
2640 | reconsider = 1; | |
2641 | rest_of_decl_compilation (decl, NULL_PTR, 1, 1); | |
2642 | } | |
2643 | ||
2644 | if (TREE_CODE (decl) == FUNCTION_DECL | |
2645 | && DECL_INITIAL (decl) != 0 | |
2646 | && DECL_SAVED_INSNS (decl) != 0 | |
2647 | && (flag_keep_inline_functions | |
2648 | || TREE_PUBLIC (decl) | |
2649 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) | |
2650 | { | |
2651 | reconsider = 1; | |
2652 | temporary_allocation (); | |
2653 | output_inline_function (decl); | |
2654 | permanent_allocation (1); | |
2655 | } | |
2656 | } | |
2657 | } | |
2658 | ||
2659 | /* Now that all possible functions have been output, we can dump | |
2660 | the exception table. */ | |
2661 | ||
2662 | output_exception_table (); | |
2663 | ||
2664 | for (i = 0; i < len; i++) | |
2665 | { | |
2666 | decl = vec[i]; | |
2667 | ||
2668 | if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) | |
2669 | && ! TREE_ASM_WRITTEN (decl)) | |
2670 | /* Cancel the RTL for this decl so that, if debugging info | |
2671 | output for global variables is still to come, | |
2672 | this one will be omitted. */ | |
2673 | DECL_RTL (decl) = NULL; | |
2674 | ||
2675 | /* Warn about any function | |
2676 | declared static but not defined. | |
2677 | We don't warn about variables, | |
2678 | because many programs have static variables | |
2679 | that exist only to get some text into the object file. */ | |
2680 | if (TREE_CODE (decl) == FUNCTION_DECL | |
2681 | && (warn_unused | |
2682 | || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) | |
2683 | && DECL_INITIAL (decl) == 0 | |
2684 | && DECL_EXTERNAL (decl) | |
2685 | && ! DECL_ARTIFICIAL (decl) | |
2686 | && ! TREE_PUBLIC (decl)) | |
2687 | { | |
2688 | pedwarn_with_decl (decl, | |
2689 | "`%s' declared `static' but never defined"); | |
2690 | /* This symbol is effectively an "extern" declaration now. */ | |
2691 | TREE_PUBLIC (decl) = 1; | |
2692 | assemble_external (decl); | |
2693 | } | |
2694 | ||
2695 | /* Warn about static fns or vars defined but not used, | |
2696 | but not about inline functions or static consts | |
2697 | since defining those in header files is normal practice. */ | |
2698 | if (warn_unused | |
2699 | && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) | |
2700 | || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) | |
2701 | && ! DECL_IN_SYSTEM_HEADER (decl) | |
2702 | && ! DECL_EXTERNAL (decl) | |
2703 | && ! TREE_PUBLIC (decl) | |
2704 | && ! TREE_USED (decl) | |
2705 | && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) | |
2706 | /* The TREE_USED bit for file-scope decls | |
2707 | is kept in the identifier, to handle multiple | |
2708 | external decls in different scopes. */ | |
2709 | && ! TREE_USED (DECL_NAME (decl))) | |
2710 | warning_with_decl (decl, "`%s' defined but not used"); | |
2711 | ||
2712 | #ifdef SDB_DEBUGGING_INFO | |
2713 | /* The COFF linker can move initialized global vars to the end. | |
2714 | And that can screw up the symbol ordering. | |
2715 | By putting the symbols in that order to begin with, | |
2716 | we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ | |
2717 | if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL | |
2718 | && TREE_PUBLIC (decl) && DECL_INITIAL (decl) | |
2719 | && ! DECL_EXTERNAL (decl) | |
2720 | && DECL_RTL (decl) != 0) | |
2721 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2722 | ||
2723 | /* Output COFF information for non-global | |
2724 | file-scope initialized variables. */ | |
2725 | if (write_symbols == SDB_DEBUG | |
2726 | && TREE_CODE (decl) == VAR_DECL | |
2727 | && DECL_INITIAL (decl) | |
2728 | && ! DECL_EXTERNAL (decl) | |
2729 | && DECL_RTL (decl) != 0 | |
2730 | && GET_CODE (DECL_RTL (decl)) == MEM) | |
2731 | TIMEVAR (symout_time, sdbout_toplevel_data (decl)); | |
2732 | #endif /* SDB_DEBUGGING_INFO */ | |
2733 | #ifdef DWARF_DEBUGGING_INFO | |
2734 | /* Output DWARF information for file-scope tentative data object | |
2735 | declarations, file-scope (extern) function declarations (which | |
2736 | had no corresponding body) and file-scope tagged type declarations | |
2737 | and definitions which have not yet been forced out. */ | |
2738 | ||
2739 | if (write_symbols == DWARF_DEBUG | |
2740 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
2741 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); | |
2742 | #endif | |
2743 | #ifdef DWARF2_DEBUGGING_INFO | |
2744 | /* Output DWARF2 information for file-scope tentative data object | |
2745 | declarations, file-scope (extern) function declarations (which | |
2746 | had no corresponding body) and file-scope tagged type declarations | |
2747 | and definitions which have not yet been forced out. */ | |
2748 | ||
2749 | if (write_symbols == DWARF2_DEBUG | |
2750 | && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) | |
2751 | TIMEVAR (symout_time, dwarf2out_decl (decl)); | |
2752 | #endif | |
2753 | } | |
2754 | } | |
2755 | ||
2756 | /* Write out any pending weak symbol declarations. */ | |
2757 | ||
2758 | weak_finish (); | |
2759 | ||
2760 | /* Do dbx symbols */ | |
2761 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
2762 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2763 | TIMEVAR (symout_time, | |
2764 | { | |
2765 | dbxout_finish (asm_out_file, main_input_filename); | |
2766 | }); | |
2767 | #endif | |
2768 | ||
2769 | #ifdef DWARF_DEBUGGING_INFO | |
2770 | if (write_symbols == DWARF_DEBUG) | |
2771 | TIMEVAR (symout_time, | |
2772 | { | |
2773 | dwarfout_finish (); | |
2774 | }); | |
2775 | #endif | |
2776 | ||
2777 | #ifdef DWARF2_UNWIND_INFO | |
2778 | if (dwarf2out_do_frame ()) | |
2779 | dwarf2out_frame_finish (); | |
2780 | #endif | |
2781 | ||
2782 | #ifdef DWARF2_DEBUGGING_INFO | |
2783 | if (write_symbols == DWARF2_DEBUG) | |
2784 | TIMEVAR (symout_time, | |
2785 | { | |
2786 | dwarf2out_finish (); | |
2787 | }); | |
2788 | #endif | |
2789 | ||
2790 | /* Output some stuff at end of file if nec. */ | |
2791 | ||
2792 | if (!output_bytecode) | |
2793 | { | |
2794 | end_final (dump_base_name); | |
2795 | end_branch_prob (branch_prob_dump_file); | |
2796 | ||
2797 | #ifdef ASM_FILE_END | |
2798 | ASM_FILE_END (asm_out_file); | |
2799 | #endif | |
2800 | } | |
2801 | ||
2802 | /* Language-specific end of compilation actions. */ | |
2803 | ||
2804 | lang_finish (); | |
2805 | ||
2806 | if (output_bytecode) | |
2807 | bc_write_file (asm_out_file); | |
2808 | ||
2809 | /* Close the dump files. */ | |
2810 | ||
2811 | if (flag_gen_aux_info) | |
2812 | { | |
2813 | fclose (aux_info_file); | |
2814 | if (errorcount) | |
2815 | unlink (aux_info_file_name); | |
2816 | } | |
2817 | ||
2818 | if (rtl_dump) | |
2819 | fclose (rtl_dump_file); | |
2820 | ||
2821 | if (jump_opt_dump) | |
2822 | fclose (jump_opt_dump_file); | |
2823 | ||
2824 | if (addressof_dump) | |
2825 | fclose (addressof_dump_file); | |
2826 | ||
2827 | if (cse_dump) | |
2828 | fclose (cse_dump_file); | |
2829 | ||
2830 | if (loop_dump) | |
2831 | fclose (loop_dump_file); | |
2832 | ||
2833 | if (cse2_dump) | |
2834 | fclose (cse2_dump_file); | |
2835 | ||
2836 | if (branch_prob_dump) | |
2837 | fclose (branch_prob_dump_file); | |
2838 | ||
2839 | if (flow_dump) | |
2840 | fclose (flow_dump_file); | |
2841 | ||
2842 | if (combine_dump) | |
2843 | { | |
2844 | dump_combine_total_stats (combine_dump_file); | |
2845 | fclose (combine_dump_file); | |
2846 | } | |
2847 | ||
2848 | if (regmove_dump) | |
2849 | fclose (regmove_dump_file); | |
2850 | ||
2851 | if (sched_dump) | |
2852 | fclose (sched_dump_file); | |
2853 | ||
2854 | if (local_reg_dump) | |
2855 | fclose (local_reg_dump_file); | |
2856 | ||
2857 | if (global_reg_dump) | |
2858 | fclose (global_reg_dump_file); | |
2859 | ||
2860 | if (sched2_dump) | |
2861 | fclose (sched2_dump_file); | |
2862 | ||
2863 | if (jump2_opt_dump) | |
2864 | fclose (jump2_opt_dump_file); | |
2865 | ||
2866 | if (dbr_sched_dump) | |
2867 | fclose (dbr_sched_dump_file); | |
2868 | ||
2869 | #ifdef STACK_REGS | |
2870 | if (stack_reg_dump) | |
2871 | fclose (stack_reg_dump_file); | |
2872 | #endif | |
2873 | ||
2874 | /* Close non-debugging input and output files. Take special care to note | |
2875 | whether fclose returns an error, since the pages might still be on the | |
2876 | buffer chain while the file is open. */ | |
2877 | ||
2878 | #if USE_CPPLIB | |
2879 | finish_parse (); | |
2880 | #else | |
2881 | fclose (finput); | |
2882 | #endif | |
2883 | if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) | |
2884 | fatal_io_error (asm_file_name); | |
2885 | ||
2886 | /* Print the times. */ | |
2887 | ||
2888 | if (! quiet_flag) | |
2889 | { | |
2890 | fprintf (stderr,"\n"); | |
2891 | print_time ("parse", parse_time); | |
2892 | ||
2893 | if (!output_bytecode) | |
2894 | { | |
2895 | print_time ("integration", integration_time); | |
2896 | print_time ("jump", jump_time); | |
2897 | print_time ("cse", cse_time); | |
2898 | print_time ("loop", loop_time); | |
2899 | print_time ("cse2", cse2_time); | |
2900 | print_time ("branch-prob", branch_prob_time); | |
2901 | print_time ("flow", flow_time); | |
2902 | print_time ("combine", combine_time); | |
2903 | print_time ("regmove", regmove_time); | |
2904 | print_time ("sched", sched_time); | |
2905 | print_time ("local-alloc", local_alloc_time); | |
2906 | print_time ("global-alloc", global_alloc_time); | |
2907 | print_time ("sched2", sched2_time); | |
2908 | print_time ("dbranch", dbr_sched_time); | |
2909 | print_time ("shorten-branch", shorten_branch_time); | |
2910 | print_time ("stack-reg", stack_reg_time); | |
2911 | print_time ("final", final_time); | |
2912 | print_time ("varconst", varconst_time); | |
2913 | print_time ("symout", symout_time); | |
2914 | print_time ("dump", dump_time); | |
2915 | } | |
2916 | } | |
2917 | } | |
2918 | \f | |
2919 | /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
2920 | and TYPE_DECL nodes. | |
2921 | ||
2922 | This does nothing for local (non-static) variables. | |
2923 | Otherwise, it sets up the RTL and outputs any assembler code | |
2924 | (label definition, storage allocation and initialization). | |
2925 | ||
2926 | DECL is the declaration. If ASMSPEC is nonzero, it specifies | |
2927 | the assembler symbol name to be used. TOP_LEVEL is nonzero | |
2928 | if this declaration is not within a function. */ | |
2929 | ||
2930 | void | |
2931 | rest_of_decl_compilation (decl, asmspec, top_level, at_end) | |
2932 | tree decl; | |
2933 | char *asmspec; | |
2934 | int top_level; | |
2935 | int at_end; | |
2936 | { | |
2937 | /* Declarations of variables, and of functions defined elsewhere. */ | |
2938 | ||
2939 | /* The most obvious approach, to put an #ifndef around where | |
2940 | this macro is used, doesn't work since it's inside a macro call. */ | |
2941 | #ifndef ASM_FINISH_DECLARE_OBJECT | |
2942 | #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) | |
2943 | #endif | |
2944 | ||
2945 | /* Forward declarations for nested functions are not "external", | |
2946 | but we need to treat them as if they were. */ | |
2947 | if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) | |
2948 | || TREE_CODE (decl) == FUNCTION_DECL) | |
2949 | TIMEVAR (varconst_time, | |
2950 | { | |
2951 | make_decl_rtl (decl, asmspec, top_level); | |
2952 | /* Initialized extern variable exists to be replaced | |
2953 | with its value, or represents something that will be | |
2954 | output in another file. */ | |
2955 | if (! (TREE_CODE (decl) == VAR_DECL | |
2956 | && DECL_EXTERNAL (decl) && TREE_READONLY (decl) | |
2957 | && DECL_INITIAL (decl) != 0 | |
2958 | && DECL_INITIAL (decl) != error_mark_node)) | |
2959 | /* Don't output anything | |
2960 | when a tentative file-scope definition is seen. | |
2961 | But at end of compilation, do output code for them. */ | |
2962 | if (! (! at_end && top_level | |
2963 | && (DECL_INITIAL (decl) == 0 | |
2964 | || DECL_INITIAL (decl) == error_mark_node))) | |
2965 | assemble_variable (decl, top_level, at_end, 0); | |
2966 | if (!output_bytecode | |
2967 | && decl == last_assemble_variable_decl) | |
2968 | { | |
2969 | ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
2970 | top_level, at_end); | |
2971 | } | |
2972 | }); | |
2973 | else if (DECL_REGISTER (decl) && asmspec != 0) | |
2974 | { | |
2975 | if (decode_reg_name (asmspec) >= 0) | |
2976 | { | |
2977 | DECL_RTL (decl) = 0; | |
2978 | make_decl_rtl (decl, asmspec, top_level); | |
2979 | } | |
2980 | else | |
2981 | error ("invalid register name `%s' for register variable", asmspec); | |
2982 | } | |
2983 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
2984 | else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
2985 | && TREE_CODE (decl) == TYPE_DECL) | |
2986 | TIMEVAR (symout_time, dbxout_symbol (decl, 0)); | |
2987 | #endif | |
2988 | #ifdef SDB_DEBUGGING_INFO | |
2989 | else if (write_symbols == SDB_DEBUG && top_level | |
2990 | && TREE_CODE (decl) == TYPE_DECL) | |
2991 | TIMEVAR (symout_time, sdbout_symbol (decl, 0)); | |
2992 | #endif | |
2993 | } | |
2994 | ||
2995 | /* Called after finishing a record, union or enumeral type. */ | |
2996 | ||
2997 | void | |
2998 | rest_of_type_compilation (type, toplev) | |
2999 | tree type; | |
3000 | int toplev; | |
3001 | { | |
3002 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
3003 | if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) | |
3004 | TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
3005 | #endif | |
3006 | #ifdef SDB_DEBUGGING_INFO | |
3007 | if (write_symbols == SDB_DEBUG) | |
3008 | TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); | |
3009 | #endif | |
3010 | } | |
3011 | ||
3012 | /* This is called from finish_function (within yyparse) | |
3013 | after each top-level definition is parsed. | |
3014 | It is supposed to compile that function or variable | |
3015 | and output the assembler code for it. | |
3016 | After we return, the tree storage is freed. */ | |
3017 | ||
3018 | void | |
3019 | rest_of_compilation (decl) | |
3020 | tree decl; | |
3021 | { | |
3022 | register rtx insns; | |
3023 | int start_time = get_run_time (); | |
3024 | int tem; | |
3025 | /* Nonzero if we have saved the original DECL_INITIAL of the function, | |
3026 | to be restored after we finish compiling the function | |
3027 | (for use when compiling inline calls to this function). */ | |
3028 | tree saved_block_tree = 0; | |
3029 | /* Likewise, for DECL_ARGUMENTS. */ | |
3030 | tree saved_arguments = 0; | |
3031 | int failure = 0; | |
3032 | ||
3033 | if (output_bytecode) | |
3034 | return; | |
3035 | ||
3036 | /* If we are reconsidering an inline function | |
3037 | at the end of compilation, skip the stuff for making it inline. */ | |
3038 | ||
3039 | if (DECL_SAVED_INSNS (decl) == 0) | |
3040 | { | |
3041 | int inlinable = 0; | |
3042 | char *lose; | |
3043 | ||
3044 | /* If requested, consider whether to make this function inline. */ | |
3045 | if (DECL_INLINE (decl) || flag_inline_functions) | |
3046 | TIMEVAR (integration_time, | |
3047 | { | |
3048 | lose = function_cannot_inline_p (decl); | |
3049 | if (lose || ! optimize) | |
3050 | { | |
3051 | if (warn_inline && DECL_INLINE (decl)) | |
3052 | warning_with_decl (decl, lose); | |
3053 | DECL_ABSTRACT_ORIGIN (decl) = 0; | |
3054 | /* Don't really compile an extern inline function. | |
3055 | If we can't make it inline, pretend | |
3056 | it was only declared. */ | |
3057 | if (DECL_EXTERNAL (decl)) | |
3058 | { | |
3059 | DECL_INITIAL (decl) = 0; | |
3060 | goto exit_rest_of_compilation; | |
3061 | } | |
3062 | } | |
3063 | else | |
3064 | /* ??? Note that this has the effect of making it look | |
3065 | like "inline" was specified for a function if we choose | |
3066 | to inline it. This isn't quite right, but it's | |
3067 | probably not worth the trouble to fix. */ | |
3068 | inlinable = DECL_INLINE (decl) = 1; | |
3069 | }); | |
3070 | ||
3071 | insns = get_insns (); | |
3072 | ||
3073 | /* Dump the rtl code if we are dumping rtl. */ | |
3074 | ||
3075 | if (rtl_dump) | |
3076 | TIMEVAR (dump_time, | |
3077 | { | |
3078 | fprintf (rtl_dump_file, "\n;; Function %s\n\n", | |
3079 | (*decl_printable_name) (decl, 2)); | |
3080 | if (DECL_SAVED_INSNS (decl)) | |
3081 | fprintf (rtl_dump_file, ";; (integrable)\n\n"); | |
3082 | print_rtl (rtl_dump_file, insns); | |
3083 | fflush (rtl_dump_file); | |
3084 | }); | |
3085 | ||
3086 | /* If we can, defer compiling inlines until EOF. | |
3087 | save_for_inline_copying can be extremely expensive. */ | |
3088 | if (inlinable && ! decl_function_context (decl)) | |
3089 | DECL_DEFER_OUTPUT (decl) = 1; | |
3090 | ||
3091 | /* If function is inline, and we don't yet know whether to | |
3092 | compile it by itself, defer decision till end of compilation. | |
3093 | finish_compilation will call rest_of_compilation again | |
3094 | for those functions that need to be output. Also defer those | |
3095 | functions that we are supposed to defer. We cannot defer | |
3096 | functions containing nested functions since the nested function | |
3097 | data is in our non-saved obstack. */ | |
3098 | ||
3099 | /* If this is a nested inline, remove ADDRESSOF now so we can | |
3100 | finish compiling ourselves. Otherwise, wait until EOF. | |
3101 | We have to do this because the purge_addressof transformation | |
3102 | changes the DECL_RTL for many variables, which confuses integrate. */ | |
3103 | if (inlinable) | |
3104 | { | |
3105 | if (decl_function_context (decl)) | |
3106 | purge_addressof (insns); | |
3107 | else | |
3108 | DECL_DEFER_OUTPUT (decl) = 1; | |
3109 | } | |
3110 | ||
3111 | if (! current_function_contains_functions | |
3112 | && (DECL_DEFER_OUTPUT (decl) | |
3113 | || (DECL_INLINE (decl) | |
3114 | && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) | |
3115 | && ! flag_keep_inline_functions) | |
3116 | || DECL_EXTERNAL (decl))))) | |
3117 | { | |
3118 | DECL_DEFER_OUTPUT (decl) = 1; | |
3119 | ||
3120 | /* If -Wreturn-type, we have to do a bit of compilation. | |
3121 | However, if we just fall through we will call | |
3122 | save_for_inline_copying() which results in excessive | |
3123 | memory use. Instead, we just want to call | |
3124 | jump_optimize() to figure out whether or not we can fall | |
3125 | off the end of the function; we do the minimum amount of | |
3126 | work necessary to make that safe. And, we set optimize | |
3127 | to zero to keep jump_optimize from working too hard. */ | |
3128 | if (warn_return_type) | |
3129 | { | |
3130 | int saved_optimize = optimize; | |
3131 | optimize = 0; | |
3132 | find_exception_handler_labels (); | |
3133 | jump_optimize (get_insns(), 0, 0, 0); | |
3134 | optimize = saved_optimize; | |
3135 | } | |
3136 | ||
3137 | #ifdef DWARF_DEBUGGING_INFO | |
3138 | /* Generate the DWARF info for the "abstract" instance | |
3139 | of a function which we may later generate inlined and/or | |
3140 | out-of-line instances of. */ | |
3141 | if (write_symbols == DWARF_DEBUG) | |
3142 | { | |
3143 | set_decl_abstract_flags (decl, 1); | |
3144 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3145 | set_decl_abstract_flags (decl, 0); | |
3146 | } | |
3147 | #endif | |
3148 | #ifdef DWARF2_DEBUGGING_INFO | |
3149 | /* Generate the DWARF2 info for the "abstract" instance | |
3150 | of a function which we may later generate inlined and/or | |
3151 | out-of-line instances of. */ | |
3152 | if (write_symbols == DWARF2_DEBUG) | |
3153 | { | |
3154 | set_decl_abstract_flags (decl, 1); | |
3155 | TIMEVAR (symout_time, dwarf2out_decl (decl)); | |
3156 | set_decl_abstract_flags (decl, 0); | |
3157 | } | |
3158 | #endif | |
3159 | TIMEVAR (integration_time, save_for_inline_nocopy (decl)); | |
3160 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; | |
3161 | goto exit_rest_of_compilation; | |
3162 | } | |
3163 | ||
3164 | /* If we have to compile the function now, save its rtl and subdecls | |
3165 | so that its compilation will not affect what others get. */ | |
3166 | if (inlinable || DECL_DEFER_OUTPUT (decl)) | |
3167 | { | |
3168 | #ifdef DWARF_DEBUGGING_INFO | |
3169 | /* Generate the DWARF info for the "abstract" instance of | |
3170 | a function which we will generate an out-of-line instance | |
3171 | of almost immediately (and which we may also later generate | |
3172 | various inlined instances of). */ | |
3173 | if (write_symbols == DWARF_DEBUG) | |
3174 | { | |
3175 | set_decl_abstract_flags (decl, 1); | |
3176 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3177 | set_decl_abstract_flags (decl, 0); | |
3178 | } | |
3179 | #endif | |
3180 | #ifdef DWARF2_DEBUGGING_INFO | |
3181 | /* Generate the DWARF2 info for the "abstract" instance of | |
3182 | a function which we will generate an out-of-line instance | |
3183 | of almost immediately (and which we may also later generate | |
3184 | various inlined instances of). */ | |
3185 | if (write_symbols == DWARF2_DEBUG) | |
3186 | { | |
3187 | set_decl_abstract_flags (decl, 1); | |
3188 | TIMEVAR (symout_time, dwarf2out_decl (decl)); | |
3189 | set_decl_abstract_flags (decl, 0); | |
3190 | } | |
3191 | #endif | |
3192 | saved_block_tree = DECL_INITIAL (decl); | |
3193 | saved_arguments = DECL_ARGUMENTS (decl); | |
3194 | TIMEVAR (integration_time, save_for_inline_copying (decl)); | |
3195 | RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; | |
3196 | } | |
3197 | ||
3198 | /* If specified extern inline but we aren't inlining it, we are | |
3199 | done. */ | |
3200 | if (DECL_INLINE (decl) && DECL_EXTERNAL (decl)) | |
3201 | goto exit_rest_of_compilation; | |
3202 | } | |
3203 | ||
3204 | if (! DECL_DEFER_OUTPUT (decl)) | |
3205 | TREE_ASM_WRITTEN (decl) = 1; | |
3206 | ||
3207 | /* Now that integrate will no longer see our rtl, we need not distinguish | |
3208 | between the return value of this function and the return value of called | |
3209 | functions. */ | |
3210 | rtx_equal_function_value_matters = 0; | |
3211 | ||
3212 | /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ | |
3213 | if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) | |
3214 | { | |
3215 | goto exit_rest_of_compilation; | |
3216 | } | |
3217 | ||
3218 | /* Emit code to get eh context, if needed. */ | |
3219 | emit_eh_context (); | |
3220 | ||
3221 | #ifdef FINALIZE_PIC | |
3222 | /* If we are doing position-independent code generation, now | |
3223 | is the time to output special prologues and epilogues. | |
3224 | We do not want to do this earlier, because it just clutters | |
3225 | up inline functions with meaningless insns. */ | |
3226 | if (flag_pic) | |
3227 | FINALIZE_PIC; | |
3228 | #endif | |
3229 | ||
3230 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. | |
3231 | Note that that may have been done above, in save_for_inline_copying. | |
3232 | The call to resume_temporary_allocation near the end of this function | |
3233 | goes back to the usual state of affairs. This must be done after | |
3234 | we've built up any unwinders for exception handling, and done | |
3235 | the FINALIZE_PIC work, if necessary. */ | |
3236 | ||
3237 | rtl_in_current_obstack (); | |
3238 | ||
3239 | insns = get_insns (); | |
3240 | ||
3241 | /* Copy any shared structure that should not be shared. */ | |
3242 | ||
3243 | unshare_all_rtl (insns); | |
3244 | ||
3245 | /* Instantiate all virtual registers. */ | |
3246 | ||
3247 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
3248 | ||
3249 | /* See if we have allocated stack slots that are not directly addressable. | |
3250 | If so, scan all the insns and create explicit address computation | |
3251 | for all references to such slots. */ | |
3252 | /* fixup_stack_slots (); */ | |
3253 | ||
3254 | /* Find all the EH handlers. */ | |
3255 | find_exception_handler_labels (); | |
3256 | ||
3257 | /* Always do one jump optimization pass to ensure that JUMP_LABEL fields | |
3258 | are initialized and to compute whether control can drop off the end | |
3259 | of the function. */ | |
3260 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3261 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
3262 | ||
3263 | /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ | |
3264 | if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) | |
3265 | goto exit_rest_of_compilation; | |
3266 | ||
3267 | /* Dump rtl code after jump, if we are doing that. */ | |
3268 | ||
3269 | if (jump_opt_dump) | |
3270 | TIMEVAR (dump_time, | |
3271 | { | |
3272 | fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", | |
3273 | (*decl_printable_name) (decl, 2)); | |
3274 | print_rtl (jump_opt_dump_file, insns); | |
3275 | fflush (jump_opt_dump_file); | |
3276 | }); | |
3277 | ||
3278 | /* Perform common subexpression elimination. | |
3279 | Nonzero value from `cse_main' means that jumps were simplified | |
3280 | and some code may now be unreachable, so do | |
3281 | jump optimization again. */ | |
3282 | ||
3283 | if (cse_dump) | |
3284 | TIMEVAR (dump_time, | |
3285 | { | |
3286 | fprintf (cse_dump_file, "\n;; Function %s\n\n", | |
3287 | (*decl_printable_name) (decl, 2)); | |
3288 | }); | |
3289 | ||
3290 | if (optimize > 0) | |
3291 | { | |
3292 | TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); | |
3293 | ||
3294 | if (flag_thread_jumps) | |
3295 | /* Hacks by tiemann & kenner. */ | |
3296 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); | |
3297 | ||
3298 | TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), | |
3299 | 0, cse_dump_file)); | |
3300 | TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); | |
3301 | ||
3302 | if (tem || optimize > 1) | |
3303 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
3304 | } | |
3305 | ||
3306 | /* Dump rtl code after cse, if we are doing that. */ | |
3307 | ||
3308 | if (cse_dump) | |
3309 | TIMEVAR (dump_time, | |
3310 | { | |
3311 | print_rtl (cse_dump_file, insns); | |
3312 | fflush (cse_dump_file); | |
3313 | }); | |
3314 | ||
3315 | purge_addressof (insns); | |
3316 | reg_scan (insns, max_reg_num (), 1); | |
3317 | ||
3318 | if (addressof_dump) | |
3319 | TIMEVAR (dump_time, | |
3320 | { | |
3321 | fprintf (addressof_dump_file, "\n;; Function %s\n\n", | |
3322 | (*decl_printable_name) (decl, 2)); | |
3323 | print_rtl (addressof_dump_file, insns); | |
3324 | fflush (addressof_dump_file); | |
3325 | }); | |
3326 | ||
3327 | if (loop_dump) | |
3328 | TIMEVAR (dump_time, | |
3329 | { | |
3330 | fprintf (loop_dump_file, "\n;; Function %s\n\n", | |
3331 | (*decl_printable_name) (decl, 2)); | |
3332 | }); | |
3333 | ||
3334 | /* Move constant computations out of loops. */ | |
3335 | ||
3336 | if (optimize > 0) | |
3337 | { | |
3338 | TIMEVAR (loop_time, | |
3339 | { | |
3340 | if (flag_rerun_loop_opt) | |
3341 | { | |
3342 | /* We only want to perform unrolling once. */ | |
3343 | ||
3344 | loop_optimize (insns, loop_dump_file, 0); | |
3345 | ||
3346 | /* The regscan pass may not be necessary, but let's | |
3347 | be safe until we can prove otherwise. */ | |
3348 | reg_scan (insns, max_reg_num (), 1); | |
3349 | } | |
3350 | loop_optimize (insns, loop_dump_file, flag_unroll_loops); | |
3351 | }); | |
3352 | } | |
3353 | ||
3354 | /* Dump rtl code after loop opt, if we are doing that. */ | |
3355 | ||
3356 | if (loop_dump) | |
3357 | TIMEVAR (dump_time, | |
3358 | { | |
3359 | print_rtl (loop_dump_file, insns); | |
3360 | fflush (loop_dump_file); | |
3361 | }); | |
3362 | ||
3363 | if (cse2_dump) | |
3364 | TIMEVAR (dump_time, | |
3365 | { | |
3366 | fprintf (cse2_dump_file, "\n;; Function %s\n\n", | |
3367 | (*decl_printable_name) (decl, 2)); | |
3368 | }); | |
3369 | ||
3370 | if (optimize > 0 && flag_rerun_cse_after_loop) | |
3371 | { | |
3372 | /* Running another jump optimization pass before the second | |
3373 | cse pass sometimes simplifies the RTL enough to allow | |
3374 | the second CSE pass to do a better job. Jump_optimize can change | |
3375 | max_reg_num so we must rerun reg_scan afterwards. | |
3376 | ??? Rework to not call reg_scan so often. */ | |
3377 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3378 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); | |
3379 | ||
3380 | TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); | |
3381 | TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), | |
3382 | 1, cse2_dump_file)); | |
3383 | if (tem) | |
3384 | TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); | |
3385 | } | |
3386 | ||
3387 | if (optimize > 0 && flag_thread_jumps) | |
3388 | { | |
3389 | /* This pass of jump threading straightens out code | |
3390 | that was kinked by loop optimization. */ | |
3391 | TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); | |
3392 | TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); | |
3393 | } | |
3394 | /* Dump rtl code after cse, if we are doing that. */ | |
3395 | ||
3396 | if (cse2_dump) | |
3397 | TIMEVAR (dump_time, | |
3398 | { | |
3399 | print_rtl (cse2_dump_file, insns); | |
3400 | fflush (cse2_dump_file); | |
3401 | }); | |
3402 | ||
3403 | if (branch_prob_dump) | |
3404 | TIMEVAR (dump_time, | |
3405 | { | |
3406 | fprintf (branch_prob_dump_file, "\n;; Function %s\n\n", | |
3407 | (*decl_printable_name) (decl, 2)); | |
3408 | }); | |
3409 | ||
3410 | if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) | |
3411 | TIMEVAR (branch_prob_time, | |
3412 | { | |
3413 | branch_prob (insns, branch_prob_dump_file); | |
3414 | }); | |
3415 | ||
3416 | if (branch_prob_dump) | |
3417 | TIMEVAR (dump_time, | |
3418 | { | |
3419 | print_rtl (branch_prob_dump_file, insns); | |
3420 | fflush (branch_prob_dump_file); | |
3421 | }); | |
3422 | /* We are no longer anticipating cse in this function, at least. */ | |
3423 | ||
3424 | cse_not_expected = 1; | |
3425 | ||
3426 | /* Now we choose between stupid (pcc-like) register allocation | |
3427 | (if we got the -noreg switch and not -opt) | |
3428 | and smart register allocation. */ | |
3429 | ||
3430 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
3431 | obey_regdecls = 0; /* if optimizations being done. */ | |
3432 | ||
3433 | regclass_init (); | |
3434 | ||
3435 | /* Print function header into flow dump now | |
3436 | because doing the flow analysis makes some of the dump. */ | |
3437 | ||
3438 | if (flow_dump) | |
3439 | TIMEVAR (dump_time, | |
3440 | { | |
3441 | fprintf (flow_dump_file, "\n;; Function %s\n\n", | |
3442 | (*decl_printable_name) (decl, 2)); | |
3443 | }); | |
3444 | ||
3445 | if (obey_regdecls) | |
3446 | { | |
3447 | TIMEVAR (flow_time, | |
3448 | { | |
3449 | regclass (insns, max_reg_num ()); | |
3450 | stupid_life_analysis (insns, max_reg_num (), | |
3451 | flow_dump_file); | |
3452 | }); | |
3453 | } | |
3454 | else | |
3455 | { | |
3456 | /* Do control and data flow analysis, | |
3457 | and write some of the results to dump file. */ | |
3458 | ||
3459 | TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), | |
3460 | flow_dump_file)); | |
3461 | if (warn_uninitialized) | |
3462 | { | |
3463 | uninitialized_vars_warning (DECL_INITIAL (decl)); | |
3464 | setjmp_args_warning (); | |
3465 | } | |
3466 | } | |
3467 | ||
3468 | /* Dump rtl after flow analysis. */ | |
3469 | ||
3470 | if (flow_dump) | |
3471 | TIMEVAR (dump_time, | |
3472 | { | |
3473 | print_rtl_with_bb (flow_dump_file, insns); | |
3474 | fflush (flow_dump_file); | |
3475 | }); | |
3476 | ||
3477 | /* If -opt, try combining insns through substitution. */ | |
3478 | ||
3479 | if (optimize > 0) | |
3480 | TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); | |
3481 | ||
3482 | /* Dump rtl code after insn combination. */ | |
3483 | ||
3484 | if (combine_dump) | |
3485 | TIMEVAR (dump_time, | |
3486 | { | |
3487 | fprintf (combine_dump_file, "\n;; Function %s\n\n", | |
3488 | (*decl_printable_name) (decl, 2)); | |
3489 | dump_combine_stats (combine_dump_file); | |
3490 | print_rtl_with_bb (combine_dump_file, insns); | |
3491 | fflush (combine_dump_file); | |
3492 | }); | |
3493 | ||
3494 | if (regmove_dump) | |
3495 | TIMEVAR (dump_time, | |
3496 | { | |
3497 | fprintf (regmove_dump_file, "\n;; Function %s\n\n", | |
3498 | (*decl_printable_name) (decl, 2)); | |
3499 | }); | |
3500 | ||
3501 | /* Register allocation pre-pass, to reduce number of moves | |
3502 | necessary for two-address machines. */ | |
3503 | if (optimize > 0 && flag_regmove) | |
3504 | TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (), | |
3505 | regmove_dump_file)); | |
3506 | ||
3507 | if (regmove_dump) | |
3508 | TIMEVAR (dump_time, | |
3509 | { | |
3510 | print_rtl_with_bb (regmove_dump_file, insns); | |
3511 | fflush (regmove_dump_file); | |
3512 | }); | |
3513 | ||
3514 | /* Print function header into sched dump now | |
3515 | because doing the sched analysis makes some of the dump. */ | |
3516 | ||
3517 | if (sched_dump) | |
3518 | TIMEVAR (dump_time, | |
3519 | { | |
3520 | fprintf (sched_dump_file, "\n;; Function %s\n\n", | |
3521 | (*decl_printable_name) (decl, 2)); | |
3522 | }); | |
3523 | ||
3524 | if (optimize > 0 && flag_schedule_insns) | |
3525 | { | |
3526 | /* Do control and data sched analysis, | |
3527 | and write some of the results to dump file. */ | |
3528 | ||
3529 | TIMEVAR (sched_time, schedule_insns (sched_dump_file)); | |
3530 | } | |
3531 | ||
3532 | /* Dump rtl after instruction scheduling. */ | |
3533 | ||
3534 | if (sched_dump) | |
3535 | TIMEVAR (dump_time, | |
3536 | { | |
3537 | print_rtl_with_bb (sched_dump_file, insns); | |
3538 | fflush (sched_dump_file); | |
3539 | }); | |
3540 | ||
3541 | /* Unless we did stupid register allocation, | |
3542 | allocate pseudo-regs that are used only within 1 basic block. */ | |
3543 | ||
3544 | if (!obey_regdecls) | |
3545 | TIMEVAR (local_alloc_time, | |
3546 | { | |
3547 | regclass (insns, max_reg_num ()); | |
3548 | local_alloc (); | |
3549 | }); | |
3550 | ||
3551 | /* Dump rtl code after allocating regs within basic blocks. */ | |
3552 | ||
3553 | if (local_reg_dump) | |
3554 | TIMEVAR (dump_time, | |
3555 | { | |
3556 | fprintf (local_reg_dump_file, "\n;; Function %s\n\n", | |
3557 | (*decl_printable_name) (decl, 2)); | |
3558 | dump_flow_info (local_reg_dump_file); | |
3559 | dump_local_alloc (local_reg_dump_file); | |
3560 | print_rtl_with_bb (local_reg_dump_file, insns); | |
3561 | fflush (local_reg_dump_file); | |
3562 | }); | |
3563 | ||
3564 | if (global_reg_dump) | |
3565 | TIMEVAR (dump_time, | |
3566 | fprintf (global_reg_dump_file, "\n;; Function %s\n\n", | |
3567 | (*decl_printable_name) (decl, 2))); | |
3568 | ||
3569 | /* Save the last label number used so far, so reorg can tell | |
3570 | when it's safe to kill spill regs. */ | |
3571 | max_label_num_after_reload = max_label_num (); | |
3572 | ||
3573 | /* Unless we did stupid register allocation, | |
3574 | allocate remaining pseudo-regs, then do the reload pass | |
3575 | fixing up any insns that are invalid. */ | |
3576 | ||
3577 | TIMEVAR (global_alloc_time, | |
3578 | { | |
3579 | if (!obey_regdecls) | |
3580 | failure = global_alloc (global_reg_dump_file); | |
3581 | else | |
3582 | failure = reload (insns, 0, global_reg_dump_file); | |
3583 | }); | |
3584 | ||
3585 | if (global_reg_dump) | |
3586 | TIMEVAR (dump_time, | |
3587 | { | |
3588 | dump_global_regs (global_reg_dump_file); | |
3589 | print_rtl_with_bb (global_reg_dump_file, insns); | |
3590 | fflush (global_reg_dump_file); | |
3591 | }); | |
3592 | ||
3593 | if (failure) | |
3594 | goto exit_rest_of_compilation; | |
3595 | ||
3596 | reload_completed = 1; | |
3597 | ||
3598 | /* Do a very simple CSE pass over just the hard registers. */ | |
3599 | if (optimize > 0) | |
3600 | reload_cse_regs (insns); | |
3601 | ||
3602 | /* On some machines, the prologue and epilogue code, or parts thereof, | |
3603 | can be represented as RTL. Doing so lets us schedule insns between | |
3604 | it and the rest of the code and also allows delayed branch | |
3605 | scheduling to operate in the epilogue. */ | |
3606 | ||
3607 | thread_prologue_and_epilogue_insns (insns); | |
3608 | ||
3609 | if (optimize > 0 && flag_schedule_insns_after_reload) | |
3610 | { | |
3611 | if (sched2_dump) | |
3612 | TIMEVAR (dump_time, | |
3613 | { | |
3614 | fprintf (sched2_dump_file, "\n;; Function %s\n\n", | |
3615 | (*decl_printable_name) (decl, 2)); | |
3616 | }); | |
3617 | ||
3618 | /* Do control and data sched analysis again, | |
3619 | and write some more of the results to dump file. */ | |
3620 | ||
3621 | TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); | |
3622 | ||
3623 | /* Dump rtl after post-reorder instruction scheduling. */ | |
3624 | ||
3625 | if (sched2_dump) | |
3626 | TIMEVAR (dump_time, | |
3627 | { | |
3628 | print_rtl_with_bb (sched2_dump_file, insns); | |
3629 | fflush (sched2_dump_file); | |
3630 | }); | |
3631 | } | |
3632 | ||
3633 | #ifdef LEAF_REGISTERS | |
3634 | leaf_function = 0; | |
3635 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
3636 | leaf_function = 1; | |
3637 | #endif | |
3638 | ||
3639 | /* One more attempt to remove jumps to .+1 | |
3640 | left by dead-store-elimination. | |
3641 | Also do cross-jumping this time | |
3642 | and delete no-op move insns. */ | |
3643 | ||
3644 | if (optimize > 0) | |
3645 | { | |
3646 | TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); | |
3647 | } | |
3648 | ||
3649 | /* Dump rtl code after jump, if we are doing that. */ | |
3650 | ||
3651 | if (jump2_opt_dump) | |
3652 | TIMEVAR (dump_time, | |
3653 | { | |
3654 | fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", | |
3655 | (*decl_printable_name) (decl, 2)); | |
3656 | print_rtl_with_bb (jump2_opt_dump_file, insns); | |
3657 | fflush (jump2_opt_dump_file); | |
3658 | }); | |
3659 | ||
3660 | /* If a machine dependent reorganization is needed, call it. */ | |
3661 | #ifdef MACHINE_DEPENDENT_REORG | |
3662 | MACHINE_DEPENDENT_REORG (insns); | |
3663 | #endif | |
3664 | ||
3665 | /* If a scheduling pass for delayed branches is to be done, | |
3666 | call the scheduling code. */ | |
3667 | ||
3668 | #ifdef DELAY_SLOTS | |
3669 | if (optimize > 0 && flag_delayed_branch) | |
3670 | { | |
3671 | TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); | |
3672 | if (dbr_sched_dump) | |
3673 | { | |
3674 | TIMEVAR (dump_time, | |
3675 | { | |
3676 | fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", | |
3677 | (*decl_printable_name) (decl, 2)); | |
3678 | print_rtl_with_bb (dbr_sched_dump_file, insns); | |
3679 | fflush (dbr_sched_dump_file); | |
3680 | }); | |
3681 | } | |
3682 | } | |
3683 | #endif | |
3684 | ||
3685 | /* Shorten branches. */ | |
3686 | TIMEVAR (shorten_branch_time, | |
3687 | { | |
3688 | shorten_branches (get_insns ()); | |
3689 | }); | |
3690 | ||
3691 | #ifdef STACK_REGS | |
3692 | TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); | |
3693 | if (stack_reg_dump) | |
3694 | { | |
3695 | TIMEVAR (dump_time, | |
3696 | { | |
3697 | fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", | |
3698 | (*decl_printable_name) (decl, 2)); | |
3699 | print_rtl_with_bb (stack_reg_dump_file, insns); | |
3700 | fflush (stack_reg_dump_file); | |
3701 | }); | |
3702 | } | |
3703 | #endif | |
3704 | ||
3705 | /* Now turn the rtl into assembler code. */ | |
3706 | ||
3707 | TIMEVAR (final_time, | |
3708 | { | |
3709 | rtx x; | |
3710 | char *fnname; | |
3711 | ||
3712 | /* Get the function's name, as described by its RTL. | |
3713 | This may be different from the DECL_NAME name used | |
3714 | in the source file. */ | |
3715 | ||
3716 | x = DECL_RTL (decl); | |
3717 | if (GET_CODE (x) != MEM) | |
3718 | abort (); | |
3719 | x = XEXP (x, 0); | |
3720 | if (GET_CODE (x) != SYMBOL_REF) | |
3721 | abort (); | |
3722 | fnname = XSTR (x, 0); | |
3723 | ||
3724 | assemble_start_function (decl, fnname); | |
3725 | final_start_function (insns, asm_out_file, optimize); | |
3726 | final (insns, asm_out_file, optimize, 0); | |
3727 | final_end_function (insns, asm_out_file, optimize); | |
3728 | assemble_end_function (decl, fnname); | |
3729 | fflush (asm_out_file); | |
3730 | ||
3731 | /* Release all memory held by regsets now */ | |
3732 | regset_release_memory (); | |
3733 | }); | |
3734 | ||
3735 | /* Write DBX symbols if requested */ | |
3736 | ||
3737 | /* Note that for those inline functions where we don't initially | |
3738 | know for certain that we will be generating an out-of-line copy, | |
3739 | the first invocation of this routine (rest_of_compilation) will | |
3740 | skip over this code by doing a `goto exit_rest_of_compilation;'. | |
3741 | Later on, finish_compilation will call rest_of_compilation again | |
3742 | for those inline functions that need to have out-of-line copies | |
3743 | generated. During that call, we *will* be routed past here. */ | |
3744 | ||
3745 | #ifdef DBX_DEBUGGING_INFO | |
3746 | if (write_symbols == DBX_DEBUG) | |
3747 | TIMEVAR (symout_time, dbxout_function (decl)); | |
3748 | #endif | |
3749 | ||
3750 | #ifdef DWARF_DEBUGGING_INFO | |
3751 | if (write_symbols == DWARF_DEBUG) | |
3752 | TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); | |
3753 | #endif | |
3754 | ||
3755 | #ifdef DWARF2_DEBUGGING_INFO | |
3756 | if (write_symbols == DWARF2_DEBUG) | |
3757 | TIMEVAR (symout_time, dwarf2out_decl (decl)); | |
3758 | #endif | |
3759 | ||
3760 | exit_rest_of_compilation: | |
3761 | ||
3762 | /* In case the function was not output, | |
3763 | don't leave any temporary anonymous types | |
3764 | queued up for sdb output. */ | |
3765 | #ifdef SDB_DEBUGGING_INFO | |
3766 | if (write_symbols == SDB_DEBUG) | |
3767 | sdbout_types (NULL_TREE); | |
3768 | #endif | |
3769 | ||
3770 | /* Put back the tree of subblocks and list of arguments | |
3771 | from before we copied them. | |
3772 | Code generation and the output of debugging info may have modified | |
3773 | the copy, but the original is unchanged. */ | |
3774 | ||
3775 | if (saved_block_tree != 0) | |
3776 | { | |
3777 | DECL_INITIAL (decl) = saved_block_tree; | |
3778 | DECL_ARGUMENTS (decl) = saved_arguments; | |
3779 | DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
3780 | } | |
3781 | ||
3782 | reload_completed = 0; | |
3783 | ||
3784 | /* Clear out the insn_length contents now that they are no longer valid. */ | |
3785 | init_insn_lengths (); | |
3786 | ||
3787 | /* Clear out the real_constant_chain before some of the rtx's | |
3788 | it runs through become garbage. */ | |
3789 | ||
3790 | clear_const_double_mem (); | |
3791 | ||
3792 | /* Cancel the effect of rtl_in_current_obstack. */ | |
3793 | ||
3794 | resume_temporary_allocation (); | |
3795 | ||
3796 | /* Show no temporary slots allocated. */ | |
3797 | ||
3798 | init_temp_slots (); | |
3799 | ||
3800 | /* The parsing time is all the time spent in yyparse | |
3801 | *except* what is spent in this function. */ | |
3802 | ||
3803 | parse_time -= get_run_time () - start_time; | |
3804 | } | |
3805 | \f | |
3806 | /* Entry point of cc1/c++. Decode command args, then call compile_file. | |
3807 | Exit code is 35 if can't open files, 34 if fatal error, | |
3808 | 33 if had nonfatal errors, else success. */ | |
3809 | ||
3810 | int | |
3811 | main (argc, argv, envp) | |
3812 | int argc; | |
3813 | char **argv; | |
3814 | char **envp; | |
3815 | { | |
3816 | register int i; | |
3817 | char *filename = 0; | |
3818 | int flag_print_mem = 0; | |
3819 | int version_flag = 0; | |
3820 | char *p; | |
3821 | ||
3822 | /* save in case md file wants to emit args as a comment. */ | |
3823 | save_argc = argc; | |
3824 | save_argv = argv; | |
3825 | ||
3826 | p = argv[0] + strlen (argv[0]); | |
3827 | while (p != argv[0] && p[-1] != '/' | |
3828 | #ifdef DIR_SEPARATOR | |
3829 | && p[-1] != DIR_SEPARATOR | |
3830 | #endif | |
3831 | ) | |
3832 | --p; | |
3833 | progname = p; | |
3834 | ||
3835 | #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT) | |
3836 | /* Get rid of any avoidable limit on stack size. */ | |
3837 | { | |
3838 | struct rlimit rlim; | |
3839 | ||
3840 | /* Set the stack limit huge so that alloca does not fail. */ | |
3841 | getrlimit (RLIMIT_STACK, &rlim); | |
3842 | rlim.rlim_cur = rlim.rlim_max; | |
3843 | setrlimit (RLIMIT_STACK, &rlim); | |
3844 | } | |
3845 | #endif | |
3846 | ||
3847 | signal (SIGFPE, float_signal); | |
3848 | ||
3849 | #ifdef SIGPIPE | |
3850 | signal (SIGPIPE, pipe_closed); | |
3851 | #endif | |
3852 | ||
3853 | decl_printable_name = decl_name; | |
3854 | lang_expand_expr = (struct rtx_def *(*)()) do_abort; | |
3855 | ||
3856 | /* Initialize whether `char' is signed. */ | |
3857 | flag_signed_char = DEFAULT_SIGNED_CHAR; | |
3858 | #ifdef DEFAULT_SHORT_ENUMS | |
3859 | /* Initialize how much space enums occupy, by default. */ | |
3860 | flag_short_enums = DEFAULT_SHORT_ENUMS; | |
3861 | #endif | |
3862 | ||
3863 | /* Scan to see what optimization level has been specified. That will | |
3864 | determine the default value of many flags. */ | |
3865 | for (i = 1; i < argc; i++) | |
3866 | { | |
3867 | if (!strcmp (argv[i], "-O")) | |
3868 | { | |
3869 | optimize = 1; | |
3870 | } | |
3871 | else if (argv[i][0] == '-' && argv[i][1] == 'O') | |
3872 | { | |
3873 | /* Handle -O2, -O3, -O69, ... */ | |
3874 | char *p = &argv[i][2]; | |
3875 | int c; | |
3876 | ||
3877 | while (c = *p++) | |
3878 | if (! (c >= '0' && c <= '9')) | |
3879 | break; | |
3880 | if (c == 0) | |
3881 | optimize = atoi (&argv[i][2]); | |
3882 | } | |
3883 | } | |
3884 | ||
3885 | obey_regdecls = (optimize == 0); | |
3886 | ||
3887 | if (optimize >= 1) | |
3888 | { | |
3889 | flag_defer_pop = 1; | |
3890 | flag_thread_jumps = 1; | |
3891 | #ifdef DELAY_SLOTS | |
3892 | flag_delayed_branch = 1; | |
3893 | #endif | |
3894 | #ifdef CAN_DEBUG_WITHOUT_FP | |
3895 | flag_omit_frame_pointer = 1; | |
3896 | #endif | |
3897 | } | |
3898 | ||
3899 | if (optimize >= 2) | |
3900 | { | |
3901 | flag_cse_follow_jumps = 1; | |
3902 | flag_cse_skip_blocks = 1; | |
3903 | flag_expensive_optimizations = 1; | |
3904 | flag_strength_reduce = 1; | |
3905 | flag_rerun_cse_after_loop = 1; | |
3906 | flag_rerun_loop_opt = 1; | |
3907 | flag_caller_saves = 1; | |
3908 | flag_force_mem = 1; | |
3909 | #ifdef INSN_SCHEDULING | |
3910 | flag_schedule_insns = 1; | |
3911 | flag_schedule_insns_after_reload = 1; | |
3912 | #endif | |
3913 | flag_regmove = 1; | |
3914 | } | |
3915 | ||
3916 | if (optimize >= 3) | |
3917 | { | |
3918 | flag_inline_functions = 1; | |
3919 | } | |
3920 | ||
3921 | /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can | |
3922 | modify it. */ | |
3923 | target_flags = 0; | |
3924 | set_target_switch (""); | |
3925 | ||
3926 | #ifdef OPTIMIZATION_OPTIONS | |
3927 | /* Allow default optimizations to be specified on a per-machine basis. */ | |
3928 | OPTIMIZATION_OPTIONS (optimize); | |
3929 | #endif | |
3930 | ||
3931 | /* Initialize register usage now so switches may override. */ | |
3932 | init_reg_sets (); | |
3933 | ||
3934 | for (i = 1; i < argc; i++) | |
3935 | { | |
3936 | int j; | |
3937 | /* If this is a language-specific option, | |
3938 | decode it in a language-specific way. */ | |
3939 | for (j = 0; lang_options[j] != 0; j++) | |
3940 | if (!strncmp (argv[i], lang_options[j], | |
3941 | strlen (lang_options[j]))) | |
3942 | break; | |
3943 | if (lang_options[j] != 0) | |
3944 | /* If the option is valid for *some* language, | |
3945 | treat it as valid even if this language doesn't understand it. */ | |
3946 | lang_decode_option (argv[i]); | |
3947 | else if (argv[i][0] == '-' && argv[i][1] != 0) | |
3948 | { | |
3949 | register char *str = argv[i] + 1; | |
3950 | if (str[0] == 'Y') | |
3951 | str++; | |
3952 | ||
3953 | if (str[0] == 'm') | |
3954 | set_target_switch (&str[1]); | |
3955 | else if (!strcmp (str, "dumpbase")) | |
3956 | { | |
3957 | dump_base_name = argv[++i]; | |
3958 | } | |
3959 | else if (str[0] == 'd') | |
3960 | { | |
3961 | register char *p = &str[1]; | |
3962 | while (*p) | |
3963 | switch (*p++) | |
3964 | { | |
3965 | case 'a': | |
3966 | branch_prob_dump = 1; | |
3967 | combine_dump = 1; | |
3968 | dbr_sched_dump = 1; | |
3969 | flow_dump = 1; | |
3970 | global_reg_dump = 1; | |
3971 | jump_opt_dump = 1; | |
3972 | addressof_dump = 1; | |
3973 | jump2_opt_dump = 1; | |
3974 | local_reg_dump = 1; | |
3975 | loop_dump = 1; | |
3976 | regmove_dump = 1; | |
3977 | rtl_dump = 1; | |
3978 | cse_dump = 1, cse2_dump = 1; | |
3979 | sched_dump = 1; | |
3980 | sched2_dump = 1; | |
3981 | stack_reg_dump = 1; | |
3982 | break; | |
3983 | case 'b': | |
3984 | branch_prob_dump = 1; | |
3985 | break; | |
3986 | case 'k': | |
3987 | stack_reg_dump = 1; | |
3988 | break; | |
3989 | case 'c': | |
3990 | combine_dump = 1; | |
3991 | break; | |
3992 | case 'd': | |
3993 | dbr_sched_dump = 1; | |
3994 | break; | |
3995 | case 'f': | |
3996 | flow_dump = 1; | |
3997 | break; | |
3998 | case 'g': | |
3999 | global_reg_dump = 1; | |
4000 | break; | |
4001 | case 'j': | |
4002 | jump_opt_dump = 1; | |
4003 | break; | |
4004 | case 'D': | |
4005 | addressof_dump = 1; | |
4006 | break; | |
4007 | case 'J': | |
4008 | jump2_opt_dump = 1; | |
4009 | break; | |
4010 | case 'l': | |
4011 | local_reg_dump = 1; | |
4012 | break; | |
4013 | case 'L': | |
4014 | loop_dump = 1; | |
4015 | break; | |
4016 | case 'm': | |
4017 | flag_print_mem = 1; | |
4018 | break; | |
4019 | case 'p': | |
4020 | flag_print_asm_name = 1; | |
4021 | break; | |
4022 | case 'r': | |
4023 | rtl_dump = 1; | |
4024 | break; | |
4025 | case 's': | |
4026 | cse_dump = 1; | |
4027 | break; | |
4028 | case 't': | |
4029 | cse2_dump = 1; | |
4030 | break; | |
4031 | case 'N': | |
4032 | regmove_dump = 1; | |
4033 | break; | |
4034 | case 'S': | |
4035 | sched_dump = 1; | |
4036 | break; | |
4037 | case 'R': | |
4038 | sched2_dump = 1; | |
4039 | break; | |
4040 | case 'y': | |
4041 | set_yydebug (1); | |
4042 | break; | |
4043 | case 'x': | |
4044 | rtl_dump_and_exit = 1; | |
4045 | break; | |
4046 | case 'A': | |
4047 | flag_debug_asm = 1; | |
4048 | break; | |
4049 | } | |
4050 | } | |
4051 | else if (str[0] == 'f') | |
4052 | { | |
4053 | register char *p = &str[1]; | |
4054 | int found = 0; | |
4055 | ||
4056 | /* Some kind of -f option. | |
4057 | P's value is the option sans `-f'. | |
4058 | Search for it in the table of options. */ | |
4059 | ||
4060 | for (j = 0; | |
4061 | !found && j < sizeof (f_options) / sizeof (f_options[0]); | |
4062 | j++) | |
4063 | { | |
4064 | if (!strcmp (p, f_options[j].string)) | |
4065 | { | |
4066 | *f_options[j].variable = f_options[j].on_value; | |
4067 | /* A goto here would be cleaner, | |
4068 | but breaks the vax pcc. */ | |
4069 | found = 1; | |
4070 | } | |
4071 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4072 | && ! strcmp (p+3, f_options[j].string)) | |
4073 | { | |
4074 | *f_options[j].variable = ! f_options[j].on_value; | |
4075 | found = 1; | |
4076 | } | |
4077 | } | |
4078 | ||
4079 | if (found) | |
4080 | ; | |
4081 | #ifdef HAIFA | |
4082 | #ifdef INSN_SCHEDULING | |
4083 | else if (!strncmp (p, "sched-verbose-",14)) | |
4084 | fix_sched_param("verbose",&p[14]); | |
4085 | else if (!strncmp (p, "sched-max-",10)) | |
4086 | fix_sched_param("max",&p[10]); | |
4087 | else if (!strncmp (p, "sched-inter-max-b-",18)) | |
4088 | fix_sched_param("interblock-max-blocks",&p[18]); | |
4089 | else if (!strncmp (p, "sched-inter-max-i-",18)) | |
4090 | fix_sched_param("interblock-max-insns",&p[18]); | |
4091 | #endif | |
4092 | #endif /* HAIFA */ | |
4093 | else if (!strncmp (p, "fixed-", 6)) | |
4094 | fix_register (&p[6], 1, 1); | |
4095 | else if (!strncmp (p, "call-used-", 10)) | |
4096 | fix_register (&p[10], 0, 1); | |
4097 | else if (!strncmp (p, "call-saved-", 11)) | |
4098 | fix_register (&p[11], 0, 0); | |
4099 | else | |
4100 | error ("Invalid option `%s'", argv[i]); | |
4101 | } | |
4102 | else if (str[0] == 'O') | |
4103 | { | |
4104 | register char *p = str+1; | |
4105 | while (*p && *p >= '0' && *p <= '9') | |
4106 | p++; | |
4107 | if (*p == '\0') | |
4108 | ; | |
4109 | else | |
4110 | error ("Invalid option `%s'", argv[i]); | |
4111 | } | |
4112 | else if (!strcmp (str, "pedantic")) | |
4113 | pedantic = 1; | |
4114 | else if (!strcmp (str, "pedantic-errors")) | |
4115 | flag_pedantic_errors = pedantic = 1; | |
4116 | else if (!strcmp (str, "quiet")) | |
4117 | quiet_flag = 1; | |
4118 | else if (!strcmp (str, "version")) | |
4119 | version_flag = 1; | |
4120 | else if (!strcmp (str, "w")) | |
4121 | inhibit_warnings = 1; | |
4122 | else if (!strcmp (str, "W")) | |
4123 | { | |
4124 | extra_warnings = 1; | |
4125 | /* We save the value of warn_uninitialized, since if they put | |
4126 | -Wuninitialized on the command line, we need to generate a | |
4127 | warning about not using it without also specifying -O. */ | |
4128 | if (warn_uninitialized != 1) | |
4129 | warn_uninitialized = 2; | |
4130 | } | |
4131 | else if (str[0] == 'W') | |
4132 | { | |
4133 | register char *p = &str[1]; | |
4134 | int found = 0; | |
4135 | ||
4136 | /* Some kind of -W option. | |
4137 | P's value is the option sans `-W'. | |
4138 | Search for it in the table of options. */ | |
4139 | ||
4140 | for (j = 0; | |
4141 | !found && j < sizeof (W_options) / sizeof (W_options[0]); | |
4142 | j++) | |
4143 | { | |
4144 | if (!strcmp (p, W_options[j].string)) | |
4145 | { | |
4146 | *W_options[j].variable = W_options[j].on_value; | |
4147 | /* A goto here would be cleaner, | |
4148 | but breaks the vax pcc. */ | |
4149 | found = 1; | |
4150 | } | |
4151 | if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' | |
4152 | && ! strcmp (p+3, W_options[j].string)) | |
4153 | { | |
4154 | *W_options[j].variable = ! W_options[j].on_value; | |
4155 | found = 1; | |
4156 | } | |
4157 | } | |
4158 | ||
4159 | if (found) | |
4160 | ; | |
4161 | else if (!strncmp (p, "id-clash-", 9)) | |
4162 | { | |
4163 | char *endp = p + 9; | |
4164 | ||
4165 | while (*endp) | |
4166 | { | |
4167 | if (*endp >= '0' && *endp <= '9') | |
4168 | endp++; | |
4169 | else | |
4170 | { | |
4171 | error ("Invalid option `%s'", argv[i]); | |
4172 | goto id_clash_lose; | |
4173 | } | |
4174 | } | |
4175 | warn_id_clash = 1; | |
4176 | id_clash_len = atoi (str + 10); | |
4177 | id_clash_lose: ; | |
4178 | } | |
4179 | else if (!strncmp (p, "larger-than-", 12)) | |
4180 | { | |
4181 | char *endp = p + 12; | |
4182 | ||
4183 | while (*endp) | |
4184 | { | |
4185 | if (*endp >= '0' && *endp <= '9') | |
4186 | endp++; | |
4187 | else | |
4188 | { | |
4189 | error ("Invalid option `%s'", argv[i]); | |
4190 | goto larger_than_lose; | |
4191 | } | |
4192 | } | |
4193 | warn_larger_than = 1; | |
4194 | larger_than_size = atoi (str + 13); | |
4195 | larger_than_lose: ; | |
4196 | } | |
4197 | else | |
4198 | error ("Invalid option `%s'", argv[i]); | |
4199 | } | |
4200 | else if (!strcmp (str, "p")) | |
4201 | { | |
4202 | profile_flag = 1; | |
4203 | } | |
4204 | else if (!strcmp (str, "a")) | |
4205 | { | |
4206 | #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4207 | warning ("`-a' option (basic block profile) not supported"); | |
4208 | #else | |
4209 | profile_block_flag = (profile_block_flag < 2) ? 1 : 3; | |
4210 | #endif | |
4211 | } | |
4212 | else if (!strcmp (str, "ax")) | |
4213 | { | |
4214 | #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) | |
4215 | warning ("`-ax' option (jump profiling) not supported"); | |
4216 | #else | |
4217 | profile_block_flag = (!profile_block_flag | |
4218 | || profile_block_flag == 2) ? 2 : 3; | |
4219 | #endif | |
4220 | } | |
4221 | else if (str[0] == 'g') | |
4222 | { | |
4223 | unsigned len; | |
4224 | unsigned level; | |
4225 | /* A lot of code assumes write_symbols == NO_DEBUG if the | |
4226 | debugging level is 0 (thus -gstabs1 -gstabs0 would lose track | |
4227 | of what debugging type has been selected). This records the | |
4228 | selected type. It is an error to specify more than one | |
4229 | debugging type. */ | |
4230 | static enum debug_info_type selected_debug_type = NO_DEBUG; | |
4231 | /* Non-zero if debugging format has been explicitly set. | |
4232 | -g and -ggdb don't explicitly set the debugging format so | |
4233 | -gdwarf -g3 is equivalent to -gdwarf3. */ | |
4234 | static int type_explicitly_set_p = 0; | |
4235 | /* Table of supported debugging formats. */ | |
4236 | static struct { | |
4237 | char *arg; | |
4238 | /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a | |
4239 | constant expression, we use NO_DEBUG in its place. */ | |
4240 | enum debug_info_type debug_type; | |
4241 | int use_extensions_p; | |
4242 | } *da, debug_args[] = { | |
4243 | { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS }, | |
4244 | { "ggdb", NO_DEBUG, 1 }, | |
4245 | #ifdef DBX_DEBUGGING_INFO | |
4246 | { "gstabs", DBX_DEBUG, 0 }, | |
4247 | { "gstabs+", DBX_DEBUG, 1 }, | |
4248 | #endif | |
4249 | #ifdef DWARF_DEBUGGING_INFO | |
4250 | { "gdwarf", DWARF_DEBUG, 0 }, | |
4251 | { "gdwarf+", DWARF_DEBUG, 1 }, | |
4252 | #endif | |
4253 | #ifdef DWARF2_DEBUGGING_INFO | |
4254 | { "gdwarf-2", DWARF2_DEBUG, 0 }, | |
4255 | #endif | |
4256 | #ifdef XCOFF_DEBUGGING_INFO | |
4257 | { "gxcoff", XCOFF_DEBUG, 0 }, | |
4258 | { "gxcoff+", XCOFF_DEBUG, 1 }, | |
4259 | #endif | |
4260 | #ifdef SDB_DEBUGGING_INFO | |
4261 | { "gcoff", SDB_DEBUG, 0 }, | |
4262 | #endif | |
4263 | { 0, 0, 0 } | |
4264 | }; | |
4265 | /* Indexed by enum debug_info_type. */ | |
4266 | static char *debug_type_names[] = { | |
4267 | "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff" | |
4268 | }; | |
4269 | ||
4270 | /* Look up STR in the table. */ | |
4271 | for (da = debug_args; da->arg; da++) | |
4272 | { | |
4273 | if (! strncmp (str, da->arg, strlen (da->arg))) | |
4274 | { | |
4275 | enum debug_info_type type = da->debug_type; | |
4276 | char *p, *q; | |
4277 | ||
4278 | p = str + strlen (da->arg); | |
4279 | if (*p && (*p < '0' || *p > '9')) | |
4280 | continue; | |
4281 | len = p - str; | |
4282 | q = p; | |
4283 | while (*q && (*q >= '0' && *q <= '9')) | |
4284 | q++; | |
4285 | if (*p) | |
4286 | { | |
4287 | level = atoi (p); | |
4288 | if (len > 1 && !strncmp (str, "gdwarf", len)) | |
4289 | { | |
4290 | error ("use -gdwarf -g%d for DWARF v1, level %d", | |
4291 | level, level); | |
4292 | if (level == 2) | |
4293 | error ("use -gdwarf-2 for DWARF v2"); | |
4294 | } | |
4295 | } | |
4296 | else | |
4297 | level = 2; /* default debugging info level */ | |
4298 | if (*q || level > 3) | |
4299 | { | |
4300 | warning ("invalid debug level specification in option: `-%s'", | |
4301 | str); | |
4302 | /* ??? This error message is incorrect in the case of | |
4303 | -g4 -g. */ | |
4304 | warning ("no debugging information will be generated"); | |
4305 | level = 0; | |
4306 | } | |
4307 | ||
4308 | if (type == NO_DEBUG) | |
4309 | { | |
4310 | type = PREFERRED_DEBUGGING_TYPE; | |
4311 | if (len > 1 && strncmp (str, "ggdb", len) == 0) | |
4312 | { | |
4313 | #ifdef DWARF2_DEBUGGING_INFO | |
4314 | type = DWARF2_DEBUG; | |
4315 | #else | |
4316 | #ifdef DBX_DEBUGGING_INFO | |
4317 | type = DBX_DEBUG; | |
4318 | #endif | |
4319 | #endif | |
4320 | } | |
4321 | } | |
4322 | ||
4323 | if (type == NO_DEBUG) | |
4324 | warning ("`-%s' not supported by this configuration of GCC", | |
4325 | str); | |
4326 | ||
4327 | /* Does it conflict with an already selected type? */ | |
4328 | if (type_explicitly_set_p | |
4329 | /* -g/-ggdb don't conflict with anything */ | |
4330 | && da->debug_type != NO_DEBUG | |
4331 | && type != selected_debug_type) | |
4332 | warning ("`-%s' ignored, conflicts with `-g%s'", | |
4333 | str, debug_type_names[(int) selected_debug_type]); | |
4334 | else | |
4335 | { | |
4336 | /* If the format has already been set, -g/-ggdb | |
4337 | only change the debug level. */ | |
4338 | if (type_explicitly_set_p | |
4339 | && da->debug_type == NO_DEBUG) | |
4340 | ; /* don't change debugging type */ | |
4341 | else | |
4342 | { | |
4343 | selected_debug_type = type; | |
4344 | type_explicitly_set_p = da->debug_type != NO_DEBUG; | |
4345 | } | |
4346 | write_symbols = (level == 0 | |
4347 | ? NO_DEBUG | |
4348 | : selected_debug_type); | |
4349 | use_gnu_debug_info_extensions = da->use_extensions_p; | |
4350 | debug_info_level = (enum debug_info_level) level; | |
4351 | } | |
4352 | break; | |
4353 | } | |
4354 | } | |
4355 | if (! da->arg) | |
4356 | warning ("`-%s' not supported by this configuration of GCC", | |
4357 | str); | |
4358 | } | |
4359 | else if (!strcmp (str, "o")) | |
4360 | { | |
4361 | asm_file_name = argv[++i]; | |
4362 | } | |
4363 | else if (str[0] == 'G') | |
4364 | { | |
4365 | g_switch_set = TRUE; | |
4366 | g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); | |
4367 | } | |
4368 | else if (!strncmp (str, "aux-info", 8)) | |
4369 | { | |
4370 | flag_gen_aux_info = 1; | |
4371 | aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); | |
4372 | } | |
4373 | else | |
4374 | error ("Invalid option `%s'", argv[i]); | |
4375 | } | |
4376 | else if (argv[i][0] == '+') | |
4377 | error ("Invalid option `%s'", argv[i]); | |
4378 | else | |
4379 | filename = argv[i]; | |
4380 | } | |
4381 | ||
4382 | /* Checker uses the frame pointer. */ | |
4383 | if (flag_check_memory_usage) | |
4384 | flag_omit_frame_pointer = 0; | |
4385 | ||
4386 | /* Initialize for bytecode output. A good idea to do this as soon as | |
4387 | possible after the "-f" options have been parsed. */ | |
4388 | if (output_bytecode) | |
4389 | { | |
4390 | #ifndef TARGET_SUPPORTS_BYTECODE | |
4391 | /* Just die with a fatal error if not supported */ | |
4392 | fatal ("-fbytecode not supported for this target"); | |
4393 | #else | |
4394 | bc_initialize (); | |
4395 | #endif | |
4396 | } | |
4397 | ||
4398 | if (optimize == 0) | |
4399 | { | |
4400 | /* Inlining does not work if not optimizing, | |
4401 | so force it not to be done. */ | |
4402 | flag_no_inline = 1; | |
4403 | warn_inline = 0; | |
4404 | ||
4405 | /* The c_decode_option and lang_decode_option functions set | |
4406 | this to `2' if -Wall is used, so we can avoid giving out | |
4407 | lots of errors for people who don't realize what -Wall does. */ | |
4408 | if (warn_uninitialized == 1) | |
4409 | warning ("-Wuninitialized is not supported without -O"); | |
4410 | } | |
4411 | ||
4412 | #ifdef OVERRIDE_OPTIONS | |
4413 | /* Some machines may reject certain combinations of options. */ | |
4414 | OVERRIDE_OPTIONS; | |
4415 | #endif | |
4416 | ||
4417 | if (exceptions_via_longjmp == 2) | |
4418 | { | |
4419 | #ifdef DWARF2_UNWIND_INFO | |
4420 | exceptions_via_longjmp = ! DWARF2_UNWIND_INFO; | |
4421 | #else | |
4422 | exceptions_via_longjmp = 1; | |
4423 | #endif | |
4424 | } | |
4425 | ||
4426 | if (profile_block_flag == 3) | |
4427 | { | |
4428 | warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); | |
4429 | profile_block_flag = 2; | |
4430 | } | |
4431 | ||
4432 | /* Unrolling all loops implies that standard loop unrolling must also | |
4433 | be done. */ | |
4434 | if (flag_unroll_all_loops) | |
4435 | flag_unroll_loops = 1; | |
4436 | /* Loop unrolling requires that strength_reduction be on also. Silently | |
4437 | turn on strength reduction here if it isn't already on. Also, the loop | |
4438 | unrolling code assumes that cse will be run after loop, so that must | |
4439 | be turned on also. */ | |
4440 | if (flag_unroll_loops) | |
4441 | { | |
4442 | flag_strength_reduce = 1; | |
4443 | flag_rerun_cse_after_loop = 1; | |
4444 | } | |
4445 | ||
4446 | /* Warn about options that are not supported on this machine. */ | |
4447 | #ifndef INSN_SCHEDULING | |
4448 | if (flag_schedule_insns || flag_schedule_insns_after_reload) | |
4449 | warning ("instruction scheduling not supported on this target machine"); | |
4450 | #endif | |
4451 | #ifndef DELAY_SLOTS | |
4452 | if (flag_delayed_branch) | |
4453 | warning ("this target machine does not have delayed branches"); | |
4454 | #endif | |
4455 | ||
4456 | /* If we are in verbose mode, write out the version and maybe all the | |
4457 | option flags in use. */ | |
4458 | if (version_flag) | |
4459 | { | |
4460 | print_version (stderr, ""); | |
4461 | if (! quiet_flag) | |
4462 | print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n"); | |
4463 | } | |
4464 | ||
4465 | compile_file (filename); | |
4466 | ||
4467 | #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__)) | |
4468 | if (flag_print_mem) | |
4469 | { | |
4470 | char *lim = (char *) sbrk (0); | |
4471 | ||
4472 | fprintf (stderr, "Data size %d.\n", | |
4473 | lim - (char *) &environ); | |
4474 | fflush (stderr); | |
4475 | ||
4476 | #ifndef __MSDOS__ | |
4477 | #ifdef USG | |
4478 | system ("ps -l 1>&2"); | |
4479 | #else /* not USG */ | |
4480 | system ("ps v"); | |
4481 | #endif /* not USG */ | |
4482 | #endif | |
4483 | } | |
4484 | #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */ | |
4485 | ||
4486 | if (errorcount) | |
4487 | exit (FATAL_EXIT_CODE); | |
4488 | if (sorrycount) | |
4489 | exit (FATAL_EXIT_CODE); | |
4490 | exit (SUCCESS_EXIT_CODE); | |
4491 | return 0; | |
4492 | } | |
4493 | \f | |
4494 | /* Decode -m switches. */ | |
4495 | ||
4496 | /* Here is a table, controlled by the tm.h file, listing each -m switch | |
4497 | and which bits in `target_switches' it should set or clear. | |
4498 | If VALUE is positive, it is bits to set. | |
4499 | If VALUE is negative, -VALUE is bits to clear. | |
4500 | (The sign bit is not used so there is no confusion.) */ | |
4501 | ||
4502 | struct {char *name; int value;} target_switches [] | |
4503 | = TARGET_SWITCHES; | |
4504 | ||
4505 | /* This table is similar, but allows the switch to have a value. */ | |
4506 | ||
4507 | #ifdef TARGET_OPTIONS | |
4508 | struct {char *prefix; char ** variable;} target_options [] | |
4509 | = TARGET_OPTIONS; | |
4510 | #endif | |
4511 | ||
4512 | /* Decode the switch -mNAME. */ | |
4513 | ||
4514 | void | |
4515 | set_target_switch (name) | |
4516 | char *name; | |
4517 | { | |
4518 | register int j; | |
4519 | int valid = 0; | |
4520 | ||
4521 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
4522 | if (!strcmp (target_switches[j].name, name)) | |
4523 | { | |
4524 | if (target_switches[j].value < 0) | |
4525 | target_flags &= ~-target_switches[j].value; | |
4526 | else | |
4527 | target_flags |= target_switches[j].value; | |
4528 | valid = 1; | |
4529 | } | |
4530 | ||
4531 | #ifdef TARGET_OPTIONS | |
4532 | if (!valid) | |
4533 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4534 | { | |
4535 | int len = strlen (target_options[j].prefix); | |
4536 | if (!strncmp (target_options[j].prefix, name, len)) | |
4537 | { | |
4538 | *target_options[j].variable = name + len; | |
4539 | valid = 1; | |
4540 | } | |
4541 | } | |
4542 | #endif | |
4543 | ||
4544 | if (!valid) | |
4545 | error ("Invalid option `%s'", name); | |
4546 | } | |
4547 | \f | |
4548 | /* Print version information to FILE. | |
4549 | Each line begins with INDENT (for the case where FILE is the | |
4550 | assembler output file). */ | |
4551 | ||
4552 | void | |
4553 | print_version (file, indent) | |
4554 | FILE *file; | |
4555 | char *indent; | |
4556 | { | |
4557 | fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "", | |
4558 | language_string, version_string); | |
4559 | fprintf (file, " (%s)", TARGET_NAME); | |
4560 | #ifdef __GNUC__ | |
4561 | #ifndef __VERSION__ | |
4562 | #define __VERSION__ "[unknown]" | |
4563 | #endif | |
4564 | fprintf (file, " compiled by GNU C version %s.\n", __VERSION__); | |
4565 | #else | |
4566 | fprintf (file, " compiled by CC.\n"); | |
4567 | #endif | |
4568 | } | |
4569 | ||
4570 | /* Print an option value and return the adjusted position in the line. | |
4571 | ??? We don't handle error returns from fprintf (disk full); presumably | |
4572 | other code will catch a disk full though. */ | |
4573 | ||
4574 | int | |
4575 | print_single_switch (file, pos, max, indent, sep, term, type, name) | |
4576 | FILE *file; | |
4577 | int pos, max; | |
4578 | char *indent, *sep, *term, *type, *name; | |
4579 | { | |
4580 | /* The ultrix fprintf returns 0 on success, so compute the result we want | |
4581 | here since we need it for the following test. */ | |
4582 | int len = strlen (sep) + strlen (type) + strlen (name); | |
4583 | ||
4584 | if (pos != 0 | |
4585 | && pos + len > max) | |
4586 | { | |
4587 | fprintf (file, "%s", term); | |
4588 | pos = 0; | |
4589 | } | |
4590 | if (pos == 0) | |
4591 | { | |
4592 | fprintf (file, "%s", indent); | |
4593 | pos = strlen (indent); | |
4594 | } | |
4595 | fprintf (file, "%s%s%s", sep, type, name); | |
4596 | pos += len; | |
4597 | return pos; | |
4598 | } | |
4599 | ||
4600 | /* Print active target switches to FILE. | |
4601 | POS is the current cursor position and MAX is the size of a "line". | |
4602 | Each line begins with INDENT and ends with TERM. | |
4603 | Each switch is separated from the next by SEP. */ | |
4604 | ||
4605 | void | |
4606 | print_switch_values (file, pos, max, indent, sep, term) | |
4607 | FILE *file; | |
4608 | int pos, max; | |
4609 | char *indent, *sep, *term; | |
4610 | { | |
4611 | int j, flags; | |
4612 | char **p; | |
4613 | ||
4614 | /* Print the options as passed. */ | |
4615 | ||
4616 | pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term, | |
4617 | "options passed: ", ""); | |
4618 | ||
4619 | for (p = &save_argv[1]; *p != NULL; p++) | |
4620 | if (**p == '-') | |
4621 | { | |
4622 | /* Ignore these. */ | |
4623 | if (strcmp (*p, "-o") == 0) | |
4624 | { | |
4625 | if (p[1] != NULL) | |
4626 | p++; | |
4627 | continue; | |
4628 | } | |
4629 | if (strcmp (*p, "-quiet") == 0) | |
4630 | continue; | |
4631 | if (strcmp (*p, "-version") == 0) | |
4632 | continue; | |
4633 | if ((*p)[1] == 'd') | |
4634 | continue; | |
4635 | ||
4636 | pos = print_single_switch (file, pos, max, indent, sep, term, *p, ""); | |
4637 | } | |
4638 | if (pos > 0) | |
4639 | fprintf (file, "%s", term); | |
4640 | ||
4641 | /* Print the -f and -m options that have been enabled. | |
4642 | We don't handle language specific options but printing argv | |
4643 | should suffice. */ | |
4644 | ||
4645 | pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, | |
4646 | "options enabled: ", ""); | |
4647 | ||
4648 | for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) | |
4649 | if (*f_options[j].variable == f_options[j].on_value) | |
4650 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4651 | "-f", f_options[j].string); | |
4652 | ||
4653 | /* Print target specific options. */ | |
4654 | ||
4655 | flags = target_flags; | |
4656 | for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) | |
4657 | if (target_switches[j].name[0] != '\0' | |
4658 | && target_switches[j].value > 0 | |
4659 | && ((target_switches[j].value & target_flags) | |
4660 | == target_switches[j].value)) | |
4661 | { | |
4662 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4663 | "-m", target_switches[j].name); | |
4664 | flags &= ~ target_switches[j].value; | |
4665 | } | |
4666 | ||
4667 | #ifdef TARGET_OPTIONS | |
4668 | for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) | |
4669 | if (*target_options[j].variable != NULL) | |
4670 | { | |
4671 | char prefix[256]; | |
4672 | sprintf (prefix, "-m%s", target_options[j].prefix); | |
4673 | pos = print_single_switch (file, pos, max, indent, sep, term, | |
4674 | prefix, *target_options[j].variable); | |
4675 | } | |
4676 | #endif | |
4677 | ||
4678 | fprintf (file, "%s", term); | |
4679 | } | |
4680 | ||
4681 | /* Record the beginning of a new source file, named FILENAME. */ | |
4682 | ||
4683 | void | |
4684 | debug_start_source_file (filename) | |
4685 | register char *filename; | |
4686 | { | |
4687 | #ifdef DBX_DEBUGGING_INFO | |
4688 | if (write_symbols == DBX_DEBUG) | |
4689 | dbxout_start_new_source_file (filename); | |
4690 | #endif | |
4691 | #ifdef DWARF_DEBUGGING_INFO | |
4692 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4693 | && write_symbols == DWARF_DEBUG) | |
4694 | dwarfout_start_new_source_file (filename); | |
4695 | #endif /* DWARF_DEBUGGING_INFO */ | |
4696 | #ifdef DWARF2_DEBUGGING_INFO | |
4697 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4698 | && write_symbols == DWARF2_DEBUG) | |
4699 | dwarf2out_start_source_file (filename); | |
4700 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4701 | #ifdef SDB_DEBUGGING_INFO | |
4702 | if (write_symbols == SDB_DEBUG) | |
4703 | sdbout_start_new_source_file (filename); | |
4704 | #endif | |
4705 | } | |
4706 | ||
4707 | /* Record the resumption of a source file. LINENO is the line number in | |
4708 | the source file we are returning to. */ | |
4709 | ||
4710 | void | |
4711 | debug_end_source_file (lineno) | |
4712 | register unsigned lineno; | |
4713 | { | |
4714 | #ifdef DBX_DEBUGGING_INFO | |
4715 | if (write_symbols == DBX_DEBUG) | |
4716 | dbxout_resume_previous_source_file (); | |
4717 | #endif | |
4718 | #ifdef DWARF_DEBUGGING_INFO | |
4719 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4720 | && write_symbols == DWARF_DEBUG) | |
4721 | dwarfout_resume_previous_source_file (lineno); | |
4722 | #endif /* DWARF_DEBUGGING_INFO */ | |
4723 | #ifdef DWARF2_DEBUGGING_INFO | |
4724 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4725 | && write_symbols == DWARF2_DEBUG) | |
4726 | dwarf2out_end_source_file (); | |
4727 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4728 | #ifdef SDB_DEBUGGING_INFO | |
4729 | if (write_symbols == SDB_DEBUG) | |
4730 | sdbout_resume_previous_source_file (); | |
4731 | #endif | |
4732 | } | |
4733 | ||
4734 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4735 | the tail part of the directive line, i.e. the part which is past the | |
4736 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4737 | ||
4738 | void | |
4739 | debug_define (lineno, buffer) | |
4740 | register unsigned lineno; | |
4741 | register char *buffer; | |
4742 | { | |
4743 | #ifdef DWARF_DEBUGGING_INFO | |
4744 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4745 | && write_symbols == DWARF_DEBUG) | |
4746 | dwarfout_define (lineno, buffer); | |
4747 | #endif /* DWARF_DEBUGGING_INFO */ | |
4748 | #ifdef DWARF2_DEBUGGING_INFO | |
4749 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4750 | && write_symbols == DWARF2_DEBUG) | |
4751 | dwarf2out_define (lineno, buffer); | |
4752 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4753 | } | |
4754 | ||
4755 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
4756 | the tail part of the directive line, i.e. the part which is past the | |
4757 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
4758 | ||
4759 | void | |
4760 | debug_undef (lineno, buffer) | |
4761 | register unsigned lineno; | |
4762 | register char *buffer; | |
4763 | { | |
4764 | #ifdef DWARF_DEBUGGING_INFO | |
4765 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4766 | && write_symbols == DWARF_DEBUG) | |
4767 | dwarfout_undef (lineno, buffer); | |
4768 | #endif /* DWARF_DEBUGGING_INFO */ | |
4769 | #ifdef DWARF2_DEBUGGING_INFO | |
4770 | if (debug_info_level == DINFO_LEVEL_VERBOSE | |
4771 | && write_symbols == DWARF2_DEBUG) | |
4772 | dwarf2out_undef (lineno, buffer); | |
4773 | #endif /* DWARF2_DEBUGGING_INFO */ | |
4774 | } |