1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* $FreeBSD: src/contrib/gcc/toplev.c,v 1.6.2.8 2002/07/03 17:56:20 ambrisko Exp $ */
23 /* $DragonFly: src/contrib/gcc/Attic/toplev.c,v 1.3 2003/12/10 22:25:05 dillon Exp $ */
25 /* This is the top level of cc1/c++.
26 It parses command args, opens files, invokes the various passes
27 in the proper order, and counts the time used by each.
28 Error messages and low-level interface to malloc also handled here. */
31 #undef FLOAT /* This is for hpux. They should change hpux. */
32 #undef FFS /* Some systems define this in param.h. */
37 #ifdef HAVE_SYS_RESOURCE_H
38 # include <sys/resource.h>
41 #ifdef HAVE_SYS_TIMES_H
42 # include <sys/times.h>
49 #include "insn-attr.h"
50 #include "insn-codes.h"
51 #include "insn-config.h"
58 #include "basic-block.h"
61 #ifdef DWARF_DEBUGGING_INFO
65 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
66 #include "dwarf2out.h"
69 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
73 #ifdef SDB_DEBUGGING_INFO
77 #ifdef XCOFF_DEBUGGING_INFO
82 /* The extra parameters substantially improve the I/O performance. */
84 vms_fopen (fname, type)
88 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
89 fixed arguments, which matches ANSI's specification but not VAXCRTL's
90 pre-ANSI implementation. This hack circumvents the mismatch problem. */
91 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
94 return (*vmslib_fopen) (fname, type, "mbc=32",
95 "deq=64", "fop=tef", "shr=nil");
97 return (*vmslib_fopen) (fname, type, "mbc=32");
99 #define fopen vms_fopen
102 #ifndef DEFAULT_GDB_EXTENSIONS
103 #define DEFAULT_GDB_EXTENSIONS 1
106 /* If more than one debugging type is supported, you must define
107 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
109 This is one long line cause VAXC can't handle a \-newline. */
110 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
111 #ifndef PREFERRED_DEBUGGING_TYPE
112 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
113 #endif /* no PREFERRED_DEBUGGING_TYPE */
114 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
115 so the following code needn't care. */
116 #ifdef DBX_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
119 #ifdef SDB_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
122 #ifdef DWARF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
125 #ifdef DWARF2_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
128 #ifdef XCOFF_DEBUGGING_INFO
129 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
131 #endif /* More than one debugger format enabled. */
133 /* If still not defined, must have been because no debugging formats
135 #ifndef PREFERRED_DEBUGGING_TYPE
136 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
139 #ifndef DIR_SEPARATOR
140 #define DIR_SEPARATOR '/'
143 #if ! (defined (VMS) || defined (OS2))
144 extern char **environ;
146 extern char *version_string, *language_string;
148 /* Carry information from ASM_DECLARE_OBJECT_NAME
149 to ASM_FINISH_DECLARE_OBJECT. */
151 extern int size_directive_output;
152 extern tree last_assemble_variable_decl;
154 extern char *init_parse PVPROTO((char *));
155 extern void finish_parse ();
156 extern void init_decl_processing ();
157 extern void init_obstacks ();
158 extern void init_tree_codes ();
159 extern void init_rtl ();
160 extern void init_regs ();
161 extern void init_optabs ();
162 extern void init_stmt ();
163 extern void init_reg_sets ();
164 extern void dump_flow_info ();
165 extern void dump_sched_info ();
166 extern void dump_local_alloc ();
167 extern void regset_release_memory ();
169 extern void print_rtl ();
170 extern void print_rtl_with_bb ();
172 void rest_of_decl_compilation ();
173 void error_with_file_and_line PVPROTO((const char *file,
174 int line, const char *s, ...));
175 void error_with_decl PVPROTO((tree decl, const char *s, ...));
176 void error_for_asm PVPROTO((rtx insn, const char *s, ...));
177 void notice PVPROTO((const char *s, ...));
178 void error PVPROTO((const char *s, ...));
179 void fatal PVPROTO((const char *s, ...));
180 void warning_with_file_and_line PVPROTO((const char *file,
181 int line, const char *s, ...));
182 void warning_with_decl PVPROTO((tree decl, const char *s, ...));
183 void warning PVPROTO((const char *s, ...));
184 void pedwarn PVPROTO((const char *s, ...));
185 void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...));
186 void pedwarn_with_file_and_line PVPROTO((const char *file,
187 int line, const char *s, ...));
188 void sorry PVPROTO((const char *s, ...));
189 static void set_target_switch PROTO((const char *));
190 static char *decl_name PROTO((tree, int));
191 static void vmessage PROTO((const char *, const char *, va_list));
192 static void v_message_with_file_and_line PROTO((const char *, int, int,
193 const char *, va_list));
194 static void v_message_with_decl PROTO((tree, int, const char *, va_list));
195 static void file_and_line_for_asm PROTO((rtx, char **, int *));
196 static void v_error_with_file_and_line PROTO((const char *, int,
197 const char *, va_list));
198 static void v_error_with_decl PROTO((tree, const char *, va_list));
199 static void v_error_for_asm PROTO((rtx, const char *, va_list));
200 static void verror PROTO((const char *, va_list));
201 static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN;
202 static void v_warning_with_file_and_line PROTO ((const char *, int,
203 const char *, va_list));
204 static void v_warning_with_decl PROTO((tree, const char *, va_list));
205 static void v_warning_for_asm PROTO((rtx, const char *, va_list));
206 static void vwarning PROTO((const char *, va_list));
207 static void vpedwarn PROTO((const char *, va_list));
208 static void v_pedwarn_with_decl PROTO((tree, const char *, va_list));
209 static void v_pedwarn_with_file_and_line PROTO((const char *, int,
210 const char *, va_list));
211 static void vsorry PROTO((const char *, va_list));
212 static void float_signal PROTO((int)) ATTRIBUTE_NORETURN;
213 static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
214 #ifdef ASM_IDENTIFY_LANGUAGE
215 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
216 static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED;
218 static void open_dump_file PROTO((const char *, const char *));
219 static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx));
220 static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx));
221 static void clean_dump_file PROTO((const char *));
222 static void compile_file PROTO((char *));
223 static void display_help PROTO ((void));
225 static void print_version PROTO((FILE *, const char *));
226 static int print_single_switch PROTO((FILE *, int, int, const char *,
227 const char *, const char *,
228 const char *, const char *));
229 static void print_switch_values PROTO((FILE *, int, int, const char *,
230 const char *, const char *));
232 void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx));
233 void clean_graph_dump_file PROTO ((const char *, const char *));
234 void finish_graph_dump_file PROTO ((const char *, const char *));
235 /* Length of line when printing switch values. */
238 /* Name of program invoked, sans directories. */
242 /* Copy of arguments to main. */
246 /* Name of current original source file (what was input to cpp).
247 This comes from each #-command in the actual input. */
249 char *input_filename;
251 /* Name of top-level original source file (what was input to cpp).
252 This comes from the #-command at the beginning of the actual input.
253 If there isn't any there, then this is the cc1 input file name. */
255 char *main_input_filename;
257 /* Current line number in real source file. */
261 /* Nonzero if it is unsafe to create any new pseudo registers. */
264 /* Stack of currently pending input files. */
266 struct file_stack *input_file_stack;
268 /* Incremented on each change to input_file_stack. */
269 int input_file_stack_tick;
271 /* FUNCTION_DECL for function now being parsed or compiled. */
273 extern tree current_function_decl;
275 /* Name to use as base of names for dump output files. */
277 const char *dump_base_name;
279 /* Bit flags that specify the machine subtype we are compiling for.
280 Bits are tested using macros TARGET_... defined in the tm.h file
281 and set by `-m...' switches. Must be defined in rtlanal.c. */
283 extern int target_flags;
285 /* Flags saying which kinds of debugging dump have been requested. */
288 int rtl_dump_and_exit = 0;
289 int jump_opt_dump = 0;
290 int addressof_dump = 0;
295 int branch_prob_dump = 0;
297 int combine_dump = 0;
298 int regmove_dump = 0;
300 int local_reg_dump = 0;
301 int global_reg_dump = 0;
304 int jump2_opt_dump = 0;
306 int dbr_sched_dump = 0;
308 int flag_print_asm_name = 0;
310 int stack_reg_dump = 0;
312 #ifdef MACHINE_DEPENDENT_REORG
313 int mach_dep_reorg_dump = 0;
315 enum graph_dump_types graph_dump_format;
317 /* Name for output file of assembly code, specified with -o. */
321 /* Value of the -G xx switch, and whether it was passed or not. */
325 /* Type(s) of debugging information we are producing (if any).
326 See flags.h for the definitions of the different possible
327 types of debugging information. */
328 enum debug_info_type write_symbols = NO_DEBUG;
330 /* Level of debugging information we are producing. See flags.h
331 for the definitions of the different possible levels. */
332 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
334 /* Nonzero means use GNU-only extensions in the generated symbolic
335 debugging information. */
336 /* Currently, this only has an effect when write_symbols is set to
337 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
338 int use_gnu_debug_info_extensions = 0;
340 /* Nonzero means do optimizations. -O.
341 Particular numeric values stand for particular amounts of optimization;
342 thus, -O2 stores 2 here. However, the optimizations beyond the basic
343 ones are not controlled directly by this variable. Instead, they are
344 controlled by individual `flag_...' variables that are defaulted
345 based on this variable. */
349 /* Nonzero means optimize for size. -Os.
350 The only valid values are zero and non-zero. When optimize_size is
351 non-zero, optimize defaults to 2, but certain individual code
352 bloating optimizations are disabled. */
354 int optimize_size = 0;
356 /* Number of error messages and warning messages so far. */
359 int warningcount = 0;
362 /* Pointer to function to compute the name to use to print a declaration.
363 DECL is the declaration in question.
364 VERBOSITY determines what information will be printed:
365 0: DECL_NAME, demangled as necessary.
366 1: and scope information.
367 2: and any other information that might be interesting, such as function
368 parameter types in C++. */
370 char *(*decl_printable_name) PROTO ((tree, int));
372 /* Pointer to function to compute rtl for a language-specific tree code. */
374 typedef rtx (*lang_expand_expr_t)
375 PROTO ((union tree_node *, rtx, enum machine_mode,
376 enum expand_modifier modifier));
378 lang_expand_expr_t lang_expand_expr = 0;
380 tree (*lang_expand_constant) PROTO((tree)) = 0;
382 /* Pointer to function to finish handling an incomplete decl at the
383 end of compilation. */
385 void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0;
387 /* Nonzero if generating code to do profiling. */
389 int profile_flag = 0;
391 /* Nonzero if generating code to do profiling on a line-by-line basis. */
393 int profile_block_flag;
395 /* Nonzero if generating code to profile program flow graph arcs. */
397 int profile_arc_flag = 0;
399 /* Nonzero if generating info for gcov to calculate line test coverage. */
401 int flag_test_coverage = 0;
403 /* Nonzero indicates that branch taken probabilities should be calculated. */
405 int flag_branch_probabilities = 0;
407 /* Nonzero for -pedantic switch: warn about anything
408 that standard spec forbids. */
412 /* Temporarily suppress certain warnings.
413 This is set while reading code from a system header file. */
415 int in_system_header = 0;
417 /* Nonzero means do stupid register allocation.
418 Currently, this is 1 if `optimize' is 0. */
420 int obey_regdecls = 0;
422 /* Don't print functions as they are compiled and don't print
423 times taken by the various passes. -quiet. */
429 /* Nonzero means `char' should be signed. */
431 int flag_signed_char;
433 /* Nonzero means give an enum type only as many bytes as it needs. */
435 int flag_short_enums;
437 /* Nonzero for -fcaller-saves: allocate values in regs that need to
438 be saved across function calls, if that produces overall better code.
439 Optional now, so people can test it. */
441 #ifdef DEFAULT_CALLER_SAVES
442 int flag_caller_saves = 1;
444 int flag_caller_saves = 0;
447 /* Nonzero if structures and unions should be returned in memory.
449 This should only be defined if compatibility with another compiler or
450 with an ABI is needed, because it results in slower code. */
452 #ifndef DEFAULT_PCC_STRUCT_RETURN
453 #define DEFAULT_PCC_STRUCT_RETURN 1
456 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
458 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
460 /* Nonzero for -fforce-mem: load memory value into a register
461 before arithmetic on it. This makes better cse but slower compilation. */
463 int flag_force_mem = 0;
465 /* Nonzero for -fforce-addr: load memory address into a register before
466 reference to memory. This makes better cse but slower compilation. */
468 int flag_force_addr = 0;
470 /* Nonzero for -fdefer-pop: don't pop args after each function call;
471 instead save them up to pop many calls' args with one insns. */
473 int flag_defer_pop = 0;
475 /* Nonzero for -ffloat-store: don't allocate floats and doubles
476 in extended-precision registers. */
478 int flag_float_store = 0;
480 /* Nonzero for -fcse-follow-jumps:
481 have cse follow jumps to do a more extensive job. */
483 int flag_cse_follow_jumps;
485 /* Nonzero for -fcse-skip-blocks:
486 have cse follow a branch around a block. */
487 int flag_cse_skip_blocks;
489 /* Nonzero for -fexpensive-optimizations:
490 perform miscellaneous relatively-expensive optimizations. */
491 int flag_expensive_optimizations;
493 /* Nonzero for -fthread-jumps:
494 have jump optimize output of loop. */
496 int flag_thread_jumps;
498 /* Nonzero enables strength-reduction in loop.c. */
500 int flag_strength_reduce = 0;
502 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
503 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
504 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
507 int flag_unroll_loops;
509 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
510 This is generally not a win. */
512 int flag_unroll_all_loops;
514 /* Nonzero forces all invariant computations in loops to be moved
517 int flag_move_all_movables = 0;
519 /* Nonzero forces all general induction variables in loops to be
522 int flag_reduce_all_givs = 0;
524 /* Nonzero to perform full register move optimization passes. This is the
527 int flag_regmove = 0;
529 /* Nonzero for -fwritable-strings:
530 store string constants in data segment and don't uniquize them. */
532 int flag_writable_strings = 0;
534 /* Nonzero means don't put addresses of constant functions in registers.
535 Used for compiling the Unix kernel, where strange substitutions are
536 done on the assembly output. */
538 int flag_no_function_cse = 0;
540 /* Nonzero for -fomit-frame-pointer:
541 don't make a frame pointer in simple functions that don't require one. */
543 int flag_omit_frame_pointer = 0;
545 /* Nonzero means place each function into its own section on those platforms
546 which support arbitrary section names and unlimited numbers of sections. */
548 int flag_function_sections = 0;
550 /* ... and similar for data. */
552 int flag_data_sections = 0;
554 /* Nonzero to inhibit use of define_optimization peephole opts. */
556 int flag_no_peephole = 0;
558 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
559 operations in the interest of optimization. For example it allows
560 GCC to assume arguments to sqrt are nonnegative numbers, allowing
561 faster code for sqrt to be generated. */
563 int flag_fast_math = 0;
565 /* Nonzero means the front end generally wants `errno' maintained by math
566 operations, like built-in SQRT, unless overridden by flag_fast_math. */
568 int flag_errno_math = 1;
570 /* 0 means straightforward implementation of complex divide acceptable.
571 1 means wide ranges of inputs must work for complex divide.
572 2 means C9X-like requirements for complex divide (not yet implemented). */
574 int flag_complex_divide_method = 0;
576 /* Nonzero means all references through pointers are volatile. */
580 /* Nonzero means treat all global and extern variables as volatile. */
582 int flag_volatile_global;
584 /* Nonzero means treat all static variables as volatile. */
586 int flag_volatile_static;
588 /* Nonzero means just do syntax checking; don't output anything. */
590 int flag_syntax_only = 0;
592 /* Nonzero means perform global cse. */
594 static int flag_gcse;
596 /* Nonzero means to rerun cse after loop optimization. This increases
597 compilation time about 20% and picks up a few more common expressions. */
599 static int flag_rerun_cse_after_loop;
601 /* Nonzero means to run loop optimizations twice. */
603 int flag_rerun_loop_opt;
605 /* Nonzero for -finline-functions: ok to inline functions that look like
606 good inline candidates. */
608 int flag_inline_functions;
610 /* Nonzero for -fkeep-inline-functions: even if we make a function
611 go inline everywhere, keep its definition around for debugging
614 int flag_keep_inline_functions;
616 /* Nonzero means that functions will not be inlined. */
620 /* Nonzero means that we should emit static const variables
621 regardless of whether or not optimization is turned on. */
623 int flag_keep_static_consts = 1;
625 /* Nonzero means we should be saving declaration info into a .X file. */
627 int flag_gen_aux_info = 0;
629 /* Specified name of aux-info file. */
631 static char *aux_info_file_name;
633 /* Nonzero means make the text shared if supported. */
635 int flag_shared_data;
637 /* Nonzero means schedule into delayed branch slots if supported. */
639 int flag_delayed_branch;
641 /* Nonzero if we are compiling pure (sharable) code.
642 Value is 1 if we are doing reasonable (i.e. simple
643 offset into offset table) pic. Value is 2 if we can
644 only perform register offsets. */
648 /* Nonzero means generate extra code for exception handling and enable
649 exception handling. */
653 /* Nonzero means use the new model for exception handling. Replaces
654 -DNEW_EH_MODEL as a compile option. */
656 int flag_new_exceptions = 0;
658 /* Nonzero means don't place uninitialized global data in common storage
663 /* Nonzero means pretend it is OK to examine bits of target floats,
664 even if that isn't true. The resulting code will have incorrect constants,
665 but the same series of instructions that the native compiler would make. */
667 int flag_pretend_float;
669 /* Nonzero means change certain warnings into errors.
670 Usually these are warnings about failure to conform to some standard. */
672 int flag_pedantic_errors = 0;
674 /* flag_schedule_insns means schedule insns within basic blocks (before
676 flag_schedule_insns_after_reload means schedule insns after
679 int flag_schedule_insns = 0;
680 int flag_schedule_insns_after_reload = 0;
683 /* The following flags have effect only for scheduling before register
686 flag_schedule_interblock means schedule insns accross basic blocks.
687 flag_schedule_speculative means allow speculative motion of non-load insns.
688 flag_schedule_speculative_load means allow speculative motion of some
690 flag_schedule_speculative_load_dangerous allows speculative motion of more
693 int flag_schedule_interblock = 1;
694 int flag_schedule_speculative = 1;
695 int flag_schedule_speculative_load = 0;
696 int flag_schedule_speculative_load_dangerous = 0;
699 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
700 by a cheaper branch, on a count register. */
701 int flag_branch_on_count_reg;
703 /* -finhibit-size-directive inhibits output of .size for ELF.
704 This is used only for compiling crtstuff.c,
705 and it may be extended to other effects
706 needed for crtstuff.c on other systems. */
707 int flag_inhibit_size_directive = 0;
709 /* -fverbose-asm causes extra commentary information to be produced in
710 the generated assembly code (to make it more readable). This option
711 is generally only of use to those who actually need to read the
712 generated assembly code (perhaps while debugging the compiler itself).
713 -fno-verbose-asm, the default, causes the extra information
714 to be omitted and is useful when comparing two assembler files. */
716 int flag_verbose_asm = 0;
718 /* -dA causes debug commentary information to be produced in
719 the generated assembly code (to make it more readable). This option
720 is generally only of use to those who actually need to read the
721 generated assembly code (perhaps while debugging the compiler itself).
722 Currently, this switch is only used by dwarfout.c; however, it is intended
723 to be a catchall for printing debug information in the assembler file. */
725 int flag_debug_asm = 0;
727 /* -fgnu-linker specifies use of the GNU linker for initializations.
728 (Or, more generally, a linker that handles initializations.)
729 -fno-gnu-linker says that collect2 will be used. */
731 int flag_gnu_linker = 0;
733 int flag_gnu_linker = 1;
736 /* Tag all structures with __attribute__(packed) */
737 int flag_pack_struct = 0;
739 /* Nonzero means that -Wformat accepts certain system-dependent formats. */
740 int flag_format_extensions = 0;
742 /* Emit code to check for stack overflow; also may cause large objects
743 to be allocated dynamically. */
744 int flag_stack_check;
746 /* -fcheck-memory-usage causes extra code to be generated in order to check
747 memory accesses. This is used by a detector of bad memory accesses such
749 int flag_check_memory_usage = 0;
751 /* -fprefix-function-name causes function name to be prefixed. This
752 can be used with -fcheck-memory-usage to isolate code compiled with
753 -fcheck-memory-usage. */
754 int flag_prefix_function_name = 0;
756 /* 0 if pointer arguments may alias each other. True in C.
757 1 if pointer arguments may not alias each other but may alias
759 2 if pointer arguments may not alias each other and may not
760 alias global variables. True in Fortran.
761 This defaults to 0 for C. */
762 int flag_argument_noalias = 0;
764 /* Nonzero if we should do (language-dependent) alias analysis.
765 Typically, this analysis will assume that expressions of certain
766 types do not alias expressions of certain other types. Only used
767 if alias analysis (in general) is enabled. */
768 int flag_strict_aliasing = 0;
770 /* Instrument functions with calls at entry and exit, for profiling. */
771 int flag_instrument_function_entry_exit = 0;
773 /* Nonzero means ignore `#ident' directives. 0 means handle them.
774 On SVR4 targets, it also controls whether or not to emit a
775 string identifying the compiler. */
777 int flag_no_ident = 0;
779 #if defined(STACK_PROTECTOR) && defined(STACK_GROWS_DOWNWARD)
780 /* Nonzero means use propolice as a stack protection method */
781 int flag_propolice_protection = 0; /* require -fstack-protector */
783 int flag_propolice_protection = 0;
786 /* Table of supported debugging formats. */
790 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
791 constant expression, we use NO_DEBUG in its place. */
792 enum debug_info_type debug_type;
793 int use_extensions_p;
794 const char * description;
798 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
799 "Generate default debug format output" },
800 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
801 #ifdef DBX_DEBUGGING_INFO
802 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
803 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
805 #ifdef DWARF_DEBUGGING_INFO
806 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
807 { "gdwarf+", DWARF_DEBUG, 1,
808 "Generated extended DWARF-1 format debug output" },
810 #ifdef DWARF2_DEBUGGING_INFO
811 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
813 #ifdef XCOFF_DEBUGGING_INFO
814 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
815 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
817 #ifdef SDB_DEBUGGING_INFO
818 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
828 const char * description;
830 lang_independent_options;
832 /* Add or remove a leading underscore from user symbols. */
833 int flag_leading_underscore = -1;
835 /* The user symbol prefix after having resolved same. */
836 const char *user_label_prefix;
838 /* A default for same. */
839 #ifndef USER_LABEL_PREFIX
840 #define USER_LABEL_PREFIX ""
843 /* Table of language-independent -f options.
844 STRING is the option name. VARIABLE is the address of the variable.
845 ON_VALUE is the value to store in VARIABLE
846 if `-fSTRING' is seen as an option.
847 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
849 lang_independent_options f_options[] =
851 {"float-store", &flag_float_store, 1,
852 "Do not store floats in registers" },
853 {"volatile", &flag_volatile, 1,
854 "Consider all mem refs through pointers as volatile"},
855 {"volatile-global", &flag_volatile_global, 1,
856 "Consider all mem refs to global data to be volatile" },
857 {"volatile-static", &flag_volatile_static, 1,
858 "Consider all mem refs to static data to be volatile" },
859 {"defer-pop", &flag_defer_pop, 1,
860 "Defer popping functions args from stack until later" },
861 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
862 "When possible do not generate stack frames"},
863 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
864 "When running CSE, follow jumps to their targets" },
865 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
866 "When running CSE, follow conditional jumps" },
867 {"expensive-optimizations", &flag_expensive_optimizations, 1,
868 "Perform a number of minor, expensive optimisations" },
869 {"thread-jumps", &flag_thread_jumps, 1,
870 "Perform jump threading optimisations"},
871 {"strength-reduce", &flag_strength_reduce, 1,
872 "Perform strength reduction optimisations" },
873 {"unroll-loops", &flag_unroll_loops, 1,
874 "Perform loop unrolling when iteration count is known" },
875 {"unroll-all-loops", &flag_unroll_all_loops, 1,
876 "Perform loop unrolling for all loops" },
877 {"move-all-movables", &flag_move_all_movables, 1,
878 "Force all loop invariant computations out of loops" },
879 {"reduce-all-givs", &flag_reduce_all_givs, 1,
880 "Strength reduce all loop general induction variables" },
881 {"writable-strings", &flag_writable_strings, 1,
882 "Store strings in writable data section" },
883 {"peephole", &flag_no_peephole, 0,
884 "Enable machine specific peephole optimisations" },
885 {"force-mem", &flag_force_mem, 1,
886 "Copy memory operands into registers before using" },
887 {"force-addr", &flag_force_addr, 1,
888 "Copy memory address constants into regs before using" },
889 {"function-cse", &flag_no_function_cse, 0,
890 "Allow function addresses to be held in registers" },
891 {"inline-functions", &flag_inline_functions, 1,
892 "Integrate simple functions into their callers" },
893 {"keep-inline-functions", &flag_keep_inline_functions, 1,
894 "Generate code for funcs even if they are fully inlined" },
895 {"inline", &flag_no_inline, 0,
896 "Pay attention to the 'inline' keyword"},
897 {"keep-static-consts", &flag_keep_static_consts, 1,
898 "Emit static const variables even if they are not used" },
899 {"syntax-only", &flag_syntax_only, 1,
900 "Check for syntax errors, then stop" },
901 {"shared-data", &flag_shared_data, 1,
902 "Mark data as shared rather than private" },
903 {"caller-saves", &flag_caller_saves, 1,
904 "Enable saving registers around function calls" },
905 {"pcc-struct-return", &flag_pcc_struct_return, 1,
906 "Return 'short' aggregates in memory, not registers" },
907 {"reg-struct-return", &flag_pcc_struct_return, 0,
908 "Return 'short' aggregates in registers" },
909 {"delayed-branch", &flag_delayed_branch, 1,
910 "Attempt to fill delay slots of branch instructions" },
911 {"gcse", &flag_gcse, 1,
912 "Perform the global common subexpression elimination" },
913 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
914 "Run CSE pass after loop optimisations"},
915 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
916 "Run the loop optimiser twice"},
917 {"pretend-float", &flag_pretend_float, 1,
918 "Pretend that host and target use the same FP format"},
919 {"schedule-insns", &flag_schedule_insns, 1,
920 "Reschedule instructions to avoid pipeline stalls"},
921 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
922 "Run two passes of the instruction scheduler"},
924 {"sched-interblock",&flag_schedule_interblock, 1,
925 "Enable scheduling across basic blocks" },
926 {"sched-spec",&flag_schedule_speculative, 1,
927 "Allow speculative motion of non-loads" },
928 {"sched-spec-load",&flag_schedule_speculative_load, 1,
929 "Allow speculative motion of some loads" },
930 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
931 "Allow speculative motion of more loads" },
933 {"branch-count-reg",&flag_branch_on_count_reg, 1,
934 "Replace add,compare,branch with branch on count reg"},
935 {"pic", &flag_pic, 1,
936 "Generate position independent code, if possible"},
937 {"PIC", &flag_pic, 2, ""},
938 {"exceptions", &flag_exceptions, 1,
939 "Enable exception handling" },
940 {"new-exceptions", &flag_new_exceptions, 1,
941 "Use the new model for exception handling" },
942 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
943 "Use setjmp/longjmp to handle exceptions" },
944 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
945 "Support asynchronous exceptions" },
946 {"profile-arcs", &profile_arc_flag, 1,
947 "Insert arc based program profiling code" },
948 {"test-coverage", &flag_test_coverage, 1,
949 "Create data files needed by gcov" },
950 {"branch-probabilities", &flag_branch_probabilities, 1,
951 "Use profiling information for branch probabilities" },
952 {"fast-math", &flag_fast_math, 1,
953 "Improve FP speed by violating ANSI & IEEE rules" },
954 {"common", &flag_no_common, 0,
955 "Do not put unitialised globals in the common section" },
956 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
957 "Do not generate .size directives" },
958 {"function-sections", &flag_function_sections, 1,
959 "place each function into its own section" },
960 {"data-sections", &flag_data_sections, 1,
961 "place data items into their own section" },
962 {"verbose-asm", &flag_verbose_asm, 1,
963 "Add extra commentry to assembler output"},
964 {"gnu-linker", &flag_gnu_linker, 1,
965 "Output GNU ld formatted global initialisers"},
966 {"regmove", &flag_regmove, 1,
967 "Enables a register move optimisation"},
968 {"optimize-register-move", &flag_regmove, 1,
969 "Do the full regmove optimization pass"},
970 {"pack-struct", &flag_pack_struct, 1,
971 "Pack structure members together without holes" },
972 {"format-extensions", &flag_format_extensions, 1,
973 "-Wformat accepts certain FreeBSD system-dependent formats" },
974 {"stack-check", &flag_stack_check, 1,
975 "Insert stack checking code into the program" },
976 {"argument-alias", &flag_argument_noalias, 0,
977 "Specify that arguments may alias each other & globals"},
978 {"argument-noalias", &flag_argument_noalias, 1,
979 "Assume arguments may alias globals but not each other"},
980 {"argument-noalias-global", &flag_argument_noalias, 2,
981 "Assume arguments do not alias each other or globals" },
982 {"strict-aliasing", &flag_strict_aliasing, 1,
983 "Assume strict aliasing rules apply" },
984 {"check-memory-usage", &flag_check_memory_usage, 1,
985 "Generate code to check every memory access" },
986 {"prefix-function-name", &flag_prefix_function_name, 1,
987 "Add a prefix to all function names" },
988 {"dump-unnumbered", &flag_dump_unnumbered, 1,
989 "Suppress output of instruction numbers and line number notes in debugging dumps"},
990 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
991 "Instrument function entry/exit with profiling calls"},
992 {"leading-underscore", &flag_leading_underscore, 1,
993 "External symbols have a leading underscore" },
994 {"ident", &flag_no_ident, 0,
995 "Process #ident directives"},
996 {"stack-protector", &flag_propolice_protection, 1,
997 "Enables stack protection" },
998 {"no-stack-protector", &flag_propolice_protection, 0,
999 "Disables stack protection" },
1002 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1004 /* Table of language-specific options. */
1006 static struct lang_opt
1008 const char * option;
1009 const char * description;
1011 documented_lang_options[] =
1013 /* In order not to overload the --help output, the convention
1014 used here is to only describe those options which are not
1015 enabled by default. */
1017 { "-ansi", "Compile just for ANSI C" },
1018 { "-fallow-single-precision",
1019 "Do not promote floats to double if using -traditional" },
1020 { "-std= ", "Determine language standard"},
1022 { "-fsigned-bitfields", "" },
1023 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1024 { "-fno-signed-bitfields", "" },
1025 { "-fno-unsigned-bitfields","" },
1026 { "-fsigned-char", "Make 'char' be signed by default"},
1027 { "-funsigned-char", "Make 'char' be unsigned by default"},
1028 { "-fno-signed-char", "" },
1029 { "-fno-unsigned-char", "" },
1031 { "-ftraditional", "" },
1032 { "-traditional", "Attempt to support traditional K&R style C"},
1033 { "-fnotraditional", "" },
1034 { "-fno-traditional", "" },
1037 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1038 { "-fbuiltin", "" },
1039 { "-fno-builtin", "Do not recognise any built in functions" },
1040 { "-fhosted", "Assume normal C execution environment" },
1041 { "-fno-hosted", "" },
1043 "Assume that standard libraries & main might not exist" },
1044 { "-fno-freestanding", "" },
1045 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1046 { "-fno-cond-mismatch", "" },
1047 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1048 { "-fno-dollars-in-identifiers", "" },
1049 { "-fshort-double", "Use the same size for double as for float" },
1050 { "-fno-short-double", "" },
1051 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1052 { "-fno-short-enums", "" },
1054 { "-Wall", "Enable most warning messages" },
1055 { "-Wbad-function-cast",
1056 "Warn about casting functions to incompatible types" },
1057 { "-Wno-bad-function-cast", "" },
1058 { "-Wmissing-noreturn",
1059 "Warn about functions which might be candidates for attribute noreturn" },
1060 { "-Wno-missing-noreturn", "" },
1061 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1062 { "-Wno-cast-qual", "" },
1063 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1064 { "-Wno-char-subscripts", "" },
1065 { "-Wcomment", "Warn if nested comments are detected" },
1066 { "-Wno-comment", "" },
1067 { "-Wcomments", "Warn if nested comments are detected" },
1068 { "-Wno-comments", "" },
1069 { "-Wconversion", "Warn about possibly confusing type conversions" },
1070 { "-Wno-conversion", "" },
1071 { "-Wformat", "Warn about printf format anomalies" },
1072 { "-Wnon-const-format", "Warn about printf-like format strings" },
1073 { "-Wno-format", "" },
1074 { "-Wno-format-extra-args", "" },
1075 { "-Wimplicit-function-declaration",
1076 "Warn about implicit function declarations" },
1077 { "-Wno-implicit-function-declaration", "" },
1078 { "-Werror-implicit-function-declaration", "" },
1079 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1080 { "-Wno-implicit-int", "" },
1081 { "-Wimplicit", "" },
1082 { "-Wno-implicit", "" },
1083 { "-Wimport", "Warn about the use of the #import directive" },
1084 { "-Wno-import", "" },
1085 { "-Wlong-long","" },
1086 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1087 { "-Wmain", "Warn about suspicious declarations of main" },
1088 { "-Wframe-size-<N>",
1089 "Warn if frame uses greater than <N> bytes." },
1090 { "-Warglist-size-<N>",
1091 "Warn if function argument list uses greater than <N> bytes." },
1092 { "-Wno-main", "" },
1093 { "-Wmissing-braces",
1094 "Warn about possibly missing braces around initialisers" },
1095 { "-Wno-missing-braces", "" },
1096 { "-Wmissing-declarations",
1097 "Warn about global funcs without previous declarations"},
1098 { "-Wno-missing-declarations", "" },
1099 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1100 { "-Wno-missing-prototypes", "" },
1101 { "-Wmultichar", "Warn about use of multicharacter literals"},
1102 { "-Wno-multichar", "" },
1103 { "-Wnested-externs", "Warn about externs not at file scope level" },
1104 { "-Wno-nested-externs", "" },
1105 { "-Wparentheses", "Warn about possible missing parentheses" },
1106 { "-Wno-parentheses", "" },
1107 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1108 { "-Wno-pointer-arith", "" },
1109 { "-Wredundant-decls",
1110 "Warn about multiple declarations of the same object" },
1111 { "-Wno-redundant-decls", "" },
1112 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1113 { "-Wno-sign-compare", "" },
1114 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1115 { "-Wno-unknown-pragmas", "" },
1116 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1117 { "-Wno-strict-prototypes", "" },
1118 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1119 { "-Wno-traditional", "" },
1120 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1121 { "-Wno-trigraphs", "" },
1123 { "-Wno-undef", "" },
1124 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1125 { "-Wno-write-strings", "" },
1127 /* These are for languages with USE_CPPLIB. */
1128 /* These options are already documented in cpplib.c */
1134 { "-MD", "Print dependencies to FILE.d" },
1135 { "-MMD", "Print dependencies to FILE.d" },
1136 { "-M", "Print dependencies to stdout" },
1137 { "-MM", "Print dependencies to stdout" },
1138 #endif /* USE_CPPLIB */
1141 { "-idirafter", "" },
1146 { "-iwithprefix", "" },
1147 { "-iwithprefixbefore", "" },
1149 { "-lang-c89", "" },
1150 { "-lang-c++", "" },
1152 { "-nostdinc", "" },
1153 { "-nostdinc++", "" },
1154 { "-trigraphs", "" },
1157 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1159 /* These are for obj c. */
1160 DEFINE_LANG_NAME ("Objective C")
1162 { "-lang-objc", "" },
1163 { "-gen-decls", "Dump decls to a .decl file" },
1164 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1165 { "-fno-gnu-runtime", "" },
1166 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1167 { "-fno-next-runtime", "" },
1168 { "-Wselector", "Warn if a selector has multiple methods" },
1169 { "-Wno-selector", "" },
1170 { "-Wprotocol", "" },
1171 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1172 { "-print-objc-runtime-info",
1173 "Generate C header of platform specific features" },
1175 #include "options.h"
1179 /* Here is a table, controlled by the tm.h file, listing each -m switch
1180 and which bits in `target_switches' it should set or clear.
1181 If VALUE is positive, it is bits to set.
1182 If VALUE is negative, -VALUE is bits to clear.
1183 (The sign bit is not used so there is no confusion.) */
1189 const char * description;
1191 target_switches [] = TARGET_SWITCHES;
1193 /* This table is similar, but allows the switch to have a value. */
1195 #ifdef TARGET_OPTIONS
1198 const char * prefix;
1199 const char ** variable;
1200 const char * description;
1202 target_options [] = TARGET_OPTIONS;
1205 /* Options controlling warnings */
1207 /* Don't print warning messages. -w. */
1209 int inhibit_warnings = 0;
1211 /* Print various extra warnings. -W. */
1213 int extra_warnings = 0;
1215 /* Treat warnings as errors. -Werror. */
1217 int warnings_are_errors = 0;
1219 /* Nonzero to warn about unused local variables. */
1223 /* Nonzero to warn about variables used before they are initialized. */
1225 int warn_uninitialized;
1227 /* Nonzero means warn about all declarations which shadow others. */
1231 /* Warn if a switch on an enum fails to have a case for every enum value. */
1235 /* Nonzero means warn about function definitions that default the return type
1236 or that use a null return and have a return-type other than void. */
1238 int warn_return_type;
1240 /* Nonzero means warn about pointer casts that increase the required
1241 alignment of the target type (and might therefore lead to a crash
1242 due to a misaligned access). */
1244 int warn_cast_align;
1246 /* Nonzero means warn if a frame is larger that N bytes. The value
1247 of N is warn_frame_size. */
1249 int warn_frame_size_flag = 0;
1250 int warn_frame_size;
1252 /* Nonzero means warn if a function call pushes more than N bytes
1253 onto the stack. The value of N is warn_arglist_size. */
1255 int warn_arglist_size_flag = 0;
1256 int warn_arglist_size;
1258 /* Nonzero means warn about any identifiers that match in the first N
1259 characters. The value N is in `id_clash_len'. */
1262 unsigned id_clash_len;
1264 /* Nonzero means warn about any objects definitions whose size is larger
1265 than N bytes. Also want about function definitions whose returned
1266 values are larger than N bytes. The value N is in `larger_than_size'. */
1268 int warn_larger_than;
1269 unsigned larger_than_size;
1271 /* Nonzero means warn if inline function is too large. */
1275 /* Warn if a function returns an aggregate,
1276 since there are often incompatible calling conventions for doing this. */
1278 int warn_aggregate_return;
1280 /* Likewise for -W. */
1282 lang_independent_options W_options[] =
1284 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1285 {"error", &warnings_are_errors, 1, ""},
1286 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1287 {"switch", &warn_switch, 1,
1288 "Warn about enumerated switches missing a specific case" },
1289 {"aggregate-return", &warn_aggregate_return, 1,
1290 "Warn about returning structures, unions or arrays" },
1291 {"cast-align", &warn_cast_align, 1,
1292 "Warn about pointer casts which increase alignment" },
1293 {"uninitialized", &warn_uninitialized, 1,
1294 "Warn about unitialized automatic variables"},
1295 {"inline", &warn_inline, 1,
1296 "Warn when an inlined function cannot be inlined"},
1297 {"stack-protector", &warn_stack_protector, 1,
1298 "Warn when disabling stack protector for some reason"}
1301 /* Output files for assembler code (real compiler output)
1302 and debugging dumps. */
1305 FILE *aux_info_file;
1306 FILE *rtl_dump_file = NULL;
1308 /* Decode the string P as an integral parameter.
1309 If the string is indeed an integer return its numeric value else
1310 issue an Invalid Option error for the option PNAME and return DEFVAL.
1311 If PNAME is zero just return DEFVAL, do not call error. */
1314 read_integral_parameter (p, pname, defval)
1319 const char *endp = p;
1323 if (*endp >= '0' && *endp <= '9')
1332 error ("Invalid option `%s'", pname);
1340 /* Time accumulators, to count the total time spent in various passes. */
1344 int integration_time;
1350 int branch_prob_time;
1355 int local_alloc_time;
1356 int global_alloc_time;
1362 int shorten_branch_time;
1368 /* Return time used so far, in microseconds. */
1378 #else /* not BeOS */
1379 #if defined (_WIN32) && !defined (__CYGWIN__)
1383 return (clock() * 1000);
1384 #else /* not _WIN32 */
1390 tick = 1000000 / sysconf(_SC_CLK_TCK);
1392 return (tms.tms_utime + tms.tms_stime) * tick;
1398 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1399 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1402 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1404 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1408 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1413 struct rusage rusage;
1414 getrusage (0, &rusage);
1415 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1416 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1423 int proc_system_time;
1424 int child_user_time;
1425 int child_system_time;
1427 times ((void *) &vms_times);
1428 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1432 #endif /* _SC_CLK_TCK */
1434 #endif /* __BEOS__ */
1437 #define TIMEVAR(VAR, BODY) \
1438 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1441 print_time (str, total)
1446 "time in %s: %d.%06d\n",
1447 str, total / 1000000, total % 1000000);
1450 /* Count an error or warning. Return 1 if the message should be printed. */
1453 count_error (warningp)
1456 if (warningp && inhibit_warnings)
1459 if (warningp && !warnings_are_errors)
1463 static int warning_message = 0;
1465 if (warningp && !warning_message)
1467 notice ("%s: warnings being treated as errors\n", progname);
1468 warning_message = 1;
1476 /* Print a fatal error message. NAME is the text.
1477 Also include a system error message based on `errno'. */
1480 pfatal_with_name (name)
1483 fprintf (stderr, "%s: ", progname);
1485 exit (FATAL_EXIT_CODE);
1489 fatal_io_error (name)
1492 notice ("%s: %s: I/O error\n", progname, name);
1493 exit (FATAL_EXIT_CODE);
1496 /* Called to give a better error message for a bad insn rather than
1497 just calling abort(). */
1500 fatal_insn VPROTO((const char *msgid, rtx insn, ...))
1502 #ifndef ANSI_PROTOTYPES
1508 VA_START (ap, insn);
1510 #ifndef ANSI_PROTOTYPES
1511 msgid = va_arg (ap, const char *);
1512 insn = va_arg (ap, rtx);
1517 exit (FATAL_EXIT_CODE);
1520 /* Called to give a better error message when we don't have an insn to match
1521 what we are looking for or if the insn's constraints aren't satisfied,
1522 rather than just calling abort(). */
1525 fatal_insn_not_found (insn)
1528 if (INSN_CODE (insn) < 0)
1529 fatal_insn ("internal error--unrecognizable insn:", insn);
1531 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1534 /* This is the default decl_printable_name function. */
1537 decl_name (decl, verbosity)
1539 int verbosity ATTRIBUTE_UNUSED;
1541 return IDENTIFIER_POINTER (DECL_NAME (decl));
1544 static int need_error_newline;
1546 /* Function of last error message;
1547 more generally, function such that if next error message is in it
1548 then we don't have to mention the function name. */
1549 static tree last_error_function = NULL;
1551 /* Used to detect when input_file_stack has changed since last described. */
1552 static int last_error_tick;
1554 /* Called when the start of a function definition is parsed,
1555 this function prints on stderr the name of the function. */
1558 announce_function (decl)
1563 if (rtl_dump_and_exit)
1564 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1566 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1568 need_error_newline = 1;
1569 last_error_function = current_function_decl;
1573 /* The default function to print out name of current function that caused
1577 default_print_error_function (file)
1580 if (last_error_function != current_function_decl)
1583 fprintf (stderr, "%s: ", file);
1585 if (current_function_decl == NULL)
1586 notice ("At top level:\n");
1588 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1589 ? "In method `%s':\n"
1590 : "In function `%s':\n"),
1591 (*decl_printable_name) (current_function_decl, 2));
1593 last_error_function = current_function_decl;
1597 /* Called by report_error_function to print out function name.
1598 * Default may be overridden by language front-ends. */
1600 void (*print_error_function) PROTO((const char *)) =
1601 default_print_error_function;
1603 /* Prints out, if necessary, the name of the current function
1604 that caused an error. Called from all error and warning functions.
1605 We ignore the FILE parameter, as it cannot be relied upon. */
1608 report_error_function (file)
1609 const char *file ATTRIBUTE_UNUSED;
1611 struct file_stack *p;
1613 if (need_error_newline)
1615 fprintf (stderr, "\n");
1616 need_error_newline = 0;
1619 if (input_file_stack && input_file_stack->next != 0
1620 && input_file_stack_tick != last_error_tick)
1622 for (p = input_file_stack->next; p; p = p->next)
1623 notice ((p == input_file_stack->next
1624 ? "In file included from %s:%d"
1625 : ",\n from %s:%d"),
1627 fprintf (stderr, ":\n");
1628 last_error_tick = input_file_stack_tick;
1631 (*print_error_function) (input_filename);
1634 /* Print a message. */
1637 vnotice (file, msgid, ap)
1642 vfprintf (file, _(msgid), ap);
1646 notice VPROTO((const char *msgid, ...))
1648 #ifndef ANSI_PROTOTYPES
1653 VA_START (ap, msgid);
1655 #ifndef ANSI_PROTOTYPES
1656 msgid = va_arg (ap, char *);
1659 vnotice (stderr, msgid, ap);
1664 fnotice VPROTO((FILE *file, const char *msgid, ...))
1666 #ifndef ANSI_PROTOTYPES
1672 VA_START (ap, msgid);
1674 #ifndef ANSI_PROTOTYPES
1675 file = va_arg (ap, FILE *);
1676 msgid = va_arg (ap, const char *);
1679 vnotice (file, msgid, ap);
1683 /* Report FILE and LINE (or program name), and optionally just WARN. */
1686 report_file_and_line (file, line, warn)
1692 fprintf (stderr, "%s:%d: ", file, line);
1694 fprintf (stderr, "%s: ", progname);
1697 notice ("warning: ");
1700 /* Print a message. */
1703 vmessage (prefix, msgid, ap)
1709 fprintf (stderr, "%s: ", prefix);
1711 vfprintf (stderr, msgid, ap);
1714 /* Print a message relevant to line LINE of file FILE. */
1717 v_message_with_file_and_line (file, line, warn, msgid, ap)
1724 report_file_and_line (file, line, warn);
1725 vnotice (stderr, msgid, ap);
1726 fputc ('\n', stderr);
1729 /* Print a message relevant to the given DECL. */
1732 v_message_with_decl (decl, warn, msgid, ap)
1740 report_file_and_line (DECL_SOURCE_FILE (decl),
1741 DECL_SOURCE_LINE (decl), warn);
1743 /* Do magic to get around lack of varargs support for insertion
1744 of arguments into existing list. We know that the decl is first;
1745 we ass_u_me that it will be printed with "%s". */
1747 for (p = _(msgid); *p; ++p)
1751 if (*(p + 1) == '%')
1753 else if (*(p + 1) != 's')
1760 if (p > _(msgid)) /* Print the left-hand substring. */
1762 char fmt[sizeof "%.255s"];
1763 long width = p - _(msgid);
1765 if (width > 255L) width = 255L; /* arbitrary */
1766 sprintf (fmt, "%%.%lds", width);
1767 fprintf (stderr, fmt, _(msgid));
1770 if (*p == '%') /* Print the name. */
1772 const char *n = (DECL_NAME (decl)
1773 ? (*decl_printable_name) (decl, 2)
1779 if (ISALPHA (*(p - 1) & 0xFF))
1784 if (*p) /* Print the rest of the message. */
1785 vmessage ((char *)NULL, p, ap);
1787 fputc ('\n', stderr);
1790 /* Figure file and line of the given INSN. */
1793 file_and_line_for_asm (insn, pfile, pline)
1798 rtx body = PATTERN (insn);
1801 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1802 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1803 asmop = SET_SRC (body);
1804 else if (GET_CODE (body) == ASM_OPERANDS)
1806 else if (GET_CODE (body) == PARALLEL
1807 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1808 asmop = SET_SRC (XVECEXP (body, 0, 0));
1809 else if (GET_CODE (body) == PARALLEL
1810 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1811 asmop = XVECEXP (body, 0, 0);
1817 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1818 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1822 *pfile = input_filename;
1827 /* Report an error at line LINE of file FILE. */
1830 v_error_with_file_and_line (file, line, msgid, ap)
1837 report_error_function (file);
1838 v_message_with_file_and_line (file, line, 0, msgid, ap);
1842 error_with_file_and_line VPROTO((const char *file, int line,
1843 const char *msgid, ...))
1845 #ifndef ANSI_PROTOTYPES
1852 VA_START (ap, msgid);
1854 #ifndef ANSI_PROTOTYPES
1855 file = va_arg (ap, const char *);
1856 line = va_arg (ap, int);
1857 msgid = va_arg (ap, const char *);
1860 v_error_with_file_and_line (file, line, msgid, ap);
1864 /* Report an error at the declaration DECL.
1865 MSGID is a format string which uses %s to substitute the declaration
1866 name; subsequent substitutions are a la printf. */
1869 v_error_with_decl (decl, msgid, ap)
1875 report_error_function (DECL_SOURCE_FILE (decl));
1876 v_message_with_decl (decl, 0, msgid, ap);
1880 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1882 #ifndef ANSI_PROTOTYPES
1888 VA_START (ap, msgid);
1890 #ifndef ANSI_PROTOTYPES
1891 decl = va_arg (ap, tree);
1892 msgid = va_arg (ap, const char *);
1895 v_error_with_decl (decl, msgid, ap);
1899 /* Report an error at the line number of the insn INSN.
1900 This is used only when INSN is an `asm' with operands,
1901 and each ASM_OPERANDS records its own source file and line. */
1904 v_error_for_asm (insn, msgid, ap)
1913 file_and_line_for_asm (insn, &file, &line);
1914 report_error_function (file);
1915 v_message_with_file_and_line (file, line, 0, msgid, ap);
1919 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1921 #ifndef ANSI_PROTOTYPES
1927 VA_START (ap, msgid);
1929 #ifndef ANSI_PROTOTYPES
1930 insn = va_arg (ap, rtx);
1931 msgid = va_arg (ap, const char *);
1934 v_error_for_asm (insn, msgid, ap);
1938 /* Report an error at the current line number. */
1945 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1949 error VPROTO((const char *msgid, ...))
1951 #ifndef ANSI_PROTOTYPES
1956 VA_START (ap, msgid);
1958 #ifndef ANSI_PROTOTYPES
1959 msgid = va_arg (ap, const char *);
1966 /* Report a fatal error at the current line number. */
1974 exit (FATAL_EXIT_CODE);
1978 fatal VPROTO((const char *msgid, ...))
1980 #ifndef ANSI_PROTOTYPES
1985 VA_START (ap, msgid);
1987 #ifndef ANSI_PROTOTYPES
1988 msgid = va_arg (ap, const char *);
1995 /* Report a warning at line LINE of file FILE. */
1998 v_warning_with_file_and_line (file, line, msgid, ap)
2004 if (count_error (1))
2006 report_error_function (file);
2007 v_message_with_file_and_line (file, line, 1, msgid, ap);
2012 warning_with_file_and_line VPROTO((const char *file, int line,
2013 const char *msgid, ...))
2015 #ifndef ANSI_PROTOTYPES
2022 VA_START (ap, msgid);
2024 #ifndef ANSI_PROTOTYPES
2025 file = va_arg (ap, const char *);
2026 line = va_arg (ap, int);
2027 msgid = va_arg (ap, const char *);
2030 v_warning_with_file_and_line (file, line, msgid, ap);
2034 /* Report a warning at the declaration DECL.
2035 MSGID is a format string which uses %s to substitute the declaration
2036 name; subsequent substitutions are a la printf. */
2039 v_warning_with_decl (decl, msgid, ap)
2044 if (count_error (1))
2046 report_error_function (DECL_SOURCE_FILE (decl));
2047 v_message_with_decl (decl, 1, msgid, ap);
2052 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2054 #ifndef ANSI_PROTOTYPES
2060 VA_START (ap, msgid);
2062 #ifndef ANSI_PROTOTYPES
2063 decl = va_arg (ap, tree);
2064 msgid = va_arg (ap, const char *);
2067 v_warning_with_decl (decl, msgid, ap);
2071 /* Report a warning at the line number of the insn INSN.
2072 This is used only when INSN is an `asm' with operands,
2073 and each ASM_OPERANDS records its own source file and line. */
2076 v_warning_for_asm (insn, msgid, ap)
2081 if (count_error (1))
2086 file_and_line_for_asm (insn, &file, &line);
2087 report_error_function (file);
2088 v_message_with_file_and_line (file, line, 1, msgid, ap);
2093 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2095 #ifndef ANSI_PROTOTYPES
2101 VA_START (ap, msgid);
2103 #ifndef ANSI_PROTOTYPES
2104 insn = va_arg (ap, rtx);
2105 msgid = va_arg (ap, const char *);
2108 v_warning_for_asm (insn, msgid, ap);
2112 /* Report a warning at the current line number. */
2115 vwarning (msgid, ap)
2119 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2123 warning VPROTO((const char *msgid, ...))
2125 #ifndef ANSI_PROTOTYPES
2130 VA_START (ap, msgid);
2132 #ifndef ANSI_PROTOTYPES
2133 msgid = va_arg (ap, const char *);
2136 vwarning (msgid, ap);
2140 /* These functions issue either warnings or errors depending on
2141 -pedantic-errors. */
2144 vpedwarn (msgid, ap)
2148 if (flag_pedantic_errors)
2151 vwarning (msgid, ap);
2155 pedwarn VPROTO((const char *msgid, ...))
2157 #ifndef ANSI_PROTOTYPES
2162 VA_START (ap, msgid);
2164 #ifndef ANSI_PROTOTYPES
2165 msgid = va_arg (ap, const char *);
2168 vpedwarn (msgid, ap);
2173 v_pedwarn_with_decl (decl, msgid, ap)
2178 /* We don't want -pedantic-errors to cause the compilation to fail from
2179 "errors" in system header files. Sometimes fixincludes can't fix what's
2180 broken (eg: unsigned char bitfields - fixing it may change the alignment
2181 which will cause programs to mysteriously fail because the C library
2182 or kernel uses the original layout). There's no point in issuing a
2183 warning either, it's just unnecessary noise. */
2185 if (! DECL_IN_SYSTEM_HEADER (decl))
2187 if (flag_pedantic_errors)
2188 v_error_with_decl (decl, msgid, ap);
2190 v_warning_with_decl (decl, msgid, ap);
2195 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2197 #ifndef ANSI_PROTOTYPES
2203 VA_START (ap, msgid);
2205 #ifndef ANSI_PROTOTYPES
2206 decl = va_arg (ap, tree);
2207 msgid = va_arg (ap, const char *);
2210 v_pedwarn_with_decl (decl, msgid, ap);
2215 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2221 if (flag_pedantic_errors)
2222 v_error_with_file_and_line (file, line, msgid, ap);
2224 v_warning_with_file_and_line (file, line, msgid, ap);
2228 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2229 const char *msgid, ...))
2231 #ifndef ANSI_PROTOTYPES
2238 VA_START (ap, msgid);
2240 #ifndef ANSI_PROTOTYPES
2241 file = va_arg (ap, const char *);
2242 line = va_arg (ap, int);
2243 msgid = va_arg (ap, const char *);
2246 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2250 /* Apologize for not implementing some feature. */
2259 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2261 fprintf (stderr, "%s: ", progname);
2262 notice ("sorry, not implemented: ");
2263 vnotice (stderr, msgid, ap);
2264 fputc ('\n', stderr);
2268 sorry VPROTO((const char *msgid, ...))
2270 #ifndef ANSI_PROTOTYPES
2275 VA_START (ap, msgid);
2277 #ifndef ANSI_PROTOTYPES
2278 msgid = va_arg (ap, const char *);
2285 /* Given a partial pathname as input, return another pathname that shares
2286 no elements with the pathname of __FILE__. This is used by abort() to
2287 print `Internal compiler error in expr.c' instead of `Internal compiler
2288 error in ../../egcs/gcc/expr.c'. */
2290 trim_filename (name)
2293 static const char *this_file = __FILE__;
2294 const char *p = name, *q = this_file;
2296 while (*p == *q && *p != 0 && *q != 0) p++, q++;
2297 while (p > name && p[-1] != DIR_SEPARATOR
2298 #ifdef DIR_SEPARATOR_2
2299 && p[-1] != DIR_SEPARATOR_2
2307 /* More 'friendly' abort that prints the line and file.
2308 config.h can #define abort fancy_abort if you like that sort of thing.
2310 I don't think this is actually a good idea.
2311 Other sorts of crashes will look a certain way.
2312 It is a good thing if crashes from calling abort look the same way.
2318 fatal ("internal gcc abort");
2321 /* This calls abort and is used to avoid problems when abort if a macro.
2322 It is used when we need to pass the address of abort. */
2330 /* When `malloc.c' is compiled with `rcheck' defined,
2331 it calls this function to report clobberage. */
2335 const char * s ATTRIBUTE_UNUSED;
2340 /* Same as `malloc' but report error if no memory available. */
2351 value = (PTR) malloc (size);
2353 fatal ("virtual memory exhausted");
2357 /* Same as `calloc' but report error if no memory available. */
2360 xcalloc (size1, size2)
2361 size_t size1, size2;
2365 if (size1 == 0 || size2 == 0)
2368 value = (PTR) calloc (size1, size2);
2370 fatal ("virtual memory exhausted");
2375 /* Same as `realloc' but report error if no memory available.
2376 Also handle null PTR even if the vendor realloc gets it wrong. */
2379 xrealloc (ptr, size)
2383 register PTR result;
2388 result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size));
2391 fatal ("virtual memory exhausted");
2396 /* Same as `strdup' but report error if no memory available. */
2400 register const char *s;
2402 register char *result = (char *) malloc (strlen (s) + 1);
2405 fatal ("virtual memory exhausted");
2410 /* Return the logarithm of X, base 2, considering X unsigned,
2411 if X is a power of 2. Otherwise, returns -1.
2413 This should be used via the `exact_log2' macro. */
2417 register unsigned HOST_WIDE_INT x;
2419 register int log = 0;
2420 /* Test for 0 or a power of 2. */
2421 if (x == 0 || x != (x & -x))
2423 while ((x >>= 1) != 0)
2428 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2429 If X is 0, return -1.
2431 This should be used via the floor_log2 macro. */
2435 register unsigned HOST_WIDE_INT x;
2437 register int log = -1;
2444 static int float_handler_set;
2446 jmp_buf float_handler;
2448 /* Signals actually come here. */
2451 float_signal (signo)
2452 /* If this is missing, some compilers complain. */
2453 int signo ATTRIBUTE_UNUSED;
2455 if (float_handled == 0)
2457 #if defined (USG) || defined (hpux)
2458 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2461 signal (SIGFPE, float_signal);
2462 longjmp (float_handler, 1);
2465 /* Specify where to longjmp to when a floating arithmetic error happens.
2466 If HANDLER is 0, it means don't handle the errors any more. */
2469 set_float_handler (handler)
2472 float_handled = (handler != 0);
2474 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2476 if (float_handled && ! float_handler_set)
2478 signal (SIGFPE, float_signal);
2479 float_handler_set = 1;
2483 /* This is a wrapper function for code which might elicit an
2484 arithmetic exception. That code should be passed in as a function
2485 pointer FN, and one argument DATA. DATA is usually a struct which
2486 contains the real input and output for function FN. This function
2487 returns 0 (failure) if longjmp was called (i.e. an exception
2488 occured.) It returns 1 (success) otherwise. */
2491 do_float_handler (fn, data)
2492 void (*fn) PROTO ((PTR));
2499 /* We got here via longjmp() caused by an exception in function fn() */
2500 set_float_handler (NULL);
2504 set_float_handler (buf);
2506 set_float_handler (NULL);
2510 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2511 error happens, pushing the previous specification into OLD_HANDLER.
2512 Return an indication of whether there was a previous handler in effect. */
2515 push_float_handler (handler, old_handler)
2516 jmp_buf handler, old_handler;
2518 int was_handled = float_handled;
2522 memcpy ((char *) old_handler, (char *) float_handler,
2523 sizeof (float_handler));
2525 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2529 /* Restore the previous specification of whether and where to longjmp to
2530 when a floating arithmetic error happens. */
2533 pop_float_handler (handled, handler)
2537 float_handled = handled;
2539 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2542 /* Handler for SIGPIPE. */
2546 /* If this is missing, some compilers complain. */
2547 int signo ATTRIBUTE_UNUSED;
2549 fatal ("output pipe has been closed");
2552 /* Strip off a legitimate source ending from the input string NAME of
2553 length LEN. Rather than having to know the names used by all of
2554 our front ends, we strip off an ending of a period followed by
2555 up to five characters. (Java uses ".class".) */
2558 strip_off_ending (name, len)
2563 for (i = 2; i < 6 && len > i; i++)
2565 if (name[len - i] == '.')
2567 name[len - i] = '\0';
2573 /* Output a quoted string. */
2576 output_quoted_string (asm_file, string)
2580 #ifdef OUTPUT_QUOTED_STRING
2581 OUTPUT_QUOTED_STRING (asm_file, string);
2585 putc ('\"', asm_file);
2586 while ((c = *string++) != 0)
2588 if (c == '\"' || c == '\\')
2589 putc ('\\', asm_file);
2592 putc ('\"', asm_file);
2596 /* Output a file name in the form wanted by System V. */
2599 output_file_directive (asm_file, input_name)
2601 const char *input_name;
2603 int len = strlen (input_name);
2604 const char *na = input_name + len;
2606 /* NA gets INPUT_NAME sans directory names. */
2607 while (na > input_name)
2611 #ifdef DIR_SEPARATOR
2612 if (na[-1] == DIR_SEPARATOR)
2618 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2619 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2621 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2622 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2624 fprintf (asm_file, "\t.file\t");
2625 output_quoted_string (asm_file, na);
2626 fputc ('\n', asm_file);
2631 #ifdef ASM_IDENTIFY_LANGUAGE
2632 /* Routine to build language identifier for object file. */
2634 output_lang_identify (asm_out_file)
2637 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2638 char *s = (char *) alloca (len);
2639 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2640 ASM_OUTPUT_LABEL (asm_out_file, s);
2644 /* Routine to open a dump file. */
2646 open_dump_file (suffix, function_name)
2648 const char *function_name;
2655 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2657 if (rtl_dump_file != NULL)
2658 fclose (rtl_dump_file);
2660 strcpy (dumpname, dump_base_name);
2661 strcat (dumpname, suffix);
2663 rtl_dump_file = fopen (dumpname, "a");
2665 if (rtl_dump_file == NULL)
2666 pfatal_with_name (dumpname);
2671 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2677 /* Routine to close a dump file. */
2679 close_dump_file (func, insns)
2680 void (*func) PROTO ((FILE *, rtx));
2687 func (rtl_dump_file, insns);
2689 fflush (rtl_dump_file);
2690 fclose (rtl_dump_file);
2692 rtl_dump_file = NULL;
2698 /* Routine to dump rtl into a file. */
2700 dump_rtl (suffix, decl, func, insns)
2703 void (*func) PROTO ((FILE *, rtx));
2706 open_dump_file (suffix, decl_printable_name (decl, 2));
2707 close_dump_file (func, insns);
2710 /* Routine to empty a dump file. */
2712 clean_dump_file (suffix)
2717 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2719 strcpy (dumpname, dump_base_name);
2720 strcat (dumpname, suffix);
2722 rtl_dump_file = fopen (dumpname, "w");
2724 if (rtl_dump_file == NULL)
2725 pfatal_with_name (dumpname);
2729 fclose (rtl_dump_file);
2730 rtl_dump_file = NULL;
2735 /* Do any final processing required for the declarations in VEC, of
2736 which there are LEN. We write out inline functions and variables
2737 that have been deferred until this point, but which are required.
2738 Returns non-zero if anything was put out. */
2740 wrapup_global_declarations (vec, len)
2747 int output_something = 0;
2749 for (i = 0; i < len; i++)
2753 /* We're not deferring this any longer. */
2754 DECL_DEFER_OUTPUT (decl) = 0;
2756 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2757 && incomplete_decl_finalize_hook != 0)
2758 (*incomplete_decl_finalize_hook) (decl);
2761 /* Now emit any global variables or functions that we have been
2762 putting off. We need to loop in case one of the things emitted
2763 here references another one which comes earlier in the list. */
2767 for (i = 0; i < len; i++)
2771 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2774 /* Don't write out static consts, unless we still need them.
2776 We also keep static consts if not optimizing (for debugging),
2777 unless the user specified -fno-keep-static-consts.
2778 ??? They might be better written into the debug information.
2779 This is possible when using DWARF.
2781 A language processor that wants static constants to be always
2782 written out (even if it is not used) is responsible for
2783 calling rest_of_decl_compilation itself. E.g. the C front-end
2784 calls rest_of_decl_compilation from finish_decl.
2785 One motivation for this is that is conventional in some
2786 environments to write things like:
2787 static const char rcsid[] = "... version string ...";
2788 intending to force the string to be in the executable.
2790 A language processor that would prefer to have unneeded
2791 static constants "optimized away" would just defer writing
2792 them out until here. E.g. C++ does this, because static
2793 constants are often defined in header files.
2795 ??? A tempting alternative (for both C and C++) would be
2796 to force a constant to be written if and only if it is
2797 defined in a main file, as opposed to an include file. */
2799 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2800 && (! TREE_READONLY (decl)
2801 || TREE_PUBLIC (decl)
2802 || (!optimize && flag_keep_static_consts)
2803 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2806 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2809 if (TREE_CODE (decl) == FUNCTION_DECL
2810 && DECL_INITIAL (decl) != 0
2811 && DECL_SAVED_INSNS (decl) != 0
2812 && (flag_keep_inline_functions
2813 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2814 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2817 temporary_allocation ();
2818 output_inline_function (decl);
2819 permanent_allocation (1);
2824 output_something = 1;
2828 return output_something;
2831 /* Issue appropriate warnings for the global declarations in VEC (of
2832 which there are LEN). Output debugging information for them. */
2834 check_global_declarations (vec, len)
2841 for (i = 0; i < len; i++)
2845 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2846 && ! TREE_ASM_WRITTEN (decl))
2847 /* Cancel the RTL for this decl so that, if debugging info
2848 output for global variables is still to come,
2849 this one will be omitted. */
2850 DECL_RTL (decl) = NULL;
2852 /* Warn about any function
2853 declared static but not defined.
2854 We don't warn about variables,
2855 because many programs have static variables
2856 that exist only to get some text into the object file. */
2857 if (TREE_CODE (decl) == FUNCTION_DECL
2859 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2860 && DECL_INITIAL (decl) == 0
2861 && DECL_EXTERNAL (decl)
2862 && ! DECL_ARTIFICIAL (decl)
2863 && ! TREE_PUBLIC (decl))
2865 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2866 pedwarn_with_decl (decl,
2867 "`%s' used but never defined");
2869 warning_with_decl (decl,
2870 "`%s' declared `static' but never defined");
2871 /* This symbol is effectively an "extern" declaration now. */
2872 TREE_PUBLIC (decl) = 1;
2873 assemble_external (decl);
2876 /* Warn about static fns or vars defined but not used,
2877 but not about inline functions or static consts
2878 since defining those in header files is normal practice. */
2880 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2881 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2882 && ! DECL_IN_SYSTEM_HEADER (decl)
2883 && ! DECL_EXTERNAL (decl)
2884 && ! TREE_PUBLIC (decl)
2885 && ! TREE_USED (decl)
2886 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2887 /* The TREE_USED bit for file-scope decls
2888 is kept in the identifier, to handle multiple
2889 external decls in different scopes. */
2890 && ! TREE_USED (DECL_NAME (decl)))
2891 warning_with_decl (decl, "`%s' defined but not used");
2893 #ifdef SDB_DEBUGGING_INFO
2894 /* The COFF linker can move initialized global vars to the end.
2895 And that can screw up the symbol ordering.
2896 By putting the symbols in that order to begin with,
2897 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2898 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2899 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2900 && ! DECL_EXTERNAL (decl)
2901 && DECL_RTL (decl) != 0)
2902 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2904 /* Output COFF information for non-global
2905 file-scope initialized variables. */
2906 if (write_symbols == SDB_DEBUG
2907 && TREE_CODE (decl) == VAR_DECL
2908 && DECL_INITIAL (decl)
2909 && ! DECL_EXTERNAL (decl)
2910 && DECL_RTL (decl) != 0
2911 && GET_CODE (DECL_RTL (decl)) == MEM)
2912 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2913 #endif /* SDB_DEBUGGING_INFO */
2914 #ifdef DWARF_DEBUGGING_INFO
2915 /* Output DWARF information for file-scope tentative data object
2916 declarations, file-scope (extern) function declarations (which
2917 had no corresponding body) and file-scope tagged type declarations
2918 and definitions which have not yet been forced out. */
2920 if (write_symbols == DWARF_DEBUG
2921 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2922 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2924 #ifdef DWARF2_DEBUGGING_INFO
2925 /* Output DWARF2 information for file-scope tentative data object
2926 declarations, file-scope (extern) function declarations (which
2927 had no corresponding body) and file-scope tagged type declarations
2928 and definitions which have not yet been forced out. */
2930 if (write_symbols == DWARF2_DEBUG
2931 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2932 TIMEVAR (symout_time, dwarf2out_decl (decl));
2937 /* Compile an entire file of output from cpp, named NAME.
2938 Write a file of assembly output and various debugging dumps. */
2947 int name_specified = name != 0;
2949 if (dump_base_name == 0)
2950 dump_base_name = name ? name : "gccdump";
2954 integration_time = 0;
2960 branch_prob_time = 0;
2965 local_alloc_time = 0;
2966 global_alloc_time = 0;
2972 shorten_branch_time = 0;
2978 /* Initialize data in various passes. */
2982 name = init_parse (name);
2984 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2985 || debug_info_level == DINFO_LEVEL_VERBOSE
2986 || flag_test_coverage);
2988 init_decl_processing ();
2997 if (flag_caller_saves)
2998 init_caller_save ();
3000 /* If auxiliary info generation is desired, open the output file.
3001 This goes in the same directory as the source file--unlike
3002 all the other output files. */
3003 if (flag_gen_aux_info)
3005 aux_info_file = fopen (aux_info_file_name, "w");
3006 if (aux_info_file == 0)
3007 pfatal_with_name (aux_info_file_name);
3010 /* Clear the dump files. */
3012 clean_dump_file (".rtl");
3015 clean_dump_file (".jump");
3016 if (graph_dump_format != no_graph)
3017 clean_graph_dump_file (dump_base_name, ".jump");
3021 clean_dump_file (".addressof");
3022 if (graph_dump_format != no_graph)
3023 clean_graph_dump_file (dump_base_name, ".addressof");
3027 clean_dump_file (".cse");
3028 if (graph_dump_format != no_graph)
3029 clean_graph_dump_file (dump_base_name, ".cse");
3033 clean_dump_file (".loop");
3034 if (graph_dump_format != no_graph)
3035 clean_graph_dump_file (dump_base_name, ".loop");
3039 clean_dump_file (".cse2");
3040 if (graph_dump_format != no_graph)
3041 clean_graph_dump_file (dump_base_name, ".cse2");
3043 if (branch_prob_dump)
3045 clean_dump_file (".bp");
3046 if (graph_dump_format != no_graph)
3047 clean_graph_dump_file (dump_base_name, ".bp");
3051 clean_dump_file (".flow");
3052 if (graph_dump_format != no_graph)
3053 clean_graph_dump_file (dump_base_name, ".flow");
3057 clean_dump_file (".combine");
3058 if (graph_dump_format != no_graph)
3059 clean_graph_dump_file (dump_base_name, ".combine");
3063 clean_dump_file (".regmove");
3064 if (graph_dump_format != no_graph)
3065 clean_graph_dump_file (dump_base_name, ".regmove");
3069 clean_dump_file (".sched");
3070 if (graph_dump_format != no_graph)
3071 clean_graph_dump_file (dump_base_name, ".sched");
3075 clean_dump_file (".lreg");
3076 if (graph_dump_format != no_graph)
3077 clean_graph_dump_file (dump_base_name, ".lreg");
3079 if (global_reg_dump)
3081 clean_dump_file (".greg");
3082 if (graph_dump_format != no_graph)
3083 clean_graph_dump_file (dump_base_name, ".greg");
3087 clean_dump_file (".flow2");
3088 if (graph_dump_format != no_graph)
3089 clean_graph_dump_file (dump_base_name, ".flow2");
3093 clean_dump_file (".sched2");
3094 if (graph_dump_format != no_graph)
3095 clean_graph_dump_file (dump_base_name, ".sched2");
3099 clean_dump_file (".jump2");
3100 if (graph_dump_format != no_graph)
3101 clean_graph_dump_file (dump_base_name, ".jump2");
3106 clean_dump_file (".dbr");
3107 if (graph_dump_format != no_graph)
3108 clean_graph_dump_file (dump_base_name, ".dbr");
3113 clean_dump_file (".gcse");
3114 if (graph_dump_format != no_graph)
3115 clean_graph_dump_file (dump_base_name, ".gcse");
3120 clean_dump_file (".stack");
3121 if (graph_dump_format != no_graph)
3122 clean_graph_dump_file (dump_base_name, ".stack");
3125 #ifdef MACHINE_DEPENDENT_REORG
3126 if (mach_dep_reorg_dump)
3128 clean_dump_file (".mach");
3129 if (graph_dump_format != no_graph)
3130 clean_graph_dump_file (dump_base_name, ".mach");
3134 /* Open assembler code output file. */
3136 if (flag_syntax_only)
3137 asm_out_file = NULL;
3140 if (! name_specified && asm_file_name == 0)
3141 asm_out_file = stdout;
3144 int len = strlen (dump_base_name);
3145 register char *dumpname = (char *) xmalloc (len + 6);
3146 strcpy (dumpname, dump_base_name);
3147 strip_off_ending (dumpname, len);
3148 strcat (dumpname, ".s");
3149 if (asm_file_name == 0)
3151 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
3152 strcpy (asm_file_name, dumpname);
3154 if (!strcmp (asm_file_name, "-"))
3155 asm_out_file = stdout;
3157 asm_out_file = fopen (asm_file_name, "w");
3158 if (asm_out_file == 0)
3159 pfatal_with_name (asm_file_name);
3162 #ifdef IO_BUFFER_SIZE
3163 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3164 _IOFBF, IO_BUFFER_SIZE);
3168 input_filename = name;
3170 /* Put an entry on the input file stack for the main input file. */
3172 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3173 input_file_stack->next = 0;
3174 input_file_stack->name = input_filename;
3176 /* Perform language-specific initialization.
3177 This may set main_input_filename. */
3180 /* If the input doesn't start with a #line, use the input name
3181 as the official input file name. */
3182 if (main_input_filename == 0)
3183 main_input_filename = name;
3185 if (flag_syntax_only)
3187 write_symbols = NO_DEBUG;
3189 profile_block_flag = 0;
3193 ASM_FILE_START (asm_out_file);
3195 #ifdef ASM_COMMENT_START
3196 if (flag_verbose_asm)
3198 /* Print the list of options in effect. */
3199 print_version (asm_out_file, ASM_COMMENT_START);
3200 print_switch_values (asm_out_file, 0, MAX_LINE,
3201 ASM_COMMENT_START, " ", "\n");
3202 /* Add a blank line here so it appears in assembler output but not
3204 fprintf (asm_out_file, "\n");
3208 /* Output something to inform GDB that this compilation was by GCC. */
3209 #ifndef ASM_IDENTIFY_GCC
3210 fprintf (asm_out_file, "gcc2_compiled.:\n");
3212 ASM_IDENTIFY_GCC (asm_out_file);
3215 /* Output something to identify which front-end produced this file. */
3216 #ifdef ASM_IDENTIFY_LANGUAGE
3217 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3219 } /* ! flag_syntax_only */
3221 #ifndef ASM_OUTPUT_SECTION_NAME
3222 if (flag_function_sections)
3224 warning ("-ffunction-sections not supported for this target.");
3225 flag_function_sections = 0;
3227 if (flag_data_sections)
3229 warning ("-fdata-sections not supported for this target.");
3230 flag_data_sections = 0;
3234 if (flag_function_sections
3235 && (profile_flag || profile_block_flag))
3237 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3238 flag_function_sections = 0;
3241 #ifndef OBJECT_FORMAT_ELF
3242 if (flag_function_sections && write_symbols != NO_DEBUG)
3243 warning ("-ffunction-sections may affect debugging on some targets.");
3246 /* ??? Note: There used to be a conditional here
3247 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3248 This was to guarantee separation between gcc_compiled. and
3249 the first function, for the sake of dbx on Suns.
3250 However, having the extra zero here confused the Emacs
3251 code for unexec, and might confuse other programs too.
3252 Therefore, I took out that change.
3253 In future versions we should find another way to solve
3254 that dbx problem. -- rms, 23 May 93. */
3256 /* Don't let the first function fall at the same address
3257 as gcc_compiled., if profiling. */
3258 if (profile_flag || profile_block_flag)
3260 /* It's best if we can write a nop here since some
3261 assemblers don't tolerate zeros in the text section. */
3262 if (insn_template[CODE_FOR_nop] != 0)
3263 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
3265 assemble_zeros (UNITS_PER_WORD);
3268 /* If dbx symbol table desired, initialize writing it
3269 and output the predefined types. */
3270 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3271 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3272 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3275 #ifdef SDB_DEBUGGING_INFO
3276 if (write_symbols == SDB_DEBUG)
3277 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3280 #ifdef DWARF_DEBUGGING_INFO
3281 if (write_symbols == DWARF_DEBUG)
3282 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3284 #ifdef DWARF2_UNWIND_INFO
3285 if (dwarf2out_do_frame ())
3286 dwarf2out_frame_init ();
3288 #ifdef DWARF2_DEBUGGING_INFO
3289 if (write_symbols == DWARF2_DEBUG)
3290 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3293 /* Initialize yet another pass. */
3295 init_final (main_input_filename);
3296 init_branch_prob (dump_base_name);
3298 start_time = get_run_time ();
3300 /* Call the parser, which parses the entire file
3301 (calling rest_of_compilation for each function). */
3303 if (yyparse () != 0)
3305 if (errorcount == 0)
3306 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3308 /* In case there were missing closebraces,
3309 get us back to the global binding level. */
3310 while (! global_bindings_p ())
3314 /* Compilation is now finished except for writing
3315 what's left of the symbol table output. */
3317 parse_time += get_run_time () - start_time;
3319 parse_time -= integration_time;
3320 parse_time -= varconst_time;
3322 if (flag_syntax_only)
3325 globals = getdecls ();
3327 /* Really define vars that have had only a tentative definition.
3328 Really output inline functions that must actually be callable
3329 and have not been output so far. */
3332 int len = list_length (globals);
3333 tree *vec = (tree *) alloca (sizeof (tree) * len);
3337 /* Process the decls in reverse order--earliest first.
3338 Put them into VEC from back to front, then take out from front. */
3340 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3341 vec[len - i - 1] = decl;
3343 wrapup_global_declarations (vec, len);
3345 /* This must occur after the loop to output deferred functions. Else
3346 the profiler initializer would not be emitted if all the functions
3347 in this compilation unit were deferred.
3349 output_func_start_profiler can not cause any additional functions or
3350 data to need to be output, so it need not be in the deferred function
3352 output_func_start_profiler ();
3354 /* Now that all possible functions have been output, we can dump
3355 the exception table. */
3357 output_exception_table ();
3359 check_global_declarations (vec, len);
3362 /* Write out any pending weak symbol declarations. */
3366 /* Do dbx symbols */
3367 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3368 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3369 TIMEVAR (symout_time,
3371 dbxout_finish (asm_out_file, main_input_filename);
3375 #ifdef DWARF_DEBUGGING_INFO
3376 if (write_symbols == DWARF_DEBUG)
3377 TIMEVAR (symout_time,
3383 #ifdef DWARF2_UNWIND_INFO
3384 if (dwarf2out_do_frame ())
3385 dwarf2out_frame_finish ();
3388 #ifdef DWARF2_DEBUGGING_INFO
3389 if (write_symbols == DWARF2_DEBUG)
3390 TIMEVAR (symout_time,
3392 dwarf2out_finish ();
3396 /* Output some stuff at end of file if nec. */
3398 end_final (dump_base_name);
3400 if (branch_prob_dump)
3401 open_dump_file (".bp", NULL);
3403 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3405 if (branch_prob_dump)
3406 close_dump_file (NULL, NULL_RTX);
3409 ASM_FILE_END (asm_out_file);
3413 /* Language-specific end of compilation actions. */
3417 /* Close the dump files. */
3419 if (flag_gen_aux_info)
3421 fclose (aux_info_file);
3423 unlink (aux_info_file_name);
3428 open_dump_file (".combine", NULL);
3429 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3430 close_dump_file (NULL, NULL_RTX);
3433 /* Close non-debugging input and output files. Take special care to note
3434 whether fclose returns an error, since the pages might still be on the
3435 buffer chain while the file is open. */
3439 if (! flag_syntax_only
3440 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3441 fatal_io_error (asm_file_name);
3443 /* Do whatever is necessary to finish printing the graphs. */
3444 if (graph_dump_format != no_graph)
3447 finish_graph_dump_file (dump_base_name, ".jump");
3449 finish_graph_dump_file (dump_base_name, ".addressof");
3451 finish_graph_dump_file (dump_base_name, ".cse");
3453 finish_graph_dump_file (dump_base_name, ".loop");
3455 finish_graph_dump_file (dump_base_name, ".cse2");
3456 if (branch_prob_dump)
3457 finish_graph_dump_file (dump_base_name, ".bp");
3459 finish_graph_dump_file (dump_base_name, ".flow");
3461 finish_graph_dump_file (dump_base_name, ".combine");
3463 finish_graph_dump_file (dump_base_name, ".regmove");
3465 finish_graph_dump_file (dump_base_name, ".sched");
3467 finish_graph_dump_file (dump_base_name, ".lreg");
3468 if (global_reg_dump)
3469 finish_graph_dump_file (dump_base_name, ".greg");
3471 finish_graph_dump_file (dump_base_name, ".flow2");
3473 finish_graph_dump_file (dump_base_name, ".sched2");
3475 finish_graph_dump_file (dump_base_name, ".jump2");
3478 finish_graph_dump_file (dump_base_name, ".dbr");
3481 finish_graph_dump_file (dump_base_name, ".gcse");
3484 finish_graph_dump_file (dump_base_name, ".stack");
3486 #ifdef MACHINE_DEPENDENT_REORG
3487 if (mach_dep_reorg_dump)
3488 finish_graph_dump_file (dump_base_name, ".mach");
3492 /* Free up memory for the benefit of leak detectors. */
3495 /* Print the times. */
3499 fprintf (stderr,"\n");
3500 print_time ("parse", parse_time);
3502 print_time ("integration", integration_time);
3503 print_time ("jump", jump_time);
3504 print_time ("cse", cse_time);
3505 print_time ("gcse", gcse_time);
3506 print_time ("loop", loop_time);
3507 print_time ("cse2", cse2_time);
3508 print_time ("branch-prob", branch_prob_time);
3509 print_time ("flow", flow_time);
3510 print_time ("combine", combine_time);
3511 print_time ("regmove", regmove_time);
3512 print_time ("sched", sched_time);
3513 print_time ("local-alloc", local_alloc_time);
3514 print_time ("global-alloc", global_alloc_time);
3515 print_time ("flow2", flow2_time);
3516 print_time ("sched2", sched2_time);
3518 print_time ("dbranch", dbr_sched_time);
3520 print_time ("shorten-branch", shorten_branch_time);
3521 print_time ("stack-reg", stack_reg_time);
3522 print_time ("final", final_time);
3523 print_time ("varconst", varconst_time);
3524 print_time ("symout", symout_time);
3525 print_time ("dump", dump_time);
3529 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3530 and TYPE_DECL nodes.
3532 This does nothing for local (non-static) variables.
3533 Otherwise, it sets up the RTL and outputs any assembler code
3534 (label definition, storage allocation and initialization).
3536 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3537 the assembler symbol name to be used. TOP_LEVEL is nonzero
3538 if this declaration is not within a function. */
3541 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3543 const char *asmspec;
3547 /* Declarations of variables, and of functions defined elsewhere. */
3549 /* The most obvious approach, to put an #ifndef around where
3550 this macro is used, doesn't work since it's inside a macro call. */
3551 #ifndef ASM_FINISH_DECLARE_OBJECT
3552 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3555 /* Forward declarations for nested functions are not "external",
3556 but we need to treat them as if they were. */
3557 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3558 || TREE_CODE (decl) == FUNCTION_DECL)
3559 TIMEVAR (varconst_time,
3561 make_decl_rtl (decl, asmspec, top_level);
3562 /* Initialized extern variable exists to be replaced
3563 with its value, or represents something that will be
3564 output in another file. */
3565 if (! (TREE_CODE (decl) == VAR_DECL
3566 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3567 && DECL_INITIAL (decl) != 0
3568 && DECL_INITIAL (decl) != error_mark_node))
3569 /* Don't output anything
3570 when a tentative file-scope definition is seen.
3571 But at end of compilation, do output code for them. */
3572 if (! (! at_end && top_level
3573 && (DECL_INITIAL (decl) == 0
3574 || DECL_INITIAL (decl) == error_mark_node)))
3575 assemble_variable (decl, top_level, at_end, 0);
3576 if (decl == last_assemble_variable_decl)
3578 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3582 else if (DECL_REGISTER (decl) && asmspec != 0)
3584 if (decode_reg_name (asmspec) >= 0)
3586 DECL_RTL (decl) = 0;
3587 make_decl_rtl (decl, asmspec, top_level);
3590 error ("invalid register name `%s' for register variable", asmspec);
3592 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3593 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3594 && TREE_CODE (decl) == TYPE_DECL)
3595 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3597 #ifdef SDB_DEBUGGING_INFO
3598 else if (write_symbols == SDB_DEBUG && top_level
3599 && TREE_CODE (decl) == TYPE_DECL)
3600 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3604 /* Called after finishing a record, union or enumeral type. */
3607 rest_of_type_compilation (type, toplev)
3608 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3612 tree type ATTRIBUTE_UNUSED;
3613 int toplev ATTRIBUTE_UNUSED;
3616 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3617 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3618 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3620 #ifdef SDB_DEBUGGING_INFO
3621 if (write_symbols == SDB_DEBUG)
3622 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3626 /* This is called from finish_function (within yyparse)
3627 after each top-level definition is parsed.
3628 It is supposed to compile that function or variable
3629 and output the assembler code for it.
3630 After we return, the tree storage is freed. */
3633 rest_of_compilation (decl)
3637 int start_time = get_run_time ();
3639 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3640 to be restored after we finish compiling the function
3641 (for use when compiling inline calls to this function). */
3642 tree saved_block_tree = 0;
3643 /* Likewise, for DECL_ARGUMENTS. */
3644 tree saved_arguments = 0;
3646 int rebuild_label_notes_after_reload;
3648 /* When processing delayed functions, init_function_start() won't
3649 have been run to re-initialize it. */
3650 cse_not_expected = ! optimize;
3652 /* If we are reconsidering an inline function
3653 at the end of compilation, skip the stuff for making it inline. */
3655 if (DECL_SAVED_INSNS (decl) == 0)
3660 /* If requested, consider whether to make this function inline. */
3661 if (DECL_INLINE (decl) || flag_inline_functions)
3662 TIMEVAR (integration_time,
3664 lose = function_cannot_inline_p (decl);
3665 if (lose || ! optimize)
3667 if (warn_inline && DECL_INLINE (decl))
3668 warning_with_decl (decl, lose);
3669 DECL_ABSTRACT_ORIGIN (decl) = 0;
3670 /* Don't really compile an extern inline function.
3671 If we can't make it inline, pretend
3672 it was only declared. */
3673 if (DECL_EXTERNAL (decl))
3675 DECL_INITIAL (decl) = 0;
3676 goto exit_rest_of_compilation;
3680 /* ??? Note that this has the effect of making it look
3681 like "inline" was specified for a function if we choose
3682 to inline it. This isn't quite right, but it's
3683 probably not worth the trouble to fix. */
3684 inlinable = DECL_INLINE (decl) = 1;
3687 insns = get_insns ();
3689 if (flag_propolice_protection) prepare_stack_protection (inlinable);
3691 /* Dump the rtl code if we are dumping rtl. */
3695 open_dump_file (".rtl", decl_printable_name (decl, 2));
3697 if (DECL_SAVED_INSNS (decl))
3698 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3700 close_dump_file (print_rtl, insns);
3703 /* If we can, defer compiling inlines until EOF.
3704 save_for_inline_copying can be extremely expensive. */
3705 if (inlinable && ! decl_function_context (decl))
3706 DECL_DEFER_OUTPUT (decl) = 1;
3708 /* If function is inline, and we don't yet know whether to
3709 compile it by itself, defer decision till end of compilation.
3710 finish_compilation will call rest_of_compilation again
3711 for those functions that need to be output. Also defer those
3712 functions that we are supposed to defer. We cannot defer
3713 functions containing nested functions since the nested function
3714 data is in our non-saved obstack. We cannot defer nested
3715 functions for the same reason. */
3717 /* If this is a nested inline, remove ADDRESSOF now so we can
3718 finish compiling ourselves. Otherwise, wait until EOF.
3719 We have to do this because the purge_addressof transformation
3720 changes the DECL_RTL for many variables, which confuses integrate. */
3723 if (decl_function_context (decl))
3724 purge_addressof (insns);
3726 DECL_DEFER_OUTPUT (decl) = 1;
3729 if (! current_function_contains_functions
3730 && (DECL_DEFER_OUTPUT (decl)
3731 || (DECL_INLINE (decl)
3732 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3733 && ! flag_keep_inline_functions)
3734 || DECL_EXTERNAL (decl)))))
3736 DECL_DEFER_OUTPUT (decl) = 1;
3738 /* If -Wreturn-type, we have to do a bit of compilation.
3739 However, if we just fall through we will call
3740 save_for_inline_copying() which results in excessive
3741 memory use. Instead, we just want to call
3742 jump_optimize() to figure out whether or not we can fall
3743 off the end of the function; we do the minimum amount of
3744 work necessary to make that safe. And, we set optimize
3745 to zero to keep jump_optimize from working too hard. */
3746 if (warn_return_type)
3748 int saved_optimize = optimize;
3750 find_exception_handler_labels ();
3751 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3752 !JUMP_AFTER_REGSCAN);
3753 optimize = saved_optimize;
3756 #ifdef DWARF_DEBUGGING_INFO
3757 /* Generate the DWARF info for the "abstract" instance
3758 of a function which we may later generate inlined and/or
3759 out-of-line instances of. */
3760 if (write_symbols == DWARF_DEBUG)
3762 set_decl_abstract_flags (decl, 1);
3763 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3764 set_decl_abstract_flags (decl, 0);
3767 #ifdef DWARF2_DEBUGGING_INFO
3768 /* Generate the DWARF2 info for the "abstract" instance
3769 of a function which we may later generate inlined and/or
3770 out-of-line instances of. */
3771 if (write_symbols == DWARF2_DEBUG)
3773 set_decl_abstract_flags (decl, 1);
3774 TIMEVAR (symout_time, dwarf2out_decl (decl));
3775 set_decl_abstract_flags (decl, 0);
3778 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3779 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3780 goto exit_rest_of_compilation;
3783 /* If we have to compile the function now, save its rtl and subdecls
3784 so that its compilation will not affect what others get. */
3785 if (inlinable || DECL_DEFER_OUTPUT (decl))
3787 #ifdef DWARF_DEBUGGING_INFO
3788 /* Generate the DWARF info for the "abstract" instance of
3789 a function which we will generate an out-of-line instance
3790 of almost immediately (and which we may also later generate
3791 various inlined instances of). */
3792 if (write_symbols == DWARF_DEBUG)
3794 set_decl_abstract_flags (decl, 1);
3795 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3796 set_decl_abstract_flags (decl, 0);
3799 #ifdef DWARF2_DEBUGGING_INFO
3800 /* Generate the DWARF2 info for the "abstract" instance of
3801 a function which we will generate an out-of-line instance
3802 of almost immediately (and which we may also later generate
3803 various inlined instances of). */
3804 if (write_symbols == DWARF2_DEBUG)
3806 set_decl_abstract_flags (decl, 1);
3807 TIMEVAR (symout_time, dwarf2out_decl (decl));
3808 set_decl_abstract_flags (decl, 0);
3811 saved_block_tree = DECL_INITIAL (decl);
3812 saved_arguments = DECL_ARGUMENTS (decl);
3813 TIMEVAR (integration_time, save_for_inline_copying (decl));
3814 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3817 /* If specified extern inline but we aren't inlining it, we are
3818 done. This goes for anything that gets here with DECL_EXTERNAL
3819 set, not just things with DECL_INLINE. */
3820 if (DECL_EXTERNAL (decl))
3821 goto exit_rest_of_compilation;
3824 if (! DECL_DEFER_OUTPUT (decl))
3825 TREE_ASM_WRITTEN (decl) = 1;
3827 /* Now that integrate will no longer see our rtl, we need not distinguish
3828 between the return value of this function and the return value of called
3830 rtx_equal_function_value_matters = 0;
3832 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3833 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3835 goto exit_rest_of_compilation;
3838 /* Emit code to get eh context, if needed. */
3842 /* If we are doing position-independent code generation, now
3843 is the time to output special prologues and epilogues.
3844 We do not want to do this earlier, because it just clutters
3845 up inline functions with meaningless insns. */
3850 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3851 Note that that may have been done above, in save_for_inline_copying.
3852 The call to resume_temporary_allocation near the end of this function
3853 goes back to the usual state of affairs. This must be done after
3854 we've built up any unwinders for exception handling, and done
3855 the FINALIZE_PIC work, if necessary. */
3857 rtl_in_current_obstack ();
3859 insns = get_insns ();
3861 /* Copy any shared structure that should not be shared. */
3863 unshare_all_rtl (current_function_decl, insns);
3865 #ifdef SETJMP_VIA_SAVE_AREA
3866 /* This must be performed before virutal register instantiation. */
3867 if (current_function_calls_alloca)
3868 optimize_save_area_alloca (insns);
3871 /* Instantiate all virtual registers. */
3873 instantiate_virtual_regs (current_function_decl, get_insns ());
3875 /* See if we have allocated stack slots that are not directly addressable.
3876 If so, scan all the insns and create explicit address computation
3877 for all references to such slots. */
3878 /* fixup_stack_slots (); */
3880 /* Find all the EH handlers. */
3881 find_exception_handler_labels ();
3883 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3884 are initialized and to compute whether control can drop off the end
3886 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3887 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3888 JUMP_AFTER_REGSCAN));
3890 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3891 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3892 goto exit_rest_of_compilation;
3894 /* Dump rtl code after jump, if we are doing that. */
3897 dump_rtl (".jump", decl, print_rtl, insns);
3899 /* Perform common subexpression elimination.
3900 Nonzero value from `cse_main' means that jumps were simplified
3901 and some code may now be unreachable, so do
3902 jump optimization again. */
3907 open_dump_file (".cse", decl_printable_name (decl, 2));
3909 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3911 if (flag_thread_jumps)
3912 /* Hacks by tiemann & kenner. */
3913 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3915 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3917 if (tem || optimize > 1)
3918 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3920 !JUMP_AFTER_REGSCAN));
3922 /* Run this after jump optmizations remove all the unreachable code
3923 so that unreachable code will not keep values live. */
3924 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3926 /* Dump rtl code after cse, if we are doing that. */
3930 close_dump_file (print_rtl, insns);
3931 if (graph_dump_format != no_graph)
3932 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3936 purge_addressof (insns);
3937 reg_scan (insns, max_reg_num (), 1);
3941 dump_rtl (".addressof", decl, print_rtl, insns);
3942 if (graph_dump_format != no_graph)
3943 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3946 /* Perform global cse. */
3948 if (optimize > 0 && flag_gcse)
3951 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3953 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3955 /* If gcse altered any jumps, rerun jump optimizations to clean
3959 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3961 !JUMP_AFTER_REGSCAN));
3966 close_dump_file (print_rtl, insns);
3967 if (graph_dump_format != no_graph)
3968 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3971 /* Move constant computations out of loops. */
3976 open_dump_file (".loop", decl_printable_name (decl, 2));
3981 if (flag_rerun_loop_opt)
3983 /* We only want to perform unrolling once. */
3985 loop_optimize (insns, rtl_dump_file, 0, 0);
3988 /* The first call to loop_optimize makes some instructions
3989 trivially dead. We delete those instructions now in the
3990 hope that doing so will make the heuristics in loop work
3991 better and possibly speed up compilation. */
3992 delete_trivially_dead_insns (insns, max_reg_num ());
3994 /* The regscan pass is currently necessary as the alias
3995 analysis code depends on this information. */
3996 reg_scan (insns, max_reg_num (), 1);
3998 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
4001 /* Dump rtl code after loop opt, if we are doing that. */
4005 close_dump_file (print_rtl, insns);
4006 if (graph_dump_format != no_graph)
4007 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
4014 open_dump_file (".cse2", decl_printable_name (decl, 2));
4016 if (flag_rerun_cse_after_loop)
4018 /* Running another jump optimization pass before the second
4019 cse pass sometimes simplifies the RTL enough to allow
4020 the second CSE pass to do a better job. Jump_optimize can change
4021 max_reg_num so we must rerun reg_scan afterwards.
4022 ??? Rework to not call reg_scan so often. */
4023 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4024 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4026 JUMP_AFTER_REGSCAN));
4028 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
4029 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
4032 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4034 !JUMP_AFTER_REGSCAN));
4037 if (flag_thread_jumps)
4039 /* This pass of jump threading straightens out code
4040 that was kinked by loop optimization. */
4041 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4042 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
4045 /* Dump rtl code after cse, if we are doing that. */
4049 close_dump_file (print_rtl, insns);
4050 if (graph_dump_format != no_graph)
4051 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
4055 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
4057 if (branch_prob_dump)
4058 open_dump_file (".bp", decl_printable_name (decl, 2));
4063 branch_prob (insns, rtl_dump_file);
4066 if (branch_prob_dump)
4068 close_dump_file (print_rtl, insns);
4069 if (graph_dump_format != no_graph)
4070 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
4074 /* We are no longer anticipating cse in this function, at least. */
4076 cse_not_expected = 1;
4078 /* Now we choose between stupid (pcc-like) register allocation
4079 (if we got the -noreg switch and not -opt)
4080 and smart register allocation. */
4082 if (optimize > 0) /* Stupid allocation probably won't work */
4083 obey_regdecls = 0; /* if optimizations being done. */
4087 /* Print function header into flow dump now
4088 because doing the flow analysis makes some of the dump. */
4091 open_dump_file (".flow", decl_printable_name (decl, 2));
4097 regclass (insns, max_reg_num ());
4098 stupid_life_analysis (insns, max_reg_num (),
4104 /* Do control and data flow analysis,
4105 and write some of the results to dump file. */
4110 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4111 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4114 if (warn_uninitialized)
4116 uninitialized_vars_warning (DECL_INITIAL (decl));
4117 setjmp_args_warning ();
4121 /* Dump rtl after flow analysis. */
4125 close_dump_file (print_rtl_with_bb, insns);
4126 if (graph_dump_format != no_graph)
4127 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
4130 /* The first life analysis pass has finished. From now on we can not
4131 generate any new pseudos. */
4134 /* If -opt, try combining insns through substitution. */
4138 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4140 /* Dump rtl code after insn combination. */
4144 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4145 if (graph_dump_format != no_graph)
4146 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4150 /* Register allocation pre-pass, to reduce number of moves
4151 necessary for two-address machines. */
4152 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4155 open_dump_file (".regmove", decl_printable_name (decl, 2));
4157 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4162 close_dump_file (print_rtl_with_bb, insns);
4163 if (graph_dump_format != no_graph)
4164 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4168 /* Print function header into sched dump now
4169 because doing the sched analysis makes some of the dump. */
4171 if (optimize > 0 && flag_schedule_insns)
4174 open_dump_file (".sched", decl_printable_name (decl, 2));
4176 /* Do control and data sched analysis,
4177 and write some of the results to dump file. */
4179 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4181 /* Dump rtl after instruction scheduling. */
4185 close_dump_file (print_rtl_with_bb, insns);
4186 if (graph_dump_format != no_graph)
4187 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4191 /* Determine if the current function is a leaf before running reload
4192 since this can impact optimizations done by the prologue and
4193 epilogue thus changing register elimination offsets. */
4194 current_function_is_leaf = leaf_function_p ();
4196 /* Unless we did stupid register allocation,
4197 allocate pseudo-regs that are used only within 1 basic block.
4199 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4200 jump optimizer after register allocation and reloading are finished. */
4203 TIMEVAR (local_alloc_time,
4205 recompute_reg_usage (insns, ! optimize_size);
4206 regclass (insns, max_reg_num ());
4207 rebuild_label_notes_after_reload = local_alloc ();
4210 rebuild_label_notes_after_reload = 0;
4212 /* Dump rtl code after allocating regs within basic blocks. */
4216 open_dump_file (".lreg", decl_printable_name (decl, 2));
4218 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4219 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4221 close_dump_file (print_rtl_with_bb, insns);
4222 if (graph_dump_format != no_graph)
4223 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4226 if (global_reg_dump)
4227 open_dump_file (".greg", decl_printable_name (decl, 2));
4229 /* Unless we did stupid register allocation,
4230 allocate remaining pseudo-regs, then do the reload pass
4231 fixing up any insns that are invalid. */
4233 TIMEVAR (global_alloc_time,
4236 failure = global_alloc (rtl_dump_file);
4238 failure = reload (insns, 0, rtl_dump_file);
4243 goto exit_rest_of_compilation;
4245 /* Do a very simple CSE pass over just the hard registers. */
4247 reload_cse_regs (insns);
4249 /* Register allocation and reloading may have turned an indirect jump into
4250 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4251 jumping instructions. */
4252 if (rebuild_label_notes_after_reload)
4253 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4255 /* If optimizing and we are performing instruction scheduling after
4256 reload, then go ahead and split insns now since we are about to
4257 recompute flow information anyway.
4259 reload_cse_regs may expose more splitting opportunities, expecially
4260 for double-word operations. */
4261 if (optimize > 0 && flag_schedule_insns_after_reload)
4265 for (insn = insns; insn; insn = NEXT_INSN (insn))
4269 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4272 last = try_split (PATTERN (insn), insn, 1);
4276 PUT_CODE (insn, NOTE);
4277 NOTE_SOURCE_FILE (insn) = 0;
4278 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4283 if (global_reg_dump)
4285 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4286 close_dump_file (print_rtl_with_bb, insns);
4287 if (graph_dump_format != no_graph)
4288 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4291 /* Re-create the death notes which were deleted during reload. */
4293 open_dump_file (".flow2", decl_printable_name (decl, 2));
4300 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4301 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4305 flow2_completed = 1;
4307 /* On some machines, the prologue and epilogue code, or parts thereof,
4308 can be represented as RTL. Doing so lets us schedule insns between
4309 it and the rest of the code and also allows delayed branch
4310 scheduling to operate in the epilogue. */
4312 thread_prologue_and_epilogue_insns (insns);
4316 close_dump_file (print_rtl_with_bb, insns);
4317 if (graph_dump_format != no_graph)
4318 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4321 if (optimize > 0 && flag_schedule_insns_after_reload)
4324 open_dump_file (".sched2", decl_printable_name (decl, 2));
4326 /* Do control and data sched analysis again,
4327 and write some more of the results to dump file. */
4329 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4331 /* Dump rtl after post-reorder instruction scheduling. */
4335 close_dump_file (print_rtl_with_bb, insns);
4336 if (graph_dump_format != no_graph)
4337 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns);
4341 #ifdef LEAF_REGISTERS
4342 current_function_uses_only_leaf_regs
4343 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4346 /* One more attempt to remove jumps to .+1
4347 left by dead-store-elimination.
4348 Also do cross-jumping this time
4349 and delete no-op move insns. */
4353 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4355 !JUMP_AFTER_REGSCAN));
4357 /* Dump rtl code after jump, if we are doing that. */
4361 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4362 if (graph_dump_format != no_graph)
4363 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4367 /* If a machine dependent reorganization is needed, call it. */
4368 #ifdef MACHINE_DEPENDENT_REORG
4369 MACHINE_DEPENDENT_REORG (insns);
4371 if (mach_dep_reorg_dump)
4373 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
4374 if (graph_dump_format != no_graph)
4375 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4379 /* If a scheduling pass for delayed branches is to be done,
4380 call the scheduling code. */
4383 if (optimize > 0 && flag_delayed_branch)
4386 open_dump_file (".dbr", decl_printable_name (decl, 2));
4388 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4392 close_dump_file (print_rtl_with_bb, insns);
4393 if (graph_dump_format != no_graph)
4394 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4399 /* Shorten branches. */
4400 TIMEVAR (shorten_branch_time,
4402 shorten_branches (get_insns ());
4407 open_dump_file (".stack", decl_printable_name (decl, 2));
4409 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4413 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4414 if (graph_dump_format != no_graph)
4415 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4419 if (warn_frame_size_flag)
4420 if (get_frame_size () > warn_frame_size)
4421 warning ("%d byte frame exceeds user specified limit (%d bytes)",
4422 get_frame_size (), warn_frame_size);
4424 /* Now turn the rtl into assembler code. */
4426 TIMEVAR (final_time,
4431 /* Get the function's name, as described by its RTL.
4432 This may be different from the DECL_NAME name used
4433 in the source file. */
4435 x = DECL_RTL (decl);
4436 if (GET_CODE (x) != MEM)
4439 if (GET_CODE (x) != SYMBOL_REF)
4441 fnname = XSTR (x, 0);
4443 assemble_start_function (decl, fnname);
4444 final_start_function (insns, asm_out_file, optimize);
4445 final (insns, asm_out_file, optimize, 0);
4446 final_end_function (insns, asm_out_file, optimize);
4447 assemble_end_function (decl, fnname);
4449 fflush (asm_out_file);
4451 /* Release all memory allocated by flow. */
4452 free_basic_block_vars (0);
4454 /* Release all memory held by regsets now */
4455 regset_release_memory ();
4458 /* Write DBX symbols if requested */
4460 /* Note that for those inline functions where we don't initially
4461 know for certain that we will be generating an out-of-line copy,
4462 the first invocation of this routine (rest_of_compilation) will
4463 skip over this code by doing a `goto exit_rest_of_compilation;'.
4464 Later on, finish_compilation will call rest_of_compilation again
4465 for those inline functions that need to have out-of-line copies
4466 generated. During that call, we *will* be routed past here. */
4468 #ifdef DBX_DEBUGGING_INFO
4469 if (write_symbols == DBX_DEBUG)
4470 TIMEVAR (symout_time, dbxout_function (decl));
4473 #ifdef DWARF_DEBUGGING_INFO
4474 if (write_symbols == DWARF_DEBUG)
4475 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4478 #ifdef DWARF2_DEBUGGING_INFO
4479 if (write_symbols == DWARF2_DEBUG)
4480 TIMEVAR (symout_time, dwarf2out_decl (decl));
4483 exit_rest_of_compilation:
4487 /* In case the function was not output,
4488 don't leave any temporary anonymous types
4489 queued up for sdb output. */
4490 #ifdef SDB_DEBUGGING_INFO
4491 if (write_symbols == SDB_DEBUG)
4492 sdbout_types (NULL_TREE);
4495 /* Put back the tree of subblocks and list of arguments
4496 from before we copied them.
4497 Code generation and the output of debugging info may have modified
4498 the copy, but the original is unchanged. */
4500 if (saved_block_tree != 0)
4502 DECL_INITIAL (decl) = saved_block_tree;
4503 DECL_ARGUMENTS (decl) = saved_arguments;
4504 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4507 reload_completed = 0;
4508 flow2_completed = 0;
4511 TIMEVAR (final_time,
4513 /* Clear out the insn_length contents now that they are no
4515 init_insn_lengths ();
4517 /* Clear out the real_constant_chain before some of the rtx's
4518 it runs through become garbage. */
4519 clear_const_double_mem ();
4521 /* Cancel the effect of rtl_in_current_obstack. */
4522 resume_temporary_allocation ();
4524 /* Show no temporary slots allocated. */
4528 /* Make sure volatile mem refs aren't considered valid operands for
4529 arithmetic insns. We must call this here if this is a nested inline
4530 function, since the above code leaves us in the init_recog state
4531 (from final.c), and the function context push/pop code does not
4532 save/restore volatile_ok.
4534 ??? Maybe it isn't necessary for expand_start_function to call this
4535 anymore if we do it here? */
4537 init_recog_no_volatile ();
4539 /* The parsing time is all the time spent in yyparse
4540 *except* what is spent in this function. */
4542 parse_time -= get_run_time () - start_time;
4544 /* Reset global variables. */
4545 free_basic_block_vars (0);
4556 printf ("Usage: %s input [switches]\n", progname);
4557 printf ("Switches:\n");
4559 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4560 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4561 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4562 printf (" -finline-limit-<number> Limits the size of inlined functions to <number>\n");
4564 for (i = NUM_ELEM (f_options); i--;)
4566 const char * description = f_options[i].description;
4568 if (description != NULL && * description != 0)
4569 printf (" -f%-21s %s\n",
4570 f_options[i].string, description);
4573 printf (" -O[number] Set optimisation level to [number]\n");
4574 printf (" -Os Optimise for space rather than speed\n");
4575 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4576 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4577 printf (" -w Suppress warnings\n");
4578 printf (" -W Enable extra warnings\n");
4580 for (i = NUM_ELEM (W_options); i--;)
4582 const char * description = W_options[i].description;
4584 if (description != NULL && * description != 0)
4585 printf (" -W%-21s %s\n",
4586 W_options[i].string, description);
4589 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4590 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4591 printf (" -p Enable function profiling\n");
4592 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4593 printf (" -a Enable block profiling \n");
4595 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4596 printf (" -ax Enable jump profiling \n");
4598 printf (" -o <file> Place output into <file> \n");
4599 printf (" -G <number> Put global and static data smaller than <number>\n");
4600 printf (" bytes into a special section (on some targets)\n");
4602 for (i = NUM_ELEM (debug_args); i--;)
4604 if (debug_args[i].description != NULL)
4605 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4608 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4609 printf (" -quiet Do not display functions compiled or elapsed time\n");
4610 printf (" -version Display the compiler's version\n");
4611 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4612 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4613 #if defined HAIFA || defined INSN_SCHEDULING
4614 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4616 printf (" --help Display this information\n");
4621 /* Display descriptions of language specific options.
4622 If there is no description, note that there is an undocumented option.
4623 If the description is empty, do not display anything. (This allows
4624 options to be deliberately undocumented, for whatever reason).
4625 If the option string is missing, then this is a marker, indicating
4626 that the description string is in fact the name of a language, whose
4627 language specific options are to follow. */
4629 if (NUM_ELEM (documented_lang_options) > 1)
4631 printf ("\nLanguage specific options:\n");
4633 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4635 const char * description = documented_lang_options[i].description;
4636 const char * option = documented_lang_options[i].option;
4638 if (description == NULL)
4643 printf (" %-23.23s [undocumented]\n", option);
4645 else if (* description == 0)
4647 else if (option == NULL)
4651 ("\nThere are undocumented %s specific options as well.\n",
4655 printf ("\n Options for %s:\n", description);
4660 printf (" %-23.23s %s\n", option, description);
4665 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4667 if (NUM_ELEM (target_switches) > 1
4668 #ifdef TARGET_OPTIONS
4669 || NUM_ELEM (target_options) > 1
4677 printf ("\nTarget specific options:\n");
4679 for (i = NUM_ELEM (target_switches); i--;)
4681 const char * option = target_switches[i].name;
4682 const char * description = target_switches[i].description;
4684 if (option == NULL || * option == 0)
4686 else if (description == NULL)
4691 printf (" -m%-21.21s [undocumented]\n", option);
4693 else if (* description != 0)
4694 doc += printf (" -m%-21.21s %s\n", option, description);
4697 #ifdef TARGET_OPTIONS
4698 for (i = NUM_ELEM (target_options); i--;)
4700 const char * option = target_options[i].prefix;
4701 const char * description = target_options[i].description;
4703 if (option == NULL || * option == 0)
4705 else if (description == NULL)
4710 printf (" -m%-21.21s [undocumented]\n", option);
4712 else if (* description != 0)
4713 doc += printf (" -m%-21.21s %s\n", option, description);
4719 printf ("\nThere are undocumented target specific options as well.\n");
4721 printf (" They exist, but they are not documented.\n");
4726 /* Compare the user specified 'option' with the language
4727 specific 'lang_option'. Return true if they match, or
4728 if 'option' is a viable prefix of 'lang_option'. */
4731 check_lang_option (option, lang_option)
4735 lang_independent_options * indep_options;
4741 /* Ignore NULL entries. */
4742 if (option == NULL || lang_option == NULL)
4745 if ((space = strchr (lang_option, ' ')) != NULL)
4746 len = space - lang_option;
4747 else if ((space = strchr (lang_option, '<')) != NULL)
4748 len = space - lang_option;
4750 len = strlen (lang_option);
4752 /* If they do not match to the first n characters then fail. */
4753 if (strncmp (option, lang_option, len) != 0)
4756 /* Do not accept a lang option, if it matches a normal -f or -W
4757 option. Chill defines a -fpack, but we want to support
4760 /* An exact match is OK */
4761 if ((int) strlen (option) == len)
4764 /* If it is not an -f or -W option allow the match */
4765 if (option[0] != '-')
4771 indep_options = f_options;
4772 numopts = NUM_ELEM (f_options);
4775 indep_options = W_options;
4776 numopts = NUM_ELEM (W_options);
4781 /* The option is a -f or -W option.
4782 Skip past the prefix and search for the remainder in the
4783 appropriate table of options. */
4786 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4789 for (k = numopts; k--;)
4791 if (!strcmp (option, indep_options[k].string))
4793 /* The option matched a language independent option,
4794 do not allow the language specific match. */
4800 /* The option matches the start of the langauge specific option
4801 and it is not an exact match for a language independent option. */
4805 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4806 Exit code is 35 if can't open files, 34 if fatal error,
4807 33 if had nonfatal errors, else success. */
4816 int flag_print_mem = 0;
4817 int version_flag = 0;
4820 /* save in case md file wants to emit args as a comment. */
4824 p = argv[0] + strlen (argv[0]);
4825 while (p != argv[0] && p[-1] != '/'
4826 #ifdef DIR_SEPARATOR
4827 && p[-1] != DIR_SEPARATOR
4833 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4834 /* Get rid of any avoidable limit on stack size. */
4838 /* Set the stack limit huge so that alloca does not fail. */
4839 getrlimit (RLIMIT_STACK, &rlim);
4840 rlim.rlim_cur = rlim.rlim_max;
4841 setrlimit (RLIMIT_STACK, &rlim);
4845 #ifdef HAVE_LC_MESSAGES
4846 setlocale (LC_MESSAGES, "");
4848 (void) bindtextdomain (PACKAGE, localedir);
4849 (void) textdomain (PACKAGE);
4851 signal (SIGFPE, float_signal);
4854 signal (SIGPIPE, pipe_closed);
4857 decl_printable_name = decl_name;
4858 lang_expand_expr = (lang_expand_expr_t) do_abort;
4860 /* Initialize whether `char' is signed. */
4861 flag_signed_char = DEFAULT_SIGNED_CHAR;
4862 #ifdef DEFAULT_SHORT_ENUMS
4863 /* Initialize how much space enums occupy, by default. */
4864 flag_short_enums = DEFAULT_SHORT_ENUMS;
4867 /* Perform language-specific options intialization. */
4868 lang_init_options ();
4870 /* Scan to see what optimization level has been specified. That will
4871 determine the default value of many flags. */
4872 for (i = 1; i < argc; i++)
4874 if (!strcmp (argv[i], "-O"))
4879 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4881 /* Handle -Os, -O2, -O3, -O69, ... */
4882 char *p = &argv[i][2];
4884 if ((p[0] == 's') && (p[1] == 0))
4888 /* Optimizing for size forces optimize to be 2. */
4893 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4894 if (optimize_val != -1)
4896 optimize = optimize_val;
4897 #ifdef FORCE_OPTIMIZATION_DOWNGRADE
4898 #warning FORCE_OPTIMIZATION_DOWNGRADE
4899 if (optimize > FORCE_OPTIMIZATION_DOWNGRADE)
4901 optimize = FORCE_OPTIMIZATION_DOWNGRADE;
4902 warning ("\n***\n***\t-O%d converted to \"-O%d\" due to optimizer bugs on this platform\n***",
4904 FORCE_OPTIMIZATION_DOWNGRADE);
4907 #endif /*FORCE_OPTIMIZATION_DOWNGRADE*/
4908 #if defined(__alpha__)
4911 warning ("\n***\n***\tThe -O%d flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM\n***",
4914 #endif /*__alpha__*/
4921 obey_regdecls = (optimize == 0);
4926 flag_thread_jumps = 1;
4928 flag_delayed_branch = 1;
4930 #ifdef CAN_DEBUG_WITHOUT_FP
4931 flag_omit_frame_pointer = 1;
4937 flag_cse_follow_jumps = 1;
4938 flag_cse_skip_blocks = 1;
4940 flag_expensive_optimizations = 1;
4941 flag_strength_reduce = 1;
4942 flag_rerun_cse_after_loop = 1;
4943 flag_rerun_loop_opt = 1;
4944 flag_caller_saves = 1;
4946 #ifdef INSN_SCHEDULING
4947 flag_schedule_insns = 1;
4948 flag_schedule_insns_after_reload = 1;
4955 flag_inline_functions = 1;
4958 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4961 set_target_switch ("");
4963 #ifdef OPTIMIZATION_OPTIONS
4964 /* Allow default optimizations to be specified on a per-machine basis. */
4965 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4968 /* Initialize register usage now so switches may override. */
4971 for (i = 1; i < argc; i++)
4975 /* If this is a language-specific option,
4976 decode it in a language-specific way. */
4977 for (j = NUM_ELEM (documented_lang_options); j--;)
4978 if (check_lang_option (argv[i], documented_lang_options[j].option))
4981 if (j != (size_t)-1)
4983 /* If the option is valid for *some* language,
4984 treat it as valid even if this language doesn't understand it. */
4985 int strings_processed = lang_decode_option (argc - i, argv + i);
4987 if (!strcmp (argv[i], "--help"))
4993 if (strings_processed != 0)
4994 i += strings_processed - 1;
4996 else if (argv[i][0] == '-' && argv[i][1] != 0)
4998 register char *str = argv[i] + 1;
5003 set_target_switch (&str[1]);
5004 else if (!strcmp (str, "dumpbase"))
5006 dump_base_name = argv[++i];
5008 else if (str[0] == 'd')
5010 register char *p = &str[1];
5015 branch_prob_dump = 1;
5022 global_reg_dump = 1;
5030 cse_dump = 1, cse2_dump = 1;
5037 #ifdef MACHINE_DEPENDENT_REORG
5038 mach_dep_reorg_dump = 1;
5045 branch_prob_dump = 1;
5062 global_reg_dump = 1;
5087 #ifdef MACHINE_DEPENDENT_REORG
5089 mach_dep_reorg_dump = 1;
5093 flag_print_asm_name = 1;
5114 graph_dump_format = vcg;
5123 rtl_dump_and_exit = 1;
5125 case 'D': /* these are handled by the preprocessor */
5129 warning ("unrecognised gcc debugging option: %c", p[-1]);
5133 else if (str[0] == 'f')
5135 register char *p = &str[1];
5138 /* Some kind of -f option.
5139 P's value is the option sans `-f'.
5140 Search for it in the table of options. */
5143 !found && j < sizeof (f_options) / sizeof (f_options[0]);
5146 if (!strcmp (p, f_options[j].string))
5148 *f_options[j].variable = f_options[j].on_value;
5149 /* A goto here would be cleaner,
5150 but breaks the vax pcc. */
5153 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5154 && ! strcmp (p+3, f_options[j].string))
5156 *f_options[j].variable = ! f_options[j].on_value;
5163 else if (!strncmp (p, "inline-limit-", 13))
5165 read_integral_parameter (p + 13, p - 2, inline_max_insns);
5167 #ifdef INSN_SCHEDULING
5168 else if (!strncmp (p, "sched-verbose-",14))
5169 fix_sched_param("verbose",&p[14]);
5172 else if (!strncmp (p, "fixed-", 6))
5173 fix_register (&p[6], 1, 1);
5174 else if (!strncmp (p, "call-used-", 10))
5175 fix_register (&p[10], 0, 1);
5176 else if (!strncmp (p, "call-saved-", 11))
5177 fix_register (&p[11], 0, 0);
5179 error ("Invalid option `%s'", argv[i]);
5181 else if (str[0] == 'O')
5183 /* Already been treated above. Do nothing. */
5185 else if (!strcmp (str, "pedantic"))
5187 else if (!strcmp (str, "pedantic-errors"))
5188 flag_pedantic_errors = pedantic = 1;
5189 else if (!strcmp (str, "quiet"))
5191 else if (!strcmp (str, "version"))
5193 else if (!strcmp (str, "w"))
5194 inhibit_warnings = 1;
5195 else if (!strcmp (str, "W"))
5198 /* We save the value of warn_uninitialized, since if they put
5199 -Wuninitialized on the command line, we need to generate a
5200 warning about not using it without also specifying -O. */
5201 if (warn_uninitialized != 1)
5202 warn_uninitialized = 2;
5204 else if (str[0] == 'W')
5206 register char *p = &str[1];
5209 /* Some kind of -W option.
5210 P's value is the option sans `-W'.
5211 Search for it in the table of options. */
5214 !found && j < sizeof (W_options) / sizeof (W_options[0]);
5217 if (!strcmp (p, W_options[j].string))
5219 *W_options[j].variable = W_options[j].on_value;
5220 /* A goto here would be cleaner,
5221 but breaks the vax pcc. */
5224 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5225 && ! strcmp (p+3, W_options[j].string))
5227 *W_options[j].variable = ! W_options[j].on_value;
5234 else if (!strncmp (p, "id-clash-", 9))
5236 const int id_clash_val
5237 = read_integral_parameter (p + 9, p - 2, -1);
5238 if (id_clash_val != -1)
5240 id_clash_len = id_clash_val;
5244 else if (!strncmp (p, "larger-than-", 12))
5246 const int larger_than_val
5247 = read_integral_parameter (p + 12, p - 2, -1);
5248 if (larger_than_val != -1)
5250 larger_than_size = larger_than_val;
5251 warn_larger_than = 1;
5255 error ("Invalid option `%s'", argv[i]);
5257 else if (!strcmp (str, "p"))
5261 else if (!strcmp (str, "a"))
5263 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5264 warning ("`-a' option (basic block profile) not supported");
5266 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5269 else if (!strcmp (str, "ax"))
5271 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5272 warning ("`-ax' option (jump profiling) not supported");
5274 profile_block_flag = (!profile_block_flag
5275 || profile_block_flag == 2) ? 2 : 3;
5278 else if (str[0] == 'g')
5281 /* A lot of code assumes write_symbols == NO_DEBUG if the
5282 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5283 of what debugging type has been selected). This records the
5284 selected type. It is an error to specify more than one
5286 static enum debug_info_type selected_debug_type = NO_DEBUG;
5287 /* Non-zero if debugging format has been explicitly set.
5288 -g and -ggdb don't explicitly set the debugging format so
5289 -gdwarf -g3 is equivalent to -gdwarf3. */
5290 static int type_explicitly_set_p = 0;
5291 /* Indexed by enum debug_info_type. */
5292 static const char *debug_type_names[] =
5294 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5297 /* The maximum admissible debug level value. */
5298 static const unsigned max_debug_level = 3;
5300 /* Look up STR in the table. */
5301 for (da = debug_args; da->arg; da++)
5303 const int da_len = strlen (da->arg);
5305 if (! strncmp (str, da->arg, da_len))
5307 enum debug_info_type type = da->debug_type;
5308 const char *p = str + da_len;
5310 if (*p && (*p < '0' || *p > '9'))
5313 /* A debug flag without a level defaults to level 2.
5314 Note we do not want to call read_integral_parameter
5315 for that case since it will call atoi which
5318 ??? We may want to generalize the interface to
5319 read_integral_parameter to better handle this case
5320 if this case shows up often. */
5322 level = read_integral_parameter (p, 0,
5323 max_debug_level + 1);
5327 if (da_len > 1 && *p && !strncmp (str, "gdwarf", da_len))
5329 error ("use -gdwarf -g%d for DWARF v1, level %d",
5332 error ("use -gdwarf-2 for DWARF v2");
5335 if (level > max_debug_level)
5337 warning ("ignoring option `%s' due to invalid debug level specification",
5339 level = debug_info_level;
5342 if (type == NO_DEBUG)
5344 type = PREFERRED_DEBUGGING_TYPE;
5345 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0)
5347 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5348 type = DWARF2_DEBUG;
5350 #ifdef DBX_DEBUGGING_INFO
5357 if (type == NO_DEBUG)
5358 warning ("`-%s' not supported by this configuration of GCC",
5361 /* Does it conflict with an already selected type? */
5362 if (type_explicitly_set_p
5363 /* -g/-ggdb don't conflict with anything */
5364 && da->debug_type != NO_DEBUG
5365 && type != selected_debug_type)
5366 warning ("`-%s' ignored, conflicts with `-g%s'",
5367 str, debug_type_names[(int) selected_debug_type]);
5370 /* If the format has already been set, -g/-ggdb
5371 only change the debug level. */
5372 if (type_explicitly_set_p
5373 && da->debug_type == NO_DEBUG)
5374 ; /* don't change debugging type */
5377 selected_debug_type = type;
5378 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5380 write_symbols = (level == 0
5382 : selected_debug_type);
5383 use_gnu_debug_info_extensions = da->use_extensions_p;
5384 debug_info_level = (enum debug_info_level) level;
5390 warning ("`-%s' not supported by this configuration of GCC",
5393 else if (!strcmp (str, "o"))
5395 asm_file_name = argv[++i];
5397 else if (str[0] == 'G')
5399 const int g_switch_val = (str[1] != '\0') ?
5400 read_integral_parameter(str + 1, 0, -1) :
5401 read_integral_parameter(argv[++i], 0, -1);
5403 if (g_switch_val != -1)
5405 g_switch_set = TRUE;
5406 g_switch_value = g_switch_val;
5410 error("Invalid option `-%s'",str);
5413 else if (!strncmp (str, "aux-info", 8))
5415 flag_gen_aux_info = 1;
5416 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
5418 else if (!strcmp (str, "-help"))
5424 error ("Invalid option `%s'", argv[i]);
5426 else if (argv[i][0] == '+')
5427 error ("Invalid option `%s'", argv[i]);
5432 /* Checker uses the frame pointer. */
5433 if (flag_check_memory_usage)
5434 flag_omit_frame_pointer = 0;
5438 /* Inlining does not work if not optimizing,
5439 so force it not to be done. */
5443 /* The c_decode_option and lang_decode_option functions set
5444 this to `2' if -Wall is used, so we can avoid giving out
5445 lots of errors for people who don't realize what -Wall does. */
5446 if (warn_uninitialized == 1)
5447 warning ("-Wuninitialized is not supported without -O");
5450 #ifdef OVERRIDE_OPTIONS
5451 /* Some machines may reject certain combinations of options. */
5455 if (exceptions_via_longjmp == 2)
5457 #ifdef DWARF2_UNWIND_INFO
5458 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5460 exceptions_via_longjmp = 1;
5464 if (profile_block_flag == 3)
5466 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5467 profile_block_flag = 2;
5470 /* Unrolling all loops implies that standard loop unrolling must also
5472 if (flag_unroll_all_loops)
5473 flag_unroll_loops = 1;
5474 /* Loop unrolling requires that strength_reduction be on also. Silently
5475 turn on strength reduction here if it isn't already on. Also, the loop
5476 unrolling code assumes that cse will be run after loop, so that must
5477 be turned on also. */
5478 if (flag_unroll_loops)
5480 flag_strength_reduce = 1;
5481 flag_rerun_cse_after_loop = 1;
5484 /* Warn about options that are not supported on this machine. */
5485 #ifndef INSN_SCHEDULING
5486 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5487 warning ("instruction scheduling not supported on this target machine");
5490 if (flag_delayed_branch)
5491 warning ("this target machine does not have delayed branches");
5494 user_label_prefix = USER_LABEL_PREFIX;
5495 if (flag_leading_underscore != -1)
5497 /* If the default prefix is more complicated than "" or "_",
5498 issue a warning and ignore this option. */
5499 if (user_label_prefix[0] == 0 ||
5500 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5502 user_label_prefix = flag_leading_underscore ? "_" : "";
5505 warning ("-f%sleading-underscore not supported on this target machine",
5506 flag_leading_underscore ? "" : "no-");
5509 /* If we are in verbose mode, write out the version and maybe all the
5510 option flags in use. */
5513 print_version (stderr, "");
5515 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5518 compile_file (filename);
5520 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5523 char *lim = (char *) sbrk (0);
5525 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5530 system ("ps -l 1>&2");
5533 #endif /* not USG */
5536 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5539 exit (FATAL_EXIT_CODE);
5541 exit (FATAL_EXIT_CODE);
5542 exit (SUCCESS_EXIT_CODE);
5546 /* Decode -m switches. */
5547 /* Decode the switch -mNAME. */
5550 set_target_switch (name)
5554 int valid_target_option = 0;
5556 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5557 if (!strcmp (target_switches[j].name, name))
5559 if (target_switches[j].value < 0)
5560 target_flags &= ~-target_switches[j].value;
5562 target_flags |= target_switches[j].value;
5563 valid_target_option = 1;
5566 #ifdef TARGET_OPTIONS
5567 if (!valid_target_option)
5568 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5570 int len = strlen (target_options[j].prefix);
5571 if (!strncmp (target_options[j].prefix, name, len))
5573 *target_options[j].variable = name + len;
5574 valid_target_option = 1;
5579 if (!valid_target_option)
5580 error ("Invalid option `%s'", name);
5583 /* Print version information to FILE.
5584 Each line begins with INDENT (for the case where FILE is the
5585 assembler output file). */
5588 print_version (file, indent)
5593 #define __VERSION__ "[?]"
5597 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5599 "%s%s%s version %s (%s) compiled by CC.\n"
5601 , indent, *indent != 0 ? " " : "",
5602 language_string, version_string, TARGET_NAME, __VERSION__);
5605 /* Print an option value and return the adjusted position in the line.
5606 ??? We don't handle error returns from fprintf (disk full); presumably
5607 other code will catch a disk full though. */
5610 print_single_switch (file, pos, max, indent, sep, term, type, name)
5613 const char *indent, *sep, *term, *type, *name;
5615 /* The ultrix fprintf returns 0 on success, so compute the result we want
5616 here since we need it for the following test. */
5617 int len = strlen (sep) + strlen (type) + strlen (name);
5622 fprintf (file, "%s", term);
5627 fprintf (file, "%s", indent);
5628 pos = strlen (indent);
5630 fprintf (file, "%s%s%s", sep, type, name);
5635 /* Print active target switches to FILE.
5636 POS is the current cursor position and MAX is the size of a "line".
5637 Each line begins with INDENT and ends with TERM.
5638 Each switch is separated from the next by SEP. */
5641 print_switch_values (file, pos, max, indent, sep, term)
5644 const char *indent, *sep, *term;
5649 /* Print the options as passed. */
5651 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5652 _("options passed: "), "");
5654 for (p = &save_argv[1]; *p != NULL; p++)
5658 if (strcmp (*p, "-o") == 0)
5664 if (strcmp (*p, "-quiet") == 0)
5666 if (strcmp (*p, "-version") == 0)
5671 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5674 fprintf (file, "%s", term);
5676 /* Print the -f and -m options that have been enabled.
5677 We don't handle language specific options but printing argv
5680 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5681 _("options enabled: "), "");
5683 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5684 if (*f_options[j].variable == f_options[j].on_value)
5685 pos = print_single_switch (file, pos, max, indent, sep, term,
5686 "-f", f_options[j].string);
5688 /* Print target specific options. */
5690 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5691 if (target_switches[j].name[0] != '\0'
5692 && target_switches[j].value > 0
5693 && ((target_switches[j].value & target_flags)
5694 == target_switches[j].value))
5696 pos = print_single_switch (file, pos, max, indent, sep, term,
5697 "-m", target_switches[j].name);
5700 #ifdef TARGET_OPTIONS
5701 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5702 if (*target_options[j].variable != NULL)
5705 sprintf (prefix, "-m%s", target_options[j].prefix);
5706 pos = print_single_switch (file, pos, max, indent, sep, term,
5707 prefix, *target_options[j].variable);
5711 fprintf (file, "%s", term);
5714 /* Record the beginning of a new source file, named FILENAME. */
5717 debug_start_source_file (filename)
5718 register char *filename ATTRIBUTE_UNUSED;
5720 #ifdef DBX_DEBUGGING_INFO
5721 if (write_symbols == DBX_DEBUG)
5722 dbxout_start_new_source_file (filename);
5724 #ifdef DWARF_DEBUGGING_INFO
5725 if (debug_info_level == DINFO_LEVEL_VERBOSE
5726 && write_symbols == DWARF_DEBUG)
5727 dwarfout_start_new_source_file (filename);
5728 #endif /* DWARF_DEBUGGING_INFO */
5729 #ifdef DWARF2_DEBUGGING_INFO
5730 if (debug_info_level == DINFO_LEVEL_VERBOSE
5731 && write_symbols == DWARF2_DEBUG)
5732 dwarf2out_start_source_file (filename);
5733 #endif /* DWARF2_DEBUGGING_INFO */
5734 #ifdef SDB_DEBUGGING_INFO
5735 if (write_symbols == SDB_DEBUG)
5736 sdbout_start_new_source_file (filename);
5740 /* Record the resumption of a source file. LINENO is the line number in
5741 the source file we are returning to. */
5744 debug_end_source_file (lineno)
5745 register unsigned lineno ATTRIBUTE_UNUSED;
5747 #ifdef DBX_DEBUGGING_INFO
5748 if (write_symbols == DBX_DEBUG)
5749 dbxout_resume_previous_source_file ();
5751 #ifdef DWARF_DEBUGGING_INFO
5752 if (debug_info_level == DINFO_LEVEL_VERBOSE
5753 && write_symbols == DWARF_DEBUG)
5754 dwarfout_resume_previous_source_file (lineno);
5755 #endif /* DWARF_DEBUGGING_INFO */
5756 #ifdef DWARF2_DEBUGGING_INFO
5757 if (debug_info_level == DINFO_LEVEL_VERBOSE
5758 && write_symbols == DWARF2_DEBUG)
5759 dwarf2out_end_source_file ();
5760 #endif /* DWARF2_DEBUGGING_INFO */
5761 #ifdef SDB_DEBUGGING_INFO
5762 if (write_symbols == SDB_DEBUG)
5763 sdbout_resume_previous_source_file ();
5767 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5768 the tail part of the directive line, i.e. the part which is past the
5769 initial whitespace, #, whitespace, directive-name, whitespace part. */
5772 debug_define (lineno, buffer)
5773 register unsigned lineno ATTRIBUTE_UNUSED;
5774 register char *buffer ATTRIBUTE_UNUSED;
5776 #ifdef DWARF_DEBUGGING_INFO
5777 if (debug_info_level == DINFO_LEVEL_VERBOSE
5778 && write_symbols == DWARF_DEBUG)
5779 dwarfout_define (lineno, buffer);
5780 #endif /* DWARF_DEBUGGING_INFO */
5781 #ifdef DWARF2_DEBUGGING_INFO
5782 if (debug_info_level == DINFO_LEVEL_VERBOSE
5783 && write_symbols == DWARF2_DEBUG)
5784 dwarf2out_define (lineno, buffer);
5785 #endif /* DWARF2_DEBUGGING_INFO */
5788 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5789 the tail part of the directive line, i.e. the part which is past the
5790 initial whitespace, #, whitespace, directive-name, whitespace part. */
5793 debug_undef (lineno, buffer)
5794 register unsigned lineno ATTRIBUTE_UNUSED;
5795 register char *buffer ATTRIBUTE_UNUSED;
5797 #ifdef DWARF_DEBUGGING_INFO
5798 if (debug_info_level == DINFO_LEVEL_VERBOSE
5799 && write_symbols == DWARF_DEBUG)
5800 dwarfout_undef (lineno, buffer);
5801 #endif /* DWARF_DEBUGGING_INFO */
5802 #ifdef DWARF2_DEBUGGING_INFO
5803 if (debug_info_level == DINFO_LEVEL_VERBOSE
5804 && write_symbols == DWARF2_DEBUG)
5805 dwarf2out_undef (lineno, buffer);
5806 #endif /* DWARF2_DEBUGGING_INFO */