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.2 2003/06/17 04:24:01 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 /* Table of supported debugging formats. */
783 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
784 constant expression, we use NO_DEBUG in its place. */
785 enum debug_info_type debug_type;
786 int use_extensions_p;
787 const char * description;
791 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
792 "Generate default debug format output" },
793 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" },
794 #ifdef DBX_DEBUGGING_INFO
795 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
796 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
798 #ifdef DWARF_DEBUGGING_INFO
799 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
800 { "gdwarf+", DWARF_DEBUG, 1,
801 "Generated extended DWARF-1 format debug output" },
803 #ifdef DWARF2_DEBUGGING_INFO
804 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
806 #ifdef XCOFF_DEBUGGING_INFO
807 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
808 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
810 #ifdef SDB_DEBUGGING_INFO
811 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" },
821 const char * description;
823 lang_independent_options;
825 /* Add or remove a leading underscore from user symbols. */
826 int flag_leading_underscore = -1;
828 /* The user symbol prefix after having resolved same. */
829 const char *user_label_prefix;
831 /* A default for same. */
832 #ifndef USER_LABEL_PREFIX
833 #define USER_LABEL_PREFIX ""
836 /* Table of language-independent -f options.
837 STRING is the option name. VARIABLE is the address of the variable.
838 ON_VALUE is the value to store in VARIABLE
839 if `-fSTRING' is seen as an option.
840 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
842 lang_independent_options f_options[] =
844 {"float-store", &flag_float_store, 1,
845 "Do not store floats in registers" },
846 {"volatile", &flag_volatile, 1,
847 "Consider all mem refs through pointers as volatile"},
848 {"volatile-global", &flag_volatile_global, 1,
849 "Consider all mem refs to global data to be volatile" },
850 {"volatile-static", &flag_volatile_static, 1,
851 "Consider all mem refs to static data to be volatile" },
852 {"defer-pop", &flag_defer_pop, 1,
853 "Defer popping functions args from stack until later" },
854 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
855 "When possible do not generate stack frames"},
856 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
857 "When running CSE, follow jumps to their targets" },
858 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
859 "When running CSE, follow conditional jumps" },
860 {"expensive-optimizations", &flag_expensive_optimizations, 1,
861 "Perform a number of minor, expensive optimisations" },
862 {"thread-jumps", &flag_thread_jumps, 1,
863 "Perform jump threading optimisations"},
864 {"strength-reduce", &flag_strength_reduce, 1,
865 "Perform strength reduction optimisations" },
866 {"unroll-loops", &flag_unroll_loops, 1,
867 "Perform loop unrolling when iteration count is known" },
868 {"unroll-all-loops", &flag_unroll_all_loops, 1,
869 "Perform loop unrolling for all loops" },
870 {"move-all-movables", &flag_move_all_movables, 1,
871 "Force all loop invariant computations out of loops" },
872 {"reduce-all-givs", &flag_reduce_all_givs, 1,
873 "Strength reduce all loop general induction variables" },
874 {"writable-strings", &flag_writable_strings, 1,
875 "Store strings in writable data section" },
876 {"peephole", &flag_no_peephole, 0,
877 "Enable machine specific peephole optimisations" },
878 {"force-mem", &flag_force_mem, 1,
879 "Copy memory operands into registers before using" },
880 {"force-addr", &flag_force_addr, 1,
881 "Copy memory address constants into regs before using" },
882 {"function-cse", &flag_no_function_cse, 0,
883 "Allow function addresses to be held in registers" },
884 {"inline-functions", &flag_inline_functions, 1,
885 "Integrate simple functions into their callers" },
886 {"keep-inline-functions", &flag_keep_inline_functions, 1,
887 "Generate code for funcs even if they are fully inlined" },
888 {"inline", &flag_no_inline, 0,
889 "Pay attention to the 'inline' keyword"},
890 {"keep-static-consts", &flag_keep_static_consts, 1,
891 "Emit static const variables even if they are not used" },
892 {"syntax-only", &flag_syntax_only, 1,
893 "Check for syntax errors, then stop" },
894 {"shared-data", &flag_shared_data, 1,
895 "Mark data as shared rather than private" },
896 {"caller-saves", &flag_caller_saves, 1,
897 "Enable saving registers around function calls" },
898 {"pcc-struct-return", &flag_pcc_struct_return, 1,
899 "Return 'short' aggregates in memory, not registers" },
900 {"reg-struct-return", &flag_pcc_struct_return, 0,
901 "Return 'short' aggregates in registers" },
902 {"delayed-branch", &flag_delayed_branch, 1,
903 "Attempt to fill delay slots of branch instructions" },
904 {"gcse", &flag_gcse, 1,
905 "Perform the global common subexpression elimination" },
906 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
907 "Run CSE pass after loop optimisations"},
908 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
909 "Run the loop optimiser twice"},
910 {"pretend-float", &flag_pretend_float, 1,
911 "Pretend that host and target use the same FP format"},
912 {"schedule-insns", &flag_schedule_insns, 1,
913 "Reschedule instructions to avoid pipeline stalls"},
914 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
915 "Run two passes of the instruction scheduler"},
917 {"sched-interblock",&flag_schedule_interblock, 1,
918 "Enable scheduling across basic blocks" },
919 {"sched-spec",&flag_schedule_speculative, 1,
920 "Allow speculative motion of non-loads" },
921 {"sched-spec-load",&flag_schedule_speculative_load, 1,
922 "Allow speculative motion of some loads" },
923 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
924 "Allow speculative motion of more loads" },
926 {"branch-count-reg",&flag_branch_on_count_reg, 1,
927 "Replace add,compare,branch with branch on count reg"},
928 {"pic", &flag_pic, 1,
929 "Generate position independent code, if possible"},
930 {"PIC", &flag_pic, 2, ""},
931 {"exceptions", &flag_exceptions, 1,
932 "Enable exception handling" },
933 {"new-exceptions", &flag_new_exceptions, 1,
934 "Use the new model for exception handling" },
935 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
936 "Use setjmp/longjmp to handle exceptions" },
937 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
938 "Support asynchronous exceptions" },
939 {"profile-arcs", &profile_arc_flag, 1,
940 "Insert arc based program profiling code" },
941 {"test-coverage", &flag_test_coverage, 1,
942 "Create data files needed by gcov" },
943 {"branch-probabilities", &flag_branch_probabilities, 1,
944 "Use profiling information for branch probabilities" },
945 {"fast-math", &flag_fast_math, 1,
946 "Improve FP speed by violating ANSI & IEEE rules" },
947 {"common", &flag_no_common, 0,
948 "Do not put unitialised globals in the common section" },
949 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
950 "Do not generate .size directives" },
951 {"function-sections", &flag_function_sections, 1,
952 "place each function into its own section" },
953 {"data-sections", &flag_data_sections, 1,
954 "place data items into their own section" },
955 {"verbose-asm", &flag_verbose_asm, 1,
956 "Add extra commentry to assembler output"},
957 {"gnu-linker", &flag_gnu_linker, 1,
958 "Output GNU ld formatted global initialisers"},
959 {"regmove", &flag_regmove, 1,
960 "Enables a register move optimisation"},
961 {"optimize-register-move", &flag_regmove, 1,
962 "Do the full regmove optimization pass"},
963 {"pack-struct", &flag_pack_struct, 1,
964 "Pack structure members together without holes" },
965 {"format-extensions", &flag_format_extensions, 1,
966 "-Wformat accepts certain FreeBSD system-dependent formats" },
967 {"stack-check", &flag_stack_check, 1,
968 "Insert stack checking code into the program" },
969 {"argument-alias", &flag_argument_noalias, 0,
970 "Specify that arguments may alias each other & globals"},
971 {"argument-noalias", &flag_argument_noalias, 1,
972 "Assume arguments may alias globals but not each other"},
973 {"argument-noalias-global", &flag_argument_noalias, 2,
974 "Assume arguments do not alias each other or globals" },
975 {"strict-aliasing", &flag_strict_aliasing, 1,
976 "Assume strict aliasing rules apply" },
977 {"check-memory-usage", &flag_check_memory_usage, 1,
978 "Generate code to check every memory access" },
979 {"prefix-function-name", &flag_prefix_function_name, 1,
980 "Add a prefix to all function names" },
981 {"dump-unnumbered", &flag_dump_unnumbered, 1,
982 "Suppress output of instruction numbers and line number notes in debugging dumps"},
983 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
984 "Instrument function entry/exit with profiling calls"},
985 {"leading-underscore", &flag_leading_underscore, 1,
986 "External symbols have a leading underscore" },
987 {"ident", &flag_no_ident, 0,
988 "Process #ident directives"}
991 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
993 /* Table of language-specific options. */
995 static struct lang_opt
998 const char * description;
1000 documented_lang_options[] =
1002 /* In order not to overload the --help output, the convention
1003 used here is to only describe those options which are not
1004 enabled by default. */
1006 { "-ansi", "Compile just for ANSI C" },
1007 { "-fallow-single-precision",
1008 "Do not promote floats to double if using -traditional" },
1009 { "-std= ", "Determine language standard"},
1011 { "-fsigned-bitfields", "" },
1012 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1013 { "-fno-signed-bitfields", "" },
1014 { "-fno-unsigned-bitfields","" },
1015 { "-fsigned-char", "Make 'char' be signed by default"},
1016 { "-funsigned-char", "Make 'char' be unsigned by default"},
1017 { "-fno-signed-char", "" },
1018 { "-fno-unsigned-char", "" },
1020 { "-ftraditional", "" },
1021 { "-traditional", "Attempt to support traditional K&R style C"},
1022 { "-fnotraditional", "" },
1023 { "-fno-traditional", "" },
1026 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1027 { "-fbuiltin", "" },
1028 { "-fno-builtin", "Do not recognise any built in functions" },
1029 { "-fhosted", "Assume normal C execution environment" },
1030 { "-fno-hosted", "" },
1032 "Assume that standard libraries & main might not exist" },
1033 { "-fno-freestanding", "" },
1034 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1035 { "-fno-cond-mismatch", "" },
1036 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1037 { "-fno-dollars-in-identifiers", "" },
1038 { "-fshort-double", "Use the same size for double as for float" },
1039 { "-fno-short-double", "" },
1040 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1041 { "-fno-short-enums", "" },
1043 { "-Wall", "Enable most warning messages" },
1044 { "-Wbad-function-cast",
1045 "Warn about casting functions to incompatible types" },
1046 { "-Wno-bad-function-cast", "" },
1047 { "-Wmissing-noreturn",
1048 "Warn about functions which might be candidates for attribute noreturn" },
1049 { "-Wno-missing-noreturn", "" },
1050 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1051 { "-Wno-cast-qual", "" },
1052 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1053 { "-Wno-char-subscripts", "" },
1054 { "-Wcomment", "Warn if nested comments are detected" },
1055 { "-Wno-comment", "" },
1056 { "-Wcomments", "Warn if nested comments are detected" },
1057 { "-Wno-comments", "" },
1058 { "-Wconversion", "Warn about possibly confusing type conversions" },
1059 { "-Wno-conversion", "" },
1060 { "-Wformat", "Warn about printf format anomalies" },
1061 { "-Wnon-const-format", "Warn about printf-like format strings" },
1062 { "-Wno-format", "" },
1063 { "-Wno-format-extra-args", "" },
1064 { "-Wimplicit-function-declaration",
1065 "Warn about implicit function declarations" },
1066 { "-Wno-implicit-function-declaration", "" },
1067 { "-Werror-implicit-function-declaration", "" },
1068 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1069 { "-Wno-implicit-int", "" },
1070 { "-Wimplicit", "" },
1071 { "-Wno-implicit", "" },
1072 { "-Wimport", "Warn about the use of the #import directive" },
1073 { "-Wno-import", "" },
1074 { "-Wlong-long","" },
1075 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1076 { "-Wmain", "Warn about suspicious declarations of main" },
1077 { "-Wframe-size-<N>",
1078 "Warn if frame uses greater than <N> bytes." },
1079 { "-Warglist-size-<N>",
1080 "Warn if function argument list uses greater than <N> bytes." },
1081 { "-Wno-main", "" },
1082 { "-Wmissing-braces",
1083 "Warn about possibly missing braces around initialisers" },
1084 { "-Wno-missing-braces", "" },
1085 { "-Wmissing-declarations",
1086 "Warn about global funcs without previous declarations"},
1087 { "-Wno-missing-declarations", "" },
1088 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1089 { "-Wno-missing-prototypes", "" },
1090 { "-Wmultichar", "Warn about use of multicharacter literals"},
1091 { "-Wno-multichar", "" },
1092 { "-Wnested-externs", "Warn about externs not at file scope level" },
1093 { "-Wno-nested-externs", "" },
1094 { "-Wparentheses", "Warn about possible missing parentheses" },
1095 { "-Wno-parentheses", "" },
1096 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1097 { "-Wno-pointer-arith", "" },
1098 { "-Wredundant-decls",
1099 "Warn about multiple declarations of the same object" },
1100 { "-Wno-redundant-decls", "" },
1101 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1102 { "-Wno-sign-compare", "" },
1103 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" },
1104 { "-Wno-unknown-pragmas", "" },
1105 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1106 { "-Wno-strict-prototypes", "" },
1107 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1108 { "-Wno-traditional", "" },
1109 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1110 { "-Wno-trigraphs", "" },
1112 { "-Wno-undef", "" },
1113 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1114 { "-Wno-write-strings", "" },
1116 /* These are for languages with USE_CPPLIB. */
1117 /* These options are already documented in cpplib.c */
1123 { "-MD", "Print dependencies to FILE.d" },
1124 { "-MMD", "Print dependencies to FILE.d" },
1125 { "-M", "Print dependencies to stdout" },
1126 { "-MM", "Print dependencies to stdout" },
1127 #endif /* USE_CPPLIB */
1130 { "-idirafter", "" },
1135 { "-iwithprefix", "" },
1136 { "-iwithprefixbefore", "" },
1138 { "-lang-c89", "" },
1139 { "-lang-c++", "" },
1141 { "-nostdinc", "" },
1142 { "-nostdinc++", "" },
1143 { "-trigraphs", "" },
1146 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1148 /* These are for obj c. */
1149 DEFINE_LANG_NAME ("Objective C")
1151 { "-lang-objc", "" },
1152 { "-gen-decls", "Dump decls to a .decl file" },
1153 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1154 { "-fno-gnu-runtime", "" },
1155 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1156 { "-fno-next-runtime", "" },
1157 { "-Wselector", "Warn if a selector has multiple methods" },
1158 { "-Wno-selector", "" },
1159 { "-Wprotocol", "" },
1160 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1161 { "-print-objc-runtime-info",
1162 "Generate C header of platform specific features" },
1164 #include "options.h"
1168 /* Here is a table, controlled by the tm.h file, listing each -m switch
1169 and which bits in `target_switches' it should set or clear.
1170 If VALUE is positive, it is bits to set.
1171 If VALUE is negative, -VALUE is bits to clear.
1172 (The sign bit is not used so there is no confusion.) */
1178 const char * description;
1180 target_switches [] = TARGET_SWITCHES;
1182 /* This table is similar, but allows the switch to have a value. */
1184 #ifdef TARGET_OPTIONS
1187 const char * prefix;
1188 const char ** variable;
1189 const char * description;
1191 target_options [] = TARGET_OPTIONS;
1194 /* Options controlling warnings */
1196 /* Don't print warning messages. -w. */
1198 int inhibit_warnings = 0;
1200 /* Print various extra warnings. -W. */
1202 int extra_warnings = 0;
1204 /* Treat warnings as errors. -Werror. */
1206 int warnings_are_errors = 0;
1208 /* Nonzero to warn about unused local variables. */
1212 /* Nonzero to warn about variables used before they are initialized. */
1214 int warn_uninitialized;
1216 /* Nonzero means warn about all declarations which shadow others. */
1220 /* Warn if a switch on an enum fails to have a case for every enum value. */
1224 /* Nonzero means warn about function definitions that default the return type
1225 or that use a null return and have a return-type other than void. */
1227 int warn_return_type;
1229 /* Nonzero means warn about pointer casts that increase the required
1230 alignment of the target type (and might therefore lead to a crash
1231 due to a misaligned access). */
1233 int warn_cast_align;
1235 /* Nonzero means warn if a frame is larger that N bytes. The value
1236 of N is warn_frame_size. */
1238 int warn_frame_size_flag = 0;
1239 int warn_frame_size;
1241 /* Nonzero means warn if a function call pushes more than N bytes
1242 onto the stack. The value of N is warn_arglist_size. */
1244 int warn_arglist_size_flag = 0;
1245 int warn_arglist_size;
1247 /* Nonzero means warn about any identifiers that match in the first N
1248 characters. The value N is in `id_clash_len'. */
1251 unsigned id_clash_len;
1253 /* Nonzero means warn about any objects definitions whose size is larger
1254 than N bytes. Also want about function definitions whose returned
1255 values are larger than N bytes. The value N is in `larger_than_size'. */
1257 int warn_larger_than;
1258 unsigned larger_than_size;
1260 /* Nonzero means warn if inline function is too large. */
1264 /* Warn if a function returns an aggregate,
1265 since there are often incompatible calling conventions for doing this. */
1267 int warn_aggregate_return;
1269 /* Likewise for -W. */
1271 lang_independent_options W_options[] =
1273 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1274 {"error", &warnings_are_errors, 1, ""},
1275 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1276 {"switch", &warn_switch, 1,
1277 "Warn about enumerated switches missing a specific case" },
1278 {"aggregate-return", &warn_aggregate_return, 1,
1279 "Warn about returning structures, unions or arrays" },
1280 {"cast-align", &warn_cast_align, 1,
1281 "Warn about pointer casts which increase alignment" },
1282 {"uninitialized", &warn_uninitialized, 1,
1283 "Warn about unitialized automatic variables"},
1284 {"inline", &warn_inline, 1,
1285 "Warn when an inlined function cannot be inlined"}
1288 /* Output files for assembler code (real compiler output)
1289 and debugging dumps. */
1292 FILE *aux_info_file;
1293 FILE *rtl_dump_file = NULL;
1295 /* Decode the string P as an integral parameter.
1296 If the string is indeed an integer return its numeric value else
1297 issue an Invalid Option error for the option PNAME and return DEFVAL.
1298 If PNAME is zero just return DEFVAL, do not call error. */
1301 read_integral_parameter (p, pname, defval)
1306 const char *endp = p;
1310 if (*endp >= '0' && *endp <= '9')
1319 error ("Invalid option `%s'", pname);
1327 /* Time accumulators, to count the total time spent in various passes. */
1331 int integration_time;
1337 int branch_prob_time;
1342 int local_alloc_time;
1343 int global_alloc_time;
1349 int shorten_branch_time;
1355 /* Return time used so far, in microseconds. */
1365 #else /* not BeOS */
1366 #if defined (_WIN32) && !defined (__CYGWIN__)
1370 return (clock() * 1000);
1371 #else /* not _WIN32 */
1377 tick = 1000000 / sysconf(_SC_CLK_TCK);
1379 return (tms.tms_utime + tms.tms_stime) * tick;
1385 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1386 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1389 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1391 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1395 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1400 struct rusage rusage;
1401 getrusage (0, &rusage);
1402 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1403 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1410 int proc_system_time;
1411 int child_user_time;
1412 int child_system_time;
1414 times ((void *) &vms_times);
1415 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1419 #endif /* _SC_CLK_TCK */
1421 #endif /* __BEOS__ */
1424 #define TIMEVAR(VAR, BODY) \
1425 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1428 print_time (str, total)
1433 "time in %s: %d.%06d\n",
1434 str, total / 1000000, total % 1000000);
1437 /* Count an error or warning. Return 1 if the message should be printed. */
1440 count_error (warningp)
1443 if (warningp && inhibit_warnings)
1446 if (warningp && !warnings_are_errors)
1450 static int warning_message = 0;
1452 if (warningp && !warning_message)
1454 notice ("%s: warnings being treated as errors\n", progname);
1455 warning_message = 1;
1463 /* Print a fatal error message. NAME is the text.
1464 Also include a system error message based on `errno'. */
1467 pfatal_with_name (name)
1470 fprintf (stderr, "%s: ", progname);
1472 exit (FATAL_EXIT_CODE);
1476 fatal_io_error (name)
1479 notice ("%s: %s: I/O error\n", progname, name);
1480 exit (FATAL_EXIT_CODE);
1483 /* Called to give a better error message for a bad insn rather than
1484 just calling abort(). */
1487 fatal_insn VPROTO((const char *msgid, rtx insn, ...))
1489 #ifndef ANSI_PROTOTYPES
1495 VA_START (ap, insn);
1497 #ifndef ANSI_PROTOTYPES
1498 msgid = va_arg (ap, const char *);
1499 insn = va_arg (ap, rtx);
1504 exit (FATAL_EXIT_CODE);
1507 /* Called to give a better error message when we don't have an insn to match
1508 what we are looking for or if the insn's constraints aren't satisfied,
1509 rather than just calling abort(). */
1512 fatal_insn_not_found (insn)
1515 if (INSN_CODE (insn) < 0)
1516 fatal_insn ("internal error--unrecognizable insn:", insn);
1518 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1521 /* This is the default decl_printable_name function. */
1524 decl_name (decl, verbosity)
1526 int verbosity ATTRIBUTE_UNUSED;
1528 return IDENTIFIER_POINTER (DECL_NAME (decl));
1531 static int need_error_newline;
1533 /* Function of last error message;
1534 more generally, function such that if next error message is in it
1535 then we don't have to mention the function name. */
1536 static tree last_error_function = NULL;
1538 /* Used to detect when input_file_stack has changed since last described. */
1539 static int last_error_tick;
1541 /* Called when the start of a function definition is parsed,
1542 this function prints on stderr the name of the function. */
1545 announce_function (decl)
1550 if (rtl_dump_and_exit)
1551 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1553 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1555 need_error_newline = 1;
1556 last_error_function = current_function_decl;
1560 /* The default function to print out name of current function that caused
1564 default_print_error_function (file)
1567 if (last_error_function != current_function_decl)
1570 fprintf (stderr, "%s: ", file);
1572 if (current_function_decl == NULL)
1573 notice ("At top level:\n");
1575 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
1576 ? "In method `%s':\n"
1577 : "In function `%s':\n"),
1578 (*decl_printable_name) (current_function_decl, 2));
1580 last_error_function = current_function_decl;
1584 /* Called by report_error_function to print out function name.
1585 * Default may be overridden by language front-ends. */
1587 void (*print_error_function) PROTO((const char *)) =
1588 default_print_error_function;
1590 /* Prints out, if necessary, the name of the current function
1591 that caused an error. Called from all error and warning functions.
1592 We ignore the FILE parameter, as it cannot be relied upon. */
1595 report_error_function (file)
1596 const char *file ATTRIBUTE_UNUSED;
1598 struct file_stack *p;
1600 if (need_error_newline)
1602 fprintf (stderr, "\n");
1603 need_error_newline = 0;
1606 if (input_file_stack && input_file_stack->next != 0
1607 && input_file_stack_tick != last_error_tick)
1609 for (p = input_file_stack->next; p; p = p->next)
1610 notice ((p == input_file_stack->next
1611 ? "In file included from %s:%d"
1612 : ",\n from %s:%d"),
1614 fprintf (stderr, ":\n");
1615 last_error_tick = input_file_stack_tick;
1618 (*print_error_function) (input_filename);
1621 /* Print a message. */
1624 vnotice (file, msgid, ap)
1629 vfprintf (file, _(msgid), ap);
1633 notice VPROTO((const char *msgid, ...))
1635 #ifndef ANSI_PROTOTYPES
1640 VA_START (ap, msgid);
1642 #ifndef ANSI_PROTOTYPES
1643 msgid = va_arg (ap, char *);
1646 vnotice (stderr, msgid, ap);
1651 fnotice VPROTO((FILE *file, const char *msgid, ...))
1653 #ifndef ANSI_PROTOTYPES
1659 VA_START (ap, msgid);
1661 #ifndef ANSI_PROTOTYPES
1662 file = va_arg (ap, FILE *);
1663 msgid = va_arg (ap, const char *);
1666 vnotice (file, msgid, ap);
1670 /* Report FILE and LINE (or program name), and optionally just WARN. */
1673 report_file_and_line (file, line, warn)
1679 fprintf (stderr, "%s:%d: ", file, line);
1681 fprintf (stderr, "%s: ", progname);
1684 notice ("warning: ");
1687 /* Print a message. */
1690 vmessage (prefix, msgid, ap)
1696 fprintf (stderr, "%s: ", prefix);
1698 vfprintf (stderr, msgid, ap);
1701 /* Print a message relevant to line LINE of file FILE. */
1704 v_message_with_file_and_line (file, line, warn, msgid, ap)
1711 report_file_and_line (file, line, warn);
1712 vnotice (stderr, msgid, ap);
1713 fputc ('\n', stderr);
1716 /* Print a message relevant to the given DECL. */
1719 v_message_with_decl (decl, warn, msgid, ap)
1727 report_file_and_line (DECL_SOURCE_FILE (decl),
1728 DECL_SOURCE_LINE (decl), warn);
1730 /* Do magic to get around lack of varargs support for insertion
1731 of arguments into existing list. We know that the decl is first;
1732 we ass_u_me that it will be printed with "%s". */
1734 for (p = _(msgid); *p; ++p)
1738 if (*(p + 1) == '%')
1740 else if (*(p + 1) != 's')
1747 if (p > _(msgid)) /* Print the left-hand substring. */
1749 char fmt[sizeof "%.255s"];
1750 long width = p - _(msgid);
1752 if (width > 255L) width = 255L; /* arbitrary */
1753 sprintf (fmt, "%%.%lds", width);
1754 fprintf (stderr, fmt, _(msgid));
1757 if (*p == '%') /* Print the name. */
1759 const char *n = (DECL_NAME (decl)
1760 ? (*decl_printable_name) (decl, 2)
1766 if (ISALPHA (*(p - 1) & 0xFF))
1771 if (*p) /* Print the rest of the message. */
1772 vmessage ((char *)NULL, p, ap);
1774 fputc ('\n', stderr);
1777 /* Figure file and line of the given INSN. */
1780 file_and_line_for_asm (insn, pfile, pline)
1785 rtx body = PATTERN (insn);
1788 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1789 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1790 asmop = SET_SRC (body);
1791 else if (GET_CODE (body) == ASM_OPERANDS)
1793 else if (GET_CODE (body) == PARALLEL
1794 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1795 asmop = SET_SRC (XVECEXP (body, 0, 0));
1796 else if (GET_CODE (body) == PARALLEL
1797 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1798 asmop = XVECEXP (body, 0, 0);
1804 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1805 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1809 *pfile = input_filename;
1814 /* Report an error at line LINE of file FILE. */
1817 v_error_with_file_and_line (file, line, msgid, ap)
1824 report_error_function (file);
1825 v_message_with_file_and_line (file, line, 0, msgid, ap);
1829 error_with_file_and_line VPROTO((const char *file, int line,
1830 const char *msgid, ...))
1832 #ifndef ANSI_PROTOTYPES
1839 VA_START (ap, msgid);
1841 #ifndef ANSI_PROTOTYPES
1842 file = va_arg (ap, const char *);
1843 line = va_arg (ap, int);
1844 msgid = va_arg (ap, const char *);
1847 v_error_with_file_and_line (file, line, msgid, ap);
1851 /* Report an error at the declaration DECL.
1852 MSGID is a format string which uses %s to substitute the declaration
1853 name; subsequent substitutions are a la printf. */
1856 v_error_with_decl (decl, msgid, ap)
1862 report_error_function (DECL_SOURCE_FILE (decl));
1863 v_message_with_decl (decl, 0, msgid, ap);
1867 error_with_decl VPROTO((tree decl, const char *msgid, ...))
1869 #ifndef ANSI_PROTOTYPES
1875 VA_START (ap, msgid);
1877 #ifndef ANSI_PROTOTYPES
1878 decl = va_arg (ap, tree);
1879 msgid = va_arg (ap, const char *);
1882 v_error_with_decl (decl, msgid, ap);
1886 /* Report an error at the line number of the insn INSN.
1887 This is used only when INSN is an `asm' with operands,
1888 and each ASM_OPERANDS records its own source file and line. */
1891 v_error_for_asm (insn, msgid, ap)
1900 file_and_line_for_asm (insn, &file, &line);
1901 report_error_function (file);
1902 v_message_with_file_and_line (file, line, 0, msgid, ap);
1906 error_for_asm VPROTO((rtx insn, const char *msgid, ...))
1908 #ifndef ANSI_PROTOTYPES
1914 VA_START (ap, msgid);
1916 #ifndef ANSI_PROTOTYPES
1917 insn = va_arg (ap, rtx);
1918 msgid = va_arg (ap, const char *);
1921 v_error_for_asm (insn, msgid, ap);
1925 /* Report an error at the current line number. */
1932 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
1936 error VPROTO((const char *msgid, ...))
1938 #ifndef ANSI_PROTOTYPES
1943 VA_START (ap, msgid);
1945 #ifndef ANSI_PROTOTYPES
1946 msgid = va_arg (ap, const char *);
1953 /* Report a fatal error at the current line number. */
1961 exit (FATAL_EXIT_CODE);
1965 fatal VPROTO((const char *msgid, ...))
1967 #ifndef ANSI_PROTOTYPES
1972 VA_START (ap, msgid);
1974 #ifndef ANSI_PROTOTYPES
1975 msgid = va_arg (ap, const char *);
1982 /* Report a warning at line LINE of file FILE. */
1985 v_warning_with_file_and_line (file, line, msgid, ap)
1991 if (count_error (1))
1993 report_error_function (file);
1994 v_message_with_file_and_line (file, line, 1, msgid, ap);
1999 warning_with_file_and_line VPROTO((const char *file, int line,
2000 const char *msgid, ...))
2002 #ifndef ANSI_PROTOTYPES
2009 VA_START (ap, msgid);
2011 #ifndef ANSI_PROTOTYPES
2012 file = va_arg (ap, const char *);
2013 line = va_arg (ap, int);
2014 msgid = va_arg (ap, const char *);
2017 v_warning_with_file_and_line (file, line, msgid, ap);
2021 /* Report a warning at the declaration DECL.
2022 MSGID is a format string which uses %s to substitute the declaration
2023 name; subsequent substitutions are a la printf. */
2026 v_warning_with_decl (decl, msgid, ap)
2031 if (count_error (1))
2033 report_error_function (DECL_SOURCE_FILE (decl));
2034 v_message_with_decl (decl, 1, msgid, ap);
2039 warning_with_decl VPROTO((tree decl, const char *msgid, ...))
2041 #ifndef ANSI_PROTOTYPES
2047 VA_START (ap, msgid);
2049 #ifndef ANSI_PROTOTYPES
2050 decl = va_arg (ap, tree);
2051 msgid = va_arg (ap, const char *);
2054 v_warning_with_decl (decl, msgid, ap);
2058 /* Report a warning at the line number of the insn INSN.
2059 This is used only when INSN is an `asm' with operands,
2060 and each ASM_OPERANDS records its own source file and line. */
2063 v_warning_for_asm (insn, msgid, ap)
2068 if (count_error (1))
2073 file_and_line_for_asm (insn, &file, &line);
2074 report_error_function (file);
2075 v_message_with_file_and_line (file, line, 1, msgid, ap);
2080 warning_for_asm VPROTO((rtx insn, const char *msgid, ...))
2082 #ifndef ANSI_PROTOTYPES
2088 VA_START (ap, msgid);
2090 #ifndef ANSI_PROTOTYPES
2091 insn = va_arg (ap, rtx);
2092 msgid = va_arg (ap, const char *);
2095 v_warning_for_asm (insn, msgid, ap);
2099 /* Report a warning at the current line number. */
2102 vwarning (msgid, ap)
2106 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
2110 warning VPROTO((const char *msgid, ...))
2112 #ifndef ANSI_PROTOTYPES
2117 VA_START (ap, msgid);
2119 #ifndef ANSI_PROTOTYPES
2120 msgid = va_arg (ap, const char *);
2123 vwarning (msgid, ap);
2127 /* These functions issue either warnings or errors depending on
2128 -pedantic-errors. */
2131 vpedwarn (msgid, ap)
2135 if (flag_pedantic_errors)
2138 vwarning (msgid, ap);
2142 pedwarn VPROTO((const char *msgid, ...))
2144 #ifndef ANSI_PROTOTYPES
2149 VA_START (ap, msgid);
2151 #ifndef ANSI_PROTOTYPES
2152 msgid = va_arg (ap, const char *);
2155 vpedwarn (msgid, ap);
2160 v_pedwarn_with_decl (decl, msgid, ap)
2165 /* We don't want -pedantic-errors to cause the compilation to fail from
2166 "errors" in system header files. Sometimes fixincludes can't fix what's
2167 broken (eg: unsigned char bitfields - fixing it may change the alignment
2168 which will cause programs to mysteriously fail because the C library
2169 or kernel uses the original layout). There's no point in issuing a
2170 warning either, it's just unnecessary noise. */
2172 if (! DECL_IN_SYSTEM_HEADER (decl))
2174 if (flag_pedantic_errors)
2175 v_error_with_decl (decl, msgid, ap);
2177 v_warning_with_decl (decl, msgid, ap);
2182 pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...))
2184 #ifndef ANSI_PROTOTYPES
2190 VA_START (ap, msgid);
2192 #ifndef ANSI_PROTOTYPES
2193 decl = va_arg (ap, tree);
2194 msgid = va_arg (ap, const char *);
2197 v_pedwarn_with_decl (decl, msgid, ap);
2202 v_pedwarn_with_file_and_line (file, line, msgid, ap)
2208 if (flag_pedantic_errors)
2209 v_error_with_file_and_line (file, line, msgid, ap);
2211 v_warning_with_file_and_line (file, line, msgid, ap);
2215 pedwarn_with_file_and_line VPROTO((const char *file, int line,
2216 const char *msgid, ...))
2218 #ifndef ANSI_PROTOTYPES
2225 VA_START (ap, msgid);
2227 #ifndef ANSI_PROTOTYPES
2228 file = va_arg (ap, const char *);
2229 line = va_arg (ap, int);
2230 msgid = va_arg (ap, const char *);
2233 v_pedwarn_with_file_and_line (file, line, msgid, ap);
2237 /* Apologize for not implementing some feature. */
2246 fprintf (stderr, "%s:%d: ", input_filename, lineno);
2248 fprintf (stderr, "%s: ", progname);
2249 notice ("sorry, not implemented: ");
2250 vnotice (stderr, msgid, ap);
2251 fputc ('\n', stderr);
2255 sorry VPROTO((const char *msgid, ...))
2257 #ifndef ANSI_PROTOTYPES
2262 VA_START (ap, msgid);
2264 #ifndef ANSI_PROTOTYPES
2265 msgid = va_arg (ap, const char *);
2272 /* Given a partial pathname as input, return another pathname that shares
2273 no elements with the pathname of __FILE__. This is used by abort() to
2274 print `Internal compiler error in expr.c' instead of `Internal compiler
2275 error in ../../egcs/gcc/expr.c'. */
2277 trim_filename (name)
2280 static const char *this_file = __FILE__;
2281 const char *p = name, *q = this_file;
2283 while (*p == *q && *p != 0 && *q != 0) p++, q++;
2284 while (p > name && p[-1] != DIR_SEPARATOR
2285 #ifdef DIR_SEPARATOR_2
2286 && p[-1] != DIR_SEPARATOR_2
2294 /* More 'friendly' abort that prints the line and file.
2295 config.h can #define abort fancy_abort if you like that sort of thing.
2297 I don't think this is actually a good idea.
2298 Other sorts of crashes will look a certain way.
2299 It is a good thing if crashes from calling abort look the same way.
2305 fatal ("internal gcc abort");
2308 /* This calls abort and is used to avoid problems when abort if a macro.
2309 It is used when we need to pass the address of abort. */
2317 /* When `malloc.c' is compiled with `rcheck' defined,
2318 it calls this function to report clobberage. */
2322 const char * s ATTRIBUTE_UNUSED;
2327 /* Same as `malloc' but report error if no memory available. */
2338 value = (PTR) malloc (size);
2340 fatal ("virtual memory exhausted");
2344 /* Same as `calloc' but report error if no memory available. */
2347 xcalloc (size1, size2)
2348 size_t size1, size2;
2352 if (size1 == 0 || size2 == 0)
2355 value = (PTR) calloc (size1, size2);
2357 fatal ("virtual memory exhausted");
2362 /* Same as `realloc' but report error if no memory available.
2363 Also handle null PTR even if the vendor realloc gets it wrong. */
2366 xrealloc (ptr, size)
2370 register PTR result;
2375 result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size));
2378 fatal ("virtual memory exhausted");
2383 /* Same as `strdup' but report error if no memory available. */
2387 register const char *s;
2389 register char *result = (char *) malloc (strlen (s) + 1);
2392 fatal ("virtual memory exhausted");
2397 /* Return the logarithm of X, base 2, considering X unsigned,
2398 if X is a power of 2. Otherwise, returns -1.
2400 This should be used via the `exact_log2' macro. */
2404 register unsigned HOST_WIDE_INT x;
2406 register int log = 0;
2407 /* Test for 0 or a power of 2. */
2408 if (x == 0 || x != (x & -x))
2410 while ((x >>= 1) != 0)
2415 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
2416 If X is 0, return -1.
2418 This should be used via the floor_log2 macro. */
2422 register unsigned HOST_WIDE_INT x;
2424 register int log = -1;
2431 static int float_handler_set;
2433 jmp_buf float_handler;
2435 /* Signals actually come here. */
2438 float_signal (signo)
2439 /* If this is missing, some compilers complain. */
2440 int signo ATTRIBUTE_UNUSED;
2442 if (float_handled == 0)
2444 #if defined (USG) || defined (hpux)
2445 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2448 signal (SIGFPE, float_signal);
2449 longjmp (float_handler, 1);
2452 /* Specify where to longjmp to when a floating arithmetic error happens.
2453 If HANDLER is 0, it means don't handle the errors any more. */
2456 set_float_handler (handler)
2459 float_handled = (handler != 0);
2461 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2463 if (float_handled && ! float_handler_set)
2465 signal (SIGFPE, float_signal);
2466 float_handler_set = 1;
2470 /* This is a wrapper function for code which might elicit an
2471 arithmetic exception. That code should be passed in as a function
2472 pointer FN, and one argument DATA. DATA is usually a struct which
2473 contains the real input and output for function FN. This function
2474 returns 0 (failure) if longjmp was called (i.e. an exception
2475 occured.) It returns 1 (success) otherwise. */
2478 do_float_handler (fn, data)
2479 void (*fn) PROTO ((PTR));
2486 /* We got here via longjmp() caused by an exception in function fn() */
2487 set_float_handler (NULL);
2491 set_float_handler (buf);
2493 set_float_handler (NULL);
2497 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2498 error happens, pushing the previous specification into OLD_HANDLER.
2499 Return an indication of whether there was a previous handler in effect. */
2502 push_float_handler (handler, old_handler)
2503 jmp_buf handler, old_handler;
2505 int was_handled = float_handled;
2509 memcpy ((char *) old_handler, (char *) float_handler,
2510 sizeof (float_handler));
2512 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
2516 /* Restore the previous specification of whether and where to longjmp to
2517 when a floating arithmetic error happens. */
2520 pop_float_handler (handled, handler)
2524 float_handled = handled;
2526 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2529 /* Handler for SIGPIPE. */
2533 /* If this is missing, some compilers complain. */
2534 int signo ATTRIBUTE_UNUSED;
2536 fatal ("output pipe has been closed");
2539 /* Strip off a legitimate source ending from the input string NAME of
2540 length LEN. Rather than having to know the names used by all of
2541 our front ends, we strip off an ending of a period followed by
2542 up to five characters. (Java uses ".class".) */
2545 strip_off_ending (name, len)
2550 for (i = 2; i < 6 && len > i; i++)
2552 if (name[len - i] == '.')
2554 name[len - i] = '\0';
2560 /* Output a quoted string. */
2563 output_quoted_string (asm_file, string)
2567 #ifdef OUTPUT_QUOTED_STRING
2568 OUTPUT_QUOTED_STRING (asm_file, string);
2572 putc ('\"', asm_file);
2573 while ((c = *string++) != 0)
2575 if (c == '\"' || c == '\\')
2576 putc ('\\', asm_file);
2579 putc ('\"', asm_file);
2583 /* Output a file name in the form wanted by System V. */
2586 output_file_directive (asm_file, input_name)
2588 const char *input_name;
2590 int len = strlen (input_name);
2591 const char *na = input_name + len;
2593 /* NA gets INPUT_NAME sans directory names. */
2594 while (na > input_name)
2598 #ifdef DIR_SEPARATOR
2599 if (na[-1] == DIR_SEPARATOR)
2605 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2606 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2608 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2609 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2611 fprintf (asm_file, "\t.file\t");
2612 output_quoted_string (asm_file, na);
2613 fputc ('\n', asm_file);
2618 #ifdef ASM_IDENTIFY_LANGUAGE
2619 /* Routine to build language identifier for object file. */
2621 output_lang_identify (asm_out_file)
2624 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2625 char *s = (char *) alloca (len);
2626 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2627 ASM_OUTPUT_LABEL (asm_out_file, s);
2631 /* Routine to open a dump file. */
2633 open_dump_file (suffix, function_name)
2635 const char *function_name;
2642 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2644 if (rtl_dump_file != NULL)
2645 fclose (rtl_dump_file);
2647 strcpy (dumpname, dump_base_name);
2648 strcat (dumpname, suffix);
2650 rtl_dump_file = fopen (dumpname, "a");
2652 if (rtl_dump_file == NULL)
2653 pfatal_with_name (dumpname);
2658 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2664 /* Routine to close a dump file. */
2666 close_dump_file (func, insns)
2667 void (*func) PROTO ((FILE *, rtx));
2674 func (rtl_dump_file, insns);
2676 fflush (rtl_dump_file);
2677 fclose (rtl_dump_file);
2679 rtl_dump_file = NULL;
2685 /* Routine to dump rtl into a file. */
2687 dump_rtl (suffix, decl, func, insns)
2690 void (*func) PROTO ((FILE *, rtx));
2693 open_dump_file (suffix, decl_printable_name (decl, 2));
2694 close_dump_file (func, insns);
2697 /* Routine to empty a dump file. */
2699 clean_dump_file (suffix)
2704 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2706 strcpy (dumpname, dump_base_name);
2707 strcat (dumpname, suffix);
2709 rtl_dump_file = fopen (dumpname, "w");
2711 if (rtl_dump_file == NULL)
2712 pfatal_with_name (dumpname);
2716 fclose (rtl_dump_file);
2717 rtl_dump_file = NULL;
2722 /* Do any final processing required for the declarations in VEC, of
2723 which there are LEN. We write out inline functions and variables
2724 that have been deferred until this point, but which are required.
2725 Returns non-zero if anything was put out. */
2727 wrapup_global_declarations (vec, len)
2734 int output_something = 0;
2736 for (i = 0; i < len; i++)
2740 /* We're not deferring this any longer. */
2741 DECL_DEFER_OUTPUT (decl) = 0;
2743 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2744 && incomplete_decl_finalize_hook != 0)
2745 (*incomplete_decl_finalize_hook) (decl);
2748 /* Now emit any global variables or functions that we have been
2749 putting off. We need to loop in case one of the things emitted
2750 here references another one which comes earlier in the list. */
2754 for (i = 0; i < len; i++)
2758 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2761 /* Don't write out static consts, unless we still need them.
2763 We also keep static consts if not optimizing (for debugging),
2764 unless the user specified -fno-keep-static-consts.
2765 ??? They might be better written into the debug information.
2766 This is possible when using DWARF.
2768 A language processor that wants static constants to be always
2769 written out (even if it is not used) is responsible for
2770 calling rest_of_decl_compilation itself. E.g. the C front-end
2771 calls rest_of_decl_compilation from finish_decl.
2772 One motivation for this is that is conventional in some
2773 environments to write things like:
2774 static const char rcsid[] = "... version string ...";
2775 intending to force the string to be in the executable.
2777 A language processor that would prefer to have unneeded
2778 static constants "optimized away" would just defer writing
2779 them out until here. E.g. C++ does this, because static
2780 constants are often defined in header files.
2782 ??? A tempting alternative (for both C and C++) would be
2783 to force a constant to be written if and only if it is
2784 defined in a main file, as opposed to an include file. */
2786 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2787 && (! TREE_READONLY (decl)
2788 || TREE_PUBLIC (decl)
2789 || (!optimize && flag_keep_static_consts)
2790 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2793 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2796 if (TREE_CODE (decl) == FUNCTION_DECL
2797 && DECL_INITIAL (decl) != 0
2798 && DECL_SAVED_INSNS (decl) != 0
2799 && (flag_keep_inline_functions
2800 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2801 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2804 temporary_allocation ();
2805 output_inline_function (decl);
2806 permanent_allocation (1);
2811 output_something = 1;
2815 return output_something;
2818 /* Issue appropriate warnings for the global declarations in VEC (of
2819 which there are LEN). Output debugging information for them. */
2821 check_global_declarations (vec, len)
2828 for (i = 0; i < len; i++)
2832 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2833 && ! TREE_ASM_WRITTEN (decl))
2834 /* Cancel the RTL for this decl so that, if debugging info
2835 output for global variables is still to come,
2836 this one will be omitted. */
2837 DECL_RTL (decl) = NULL;
2839 /* Warn about any function
2840 declared static but not defined.
2841 We don't warn about variables,
2842 because many programs have static variables
2843 that exist only to get some text into the object file. */
2844 if (TREE_CODE (decl) == FUNCTION_DECL
2846 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2847 && DECL_INITIAL (decl) == 0
2848 && DECL_EXTERNAL (decl)
2849 && ! DECL_ARTIFICIAL (decl)
2850 && ! TREE_PUBLIC (decl))
2852 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2853 pedwarn_with_decl (decl,
2854 "`%s' used but never defined");
2856 warning_with_decl (decl,
2857 "`%s' declared `static' but never defined");
2858 /* This symbol is effectively an "extern" declaration now. */
2859 TREE_PUBLIC (decl) = 1;
2860 assemble_external (decl);
2863 /* Warn about static fns or vars defined but not used,
2864 but not about inline functions or static consts
2865 since defining those in header files is normal practice. */
2867 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2868 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2869 && ! DECL_IN_SYSTEM_HEADER (decl)
2870 && ! DECL_EXTERNAL (decl)
2871 && ! TREE_PUBLIC (decl)
2872 && ! TREE_USED (decl)
2873 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2874 /* The TREE_USED bit for file-scope decls
2875 is kept in the identifier, to handle multiple
2876 external decls in different scopes. */
2877 && ! TREE_USED (DECL_NAME (decl)))
2878 warning_with_decl (decl, "`%s' defined but not used");
2880 #ifdef SDB_DEBUGGING_INFO
2881 /* The COFF linker can move initialized global vars to the end.
2882 And that can screw up the symbol ordering.
2883 By putting the symbols in that order to begin with,
2884 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2885 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2886 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2887 && ! DECL_EXTERNAL (decl)
2888 && DECL_RTL (decl) != 0)
2889 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2891 /* Output COFF information for non-global
2892 file-scope initialized variables. */
2893 if (write_symbols == SDB_DEBUG
2894 && TREE_CODE (decl) == VAR_DECL
2895 && DECL_INITIAL (decl)
2896 && ! DECL_EXTERNAL (decl)
2897 && DECL_RTL (decl) != 0
2898 && GET_CODE (DECL_RTL (decl)) == MEM)
2899 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2900 #endif /* SDB_DEBUGGING_INFO */
2901 #ifdef DWARF_DEBUGGING_INFO
2902 /* Output DWARF information for file-scope tentative data object
2903 declarations, file-scope (extern) function declarations (which
2904 had no corresponding body) and file-scope tagged type declarations
2905 and definitions which have not yet been forced out. */
2907 if (write_symbols == DWARF_DEBUG
2908 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2909 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2911 #ifdef DWARF2_DEBUGGING_INFO
2912 /* Output DWARF2 information for file-scope tentative data object
2913 declarations, file-scope (extern) function declarations (which
2914 had no corresponding body) and file-scope tagged type declarations
2915 and definitions which have not yet been forced out. */
2917 if (write_symbols == DWARF2_DEBUG
2918 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2919 TIMEVAR (symout_time, dwarf2out_decl (decl));
2924 /* Compile an entire file of output from cpp, named NAME.
2925 Write a file of assembly output and various debugging dumps. */
2934 int name_specified = name != 0;
2936 if (dump_base_name == 0)
2937 dump_base_name = name ? name : "gccdump";
2941 integration_time = 0;
2947 branch_prob_time = 0;
2952 local_alloc_time = 0;
2953 global_alloc_time = 0;
2959 shorten_branch_time = 0;
2965 /* Initialize data in various passes. */
2969 name = init_parse (name);
2971 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2972 || debug_info_level == DINFO_LEVEL_VERBOSE
2973 || flag_test_coverage);
2975 init_decl_processing ();
2984 if (flag_caller_saves)
2985 init_caller_save ();
2987 /* If auxiliary info generation is desired, open the output file.
2988 This goes in the same directory as the source file--unlike
2989 all the other output files. */
2990 if (flag_gen_aux_info)
2992 aux_info_file = fopen (aux_info_file_name, "w");
2993 if (aux_info_file == 0)
2994 pfatal_with_name (aux_info_file_name);
2997 /* Clear the dump files. */
2999 clean_dump_file (".rtl");
3002 clean_dump_file (".jump");
3003 if (graph_dump_format != no_graph)
3004 clean_graph_dump_file (dump_base_name, ".jump");
3008 clean_dump_file (".addressof");
3009 if (graph_dump_format != no_graph)
3010 clean_graph_dump_file (dump_base_name, ".addressof");
3014 clean_dump_file (".cse");
3015 if (graph_dump_format != no_graph)
3016 clean_graph_dump_file (dump_base_name, ".cse");
3020 clean_dump_file (".loop");
3021 if (graph_dump_format != no_graph)
3022 clean_graph_dump_file (dump_base_name, ".loop");
3026 clean_dump_file (".cse2");
3027 if (graph_dump_format != no_graph)
3028 clean_graph_dump_file (dump_base_name, ".cse2");
3030 if (branch_prob_dump)
3032 clean_dump_file (".bp");
3033 if (graph_dump_format != no_graph)
3034 clean_graph_dump_file (dump_base_name, ".bp");
3038 clean_dump_file (".flow");
3039 if (graph_dump_format != no_graph)
3040 clean_graph_dump_file (dump_base_name, ".flow");
3044 clean_dump_file (".combine");
3045 if (graph_dump_format != no_graph)
3046 clean_graph_dump_file (dump_base_name, ".combine");
3050 clean_dump_file (".regmove");
3051 if (graph_dump_format != no_graph)
3052 clean_graph_dump_file (dump_base_name, ".regmove");
3056 clean_dump_file (".sched");
3057 if (graph_dump_format != no_graph)
3058 clean_graph_dump_file (dump_base_name, ".sched");
3062 clean_dump_file (".lreg");
3063 if (graph_dump_format != no_graph)
3064 clean_graph_dump_file (dump_base_name, ".lreg");
3066 if (global_reg_dump)
3068 clean_dump_file (".greg");
3069 if (graph_dump_format != no_graph)
3070 clean_graph_dump_file (dump_base_name, ".greg");
3074 clean_dump_file (".flow2");
3075 if (graph_dump_format != no_graph)
3076 clean_graph_dump_file (dump_base_name, ".flow2");
3080 clean_dump_file (".sched2");
3081 if (graph_dump_format != no_graph)
3082 clean_graph_dump_file (dump_base_name, ".sched2");
3086 clean_dump_file (".jump2");
3087 if (graph_dump_format != no_graph)
3088 clean_graph_dump_file (dump_base_name, ".jump2");
3093 clean_dump_file (".dbr");
3094 if (graph_dump_format != no_graph)
3095 clean_graph_dump_file (dump_base_name, ".dbr");
3100 clean_dump_file (".gcse");
3101 if (graph_dump_format != no_graph)
3102 clean_graph_dump_file (dump_base_name, ".gcse");
3107 clean_dump_file (".stack");
3108 if (graph_dump_format != no_graph)
3109 clean_graph_dump_file (dump_base_name, ".stack");
3112 #ifdef MACHINE_DEPENDENT_REORG
3113 if (mach_dep_reorg_dump)
3115 clean_dump_file (".mach");
3116 if (graph_dump_format != no_graph)
3117 clean_graph_dump_file (dump_base_name, ".mach");
3121 /* Open assembler code output file. */
3123 if (flag_syntax_only)
3124 asm_out_file = NULL;
3127 if (! name_specified && asm_file_name == 0)
3128 asm_out_file = stdout;
3131 int len = strlen (dump_base_name);
3132 register char *dumpname = (char *) xmalloc (len + 6);
3133 strcpy (dumpname, dump_base_name);
3134 strip_off_ending (dumpname, len);
3135 strcat (dumpname, ".s");
3136 if (asm_file_name == 0)
3138 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
3139 strcpy (asm_file_name, dumpname);
3141 if (!strcmp (asm_file_name, "-"))
3142 asm_out_file = stdout;
3144 asm_out_file = fopen (asm_file_name, "w");
3145 if (asm_out_file == 0)
3146 pfatal_with_name (asm_file_name);
3149 #ifdef IO_BUFFER_SIZE
3150 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
3151 _IOFBF, IO_BUFFER_SIZE);
3155 input_filename = name;
3157 /* Put an entry on the input file stack for the main input file. */
3159 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
3160 input_file_stack->next = 0;
3161 input_file_stack->name = input_filename;
3163 /* Perform language-specific initialization.
3164 This may set main_input_filename. */
3167 /* If the input doesn't start with a #line, use the input name
3168 as the official input file name. */
3169 if (main_input_filename == 0)
3170 main_input_filename = name;
3172 if (flag_syntax_only)
3174 write_symbols = NO_DEBUG;
3176 profile_block_flag = 0;
3180 ASM_FILE_START (asm_out_file);
3182 #ifdef ASM_COMMENT_START
3183 if (flag_verbose_asm)
3185 /* Print the list of options in effect. */
3186 print_version (asm_out_file, ASM_COMMENT_START);
3187 print_switch_values (asm_out_file, 0, MAX_LINE,
3188 ASM_COMMENT_START, " ", "\n");
3189 /* Add a blank line here so it appears in assembler output but not
3191 fprintf (asm_out_file, "\n");
3195 /* Output something to inform GDB that this compilation was by GCC. */
3196 #ifndef ASM_IDENTIFY_GCC
3197 fprintf (asm_out_file, "gcc2_compiled.:\n");
3199 ASM_IDENTIFY_GCC (asm_out_file);
3202 /* Output something to identify which front-end produced this file. */
3203 #ifdef ASM_IDENTIFY_LANGUAGE
3204 ASM_IDENTIFY_LANGUAGE (asm_out_file);
3206 } /* ! flag_syntax_only */
3208 #ifndef ASM_OUTPUT_SECTION_NAME
3209 if (flag_function_sections)
3211 warning ("-ffunction-sections not supported for this target.");
3212 flag_function_sections = 0;
3214 if (flag_data_sections)
3216 warning ("-fdata-sections not supported for this target.");
3217 flag_data_sections = 0;
3221 if (flag_function_sections
3222 && (profile_flag || profile_block_flag))
3224 warning ("-ffunction-sections disabled; it makes profiling impossible.");
3225 flag_function_sections = 0;
3228 #ifndef OBJECT_FORMAT_ELF
3229 if (flag_function_sections && write_symbols != NO_DEBUG)
3230 warning ("-ffunction-sections may affect debugging on some targets.");
3233 /* ??? Note: There used to be a conditional here
3234 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
3235 This was to guarantee separation between gcc_compiled. and
3236 the first function, for the sake of dbx on Suns.
3237 However, having the extra zero here confused the Emacs
3238 code for unexec, and might confuse other programs too.
3239 Therefore, I took out that change.
3240 In future versions we should find another way to solve
3241 that dbx problem. -- rms, 23 May 93. */
3243 /* Don't let the first function fall at the same address
3244 as gcc_compiled., if profiling. */
3245 if (profile_flag || profile_block_flag)
3247 /* It's best if we can write a nop here since some
3248 assemblers don't tolerate zeros in the text section. */
3249 if (insn_template[CODE_FOR_nop] != 0)
3250 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR);
3252 assemble_zeros (UNITS_PER_WORD);
3255 /* If dbx symbol table desired, initialize writing it
3256 and output the predefined types. */
3257 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3258 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3259 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
3262 #ifdef SDB_DEBUGGING_INFO
3263 if (write_symbols == SDB_DEBUG)
3264 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
3267 #ifdef DWARF_DEBUGGING_INFO
3268 if (write_symbols == DWARF_DEBUG)
3269 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
3271 #ifdef DWARF2_UNWIND_INFO
3272 if (dwarf2out_do_frame ())
3273 dwarf2out_frame_init ();
3275 #ifdef DWARF2_DEBUGGING_INFO
3276 if (write_symbols == DWARF2_DEBUG)
3277 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
3280 /* Initialize yet another pass. */
3282 init_final (main_input_filename);
3283 init_branch_prob (dump_base_name);
3285 start_time = get_run_time ();
3287 /* Call the parser, which parses the entire file
3288 (calling rest_of_compilation for each function). */
3290 if (yyparse () != 0)
3292 if (errorcount == 0)
3293 notice ("Errors detected in input file (your bison.simple is out of date)\n");
3295 /* In case there were missing closebraces,
3296 get us back to the global binding level. */
3297 while (! global_bindings_p ())
3301 /* Compilation is now finished except for writing
3302 what's left of the symbol table output. */
3304 parse_time += get_run_time () - start_time;
3306 parse_time -= integration_time;
3307 parse_time -= varconst_time;
3309 if (flag_syntax_only)
3312 globals = getdecls ();
3314 /* Really define vars that have had only a tentative definition.
3315 Really output inline functions that must actually be callable
3316 and have not been output so far. */
3319 int len = list_length (globals);
3320 tree *vec = (tree *) alloca (sizeof (tree) * len);
3324 /* Process the decls in reverse order--earliest first.
3325 Put them into VEC from back to front, then take out from front. */
3327 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
3328 vec[len - i - 1] = decl;
3330 wrapup_global_declarations (vec, len);
3332 /* This must occur after the loop to output deferred functions. Else
3333 the profiler initializer would not be emitted if all the functions
3334 in this compilation unit were deferred.
3336 output_func_start_profiler can not cause any additional functions or
3337 data to need to be output, so it need not be in the deferred function
3339 output_func_start_profiler ();
3341 /* Now that all possible functions have been output, we can dump
3342 the exception table. */
3344 output_exception_table ();
3346 check_global_declarations (vec, len);
3349 /* Write out any pending weak symbol declarations. */
3353 /* Do dbx symbols */
3354 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3355 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3356 TIMEVAR (symout_time,
3358 dbxout_finish (asm_out_file, main_input_filename);
3362 #ifdef DWARF_DEBUGGING_INFO
3363 if (write_symbols == DWARF_DEBUG)
3364 TIMEVAR (symout_time,
3370 #ifdef DWARF2_UNWIND_INFO
3371 if (dwarf2out_do_frame ())
3372 dwarf2out_frame_finish ();
3375 #ifdef DWARF2_DEBUGGING_INFO
3376 if (write_symbols == DWARF2_DEBUG)
3377 TIMEVAR (symout_time,
3379 dwarf2out_finish ();
3383 /* Output some stuff at end of file if nec. */
3385 end_final (dump_base_name);
3387 if (branch_prob_dump)
3388 open_dump_file (".bp", NULL);
3390 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
3392 if (branch_prob_dump)
3393 close_dump_file (NULL, NULL_RTX);
3396 ASM_FILE_END (asm_out_file);
3400 /* Language-specific end of compilation actions. */
3404 /* Close the dump files. */
3406 if (flag_gen_aux_info)
3408 fclose (aux_info_file);
3410 unlink (aux_info_file_name);
3415 open_dump_file (".combine", NULL);
3416 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
3417 close_dump_file (NULL, NULL_RTX);
3420 /* Close non-debugging input and output files. Take special care to note
3421 whether fclose returns an error, since the pages might still be on the
3422 buffer chain while the file is open. */
3426 if (! flag_syntax_only
3427 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
3428 fatal_io_error (asm_file_name);
3430 /* Do whatever is necessary to finish printing the graphs. */
3431 if (graph_dump_format != no_graph)
3434 finish_graph_dump_file (dump_base_name, ".jump");
3436 finish_graph_dump_file (dump_base_name, ".addressof");
3438 finish_graph_dump_file (dump_base_name, ".cse");
3440 finish_graph_dump_file (dump_base_name, ".loop");
3442 finish_graph_dump_file (dump_base_name, ".cse2");
3443 if (branch_prob_dump)
3444 finish_graph_dump_file (dump_base_name, ".bp");
3446 finish_graph_dump_file (dump_base_name, ".flow");
3448 finish_graph_dump_file (dump_base_name, ".combine");
3450 finish_graph_dump_file (dump_base_name, ".regmove");
3452 finish_graph_dump_file (dump_base_name, ".sched");
3454 finish_graph_dump_file (dump_base_name, ".lreg");
3455 if (global_reg_dump)
3456 finish_graph_dump_file (dump_base_name, ".greg");
3458 finish_graph_dump_file (dump_base_name, ".flow2");
3460 finish_graph_dump_file (dump_base_name, ".sched2");
3462 finish_graph_dump_file (dump_base_name, ".jump2");
3465 finish_graph_dump_file (dump_base_name, ".dbr");
3468 finish_graph_dump_file (dump_base_name, ".gcse");
3471 finish_graph_dump_file (dump_base_name, ".stack");
3473 #ifdef MACHINE_DEPENDENT_REORG
3474 if (mach_dep_reorg_dump)
3475 finish_graph_dump_file (dump_base_name, ".mach");
3479 /* Free up memory for the benefit of leak detectors. */
3482 /* Print the times. */
3486 fprintf (stderr,"\n");
3487 print_time ("parse", parse_time);
3489 print_time ("integration", integration_time);
3490 print_time ("jump", jump_time);
3491 print_time ("cse", cse_time);
3492 print_time ("gcse", gcse_time);
3493 print_time ("loop", loop_time);
3494 print_time ("cse2", cse2_time);
3495 print_time ("branch-prob", branch_prob_time);
3496 print_time ("flow", flow_time);
3497 print_time ("combine", combine_time);
3498 print_time ("regmove", regmove_time);
3499 print_time ("sched", sched_time);
3500 print_time ("local-alloc", local_alloc_time);
3501 print_time ("global-alloc", global_alloc_time);
3502 print_time ("flow2", flow2_time);
3503 print_time ("sched2", sched2_time);
3505 print_time ("dbranch", dbr_sched_time);
3507 print_time ("shorten-branch", shorten_branch_time);
3508 print_time ("stack-reg", stack_reg_time);
3509 print_time ("final", final_time);
3510 print_time ("varconst", varconst_time);
3511 print_time ("symout", symout_time);
3512 print_time ("dump", dump_time);
3516 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
3517 and TYPE_DECL nodes.
3519 This does nothing for local (non-static) variables.
3520 Otherwise, it sets up the RTL and outputs any assembler code
3521 (label definition, storage allocation and initialization).
3523 DECL is the declaration. If ASMSPEC is nonzero, it specifies
3524 the assembler symbol name to be used. TOP_LEVEL is nonzero
3525 if this declaration is not within a function. */
3528 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
3530 const char *asmspec;
3534 /* Declarations of variables, and of functions defined elsewhere. */
3536 /* The most obvious approach, to put an #ifndef around where
3537 this macro is used, doesn't work since it's inside a macro call. */
3538 #ifndef ASM_FINISH_DECLARE_OBJECT
3539 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
3542 /* Forward declarations for nested functions are not "external",
3543 but we need to treat them as if they were. */
3544 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
3545 || TREE_CODE (decl) == FUNCTION_DECL)
3546 TIMEVAR (varconst_time,
3548 make_decl_rtl (decl, asmspec, top_level);
3549 /* Initialized extern variable exists to be replaced
3550 with its value, or represents something that will be
3551 output in another file. */
3552 if (! (TREE_CODE (decl) == VAR_DECL
3553 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
3554 && DECL_INITIAL (decl) != 0
3555 && DECL_INITIAL (decl) != error_mark_node))
3556 /* Don't output anything
3557 when a tentative file-scope definition is seen.
3558 But at end of compilation, do output code for them. */
3559 if (! (! at_end && top_level
3560 && (DECL_INITIAL (decl) == 0
3561 || DECL_INITIAL (decl) == error_mark_node)))
3562 assemble_variable (decl, top_level, at_end, 0);
3563 if (decl == last_assemble_variable_decl)
3565 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
3569 else if (DECL_REGISTER (decl) && asmspec != 0)
3571 if (decode_reg_name (asmspec) >= 0)
3573 DECL_RTL (decl) = 0;
3574 make_decl_rtl (decl, asmspec, top_level);
3577 error ("invalid register name `%s' for register variable", asmspec);
3579 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3580 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3581 && TREE_CODE (decl) == TYPE_DECL)
3582 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
3584 #ifdef SDB_DEBUGGING_INFO
3585 else if (write_symbols == SDB_DEBUG && top_level
3586 && TREE_CODE (decl) == TYPE_DECL)
3587 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
3591 /* Called after finishing a record, union or enumeral type. */
3594 rest_of_type_compilation (type, toplev)
3595 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
3599 tree type ATTRIBUTE_UNUSED;
3600 int toplev ATTRIBUTE_UNUSED;
3603 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
3604 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
3605 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
3607 #ifdef SDB_DEBUGGING_INFO
3608 if (write_symbols == SDB_DEBUG)
3609 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
3613 /* This is called from finish_function (within yyparse)
3614 after each top-level definition is parsed.
3615 It is supposed to compile that function or variable
3616 and output the assembler code for it.
3617 After we return, the tree storage is freed. */
3620 rest_of_compilation (decl)
3624 int start_time = get_run_time ();
3626 /* Nonzero if we have saved the original DECL_INITIAL of the function,
3627 to be restored after we finish compiling the function
3628 (for use when compiling inline calls to this function). */
3629 tree saved_block_tree = 0;
3630 /* Likewise, for DECL_ARGUMENTS. */
3631 tree saved_arguments = 0;
3633 int rebuild_label_notes_after_reload;
3635 /* If we are reconsidering an inline function
3636 at the end of compilation, skip the stuff for making it inline. */
3638 if (DECL_SAVED_INSNS (decl) == 0)
3643 /* If requested, consider whether to make this function inline. */
3644 if (DECL_INLINE (decl) || flag_inline_functions)
3645 TIMEVAR (integration_time,
3647 lose = function_cannot_inline_p (decl);
3648 if (lose || ! optimize)
3650 if (warn_inline && DECL_INLINE (decl))
3651 warning_with_decl (decl, lose);
3652 DECL_ABSTRACT_ORIGIN (decl) = 0;
3653 /* Don't really compile an extern inline function.
3654 If we can't make it inline, pretend
3655 it was only declared. */
3656 if (DECL_EXTERNAL (decl))
3658 DECL_INITIAL (decl) = 0;
3659 goto exit_rest_of_compilation;
3663 /* ??? Note that this has the effect of making it look
3664 like "inline" was specified for a function if we choose
3665 to inline it. This isn't quite right, but it's
3666 probably not worth the trouble to fix. */
3667 inlinable = DECL_INLINE (decl) = 1;
3670 insns = get_insns ();
3672 /* Dump the rtl code if we are dumping rtl. */
3676 open_dump_file (".rtl", decl_printable_name (decl, 2));
3678 if (DECL_SAVED_INSNS (decl))
3679 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3681 close_dump_file (print_rtl, insns);
3684 /* If we can, defer compiling inlines until EOF.
3685 save_for_inline_copying can be extremely expensive. */
3686 if (inlinable && ! decl_function_context (decl))
3687 DECL_DEFER_OUTPUT (decl) = 1;
3689 /* If function is inline, and we don't yet know whether to
3690 compile it by itself, defer decision till end of compilation.
3691 finish_compilation will call rest_of_compilation again
3692 for those functions that need to be output. Also defer those
3693 functions that we are supposed to defer. We cannot defer
3694 functions containing nested functions since the nested function
3695 data is in our non-saved obstack. We cannot defer nested
3696 functions for the same reason. */
3698 /* If this is a nested inline, remove ADDRESSOF now so we can
3699 finish compiling ourselves. Otherwise, wait until EOF.
3700 We have to do this because the purge_addressof transformation
3701 changes the DECL_RTL for many variables, which confuses integrate. */
3704 if (decl_function_context (decl))
3705 purge_addressof (insns);
3707 DECL_DEFER_OUTPUT (decl) = 1;
3710 if (! current_function_contains_functions
3711 && (DECL_DEFER_OUTPUT (decl)
3712 || (DECL_INLINE (decl)
3713 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3714 && ! flag_keep_inline_functions)
3715 || DECL_EXTERNAL (decl)))))
3717 DECL_DEFER_OUTPUT (decl) = 1;
3719 /* If -Wreturn-type, we have to do a bit of compilation.
3720 However, if we just fall through we will call
3721 save_for_inline_copying() which results in excessive
3722 memory use. Instead, we just want to call
3723 jump_optimize() to figure out whether or not we can fall
3724 off the end of the function; we do the minimum amount of
3725 work necessary to make that safe. And, we set optimize
3726 to zero to keep jump_optimize from working too hard. */
3727 if (warn_return_type)
3729 int saved_optimize = optimize;
3731 find_exception_handler_labels ();
3732 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3733 !JUMP_AFTER_REGSCAN);
3734 optimize = saved_optimize;
3737 #ifdef DWARF_DEBUGGING_INFO
3738 /* Generate the DWARF info for the "abstract" instance
3739 of a function which we may later generate inlined and/or
3740 out-of-line instances of. */
3741 if (write_symbols == DWARF_DEBUG)
3743 set_decl_abstract_flags (decl, 1);
3744 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3745 set_decl_abstract_flags (decl, 0);
3748 #ifdef DWARF2_DEBUGGING_INFO
3749 /* Generate the DWARF2 info for the "abstract" instance
3750 of a function which we may later generate inlined and/or
3751 out-of-line instances of. */
3752 if (write_symbols == DWARF2_DEBUG)
3754 set_decl_abstract_flags (decl, 1);
3755 TIMEVAR (symout_time, dwarf2out_decl (decl));
3756 set_decl_abstract_flags (decl, 0);
3759 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3760 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3761 goto exit_rest_of_compilation;
3764 /* If we have to compile the function now, save its rtl and subdecls
3765 so that its compilation will not affect what others get. */
3766 if (inlinable || DECL_DEFER_OUTPUT (decl))
3768 #ifdef DWARF_DEBUGGING_INFO
3769 /* Generate the DWARF info for the "abstract" instance of
3770 a function which we will generate an out-of-line instance
3771 of almost immediately (and which we may also later generate
3772 various inlined instances of). */
3773 if (write_symbols == DWARF_DEBUG)
3775 set_decl_abstract_flags (decl, 1);
3776 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3777 set_decl_abstract_flags (decl, 0);
3780 #ifdef DWARF2_DEBUGGING_INFO
3781 /* Generate the DWARF2 info for the "abstract" instance of
3782 a function which we will generate an out-of-line instance
3783 of almost immediately (and which we may also later generate
3784 various inlined instances of). */
3785 if (write_symbols == DWARF2_DEBUG)
3787 set_decl_abstract_flags (decl, 1);
3788 TIMEVAR (symout_time, dwarf2out_decl (decl));
3789 set_decl_abstract_flags (decl, 0);
3792 saved_block_tree = DECL_INITIAL (decl);
3793 saved_arguments = DECL_ARGUMENTS (decl);
3794 TIMEVAR (integration_time, save_for_inline_copying (decl));
3795 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3798 /* If specified extern inline but we aren't inlining it, we are
3799 done. This goes for anything that gets here with DECL_EXTERNAL
3800 set, not just things with DECL_INLINE. */
3801 if (DECL_EXTERNAL (decl))
3802 goto exit_rest_of_compilation;
3805 if (! DECL_DEFER_OUTPUT (decl))
3806 TREE_ASM_WRITTEN (decl) = 1;
3808 /* Now that integrate will no longer see our rtl, we need not distinguish
3809 between the return value of this function and the return value of called
3811 rtx_equal_function_value_matters = 0;
3813 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3814 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3816 goto exit_rest_of_compilation;
3819 /* Emit code to get eh context, if needed. */
3823 /* If we are doing position-independent code generation, now
3824 is the time to output special prologues and epilogues.
3825 We do not want to do this earlier, because it just clutters
3826 up inline functions with meaningless insns. */
3831 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3832 Note that that may have been done above, in save_for_inline_copying.
3833 The call to resume_temporary_allocation near the end of this function
3834 goes back to the usual state of affairs. This must be done after
3835 we've built up any unwinders for exception handling, and done
3836 the FINALIZE_PIC work, if necessary. */
3838 rtl_in_current_obstack ();
3840 insns = get_insns ();
3842 /* Copy any shared structure that should not be shared. */
3844 unshare_all_rtl (current_function_decl, insns);
3846 #ifdef SETJMP_VIA_SAVE_AREA
3847 /* This must be performed before virutal register instantiation. */
3848 if (current_function_calls_alloca)
3849 optimize_save_area_alloca (insns);
3852 /* Instantiate all virtual registers. */
3854 instantiate_virtual_regs (current_function_decl, get_insns ());
3856 /* See if we have allocated stack slots that are not directly addressable.
3857 If so, scan all the insns and create explicit address computation
3858 for all references to such slots. */
3859 /* fixup_stack_slots (); */
3861 /* Find all the EH handlers. */
3862 find_exception_handler_labels ();
3864 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3865 are initialized and to compute whether control can drop off the end
3867 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3868 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
3869 JUMP_AFTER_REGSCAN));
3871 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3872 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3873 goto exit_rest_of_compilation;
3875 /* Dump rtl code after jump, if we are doing that. */
3878 dump_rtl (".jump", decl, print_rtl, insns);
3880 /* Perform common subexpression elimination.
3881 Nonzero value from `cse_main' means that jumps were simplified
3882 and some code may now be unreachable, so do
3883 jump optimization again. */
3888 open_dump_file (".cse", decl_printable_name (decl, 2));
3890 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3892 if (flag_thread_jumps)
3893 /* Hacks by tiemann & kenner. */
3894 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3896 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3898 if (tem || optimize > 1)
3899 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3901 !JUMP_AFTER_REGSCAN));
3903 /* Run this after jump optmizations remove all the unreachable code
3904 so that unreachable code will not keep values live. */
3905 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3907 /* Dump rtl code after cse, if we are doing that. */
3911 close_dump_file (print_rtl, insns);
3912 if (graph_dump_format != no_graph)
3913 print_rtl_graph_with_bb (dump_base_name, ".cse", insns);
3917 purge_addressof (insns);
3918 reg_scan (insns, max_reg_num (), 1);
3922 dump_rtl (".addressof", decl, print_rtl, insns);
3923 if (graph_dump_format != no_graph)
3924 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns);
3927 /* Perform global cse. */
3929 if (optimize > 0 && flag_gcse)
3932 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl)));
3934 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3936 /* If gcse altered any jumps, rerun jump optimizations to clean
3940 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3942 !JUMP_AFTER_REGSCAN));
3947 close_dump_file (print_rtl, insns);
3948 if (graph_dump_format != no_graph)
3949 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns);
3952 /* Move constant computations out of loops. */
3957 open_dump_file (".loop", decl_printable_name (decl, 2));
3962 if (flag_rerun_loop_opt)
3964 /* We only want to perform unrolling once. */
3966 loop_optimize (insns, rtl_dump_file, 0, 0);
3969 /* The first call to loop_optimize makes some instructions
3970 trivially dead. We delete those instructions now in the
3971 hope that doing so will make the heuristics in loop work
3972 better and possibly speed up compilation. */
3973 delete_trivially_dead_insns (insns, max_reg_num ());
3975 /* The regscan pass is currently necessary as the alias
3976 analysis code depends on this information. */
3977 reg_scan (insns, max_reg_num (), 1);
3979 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3982 /* Dump rtl code after loop opt, if we are doing that. */
3986 close_dump_file (print_rtl, insns);
3987 if (graph_dump_format != no_graph)
3988 print_rtl_graph_with_bb (dump_base_name, ".loop", insns);
3995 open_dump_file (".cse2", decl_printable_name (decl, 2));
3997 if (flag_rerun_cse_after_loop)
3999 /* Running another jump optimization pass before the second
4000 cse pass sometimes simplifies the RTL enough to allow
4001 the second CSE pass to do a better job. Jump_optimize can change
4002 max_reg_num so we must rerun reg_scan afterwards.
4003 ??? Rework to not call reg_scan so often. */
4004 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4005 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4007 JUMP_AFTER_REGSCAN));
4009 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
4010 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
4013 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
4015 !JUMP_AFTER_REGSCAN));
4018 if (flag_thread_jumps)
4020 /* This pass of jump threading straightens out code
4021 that was kinked by loop optimization. */
4022 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
4023 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
4026 /* Dump rtl code after cse, if we are doing that. */
4030 close_dump_file (print_rtl, insns);
4031 if (graph_dump_format != no_graph)
4032 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns);
4036 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
4038 if (branch_prob_dump)
4039 open_dump_file (".bp", decl_printable_name (decl, 2));
4044 branch_prob (insns, rtl_dump_file);
4047 if (branch_prob_dump)
4049 close_dump_file (print_rtl, insns);
4050 if (graph_dump_format != no_graph)
4051 print_rtl_graph_with_bb (dump_base_name, ".bp", insns);
4055 /* We are no longer anticipating cse in this function, at least. */
4057 cse_not_expected = 1;
4059 /* Now we choose between stupid (pcc-like) register allocation
4060 (if we got the -noreg switch and not -opt)
4061 and smart register allocation. */
4063 if (optimize > 0) /* Stupid allocation probably won't work */
4064 obey_regdecls = 0; /* if optimizations being done. */
4068 /* Print function header into flow dump now
4069 because doing the flow analysis makes some of the dump. */
4072 open_dump_file (".flow", decl_printable_name (decl, 2));
4078 regclass (insns, max_reg_num ());
4079 stupid_life_analysis (insns, max_reg_num (),
4085 /* Do control and data flow analysis,
4086 and write some of the results to dump file. */
4091 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4092 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4095 if (warn_uninitialized)
4097 uninitialized_vars_warning (DECL_INITIAL (decl));
4098 setjmp_args_warning ();
4102 /* Dump rtl after flow analysis. */
4106 close_dump_file (print_rtl_with_bb, insns);
4107 if (graph_dump_format != no_graph)
4108 print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
4111 /* The first life analysis pass has finished. From now on we can not
4112 generate any new pseudos. */
4115 /* If -opt, try combining insns through substitution. */
4119 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
4121 /* Dump rtl code after insn combination. */
4125 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
4126 if (graph_dump_format != no_graph)
4127 print_rtl_graph_with_bb (dump_base_name, ".combine", insns);
4131 /* Register allocation pre-pass, to reduce number of moves
4132 necessary for two-address machines. */
4133 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
4136 open_dump_file (".regmove", decl_printable_name (decl, 2));
4138 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
4143 close_dump_file (print_rtl_with_bb, insns);
4144 if (graph_dump_format != no_graph)
4145 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns);
4149 /* Print function header into sched dump now
4150 because doing the sched analysis makes some of the dump. */
4152 if (optimize > 0 && flag_schedule_insns)
4155 open_dump_file (".sched", decl_printable_name (decl, 2));
4157 /* Do control and data sched analysis,
4158 and write some of the results to dump file. */
4160 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
4162 /* Dump rtl after instruction scheduling. */
4166 close_dump_file (print_rtl_with_bb, insns);
4167 if (graph_dump_format != no_graph)
4168 print_rtl_graph_with_bb (dump_base_name, ".sched", insns);
4172 /* Determine if the current function is a leaf before running reload
4173 since this can impact optimizations done by the prologue and
4174 epilogue thus changing register elimination offsets. */
4175 current_function_is_leaf = leaf_function_p ();
4177 /* Unless we did stupid register allocation,
4178 allocate pseudo-regs that are used only within 1 basic block.
4180 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
4181 jump optimizer after register allocation and reloading are finished. */
4184 TIMEVAR (local_alloc_time,
4186 recompute_reg_usage (insns, ! optimize_size);
4187 regclass (insns, max_reg_num ());
4188 rebuild_label_notes_after_reload = local_alloc ();
4191 rebuild_label_notes_after_reload = 0;
4193 /* Dump rtl code after allocating regs within basic blocks. */
4197 open_dump_file (".lreg", decl_printable_name (decl, 2));
4199 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
4200 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
4202 close_dump_file (print_rtl_with_bb, insns);
4203 if (graph_dump_format != no_graph)
4204 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns);
4207 if (global_reg_dump)
4208 open_dump_file (".greg", decl_printable_name (decl, 2));
4210 /* Unless we did stupid register allocation,
4211 allocate remaining pseudo-regs, then do the reload pass
4212 fixing up any insns that are invalid. */
4214 TIMEVAR (global_alloc_time,
4217 failure = global_alloc (rtl_dump_file);
4219 failure = reload (insns, 0, rtl_dump_file);
4224 goto exit_rest_of_compilation;
4226 /* Do a very simple CSE pass over just the hard registers. */
4228 reload_cse_regs (insns);
4230 /* Register allocation and reloading may have turned an indirect jump into
4231 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
4232 jumping instructions. */
4233 if (rebuild_label_notes_after_reload)
4234 TIMEVAR (jump_time, rebuild_jump_labels (insns));
4236 /* If optimizing and we are performing instruction scheduling after
4237 reload, then go ahead and split insns now since we are about to
4238 recompute flow information anyway.
4240 reload_cse_regs may expose more splitting opportunities, expecially
4241 for double-word operations. */
4242 if (optimize > 0 && flag_schedule_insns_after_reload)
4246 for (insn = insns; insn; insn = NEXT_INSN (insn))
4250 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
4253 last = try_split (PATTERN (insn), insn, 1);
4257 PUT_CODE (insn, NOTE);
4258 NOTE_SOURCE_FILE (insn) = 0;
4259 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
4264 if (global_reg_dump)
4266 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
4267 close_dump_file (print_rtl_with_bb, insns);
4268 if (graph_dump_format != no_graph)
4269 print_rtl_graph_with_bb (dump_base_name, ".greg", insns);
4272 /* Re-create the death notes which were deleted during reload. */
4274 open_dump_file (".flow2", decl_printable_name (decl, 2));
4281 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1);
4282 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
4286 flow2_completed = 1;
4288 /* On some machines, the prologue and epilogue code, or parts thereof,
4289 can be represented as RTL. Doing so lets us schedule insns between
4290 it and the rest of the code and also allows delayed branch
4291 scheduling to operate in the epilogue. */
4293 thread_prologue_and_epilogue_insns (insns);
4297 close_dump_file (print_rtl_with_bb, insns);
4298 if (graph_dump_format != no_graph)
4299 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns);
4302 if (optimize > 0 && flag_schedule_insns_after_reload)
4305 open_dump_file (".sched2", decl_printable_name (decl, 2));
4307 /* Do control and data sched analysis again,
4308 and write some more of the results to dump file. */
4310 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
4312 /* Dump rtl after post-reorder instruction scheduling. */
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, ".sched2", insns);
4322 #ifdef LEAF_REGISTERS
4323 current_function_uses_only_leaf_regs
4324 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
4327 /* One more attempt to remove jumps to .+1
4328 left by dead-store-elimination.
4329 Also do cross-jumping this time
4330 and delete no-op move insns. */
4334 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
4336 !JUMP_AFTER_REGSCAN));
4338 /* Dump rtl code after jump, if we are doing that. */
4342 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
4343 if (graph_dump_format != no_graph)
4344 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns);
4348 /* If a machine dependent reorganization is needed, call it. */
4349 #ifdef MACHINE_DEPENDENT_REORG
4350 MACHINE_DEPENDENT_REORG (insns);
4352 if (mach_dep_reorg_dump)
4354 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
4355 if (graph_dump_format != no_graph)
4356 print_rtl_graph_with_bb (dump_base_name, ".mach", insns);
4360 /* If a scheduling pass for delayed branches is to be done,
4361 call the scheduling code. */
4364 if (optimize > 0 && flag_delayed_branch)
4367 open_dump_file (".dbr", decl_printable_name (decl, 2));
4369 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
4373 close_dump_file (print_rtl_with_bb, insns);
4374 if (graph_dump_format != no_graph)
4375 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns);
4380 /* Shorten branches. */
4381 TIMEVAR (shorten_branch_time,
4383 shorten_branches (get_insns ());
4388 open_dump_file (".stack", decl_printable_name (decl, 2));
4390 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
4394 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
4395 if (graph_dump_format != no_graph)
4396 print_rtl_graph_with_bb (dump_base_name, ".stack", insns);
4400 if (warn_frame_size_flag)
4401 if (get_frame_size () > warn_frame_size)
4402 warning ("%d byte frame exceeds user specified limit (%d bytes)",
4403 get_frame_size (), warn_frame_size);
4405 /* Now turn the rtl into assembler code. */
4407 TIMEVAR (final_time,
4412 /* Get the function's name, as described by its RTL.
4413 This may be different from the DECL_NAME name used
4414 in the source file. */
4416 x = DECL_RTL (decl);
4417 if (GET_CODE (x) != MEM)
4420 if (GET_CODE (x) != SYMBOL_REF)
4422 fnname = XSTR (x, 0);
4424 assemble_start_function (decl, fnname);
4425 final_start_function (insns, asm_out_file, optimize);
4426 final (insns, asm_out_file, optimize, 0);
4427 final_end_function (insns, asm_out_file, optimize);
4428 assemble_end_function (decl, fnname);
4430 fflush (asm_out_file);
4432 /* Release all memory allocated by flow. */
4433 free_basic_block_vars (0);
4435 /* Release all memory held by regsets now */
4436 regset_release_memory ();
4439 /* Write DBX symbols if requested */
4441 /* Note that for those inline functions where we don't initially
4442 know for certain that we will be generating an out-of-line copy,
4443 the first invocation of this routine (rest_of_compilation) will
4444 skip over this code by doing a `goto exit_rest_of_compilation;'.
4445 Later on, finish_compilation will call rest_of_compilation again
4446 for those inline functions that need to have out-of-line copies
4447 generated. During that call, we *will* be routed past here. */
4449 #ifdef DBX_DEBUGGING_INFO
4450 if (write_symbols == DBX_DEBUG)
4451 TIMEVAR (symout_time, dbxout_function (decl));
4454 #ifdef DWARF_DEBUGGING_INFO
4455 if (write_symbols == DWARF_DEBUG)
4456 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
4459 #ifdef DWARF2_DEBUGGING_INFO
4460 if (write_symbols == DWARF2_DEBUG)
4461 TIMEVAR (symout_time, dwarf2out_decl (decl));
4464 exit_rest_of_compilation:
4468 /* In case the function was not output,
4469 don't leave any temporary anonymous types
4470 queued up for sdb output. */
4471 #ifdef SDB_DEBUGGING_INFO
4472 if (write_symbols == SDB_DEBUG)
4473 sdbout_types (NULL_TREE);
4476 /* Put back the tree of subblocks and list of arguments
4477 from before we copied them.
4478 Code generation and the output of debugging info may have modified
4479 the copy, but the original is unchanged. */
4481 if (saved_block_tree != 0)
4483 DECL_INITIAL (decl) = saved_block_tree;
4484 DECL_ARGUMENTS (decl) = saved_arguments;
4485 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
4488 reload_completed = 0;
4489 flow2_completed = 0;
4492 TIMEVAR (final_time,
4494 /* Clear out the insn_length contents now that they are no
4496 init_insn_lengths ();
4498 /* Clear out the real_constant_chain before some of the rtx's
4499 it runs through become garbage. */
4500 clear_const_double_mem ();
4502 /* Cancel the effect of rtl_in_current_obstack. */
4503 resume_temporary_allocation ();
4505 /* Show no temporary slots allocated. */
4509 /* Make sure volatile mem refs aren't considered valid operands for
4510 arithmetic insns. We must call this here if this is a nested inline
4511 function, since the above code leaves us in the init_recog state
4512 (from final.c), and the function context push/pop code does not
4513 save/restore volatile_ok.
4515 ??? Maybe it isn't necessary for expand_start_function to call this
4516 anymore if we do it here? */
4518 init_recog_no_volatile ();
4520 /* The parsing time is all the time spent in yyparse
4521 *except* what is spent in this function. */
4523 parse_time -= get_run_time () - start_time;
4525 /* Reset global variables. */
4526 free_basic_block_vars (0);
4537 printf ("Usage: %s input [switches]\n", progname);
4538 printf ("Switches:\n");
4540 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
4541 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
4542 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
4543 printf (" -finline-limit-<number> Limits the size of inlined functions to <number>\n");
4545 for (i = NUM_ELEM (f_options); i--;)
4547 const char * description = f_options[i].description;
4549 if (description != NULL && * description != 0)
4550 printf (" -f%-21s %s\n",
4551 f_options[i].string, description);
4554 printf (" -O[number] Set optimisation level to [number]\n");
4555 printf (" -Os Optimise for space rather than speed\n");
4556 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
4557 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
4558 printf (" -w Suppress warnings\n");
4559 printf (" -W Enable extra warnings\n");
4561 for (i = NUM_ELEM (W_options); i--;)
4563 const char * description = W_options[i].description;
4565 if (description != NULL && * description != 0)
4566 printf (" -W%-21s %s\n",
4567 W_options[i].string, description);
4570 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
4571 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
4572 printf (" -p Enable function profiling\n");
4573 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
4574 printf (" -a Enable block profiling \n");
4576 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
4577 printf (" -ax Enable jump profiling \n");
4579 printf (" -o <file> Place output into <file> \n");
4580 printf (" -G <number> Put global and static data smaller than <number>\n");
4581 printf (" bytes into a special section (on some targets)\n");
4583 for (i = NUM_ELEM (debug_args); i--;)
4585 if (debug_args[i].description != NULL)
4586 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description);
4589 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
4590 printf (" -quiet Do not display functions compiled or elapsed time\n");
4591 printf (" -version Display the compiler's version\n");
4592 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
4593 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
4594 #if defined HAIFA || defined INSN_SCHEDULING
4595 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n");
4597 printf (" --help Display this information\n");
4602 /* Display descriptions of language specific options.
4603 If there is no description, note that there is an undocumented option.
4604 If the description is empty, do not display anything. (This allows
4605 options to be deliberately undocumented, for whatever reason).
4606 If the option string is missing, then this is a marker, indicating
4607 that the description string is in fact the name of a language, whose
4608 language specific options are to follow. */
4610 if (NUM_ELEM (documented_lang_options) > 1)
4612 printf ("\nLanguage specific options:\n");
4614 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
4616 const char * description = documented_lang_options[i].description;
4617 const char * option = documented_lang_options[i].option;
4619 if (description == NULL)
4624 printf (" %-23.23s [undocumented]\n", option);
4626 else if (* description == 0)
4628 else if (option == NULL)
4632 ("\nThere are undocumented %s specific options as well.\n",
4636 printf ("\n Options for %s:\n", description);
4641 printf (" %-23.23s %s\n", option, description);
4646 printf ("\nThere are undocumented %s specific options as well.\n", lang);
4648 if (NUM_ELEM (target_switches) > 1
4649 #ifdef TARGET_OPTIONS
4650 || NUM_ELEM (target_options) > 1
4658 printf ("\nTarget specific options:\n");
4660 for (i = NUM_ELEM (target_switches); i--;)
4662 const char * option = target_switches[i].name;
4663 const char * description = target_switches[i].description;
4665 if (option == NULL || * option == 0)
4667 else if (description == NULL)
4672 printf (" -m%-21.21s [undocumented]\n", option);
4674 else if (* description != 0)
4675 doc += printf (" -m%-21.21s %s\n", option, description);
4678 #ifdef TARGET_OPTIONS
4679 for (i = NUM_ELEM (target_options); i--;)
4681 const char * option = target_options[i].prefix;
4682 const char * description = target_options[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);
4700 printf ("\nThere are undocumented target specific options as well.\n");
4702 printf (" They exist, but they are not documented.\n");
4707 /* Compare the user specified 'option' with the language
4708 specific 'lang_option'. Return true if they match, or
4709 if 'option' is a viable prefix of 'lang_option'. */
4712 check_lang_option (option, lang_option)
4716 lang_independent_options * indep_options;
4722 /* Ignore NULL entries. */
4723 if (option == NULL || lang_option == NULL)
4726 if ((space = strchr (lang_option, ' ')) != NULL)
4727 len = space - lang_option;
4728 else if ((space = strchr (lang_option, '<')) != NULL)
4729 len = space - lang_option;
4731 len = strlen (lang_option);
4733 /* If they do not match to the first n characters then fail. */
4734 if (strncmp (option, lang_option, len) != 0)
4737 /* Do not accept a lang option, if it matches a normal -f or -W
4738 option. Chill defines a -fpack, but we want to support
4741 /* An exact match is OK */
4742 if ((int) strlen (option) == len)
4745 /* If it is not an -f or -W option allow the match */
4746 if (option[0] != '-')
4752 indep_options = f_options;
4753 numopts = NUM_ELEM (f_options);
4756 indep_options = W_options;
4757 numopts = NUM_ELEM (W_options);
4762 /* The option is a -f or -W option.
4763 Skip past the prefix and search for the remainder in the
4764 appropriate table of options. */
4767 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-')
4770 for (k = numopts; k--;)
4772 if (!strcmp (option, indep_options[k].string))
4774 /* The option matched a language independent option,
4775 do not allow the language specific match. */
4781 /* The option matches the start of the langauge specific option
4782 and it is not an exact match for a language independent option. */
4786 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4787 Exit code is 35 if can't open files, 34 if fatal error,
4788 33 if had nonfatal errors, else success. */
4797 int flag_print_mem = 0;
4798 int version_flag = 0;
4801 /* save in case md file wants to emit args as a comment. */
4805 p = argv[0] + strlen (argv[0]);
4806 while (p != argv[0] && p[-1] != '/'
4807 #ifdef DIR_SEPARATOR
4808 && p[-1] != DIR_SEPARATOR
4814 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
4815 /* Get rid of any avoidable limit on stack size. */
4819 /* Set the stack limit huge so that alloca does not fail. */
4820 getrlimit (RLIMIT_STACK, &rlim);
4821 rlim.rlim_cur = rlim.rlim_max;
4822 setrlimit (RLIMIT_STACK, &rlim);
4826 #ifdef HAVE_LC_MESSAGES
4827 setlocale (LC_MESSAGES, "");
4829 (void) bindtextdomain (PACKAGE, localedir);
4830 (void) textdomain (PACKAGE);
4832 signal (SIGFPE, float_signal);
4835 signal (SIGPIPE, pipe_closed);
4838 decl_printable_name = decl_name;
4839 lang_expand_expr = (lang_expand_expr_t) do_abort;
4841 /* Initialize whether `char' is signed. */
4842 flag_signed_char = DEFAULT_SIGNED_CHAR;
4843 #ifdef DEFAULT_SHORT_ENUMS
4844 /* Initialize how much space enums occupy, by default. */
4845 flag_short_enums = DEFAULT_SHORT_ENUMS;
4848 /* Perform language-specific options intialization. */
4849 lang_init_options ();
4851 /* Scan to see what optimization level has been specified. That will
4852 determine the default value of many flags. */
4853 for (i = 1; i < argc; i++)
4855 if (!strcmp (argv[i], "-O"))
4860 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4862 /* Handle -Os, -O2, -O3, -O69, ... */
4863 char *p = &argv[i][2];
4865 if ((p[0] == 's') && (p[1] == 0))
4869 /* Optimizing for size forces optimize to be 2. */
4874 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4875 if (optimize_val != -1)
4877 optimize = optimize_val;
4878 #ifdef FORCE_OPTIMIZATION_DOWNGRADE
4879 #warning FORCE_OPTIMIZATION_DOWNGRADE
4880 if (optimize > FORCE_OPTIMIZATION_DOWNGRADE)
4882 optimize = FORCE_OPTIMIZATION_DOWNGRADE;
4883 warning ("\n***\n***\t-O%d converted to \"-O%d\" due to optimizer bugs on this platform\n***",
4885 FORCE_OPTIMIZATION_DOWNGRADE);
4888 #endif /*FORCE_OPTIMIZATION_DOWNGRADE*/
4889 #if defined(__alpha__)
4892 warning ("\n***\n***\tThe -O%d flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM\n***",
4895 #endif /*__alpha__*/
4902 obey_regdecls = (optimize == 0);
4907 flag_thread_jumps = 1;
4909 flag_delayed_branch = 1;
4911 #ifdef CAN_DEBUG_WITHOUT_FP
4912 flag_omit_frame_pointer = 1;
4918 flag_cse_follow_jumps = 1;
4919 flag_cse_skip_blocks = 1;
4921 flag_expensive_optimizations = 1;
4922 flag_strength_reduce = 1;
4923 flag_rerun_cse_after_loop = 1;
4924 flag_rerun_loop_opt = 1;
4925 flag_caller_saves = 1;
4927 #ifdef INSN_SCHEDULING
4928 flag_schedule_insns = 1;
4929 flag_schedule_insns_after_reload = 1;
4936 flag_inline_functions = 1;
4939 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4942 set_target_switch ("");
4944 #ifdef OPTIMIZATION_OPTIONS
4945 /* Allow default optimizations to be specified on a per-machine basis. */
4946 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4949 /* Initialize register usage now so switches may override. */
4952 for (i = 1; i < argc; i++)
4956 /* If this is a language-specific option,
4957 decode it in a language-specific way. */
4958 for (j = NUM_ELEM (documented_lang_options); j--;)
4959 if (check_lang_option (argv[i], documented_lang_options[j].option))
4962 if (j != (size_t)-1)
4964 /* If the option is valid for *some* language,
4965 treat it as valid even if this language doesn't understand it. */
4966 int strings_processed = lang_decode_option (argc - i, argv + i);
4968 if (!strcmp (argv[i], "--help"))
4974 if (strings_processed != 0)
4975 i += strings_processed - 1;
4977 else if (argv[i][0] == '-' && argv[i][1] != 0)
4979 register char *str = argv[i] + 1;
4984 set_target_switch (&str[1]);
4985 else if (!strcmp (str, "dumpbase"))
4987 dump_base_name = argv[++i];
4989 else if (str[0] == 'd')
4991 register char *p = &str[1];
4996 branch_prob_dump = 1;
5003 global_reg_dump = 1;
5011 cse_dump = 1, cse2_dump = 1;
5018 #ifdef MACHINE_DEPENDENT_REORG
5019 mach_dep_reorg_dump = 1;
5026 branch_prob_dump = 1;
5043 global_reg_dump = 1;
5068 #ifdef MACHINE_DEPENDENT_REORG
5070 mach_dep_reorg_dump = 1;
5074 flag_print_asm_name = 1;
5095 graph_dump_format = vcg;
5104 rtl_dump_and_exit = 1;
5106 case 'D': /* these are handled by the preprocessor */
5110 warning ("unrecognised gcc debugging option: %c", p[-1]);
5114 else if (str[0] == 'f')
5116 register char *p = &str[1];
5119 /* Some kind of -f option.
5120 P's value is the option sans `-f'.
5121 Search for it in the table of options. */
5124 !found && j < sizeof (f_options) / sizeof (f_options[0]);
5127 if (!strcmp (p, f_options[j].string))
5129 *f_options[j].variable = f_options[j].on_value;
5130 /* A goto here would be cleaner,
5131 but breaks the vax pcc. */
5134 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5135 && ! strcmp (p+3, f_options[j].string))
5137 *f_options[j].variable = ! f_options[j].on_value;
5144 else if (!strncmp (p, "inline-limit-", 13))
5146 read_integral_parameter (p + 13, p - 2, inline_max_insns);
5148 #ifdef INSN_SCHEDULING
5149 else if (!strncmp (p, "sched-verbose-",14))
5150 fix_sched_param("verbose",&p[14]);
5153 else if (!strncmp (p, "fixed-", 6))
5154 fix_register (&p[6], 1, 1);
5155 else if (!strncmp (p, "call-used-", 10))
5156 fix_register (&p[10], 0, 1);
5157 else if (!strncmp (p, "call-saved-", 11))
5158 fix_register (&p[11], 0, 0);
5160 error ("Invalid option `%s'", argv[i]);
5162 else if (str[0] == 'O')
5164 /* Already been treated above. Do nothing. */
5166 else if (!strcmp (str, "pedantic"))
5168 else if (!strcmp (str, "pedantic-errors"))
5169 flag_pedantic_errors = pedantic = 1;
5170 else if (!strcmp (str, "quiet"))
5172 else if (!strcmp (str, "version"))
5174 else if (!strcmp (str, "w"))
5175 inhibit_warnings = 1;
5176 else if (!strcmp (str, "W"))
5179 /* We save the value of warn_uninitialized, since if they put
5180 -Wuninitialized on the command line, we need to generate a
5181 warning about not using it without also specifying -O. */
5182 if (warn_uninitialized != 1)
5183 warn_uninitialized = 2;
5185 else if (str[0] == 'W')
5187 register char *p = &str[1];
5190 /* Some kind of -W option.
5191 P's value is the option sans `-W'.
5192 Search for it in the table of options. */
5195 !found && j < sizeof (W_options) / sizeof (W_options[0]);
5198 if (!strcmp (p, W_options[j].string))
5200 *W_options[j].variable = W_options[j].on_value;
5201 /* A goto here would be cleaner,
5202 but breaks the vax pcc. */
5205 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
5206 && ! strcmp (p+3, W_options[j].string))
5208 *W_options[j].variable = ! W_options[j].on_value;
5215 else if (!strncmp (p, "id-clash-", 9))
5217 const int id_clash_val
5218 = read_integral_parameter (p + 9, p - 2, -1);
5219 if (id_clash_val != -1)
5221 id_clash_len = id_clash_val;
5225 else if (!strncmp (p, "larger-than-", 12))
5227 const int larger_than_val
5228 = read_integral_parameter (p + 12, p - 2, -1);
5229 if (larger_than_val != -1)
5231 larger_than_size = larger_than_val;
5232 warn_larger_than = 1;
5236 error ("Invalid option `%s'", argv[i]);
5238 else if (!strcmp (str, "p"))
5242 else if (!strcmp (str, "a"))
5244 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5245 warning ("`-a' option (basic block profile) not supported");
5247 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
5250 else if (!strcmp (str, "ax"))
5252 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
5253 warning ("`-ax' option (jump profiling) not supported");
5255 profile_block_flag = (!profile_block_flag
5256 || profile_block_flag == 2) ? 2 : 3;
5259 else if (str[0] == 'g')
5262 /* A lot of code assumes write_symbols == NO_DEBUG if the
5263 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
5264 of what debugging type has been selected). This records the
5265 selected type. It is an error to specify more than one
5267 static enum debug_info_type selected_debug_type = NO_DEBUG;
5268 /* Non-zero if debugging format has been explicitly set.
5269 -g and -ggdb don't explicitly set the debugging format so
5270 -gdwarf -g3 is equivalent to -gdwarf3. */
5271 static int type_explicitly_set_p = 0;
5272 /* Indexed by enum debug_info_type. */
5273 static const char *debug_type_names[] =
5275 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
5278 /* The maximum admissible debug level value. */
5279 static const unsigned max_debug_level = 3;
5281 /* Look up STR in the table. */
5282 for (da = debug_args; da->arg; da++)
5284 const int da_len = strlen (da->arg);
5286 if (! strncmp (str, da->arg, da_len))
5288 enum debug_info_type type = da->debug_type;
5289 const char *p = str + da_len;
5291 if (*p && (*p < '0' || *p > '9'))
5294 /* A debug flag without a level defaults to level 2.
5295 Note we do not want to call read_integral_parameter
5296 for that case since it will call atoi which
5299 ??? We may want to generalize the interface to
5300 read_integral_parameter to better handle this case
5301 if this case shows up often. */
5303 level = read_integral_parameter (p, 0,
5304 max_debug_level + 1);
5308 if (da_len > 1 && *p && !strncmp (str, "gdwarf", da_len))
5310 error ("use -gdwarf -g%d for DWARF v1, level %d",
5313 error ("use -gdwarf-2 for DWARF v2");
5316 if (level > max_debug_level)
5318 warning ("ignoring option `%s' due to invalid debug level specification",
5320 level = debug_info_level;
5323 if (type == NO_DEBUG)
5325 type = PREFERRED_DEBUGGING_TYPE;
5326 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0)
5328 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
5329 type = DWARF2_DEBUG;
5331 #ifdef DBX_DEBUGGING_INFO
5338 if (type == NO_DEBUG)
5339 warning ("`-%s' not supported by this configuration of GCC",
5342 /* Does it conflict with an already selected type? */
5343 if (type_explicitly_set_p
5344 /* -g/-ggdb don't conflict with anything */
5345 && da->debug_type != NO_DEBUG
5346 && type != selected_debug_type)
5347 warning ("`-%s' ignored, conflicts with `-g%s'",
5348 str, debug_type_names[(int) selected_debug_type]);
5351 /* If the format has already been set, -g/-ggdb
5352 only change the debug level. */
5353 if (type_explicitly_set_p
5354 && da->debug_type == NO_DEBUG)
5355 ; /* don't change debugging type */
5358 selected_debug_type = type;
5359 type_explicitly_set_p = da->debug_type != NO_DEBUG;
5361 write_symbols = (level == 0
5363 : selected_debug_type);
5364 use_gnu_debug_info_extensions = da->use_extensions_p;
5365 debug_info_level = (enum debug_info_level) level;
5371 warning ("`-%s' not supported by this configuration of GCC",
5374 else if (!strcmp (str, "o"))
5376 asm_file_name = argv[++i];
5378 else if (str[0] == 'G')
5380 const int g_switch_val = (str[1] != '\0') ?
5381 read_integral_parameter(str + 1, 0, -1) :
5382 read_integral_parameter(argv[++i], 0, -1);
5384 if (g_switch_val != -1)
5386 g_switch_set = TRUE;
5387 g_switch_value = g_switch_val;
5391 error("Invalid option `-%s'",str);
5394 else if (!strncmp (str, "aux-info", 8))
5396 flag_gen_aux_info = 1;
5397 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
5399 else if (!strcmp (str, "-help"))
5405 error ("Invalid option `%s'", argv[i]);
5407 else if (argv[i][0] == '+')
5408 error ("Invalid option `%s'", argv[i]);
5413 /* Checker uses the frame pointer. */
5414 if (flag_check_memory_usage)
5415 flag_omit_frame_pointer = 0;
5419 /* Inlining does not work if not optimizing,
5420 so force it not to be done. */
5424 /* The c_decode_option and lang_decode_option functions set
5425 this to `2' if -Wall is used, so we can avoid giving out
5426 lots of errors for people who don't realize what -Wall does. */
5427 if (warn_uninitialized == 1)
5428 warning ("-Wuninitialized is not supported without -O");
5431 #ifdef OVERRIDE_OPTIONS
5432 /* Some machines may reject certain combinations of options. */
5436 if (exceptions_via_longjmp == 2)
5438 #ifdef DWARF2_UNWIND_INFO
5439 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
5441 exceptions_via_longjmp = 1;
5445 if (profile_block_flag == 3)
5447 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
5448 profile_block_flag = 2;
5451 /* Unrolling all loops implies that standard loop unrolling must also
5453 if (flag_unroll_all_loops)
5454 flag_unroll_loops = 1;
5455 /* Loop unrolling requires that strength_reduction be on also. Silently
5456 turn on strength reduction here if it isn't already on. Also, the loop
5457 unrolling code assumes that cse will be run after loop, so that must
5458 be turned on also. */
5459 if (flag_unroll_loops)
5461 flag_strength_reduce = 1;
5462 flag_rerun_cse_after_loop = 1;
5465 /* Warn about options that are not supported on this machine. */
5466 #ifndef INSN_SCHEDULING
5467 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5468 warning ("instruction scheduling not supported on this target machine");
5471 if (flag_delayed_branch)
5472 warning ("this target machine does not have delayed branches");
5475 user_label_prefix = USER_LABEL_PREFIX;
5476 if (flag_leading_underscore != -1)
5478 /* If the default prefix is more complicated than "" or "_",
5479 issue a warning and ignore this option. */
5480 if (user_label_prefix[0] == 0 ||
5481 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5483 user_label_prefix = flag_leading_underscore ? "_" : "";
5486 warning ("-f%sleading-underscore not supported on this target machine",
5487 flag_leading_underscore ? "" : "no-");
5490 /* If we are in verbose mode, write out the version and maybe all the
5491 option flags in use. */
5494 print_version (stderr, "");
5496 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5499 compile_file (filename);
5501 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
5504 char *lim = (char *) sbrk (0);
5506 notice ("Data size %ld.\n", (long) (lim - (char *) &environ));
5511 system ("ps -l 1>&2");
5514 #endif /* not USG */
5517 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
5520 exit (FATAL_EXIT_CODE);
5522 exit (FATAL_EXIT_CODE);
5523 exit (SUCCESS_EXIT_CODE);
5527 /* Decode -m switches. */
5528 /* Decode the switch -mNAME. */
5531 set_target_switch (name)
5535 int valid_target_option = 0;
5537 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5538 if (!strcmp (target_switches[j].name, name))
5540 if (target_switches[j].value < 0)
5541 target_flags &= ~-target_switches[j].value;
5543 target_flags |= target_switches[j].value;
5544 valid_target_option = 1;
5547 #ifdef TARGET_OPTIONS
5548 if (!valid_target_option)
5549 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5551 int len = strlen (target_options[j].prefix);
5552 if (!strncmp (target_options[j].prefix, name, len))
5554 *target_options[j].variable = name + len;
5555 valid_target_option = 1;
5560 if (!valid_target_option)
5561 error ("Invalid option `%s'", name);
5564 /* Print version information to FILE.
5565 Each line begins with INDENT (for the case where FILE is the
5566 assembler output file). */
5569 print_version (file, indent)
5574 #define __VERSION__ "[?]"
5578 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
5580 "%s%s%s version %s (%s) compiled by CC.\n"
5582 , indent, *indent != 0 ? " " : "",
5583 language_string, version_string, TARGET_NAME, __VERSION__);
5586 /* Print an option value and return the adjusted position in the line.
5587 ??? We don't handle error returns from fprintf (disk full); presumably
5588 other code will catch a disk full though. */
5591 print_single_switch (file, pos, max, indent, sep, term, type, name)
5594 const char *indent, *sep, *term, *type, *name;
5596 /* The ultrix fprintf returns 0 on success, so compute the result we want
5597 here since we need it for the following test. */
5598 int len = strlen (sep) + strlen (type) + strlen (name);
5603 fprintf (file, "%s", term);
5608 fprintf (file, "%s", indent);
5609 pos = strlen (indent);
5611 fprintf (file, "%s%s%s", sep, type, name);
5616 /* Print active target switches to FILE.
5617 POS is the current cursor position and MAX is the size of a "line".
5618 Each line begins with INDENT and ends with TERM.
5619 Each switch is separated from the next by SEP. */
5622 print_switch_values (file, pos, max, indent, sep, term)
5625 const char *indent, *sep, *term;
5630 /* Print the options as passed. */
5632 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5633 _("options passed: "), "");
5635 for (p = &save_argv[1]; *p != NULL; p++)
5639 if (strcmp (*p, "-o") == 0)
5645 if (strcmp (*p, "-quiet") == 0)
5647 if (strcmp (*p, "-version") == 0)
5652 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5655 fprintf (file, "%s", term);
5657 /* Print the -f and -m options that have been enabled.
5658 We don't handle language specific options but printing argv
5661 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5662 _("options enabled: "), "");
5664 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
5665 if (*f_options[j].variable == f_options[j].on_value)
5666 pos = print_single_switch (file, pos, max, indent, sep, term,
5667 "-f", f_options[j].string);
5669 /* Print target specific options. */
5671 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
5672 if (target_switches[j].name[0] != '\0'
5673 && target_switches[j].value > 0
5674 && ((target_switches[j].value & target_flags)
5675 == target_switches[j].value))
5677 pos = print_single_switch (file, pos, max, indent, sep, term,
5678 "-m", target_switches[j].name);
5681 #ifdef TARGET_OPTIONS
5682 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
5683 if (*target_options[j].variable != NULL)
5686 sprintf (prefix, "-m%s", target_options[j].prefix);
5687 pos = print_single_switch (file, pos, max, indent, sep, term,
5688 prefix, *target_options[j].variable);
5692 fprintf (file, "%s", term);
5695 /* Record the beginning of a new source file, named FILENAME. */
5698 debug_start_source_file (filename)
5699 register char *filename ATTRIBUTE_UNUSED;
5701 #ifdef DBX_DEBUGGING_INFO
5702 if (write_symbols == DBX_DEBUG)
5703 dbxout_start_new_source_file (filename);
5705 #ifdef DWARF_DEBUGGING_INFO
5706 if (debug_info_level == DINFO_LEVEL_VERBOSE
5707 && write_symbols == DWARF_DEBUG)
5708 dwarfout_start_new_source_file (filename);
5709 #endif /* DWARF_DEBUGGING_INFO */
5710 #ifdef DWARF2_DEBUGGING_INFO
5711 if (debug_info_level == DINFO_LEVEL_VERBOSE
5712 && write_symbols == DWARF2_DEBUG)
5713 dwarf2out_start_source_file (filename);
5714 #endif /* DWARF2_DEBUGGING_INFO */
5715 #ifdef SDB_DEBUGGING_INFO
5716 if (write_symbols == SDB_DEBUG)
5717 sdbout_start_new_source_file (filename);
5721 /* Record the resumption of a source file. LINENO is the line number in
5722 the source file we are returning to. */
5725 debug_end_source_file (lineno)
5726 register unsigned lineno ATTRIBUTE_UNUSED;
5728 #ifdef DBX_DEBUGGING_INFO
5729 if (write_symbols == DBX_DEBUG)
5730 dbxout_resume_previous_source_file ();
5732 #ifdef DWARF_DEBUGGING_INFO
5733 if (debug_info_level == DINFO_LEVEL_VERBOSE
5734 && write_symbols == DWARF_DEBUG)
5735 dwarfout_resume_previous_source_file (lineno);
5736 #endif /* DWARF_DEBUGGING_INFO */
5737 #ifdef DWARF2_DEBUGGING_INFO
5738 if (debug_info_level == DINFO_LEVEL_VERBOSE
5739 && write_symbols == DWARF2_DEBUG)
5740 dwarf2out_end_source_file ();
5741 #endif /* DWARF2_DEBUGGING_INFO */
5742 #ifdef SDB_DEBUGGING_INFO
5743 if (write_symbols == SDB_DEBUG)
5744 sdbout_resume_previous_source_file ();
5748 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5749 the tail part of the directive line, i.e. the part which is past the
5750 initial whitespace, #, whitespace, directive-name, whitespace part. */
5753 debug_define (lineno, buffer)
5754 register unsigned lineno ATTRIBUTE_UNUSED;
5755 register char *buffer ATTRIBUTE_UNUSED;
5757 #ifdef DWARF_DEBUGGING_INFO
5758 if (debug_info_level == DINFO_LEVEL_VERBOSE
5759 && write_symbols == DWARF_DEBUG)
5760 dwarfout_define (lineno, buffer);
5761 #endif /* DWARF_DEBUGGING_INFO */
5762 #ifdef DWARF2_DEBUGGING_INFO
5763 if (debug_info_level == DINFO_LEVEL_VERBOSE
5764 && write_symbols == DWARF2_DEBUG)
5765 dwarf2out_define (lineno, buffer);
5766 #endif /* DWARF2_DEBUGGING_INFO */
5769 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5770 the tail part of the directive line, i.e. the part which is past the
5771 initial whitespace, #, whitespace, directive-name, whitespace part. */
5774 debug_undef (lineno, buffer)
5775 register unsigned lineno ATTRIBUTE_UNUSED;
5776 register char *buffer ATTRIBUTE_UNUSED;
5778 #ifdef DWARF_DEBUGGING_INFO
5779 if (debug_info_level == DINFO_LEVEL_VERBOSE
5780 && write_symbols == DWARF_DEBUG)
5781 dwarfout_undef (lineno, buffer);
5782 #endif /* DWARF_DEBUGGING_INFO */
5783 #ifdef DWARF2_DEBUGGING_INFO
5784 if (debug_info_level == DINFO_LEVEL_VERBOSE
5785 && write_symbols == DWARF2_DEBUG)
5786 dwarf2out_undef (lineno, buffer);
5787 #endif /* DWARF2_DEBUGGING_INFO */