1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 88, 89, 92-7, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This is the top level of cc1/c++.
22 It parses command args, opens files, invokes the various passes
23 in the proper order, and counts the time used by each.
24 Error messages and low-level interface to malloc also handled here. */
35 #include <sys/types.h>
39 #ifdef HAVE_SYS_PARAM_H
40 #include <sys/param.h>
56 #undef FLOAT /* This is for hpux. They should change hpux. */
57 #undef FFS /* Some systems define this in param.h. */
59 #ifdef TIME_WITH_SYS_TIME
60 # include <sys/time.h>
64 # include <sys/time.h>
70 #ifdef HAVE_SYS_RESOURCE_H
71 # include <sys/resource.h>
74 #ifdef HAVE_SYS_TIMES_H
75 # include <sys/times.h>
82 #include "insn-attr.h"
87 #ifdef XCOFF_DEBUGGING_INFO
92 /* The extra parameters substantially improve the I/O performance. */
94 vms_fopen (fname, type)
98 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
99 fixed arguments, which matches ANSI's specification but not VAXCRTL's
100 pre-ANSI implementation. This hack circumvents the mismatch problem. */
101 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
104 return (*vmslib_fopen) (fname, type, "mbc=32",
105 "deq=64", "fop=tef", "shr=nil");
107 return (*vmslib_fopen) (fname, type, "mbc=32");
109 #define fopen vms_fopen
112 #ifndef DEFAULT_GDB_EXTENSIONS
113 #define DEFAULT_GDB_EXTENSIONS 1
116 /* If more than one debugging type is supported, you must define
117 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
119 This is one long line cause VAXC can't handle a \-newline. */
120 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
121 #ifndef PREFERRED_DEBUGGING_TYPE
122 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
123 #endif /* no PREFERRED_DEBUGGING_TYPE */
124 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
125 so the following code needn't care. */
126 #ifdef DBX_DEBUGGING_INFO
127 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
129 #ifdef SDB_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
132 #ifdef DWARF_DEBUGGING_INFO
133 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
135 #ifdef DWARF2_DEBUGGING_INFO
136 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
138 #ifdef XCOFF_DEBUGGING_INFO
139 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
141 #endif /* More than one debugger format enabled. */
143 /* If still not defined, must have been because no debugging formats
145 #ifndef PREFERRED_DEBUGGING_TYPE
146 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
149 extern int rtx_equal_function_value_matters;
151 #if ! (defined (VMS) || defined (OS2))
152 extern char **environ;
154 extern char *version_string, *language_string;
156 /* Carry information from ASM_DECLARE_OBJECT_NAME
157 to ASM_FINISH_DECLARE_OBJECT. */
159 extern int size_directive_output;
160 extern tree last_assemble_variable_decl;
162 extern void init_lex ();
163 extern void init_decl_processing ();
164 extern void init_obstacks ();
165 extern void init_tree_codes ();
166 extern void init_rtl ();
167 extern void init_regs ();
168 extern void init_optabs ();
169 extern void init_stmt ();
170 extern void init_reg_sets ();
171 extern void dump_flow_info ();
172 extern void dump_sched_info ();
173 extern void dump_local_alloc ();
174 extern void regset_release_memory ();
176 extern void print_rtl ();
177 extern void print_rtl_with_bb ();
179 void rest_of_decl_compilation ();
180 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
181 void error_with_decl PVPROTO((tree decl, char *s, ...));
182 void error_for_asm PVPROTO((rtx insn, char *s, ...));
183 void error PVPROTO((char *s, ...));
184 void fatal PVPROTO((char *s, ...));
185 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
186 void warning_with_decl PVPROTO((tree decl, char *s, ...));
187 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
188 void warning PVPROTO((char *s, ...));
189 void pedwarn PVPROTO((char *s, ...));
190 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
191 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
192 void sorry PVPROTO((char *s, ...));
193 void really_sorry PVPROTO((char *s, ...));
195 void set_target_switch ();
196 static char *decl_name ();
198 void print_version ();
199 int print_single_switch ();
200 void print_switch_values ();
201 /* Length of line when printing switch values. */
204 #ifdef NEED_DECLARATION_ABORT
208 #ifdef NEED_DECLARATION_SBRK
209 extern char *sbrk ();
212 /* Name of program invoked, sans directories. */
216 /* Copy of arguments to main. */
220 /* Name of current original source file (what was input to cpp).
221 This comes from each #-command in the actual input. */
223 char *input_filename;
225 /* Name of top-level original source file (what was input to cpp).
226 This comes from the #-command at the beginning of the actual input.
227 If there isn't any there, then this is the cc1 input file name. */
229 char *main_input_filename;
232 /* Stream for reading from the input file. */
236 /* Current line number in real source file. */
240 /* Stack of currently pending input files. */
242 struct file_stack *input_file_stack;
244 /* Incremented on each change to input_file_stack. */
245 int input_file_stack_tick;
247 /* FUNCTION_DECL for function now being parsed or compiled. */
249 extern tree current_function_decl;
251 /* Name to use as base of names for dump output files. */
253 char *dump_base_name;
255 /* Bit flags that specify the machine subtype we are compiling for.
256 Bits are tested using macros TARGET_... defined in the tm.h file
257 and set by `-m...' switches. Must be defined in rtlanal.c. */
259 extern int target_flags;
261 /* Flags saying which kinds of debugging dump have been requested. */
264 int rtl_dump_and_exit = 0;
265 int jump_opt_dump = 0;
266 int addressof_dump = 0;
270 int branch_prob_dump = 0;
272 int combine_dump = 0;
273 int regmove_dump = 0;
275 int local_reg_dump = 0;
276 int global_reg_dump = 0;
278 int jump2_opt_dump = 0;
280 int dbr_sched_dump = 0;
282 int flag_print_asm_name = 0;
284 int stack_reg_dump = 0;
286 #ifdef MACHINE_DEPENDENT_REORG
287 int mach_dep_reorg_dump = 0;
290 /* Name for output file of assembly code, specified with -o. */
294 /* Value of the -G xx switch, and whether it was passed or not. */
298 /* Type(s) of debugging information we are producing (if any).
299 See flags.h for the definitions of the different possible
300 types of debugging information. */
301 enum debug_info_type write_symbols = NO_DEBUG;
303 /* Level of debugging information we are producing. See flags.h
304 for the definitions of the different possible levels. */
305 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
307 /* Nonzero means use GNU-only extensions in the generated symbolic
308 debugging information. */
309 /* Currently, this only has an effect when write_symbols is set to
310 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
311 int use_gnu_debug_info_extensions = 0;
313 /* Nonzero means do optimizations. -O.
314 Particular numeric values stand for particular amounts of optimization;
315 thus, -O2 stores 2 here. However, the optimizations beyond the basic
316 ones are not controlled directly by this variable. Instead, they are
317 controlled by individual `flag_...' variables that are defaulted
318 based on this variable. */
322 /* Nonzero means optimize for size. -Os.
323 The only valid values are zero and non-zero. When optimize_size is
324 non-zero, optimize defaults to 2, but certain individual code
325 bloating optimizations are disabled. */
327 int optimize_size = 0;
329 /* Number of error messages and warning messages so far. */
332 int warningcount = 0;
335 /* Pointer to function to compute the name to use to print a declaration.
336 DECL is the declaration in question.
337 VERBOSITY determines what information will be printed:
338 0: DECL_NAME, demangled as necessary.
339 1: and scope information.
340 2: and any other information that might be interesting, such as function
341 parameter types in C++. */
343 char *(*decl_printable_name) (/* tree decl, int verbosity */);
345 /* Pointer to function to compute rtl for a language-specific tree code. */
347 struct rtx_def *(*lang_expand_expr) ();
349 /* Pointer to function to finish handling an incomplete decl at the
350 end of compilation. */
352 void (*incomplete_decl_finalize_hook) () = 0;
354 /* Highest label number used at the end of reload. */
356 int max_label_num_after_reload;
358 /* Nonzero if generating code to do profiling. */
360 int profile_flag = 0;
362 /* Nonzero if generating code to do profiling on a line-by-line basis. */
364 int profile_block_flag;
366 /* Nonzero if generating code to profile program flow graph arcs. */
368 int profile_arc_flag = 0;
370 /* Nonzero if generating info for gcov to calculate line test coverage. */
372 int flag_test_coverage = 0;
374 /* Nonzero indicates that branch taken probabilities should be calculated. */
376 int flag_branch_probabilities = 0;
378 /* Nonzero for -pedantic switch: warn about anything
379 that standard spec forbids. */
383 /* Temporarily suppress certain warnings.
384 This is set while reading code from a system header file. */
386 int in_system_header = 0;
388 /* Nonzero means do stupid register allocation.
389 Currently, this is 1 if `optimize' is 0. */
391 int obey_regdecls = 0;
393 /* Don't print functions as they are compiled and don't print
394 times taken by the various passes. -quiet. */
400 /* Nonzero means `char' should be signed. */
402 int flag_signed_char;
404 /* Nonzero means give an enum type only as many bytes as it needs. */
406 int flag_short_enums;
408 /* Nonzero for -fcaller-saves: allocate values in regs that need to
409 be saved across function calls, if that produces overall better code.
410 Optional now, so people can test it. */
412 #ifdef DEFAULT_CALLER_SAVES
413 int flag_caller_saves = 1;
415 int flag_caller_saves = 0;
418 /* Nonzero if structures and unions should be returned in memory.
420 This should only be defined if compatibility with another compiler or
421 with an ABI is needed, because it results in slower code. */
423 #ifndef DEFAULT_PCC_STRUCT_RETURN
424 #define DEFAULT_PCC_STRUCT_RETURN 1
427 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
429 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
431 /* Nonzero for -fforce-mem: load memory value into a register
432 before arithmetic on it. This makes better cse but slower compilation. */
434 int flag_force_mem = 0;
436 /* Nonzero for -fforce-addr: load memory address into a register before
437 reference to memory. This makes better cse but slower compilation. */
439 int flag_force_addr = 0;
441 /* Nonzero for -fdefer-pop: don't pop args after each function call;
442 instead save them up to pop many calls' args with one insns. */
444 int flag_defer_pop = 0;
446 /* Nonzero for -ffloat-store: don't allocate floats and doubles
447 in extended-precision registers. */
449 int flag_float_store = 0;
451 /* Nonzero for -fcse-follow-jumps:
452 have cse follow jumps to do a more extensive job. */
454 int flag_cse_follow_jumps;
456 /* Nonzero for -fcse-skip-blocks:
457 have cse follow a branch around a block. */
458 int flag_cse_skip_blocks;
460 /* Nonzero for -fexpensive-optimizations:
461 perform miscellaneous relatively-expensive optimizations. */
462 int flag_expensive_optimizations;
464 /* Nonzero for -fthread-jumps:
465 have jump optimize output of loop. */
467 int flag_thread_jumps;
469 /* Nonzero enables strength-reduction in loop.c. */
471 int flag_strength_reduce = 0;
473 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
474 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
475 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
478 int flag_unroll_loops;
480 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
481 This is generally not a win. */
483 int flag_unroll_all_loops;
485 /* Nonzero forces all invariant computations in loops to be moved
488 int flag_move_all_movables = 0;
490 /* Nonzero forces all general induction variables in loops to be
493 int flag_reduce_all_givs = 0;
495 /* Nonzero for -fwritable-strings:
496 store string constants in data segment and don't uniquize them. */
498 int flag_writable_strings = 0;
500 /* Nonzero means don't put addresses of constant functions in registers.
501 Used for compiling the Unix kernel, where strange substitutions are
502 done on the assembly output. */
504 int flag_no_function_cse = 0;
506 /* Nonzero for -fomit-frame-pointer:
507 don't make a frame pointer in simple functions that don't require one. */
509 int flag_omit_frame_pointer = 0;
511 /* Nonzero means place each function into its own section on those platforms
512 which support arbitrary section names and unlimited numbers of sections. */
514 int flag_function_sections = 0;
516 /* Nonzero to inhibit use of define_optimization peephole opts. */
518 int flag_no_peephole = 0;
520 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
521 operations in the interest of optimization. For example it allows
522 GCC to assume arguments to sqrt are nonnegative numbers, allowing
523 faster code for sqrt to be generated. */
525 int flag_fast_math = 0;
527 /* Nonzero means all references through pointers are volatile. */
531 /* Nonzero means treat all global and extern variables as global. */
533 int flag_volatile_global;
535 /* Nonzero means just do syntax checking; don't output anything. */
537 int flag_syntax_only = 0;
539 /* Nonzero means to rerun cse after loop optimization. This increases
540 compilation time about 20% and picks up a few more common expressions. */
542 static int flag_rerun_cse_after_loop;
544 /* Nonzero means to run loop optimizations twice. */
546 int flag_rerun_loop_opt;
548 /* Nonzero for -finline-functions: ok to inline functions that look like
549 good inline candidates. */
551 int flag_inline_functions;
553 /* Nonzero for -fkeep-inline-functions: even if we make a function
554 go inline everywhere, keep its definition around for debugging
557 int flag_keep_inline_functions;
559 /* Nonzero means that functions will not be inlined. */
563 /* Nonzero means that we should emit static const variables
564 regardless of whether or not optimization is turned on. */
566 int flag_keep_static_consts = 1;
568 /* Nonzero means we should be saving declaration info into a .X file. */
570 int flag_gen_aux_info = 0;
572 /* Specified name of aux-info file. */
574 static char *aux_info_file_name;
576 /* Nonzero means make the text shared if supported. */
578 int flag_shared_data;
580 /* Nonzero means schedule into delayed branch slots if supported. */
582 int flag_delayed_branch;
584 /* Nonzero if we are compiling pure (sharable) code.
585 Value is 1 if we are doing reasonable (i.e. simple
586 offset into offset table) pic. Value is 2 if we can
587 only perform register offsets. */
591 /* Nonzero means generate extra code for exception handling and enable
592 exception handling. */
594 int flag_exceptions = 2;
596 /* Nonzero means don't place uninitialized global data in common storage
601 /* Nonzero means pretend it is OK to examine bits of target floats,
602 even if that isn't true. The resulting code will have incorrect constants,
603 but the same series of instructions that the native compiler would make. */
605 int flag_pretend_float;
607 /* Nonzero means change certain warnings into errors.
608 Usually these are warnings about failure to conform to some standard. */
610 int flag_pedantic_errors = 0;
612 /* flag_schedule_insns means schedule insns within basic blocks (before
614 flag_schedule_insns_after_reload means schedule insns after
617 int flag_schedule_insns = 0;
618 int flag_schedule_insns_after_reload = 0;
621 /* The following flags have effect only for scheduling before register
624 flag_schedule_interblock means schedule insns accross basic blocks.
625 flag_schedule_speculative means allow speculative motion of non-load insns.
626 flag_schedule_speculative_load means allow speculative motion of some
628 flag_schedule_speculative_load_dangerous allows speculative motion of more
631 int flag_schedule_interblock = 1;
632 int flag_schedule_speculative = 1;
633 int flag_schedule_speculative_load = 0;
634 int flag_schedule_speculative_load_dangerous = 0;
636 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
637 by a cheaper branch, on a count register. */
638 int flag_branch_on_count_reg;
642 /* -finhibit-size-directive inhibits output of .size for ELF.
643 This is used only for compiling crtstuff.c,
644 and it may be extended to other effects
645 needed for crtstuff.c on other systems. */
646 int flag_inhibit_size_directive = 0;
648 /* -fverbose-asm causes extra commentary information to be produced in
649 the generated assembly code (to make it more readable). This option
650 is generally only of use to those who actually need to read the
651 generated assembly code (perhaps while debugging the compiler itself).
652 -fno-verbose-asm, the default, causes the extra information
653 to be omitted and is useful when comparing two assembler files. */
655 int flag_verbose_asm = 0;
657 /* -dA causes debug commentary information to be produced in
658 the generated assembly code (to make it more readable). This option
659 is generally only of use to those who actually need to read the
660 generated assembly code (perhaps while debugging the compiler itself).
661 Currently, this switch is only used by dwarfout.c; however, it is intended
662 to be a catchall for printing debug information in the assembler file. */
664 int flag_debug_asm = 0;
666 /* -fgnu-linker specifies use of the GNU linker for initializations.
667 (Or, more generally, a linker that handles initializations.)
668 -fno-gnu-linker says that collect2 will be used. */
670 int flag_gnu_linker = 0;
672 int flag_gnu_linker = 1;
675 /* Tag all structures with __attribute__(packed) */
676 int flag_pack_struct = 0;
678 /* Emit code to check for stack overflow; also may cause large objects
679 to be allocated dynamically. */
680 int flag_stack_check;
682 /* -fcheck-memory-usage causes extra code to be generated in order to check
683 memory accesses. This is used by a detector of bad memory accesses such
685 int flag_check_memory_usage = 0;
687 /* -fprefix-function-name causes function name to be prefixed. This
688 can be used with -fcheck-memory-usage to isolate code compiled with
689 -fcheck-memory-usage. */
690 int flag_prefix_function_name = 0;
692 int flag_regmove = 0;
694 /* 0 if pointer arguments may alias each other. True in C.
695 1 if pointer arguments may not alias each other but may alias
697 2 if pointer arguments may not alias each other and may not
698 alias global variables. True in Fortran.
699 This defaults to 0 for C. */
700 int flag_argument_noalias = 0;
702 /* Table of language-independent -f options.
703 STRING is the option name. VARIABLE is the address of the variable.
704 ON_VALUE is the value to store in VARIABLE
705 if `-fSTRING' is seen as an option.
706 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
708 struct { char *string; int *variable; int on_value;} f_options[] =
710 {"float-store", &flag_float_store, 1},
711 {"volatile", &flag_volatile, 1},
712 {"volatile-global", &flag_volatile_global, 1},
713 {"defer-pop", &flag_defer_pop, 1},
714 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
715 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
716 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
717 {"expensive-optimizations", &flag_expensive_optimizations, 1},
718 {"thread-jumps", &flag_thread_jumps, 1},
719 {"strength-reduce", &flag_strength_reduce, 1},
720 {"unroll-loops", &flag_unroll_loops, 1},
721 {"unroll-all-loops", &flag_unroll_all_loops, 1},
722 {"move-all-movables", &flag_move_all_movables, 1},
723 {"reduce-all-givs", &flag_reduce_all_givs, 1},
724 {"writable-strings", &flag_writable_strings, 1},
725 {"peephole", &flag_no_peephole, 0},
726 {"force-mem", &flag_force_mem, 1},
727 {"force-addr", &flag_force_addr, 1},
728 {"function-cse", &flag_no_function_cse, 0},
729 {"inline-functions", &flag_inline_functions, 1},
730 {"keep-inline-functions", &flag_keep_inline_functions, 1},
731 {"inline", &flag_no_inline, 0},
732 {"keep-static-consts", &flag_keep_static_consts, 1},
733 {"syntax-only", &flag_syntax_only, 1},
734 {"shared-data", &flag_shared_data, 1},
735 {"caller-saves", &flag_caller_saves, 1},
736 {"pcc-struct-return", &flag_pcc_struct_return, 1},
737 {"reg-struct-return", &flag_pcc_struct_return, 0},
738 {"delayed-branch", &flag_delayed_branch, 1},
739 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
740 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
741 {"pretend-float", &flag_pretend_float, 1},
742 {"schedule-insns", &flag_schedule_insns, 1},
743 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
745 {"sched-interblock",&flag_schedule_interblock, 1},
746 {"sched-spec",&flag_schedule_speculative, 1},
747 {"sched-spec-load",&flag_schedule_speculative_load, 1},
748 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
749 {"branch-count-reg",&flag_branch_on_count_reg, 1},
751 {"pic", &flag_pic, 1},
752 {"PIC", &flag_pic, 2},
753 {"exceptions", &flag_exceptions, 1},
754 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
755 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
756 {"profile-arcs", &profile_arc_flag, 1},
757 {"test-coverage", &flag_test_coverage, 1},
758 {"branch-probabilities", &flag_branch_probabilities, 1},
759 {"fast-math", &flag_fast_math, 1},
760 {"common", &flag_no_common, 0},
761 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
762 {"function-sections", &flag_function_sections, 1},
763 {"verbose-asm", &flag_verbose_asm, 1},
764 {"gnu-linker", &flag_gnu_linker, 1},
765 {"regmove", &flag_regmove, 1},
766 {"pack-struct", &flag_pack_struct, 1},
767 {"stack-check", &flag_stack_check, 1},
768 {"argument-alias", &flag_argument_noalias, 0},
769 {"argument-noalias", &flag_argument_noalias, 1},
770 {"argument-noalias-global", &flag_argument_noalias, 2},
771 {"check-memory-usage", &flag_check_memory_usage, 1},
772 {"prefix-function-name", &flag_prefix_function_name, 1}
775 /* Table of language-specific options. */
777 char *lang_options[] =
780 "-fallow-single-precision",
782 "-fsigned-bitfields",
783 "-funsigned-bitfields",
784 "-fno-signed-bitfields",
785 "-fno-unsigned-bitfields",
789 "-fno-unsigned-char",
805 "-fno-cond-mismatch",
806 "-fdollars-in-identifiers",
807 "-fno-dollars-in-identifiers",
816 "-Wbad-function-cast",
817 "-Wno-bad-function-cast",
821 "-Wno-char-subscripts",
832 "-Wimplicit-function-declaration",
833 "-Wno-implicit-function-declaration",
834 "-Werror-implicit-function-declaration",
842 "-Wno-missing-braces",
843 "-Wmissing-declarations",
844 "-Wno-missing-declarations",
845 "-Wmissing-prototypes",
846 "-Wno-missing-prototypes",
848 "-Wno-nested-externs",
852 "-Wno-pointer-arith",
854 "-Wno-redundant-decls",
858 "-Wno-unknown-pragmas",
859 "-Wstrict-prototypes",
860 "-Wno-strict-prototypes",
868 "-Wno-write-strings",
870 /* these are for obj c */
881 "-print-objc-runtime-info",
887 /* Options controlling warnings */
889 /* Don't print warning messages. -w. */
891 int inhibit_warnings = 0;
893 /* Print various extra warnings. -W. */
895 int extra_warnings = 0;
897 /* Treat warnings as errors. -Werror. */
899 int warnings_are_errors = 0;
901 /* Nonzero to warn about unused local variables. */
905 /* Nonzero to warn about variables used before they are initialized. */
907 int warn_uninitialized;
909 /* Nonzero means warn about all declarations which shadow others. */
913 /* Warn if a switch on an enum fails to have a case for every enum value. */
917 /* Nonzero means warn about function definitions that default the return type
918 or that use a null return and have a return-type other than void. */
920 int warn_return_type;
922 /* Nonzero means warn about pointer casts that increase the required
923 alignment of the target type (and might therefore lead to a crash
924 due to a misaligned access). */
928 /* Nonzero means warn about any identifiers that match in the first N
929 characters. The value N is in `id_clash_len'. */
932 unsigned id_clash_len;
934 /* Nonzero means warn about any objects definitions whose size is larger
935 than N bytes. Also want about function definitions whose returned
936 values are larger than N bytes. The value N is in `larger_than_size'. */
938 int warn_larger_than;
939 unsigned larger_than_size;
941 /* Nonzero means warn if inline function is too large. */
945 /* Warn if a function returns an aggregate,
946 since there are often incompatible calling conventions for doing this. */
948 int warn_aggregate_return;
950 /* Likewise for -W. */
952 struct { char *string; int *variable; int on_value;} W_options[] =
954 {"unused", &warn_unused, 1},
955 {"error", &warnings_are_errors, 1},
956 {"shadow", &warn_shadow, 1},
957 {"switch", &warn_switch, 1},
958 {"aggregate-return", &warn_aggregate_return, 1},
959 {"cast-align", &warn_cast_align, 1},
960 {"uninitialized", &warn_uninitialized, 1},
961 {"inline", &warn_inline, 1}
964 /* Output files for assembler code (real compiler output)
965 and debugging dumps. */
969 FILE *rtl_dump_file = NULL;
971 /* Time accumulators, to count the total time spent in various passes. */
975 int integration_time;
980 int branch_prob_time;
985 int local_alloc_time;
986 int global_alloc_time;
991 int shorten_branch_time;
997 /* Return time used so far, in microseconds. */
1007 #else /* not BeOS */
1008 #if defined (_WIN32) && !defined (__CYGWIN32__)
1012 return (clock() * 1000);
1013 #else /* not _WIN32 */
1019 tick = 1000000 / sysconf(_SC_CLK_TCK);
1021 return (tms.tms_utime + tms.tms_stime) * tick;
1028 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
1033 struct rusage rusage;
1034 getrusage (0, &rusage);
1035 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1036 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1043 int proc_system_time;
1044 int child_user_time;
1045 int child_system_time;
1047 times ((void *) &vms_times);
1048 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1052 #endif /* _SC_CLK_TCK */
1054 #endif /* __BEOS__ */
1057 #define TIMEVAR(VAR, BODY) \
1058 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1061 print_time (str, total)
1066 "time in %s: %d.%06d\n",
1067 str, total / 1000000, total % 1000000);
1070 /* Count an error or warning. Return 1 if the message should be printed. */
1073 count_error (warningp)
1076 if (warningp && inhibit_warnings)
1079 if (warningp && !warnings_are_errors)
1083 static int warning_message = 0;
1085 if (warningp && !warning_message)
1087 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1088 warning_message = 1;
1096 /* Print a fatal error message. NAME is the text.
1097 Also include a system error message based on `errno'. */
1100 pfatal_with_name (name)
1103 fprintf (stderr, "%s: ", progname);
1105 exit (FATAL_EXIT_CODE);
1109 fatal_io_error (name)
1112 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1113 exit (FATAL_EXIT_CODE);
1116 /* Called to give a better error message for a bad insn rather than
1117 just calling abort(). */
1120 fatal_insn (message, insn)
1127 fflush (asm_out_file);
1129 fflush (aux_info_file);
1130 if (rtl_dump_file != NULL)
1131 fflush (rtl_dump_file);
1137 /* Called to give a better error message when we don't have an insn to match
1138 what we are looking for or if the insn's constraints aren't satisfied,
1139 rather than just calling abort(). */
1142 fatal_insn_not_found (insn)
1145 if (INSN_CODE (insn) < 0)
1146 fatal_insn ("internal error--unrecognizable insn:", insn);
1148 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1151 /* This is the default decl_printable_name function. */
1154 decl_name (decl, verbosity)
1158 return IDENTIFIER_POINTER (DECL_NAME (decl));
1161 static int need_error_newline;
1163 /* Function of last error message;
1164 more generally, function such that if next error message is in it
1165 then we don't have to mention the function name. */
1166 static tree last_error_function = NULL;
1168 /* Used to detect when input_file_stack has changed since last described. */
1169 static int last_error_tick;
1171 /* Called when the start of a function definition is parsed,
1172 this function prints on stderr the name of the function. */
1175 announce_function (decl)
1180 if (rtl_dump_and_exit)
1181 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1183 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1185 need_error_newline = 1;
1186 last_error_function = current_function_decl;
1190 /* The default function to print out name of current function that caused
1194 default_print_error_function (file)
1197 if (last_error_function != current_function_decl)
1199 char *kind = "function";
1200 if (current_function_decl != 0
1201 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1205 fprintf (stderr, "%s: ", file);
1207 if (current_function_decl == NULL)
1208 fprintf (stderr, "At top level:\n");
1211 char *name = (*decl_printable_name) (current_function_decl, 2);
1212 fprintf (stderr, "In %s `%s':\n", kind, name);
1215 last_error_function = current_function_decl;
1219 /* Called by report_error_function to print out function name.
1220 * Default may be overridden by language front-ends. */
1222 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1224 /* Prints out, if necessary, the name of the current function
1225 that caused an error. Called from all error and warning functions. */
1228 report_error_function (file)
1231 struct file_stack *p;
1233 if (need_error_newline)
1235 fprintf (stderr, "\n");
1236 need_error_newline = 0;
1239 (*print_error_function) (file);
1241 if (input_file_stack && input_file_stack->next != 0
1242 && input_file_stack_tick != last_error_tick
1243 && file == input_filename)
1245 fprintf (stderr, "In file included");
1246 for (p = input_file_stack->next; p; p = p->next)
1248 fprintf (stderr, " from %s:%d", p->name, p->line);
1250 fprintf (stderr, ",\n ");
1252 fprintf (stderr, ":\n");
1253 last_error_tick = input_file_stack_tick;
1257 /* Print a message. */
1260 vmessage (prefix, s, ap)
1266 fprintf (stderr, "%s: ", prefix);
1269 vfprintf (stderr, s, ap);
1272 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1273 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1274 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1275 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1276 fprintf (stderr, s, v1, v2, v3, v4);
1281 /* Print a message relevant to line LINE of file FILE. */
1284 v_message_with_file_and_line (file, line, prefix, s, ap)
1292 fprintf (stderr, "%s:%d: ", file, line);
1294 fprintf (stderr, "%s: ", progname);
1296 vmessage (prefix, s, ap);
1297 fputc ('\n', stderr);
1300 /* Print a message relevant to the given DECL. */
1303 v_message_with_decl (decl, prefix, s, ap)
1311 fprintf (stderr, "%s:%d: ",
1312 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1315 fprintf (stderr, "%s: ", prefix);
1317 /* Do magic to get around lack of varargs support for insertion
1318 of arguments into existing list. We know that the decl is first;
1319 we ass_u_me that it will be printed with "%s". */
1321 for (p = s; *p; ++p)
1325 if (*(p + 1) == '%')
1332 if (p > s) /* Print the left-hand substring. */
1334 char fmt[sizeof "%.255s"];
1337 if (width > 255L) width = 255L; /* arbitrary */
1338 sprintf (fmt, "%%.%lds", width);
1339 fprintf (stderr, fmt, s);
1342 if (*p == '%') /* Print the name. */
1344 char *n = (DECL_NAME (decl)
1345 ? (*decl_printable_name) (decl, 2)
1351 if (isalpha (*(p - 1) & 0xFF))
1356 if (*p) /* Print the rest of the message. */
1357 vmessage ((char *)NULL, p, ap);
1359 fputc ('\n', stderr);
1362 /* Figure file and line of the given INSN. */
1365 file_and_line_for_asm (insn, pfile, pline)
1370 rtx body = PATTERN (insn);
1373 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1374 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1375 asmop = SET_SRC (body);
1376 else if (GET_CODE (body) == ASM_OPERANDS)
1378 else if (GET_CODE (body) == PARALLEL
1379 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1380 asmop = SET_SRC (XVECEXP (body, 0, 0));
1381 else if (GET_CODE (body) == PARALLEL
1382 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1383 asmop = XVECEXP (body, 0, 0);
1389 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1390 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1394 *pfile = input_filename;
1399 /* Report an error at line LINE of file FILE. */
1402 v_error_with_file_and_line (file, line, s, ap)
1409 report_error_function (file);
1410 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1414 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1426 file = va_arg (ap, char *);
1427 line = va_arg (ap, int);
1428 s = va_arg (ap, char *);
1431 v_error_with_file_and_line (file, line, s, ap);
1435 /* Report an error at the declaration DECL.
1436 S is a format string which uses %s to substitute the declaration
1437 name; subsequent substitutions are a la printf. */
1440 v_error_with_decl (decl, s, ap)
1446 report_error_function (DECL_SOURCE_FILE (decl));
1447 v_message_with_decl (decl, (char *)NULL, s, ap);
1451 error_with_decl VPROTO((tree decl, char *s, ...))
1462 decl = va_arg (ap, tree);
1463 s = va_arg (ap, char *);
1466 v_error_with_decl (decl, s, ap);
1470 /* Report an error at the line number of the insn INSN.
1471 This is used only when INSN is an `asm' with operands,
1472 and each ASM_OPERANDS records its own source file and line. */
1475 v_error_for_asm (insn, s, ap)
1484 file_and_line_for_asm (insn, &file, &line);
1485 report_error_function (file);
1486 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1490 error_for_asm VPROTO((rtx insn, char *s, ...))
1501 insn = va_arg (ap, rtx);
1502 s = va_arg (ap, char *);
1505 v_error_for_asm (insn, s, ap);
1509 /* Report an error at the current line number. */
1516 v_error_with_file_and_line (input_filename, lineno, s, ap);
1520 error VPROTO((char *s, ...))
1530 s = va_arg (ap, char *);
1537 /* Report a fatal error at the current line number. */
1545 exit (FATAL_EXIT_CODE);
1549 fatal VPROTO((char *s, ...))
1559 s = va_arg (ap, char *);
1566 /* Report a warning at line LINE of file FILE. */
1569 v_warning_with_file_and_line (file, line, s, ap)
1575 if (count_error (1))
1577 report_error_function (file);
1578 v_message_with_file_and_line (file, line, "warning", s, ap);
1583 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1595 file = va_arg (ap, char *);
1596 line = va_arg (ap, int);
1597 s = va_arg (ap, char *);
1600 v_warning_with_file_and_line (file, line, s, ap);
1604 /* Report a warning at the declaration DECL.
1605 S is a format string which uses %s to substitute the declaration
1606 name; subsequent substitutions are a la printf. */
1609 v_warning_with_decl (decl, s, ap)
1614 if (count_error (1))
1616 report_error_function (DECL_SOURCE_FILE (decl));
1617 v_message_with_decl (decl, "warning", s, ap);
1622 warning_with_decl VPROTO((tree decl, char *s, ...))
1633 decl = va_arg (ap, tree);
1634 s = va_arg (ap, char *);
1637 v_warning_with_decl (decl, s, ap);
1641 /* Report a warning at the line number of the insn INSN.
1642 This is used only when INSN is an `asm' with operands,
1643 and each ASM_OPERANDS records its own source file and line. */
1646 v_warning_for_asm (insn, s, ap)
1651 if (count_error (1))
1656 file_and_line_for_asm (insn, &file, &line);
1657 report_error_function (file);
1658 v_message_with_file_and_line (file, line, "warning", s, ap);
1663 warning_for_asm VPROTO((rtx insn, char *s, ...))
1674 insn = va_arg (ap, rtx);
1675 s = va_arg (ap, char *);
1678 v_warning_for_asm (insn, s, ap);
1682 /* Report a warning at the current line number. */
1689 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1693 warning VPROTO((char *s, ...))
1703 s = va_arg (ap, char *);
1710 /* These functions issue either warnings or errors depending on
1711 -pedantic-errors. */
1718 if (flag_pedantic_errors)
1725 pedwarn VPROTO((char *s, ...))
1735 s = va_arg (ap, char *);
1743 v_pedwarn_with_decl (decl, s, ap)
1748 /* We don't want -pedantic-errors to cause the compilation to fail from
1749 "errors" in system header files. Sometimes fixincludes can't fix what's
1750 broken (eg: unsigned char bitfields - fixing it may change the alignment
1751 which will cause programs to mysteriously fail because the C library
1752 or kernel uses the original layout). There's no point in issuing a
1753 warning either, it's just unnecessary noise. */
1755 if (! DECL_IN_SYSTEM_HEADER (decl))
1757 if (flag_pedantic_errors)
1758 v_error_with_decl (decl, s, ap);
1760 v_warning_with_decl (decl, s, ap);
1765 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1776 decl = va_arg (ap, tree);
1777 s = va_arg (ap, char *);
1780 v_pedwarn_with_decl (decl, s, ap);
1785 v_pedwarn_with_file_and_line (file, line, s, ap)
1791 if (flag_pedantic_errors)
1792 v_error_with_file_and_line (file, line, s, ap);
1794 v_warning_with_file_and_line (file, line, s, ap);
1798 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1810 file = va_arg (ap, char *);
1811 line = va_arg (ap, int);
1812 s = va_arg (ap, char *);
1815 v_pedwarn_with_file_and_line (file, line, s, ap);
1819 /* Apologize for not implementing some feature. */
1828 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1830 fprintf (stderr, "%s: ", progname);
1831 vmessage ("sorry, not implemented", s, ap);
1832 fputc ('\n', stderr);
1836 sorry VPROTO((char *s, ...))
1846 s = va_arg (ap, char *);
1853 /* Apologize for not implementing some feature, then quit. */
1856 v_really_sorry (s, ap)
1862 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1864 fprintf (stderr, "%s: ", progname);
1865 vmessage ("sorry, not implemented", s, ap);
1866 fatal (" (fatal)\n");
1870 really_sorry VPROTO((char *s, ...))
1880 s = va_arg (ap, char *);
1883 v_really_sorry (s, ap);
1887 /* More 'friendly' abort that prints the line and file.
1888 config.h can #define abort fancy_abort if you like that sort of thing.
1890 I don't think this is actually a good idea.
1891 Other sorts of crashes will look a certain way.
1892 It is a good thing if crashes from calling abort look the same way.
1898 fatal ("internal gcc abort");
1901 /* This calls abort and is used to avoid problems when abort if a macro.
1902 It is used when we need to pass the address of abort. */
1910 /* When `malloc.c' is compiled with `rcheck' defined,
1911 it calls this function to report clobberage. */
1920 /* Same as `malloc' but report error if no memory available. */
1926 register char *value = (char *) malloc (size);
1927 if (value == 0 && size != 0)
1928 fatal ("virtual memory exhausted");
1932 /* Same as `realloc' but report error if no memory available.
1933 Also handle null PTR even if the vendor realloc gets it wrong. */
1936 xrealloc (ptr, size)
1941 ? (char *) realloc (ptr, size)
1942 : (char *) malloc (size));
1944 fatal ("virtual memory exhausted");
1948 /* Same as `strdup' but report error if no memory available. */
1954 register char *result = (char *) malloc (strlen (s) + 1);
1957 fatal ("virtual memory exhausted");
1962 /* Return the logarithm of X, base 2, considering X unsigned,
1963 if X is a power of 2. Otherwise, returns -1.
1965 This should be used via the `exact_log2' macro. */
1969 register unsigned HOST_WIDE_INT x;
1971 register int log = 0;
1972 /* Test for 0 or a power of 2. */
1973 if (x == 0 || x != (x & -x))
1975 while ((x >>= 1) != 0)
1980 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1981 If X is 0, return -1.
1983 This should be used via the floor_log2 macro. */
1987 register unsigned HOST_WIDE_INT x;
1989 register int log = -1;
1996 static int float_handler_set;
1998 jmp_buf float_handler;
2000 /* Signals actually come here. */
2003 float_signal (signo)
2004 /* If this is missing, some compilers complain. */
2007 if (float_handled == 0)
2009 #if defined (USG) || defined (hpux)
2010 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2013 signal (SIGFPE, float_signal);
2014 longjmp (float_handler, 1);
2017 /* Specify where to longjmp to when a floating arithmetic error happens.
2018 If HANDLER is 0, it means don't handle the errors any more. */
2021 set_float_handler (handler)
2024 float_handled = (handler != 0);
2026 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2028 if (float_handled && ! float_handler_set)
2030 signal (SIGFPE, float_signal);
2031 float_handler_set = 1;
2035 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2036 error happens, pushing the previous specification into OLD_HANDLER.
2037 Return an indication of whether there was a previous handler in effect. */
2040 push_float_handler (handler, old_handler)
2041 jmp_buf handler, old_handler;
2043 int was_handled = float_handled;
2047 bcopy ((char *) float_handler, (char *) old_handler,
2048 sizeof (float_handler));
2050 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2054 /* Restore the previous specification of whether and where to longjmp to
2055 when a floating arithmetic error happens. */
2058 pop_float_handler (handled, handler)
2062 float_handled = handled;
2064 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2067 /* Handler for SIGPIPE. */
2071 /* If this is missing, some compilers complain. */
2074 fatal ("output pipe has been closed");
2077 /* Strip off a legitimate source ending from the input string NAME of
2078 length LEN. Rather than having to know the names used by all of
2079 our front ends, we strip off an ending of a period followed by
2080 up to five characters. (Java uses ".class".) */
2083 strip_off_ending (name, len)
2088 for (i = 2; i < 6 && len > i; i++)
2090 if (name[len - i] == '.')
2092 name[len - i] = '\0';
2098 /* Output a quoted string. */
2101 output_quoted_string (asm_file, string)
2105 #ifdef OUTPUT_QUOTED_STRING
2106 OUTPUT_QUOTED_STRING (asm_file, string);
2110 putc ('\"', asm_file);
2111 while ((c = *string++) != 0)
2113 if (c == '\"' || c == '\\')
2114 putc ('\\', asm_file);
2117 putc ('\"', asm_file);
2121 /* Output a file name in the form wanted by System V. */
2124 output_file_directive (asm_file, input_name)
2128 int len = strlen (input_name);
2129 char *na = input_name + len;
2131 /* NA gets INPUT_NAME sans directory names. */
2132 while (na > input_name)
2139 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2140 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2142 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2143 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2145 fprintf (asm_file, "\t.file\t");
2146 output_quoted_string (asm_file, na);
2147 fputc ('\n', asm_file);
2152 /* Routine to build language identifier for object file. */
2155 output_lang_identify (asm_out_file)
2158 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2159 char *s = (char *) alloca (len);
2160 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2161 ASM_OUTPUT_LABEL (asm_out_file, s);
2164 /* Routine to open a dump file. */
2166 open_dump_file (suffix, function_name)
2168 char *function_name;
2175 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2177 if (rtl_dump_file != NULL)
2178 fclose (rtl_dump_file);
2180 strcpy (dumpname, dump_base_name);
2181 strcat (dumpname, suffix);
2183 rtl_dump_file = fopen (dumpname, "a");
2185 if (rtl_dump_file == NULL)
2186 pfatal_with_name (dumpname);
2191 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2197 /* Routine to close a dump file. */
2199 close_dump_file (func, insns)
2200 void (*func) PROTO ((FILE *, rtx));
2207 func (rtl_dump_file, insns);
2209 fflush (rtl_dump_file);
2210 fclose (rtl_dump_file);
2212 rtl_dump_file = NULL;
2218 /* Routine to dump rtl into a file. */
2220 dump_rtl (suffix, decl, func, insns)
2223 void (*func) PROTO ((FILE *, rtx));
2226 open_dump_file (suffix, decl_printable_name (decl, 2));
2227 close_dump_file (func, insns);
2230 /* Routine to empty a dump file. */
2232 clean_dump_file (suffix)
2237 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2239 strcpy (dumpname, dump_base_name);
2240 strcat (dumpname, suffix);
2242 rtl_dump_file = fopen (dumpname, "w");
2244 if (rtl_dump_file == NULL)
2245 pfatal_with_name (dumpname);
2249 fclose (rtl_dump_file);
2250 rtl_dump_file = NULL;
2256 /* Compile an entire file of output from cpp, named NAME.
2257 Write a file of assembly output and various debugging dumps. */
2266 int name_specified = name != 0;
2268 if (dump_base_name == 0)
2269 dump_base_name = name ? name : "gccdump";
2273 integration_time = 0;
2278 branch_prob_time = 0;
2283 local_alloc_time = 0;
2284 global_alloc_time = 0;
2289 shorten_branch_time = 0;
2296 /* Open input file. */
2298 if (name == 0 || !strcmp (name, "-"))
2304 finput = fopen (name, "r");
2306 pfatal_with_name (name);
2308 #ifdef IO_BUFFER_SIZE
2309 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2311 #endif /* !USE_CPPLIB */
2313 /* Initialize data in various passes. */
2323 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2324 || debug_info_level == DINFO_LEVEL_VERBOSE
2325 || flag_test_coverage);
2327 init_decl_processing ();
2336 if (flag_caller_saves)
2337 init_caller_save ();
2339 /* If auxiliary info generation is desired, open the output file.
2340 This goes in the same directory as the source file--unlike
2341 all the other output files. */
2342 if (flag_gen_aux_info)
2344 aux_info_file = fopen (aux_info_file_name, "w");
2345 if (aux_info_file == 0)
2346 pfatal_with_name (aux_info_file_name);
2349 /* Clear the dump files file. */
2351 clean_dump_file (".rtl");
2353 clean_dump_file (".jump");
2355 clean_dump_file (".addressof");
2357 clean_dump_file (".cse");
2359 clean_dump_file (".loop");
2361 clean_dump_file (".cse2");
2362 if (branch_prob_dump)
2363 clean_dump_file (".bp");
2365 clean_dump_file (".flow");
2367 clean_dump_file (".combine");
2369 clean_dump_file (".regmove");
2371 clean_dump_file (".sched");
2373 clean_dump_file (".lreg");
2374 if (global_reg_dump)
2375 clean_dump_file (".greg");
2377 clean_dump_file (".sched2");
2379 clean_dump_file (".jump2");
2382 clean_dump_file (".dbr");
2386 clean_dump_file (".stack");
2388 #ifdef MACHINE_DEPENDENT_REORG
2389 if (mach_dep_reorg_dump)
2390 clean_dump_file (".mach");
2393 /* Open assembler code output file. */
2395 if (! name_specified && asm_file_name == 0)
2396 asm_out_file = stdout;
2399 int len = strlen (dump_base_name);
2400 register char *dumpname = (char *) xmalloc (len + 6);
2401 strcpy (dumpname, dump_base_name);
2402 strip_off_ending (dumpname, len);
2403 strcat (dumpname, ".s");
2404 if (asm_file_name == 0)
2406 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2407 strcpy (asm_file_name, dumpname);
2409 if (!strcmp (asm_file_name, "-"))
2410 asm_out_file = stdout;
2412 asm_out_file = fopen (asm_file_name, "w");
2413 if (asm_out_file == 0)
2414 pfatal_with_name (asm_file_name);
2417 #ifdef IO_BUFFER_SIZE
2418 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2419 _IOFBF, IO_BUFFER_SIZE);
2422 input_filename = name;
2424 /* Put an entry on the input file stack for the main input file. */
2426 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2427 input_file_stack->next = 0;
2428 input_file_stack->name = input_filename;
2430 /* Gross. Gross. lang_init is (I think) the first callback into
2431 the language front end, and is thus the first opportunity to
2432 have the selected language override the default value for any
2435 So the default value for flag_exceptions is 2 (uninitialized).
2436 If we encounter -fno-exceptions or -fexceptions, then flag_exceptions
2437 will be set to zero or one respectively.
2439 flag_exceptions can also be set by lang_init to something other
2440 than the default "uninitialized" value of 2.
2442 After lang_init, if the value is still 2, then we default to
2443 -fno-exceptions (value will be reset to zero).
2445 When our EH mechanism is low enough overhead that we can enable
2446 it by default for languages other than C++, then all this braindamage
2449 /* Perform language-specific initialization.
2450 This may set main_input_filename. */
2453 if (flag_exceptions == 2)
2454 flag_exceptions = 0;
2456 /* If the input doesn't start with a #line, use the input name
2457 as the official input file name. */
2458 if (main_input_filename == 0)
2459 main_input_filename = name;
2461 ASM_FILE_START (asm_out_file);
2463 #ifdef ASM_COMMENT_START
2464 if (flag_verbose_asm)
2466 /* Print the list of options in effect. */
2467 print_version (asm_out_file, ASM_COMMENT_START);
2468 print_switch_values (asm_out_file, 0, MAX_LINE,
2469 ASM_COMMENT_START, " ", "\n");
2470 /* Add a blank line here so it appears in assembler output but not
2472 fprintf (asm_out_file, "\n");
2476 /* Output something to inform GDB that this compilation was by GCC. */
2477 #ifndef ASM_IDENTIFY_GCC
2478 fprintf (asm_out_file, "gcc2_compiled.:\n");
2480 ASM_IDENTIFY_GCC (asm_out_file);
2483 /* Output something to identify which front-end produced this file. */
2484 #ifdef ASM_IDENTIFY_LANGUAGE
2485 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2488 #ifndef ASM_OUTPUT_SECTION_NAME
2489 if (flag_function_sections)
2491 warning ("-ffunction-sections not supported for this target.");
2492 flag_function_sections = 0;
2496 if (flag_function_sections
2497 && (profile_flag || profile_block_flag))
2499 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2500 flag_function_sections = 0;
2503 if (flag_function_sections && write_symbols != NO_DEBUG)
2504 warning ("-ffunction-sections may affect debugging on some targets.");
2506 /* ??? Note: There used to be a conditional here
2507 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2508 This was to guarantee separation between gcc_compiled. and
2509 the first function, for the sake of dbx on Suns.
2510 However, having the extra zero here confused the Emacs
2511 code for unexec, and might confuse other programs too.
2512 Therefore, I took out that change.
2513 In future versions we should find another way to solve
2514 that dbx problem. -- rms, 23 May 93. */
2516 /* Don't let the first function fall at the same address
2517 as gcc_compiled., if profiling. */
2518 if (profile_flag || profile_block_flag)
2519 assemble_zeros (UNITS_PER_WORD);
2521 /* If dbx symbol table desired, initialize writing it
2522 and output the predefined types. */
2523 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2524 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2525 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2528 #ifdef SDB_DEBUGGING_INFO
2529 if (write_symbols == SDB_DEBUG)
2530 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2533 #ifdef DWARF_DEBUGGING_INFO
2534 if (write_symbols == DWARF_DEBUG)
2535 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2537 #ifdef DWARF2_UNWIND_INFO
2538 if (dwarf2out_do_frame ())
2539 dwarf2out_frame_init ();
2541 #ifdef DWARF2_DEBUGGING_INFO
2542 if (write_symbols == DWARF2_DEBUG)
2543 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2546 /* Initialize yet another pass. */
2548 init_final (main_input_filename);
2549 init_branch_prob (dump_base_name);
2551 start_time = get_run_time ();
2553 /* Call the parser, which parses the entire file
2554 (calling rest_of_compilation for each function). */
2556 if (yyparse () != 0)
2558 if (errorcount == 0)
2559 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2561 /* In case there were missing closebraces,
2562 get us back to the global binding level. */
2563 while (! global_bindings_p ())
2567 output_func_start_profiler ();
2569 /* Compilation is now finished except for writing
2570 what's left of the symbol table output. */
2572 parse_time += get_run_time () - start_time;
2574 parse_time -= integration_time;
2575 parse_time -= varconst_time;
2577 globals = getdecls ();
2579 /* Really define vars that have had only a tentative definition.
2580 Really output inline functions that must actually be callable
2581 and have not been output so far. */
2584 int len = list_length (globals);
2585 tree *vec = (tree *) alloca (sizeof (tree) * len);
2590 /* Process the decls in reverse order--earliest first.
2591 Put them into VEC from back to front, then take out from front. */
2593 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2594 vec[len - i - 1] = decl;
2596 for (i = 0; i < len; i++)
2600 /* We're not deferring this any longer. */
2601 DECL_DEFER_OUTPUT (decl) = 0;
2603 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2604 && incomplete_decl_finalize_hook != 0)
2605 (*incomplete_decl_finalize_hook) (decl);
2608 /* Now emit any global variables or functions that we have been putting
2609 off. We need to loop in case one of the things emitted here
2610 references another one which comes earlier in the list. */
2614 for (i = 0; i < len; i++)
2618 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2621 /* Don't write out static consts, unless we still need them.
2623 We also keep static consts if not optimizing (for debugging),
2624 unless the user specified -fno-keep-static-consts.
2625 ??? They might be better written into the debug information.
2626 This is possible when using DWARF.
2628 A language processor that wants static constants to be always
2629 written out (even if it is not used) is responsible for
2630 calling rest_of_decl_compilation itself. E.g. the C front-end
2631 calls rest_of_decl_compilation from finish_decl.
2632 One motivation for this is that is conventional in some
2633 environments to write things like:
2634 static const char rcsid[] = "... version string ...";
2635 intending to force the string to be in the executable.
2637 A language processor that would prefer to have unneeded
2638 static constants "optimized away" would just defer writing
2639 them out until here. E.g. C++ does this, because static
2640 constants are often defined in header files.
2642 ??? A tempting alternative (for both C and C++) would be
2643 to force a constant to be written if and only if it is
2644 defined in a main file, as opposed to an include file. */
2646 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2647 && (! TREE_READONLY (decl)
2648 || TREE_PUBLIC (decl)
2649 || (!optimize && flag_keep_static_consts)
2650 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2653 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2656 if (TREE_CODE (decl) == FUNCTION_DECL
2657 && DECL_INITIAL (decl) != 0
2658 && DECL_SAVED_INSNS (decl) != 0
2659 && (flag_keep_inline_functions
2660 || TREE_PUBLIC (decl)
2661 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2664 temporary_allocation ();
2665 output_inline_function (decl);
2666 permanent_allocation (1);
2671 /* Now that all possible functions have been output, we can dump
2672 the exception table. */
2674 output_exception_table ();
2676 for (i = 0; i < len; i++)
2680 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2681 && ! TREE_ASM_WRITTEN (decl))
2682 /* Cancel the RTL for this decl so that, if debugging info
2683 output for global variables is still to come,
2684 this one will be omitted. */
2685 DECL_RTL (decl) = NULL;
2687 /* Warn about any function
2688 declared static but not defined.
2689 We don't warn about variables,
2690 because many programs have static variables
2691 that exist only to get some text into the object file. */
2692 if (TREE_CODE (decl) == FUNCTION_DECL
2694 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2695 && DECL_INITIAL (decl) == 0
2696 && DECL_EXTERNAL (decl)
2697 && ! DECL_ARTIFICIAL (decl)
2698 && ! TREE_PUBLIC (decl))
2700 pedwarn_with_decl (decl,
2701 "`%s' declared `static' but never defined");
2702 /* This symbol is effectively an "extern" declaration now. */
2703 TREE_PUBLIC (decl) = 1;
2704 assemble_external (decl);
2707 /* Warn about static fns or vars defined but not used,
2708 but not about inline functions or static consts
2709 since defining those in header files is normal practice. */
2711 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2712 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2713 && ! DECL_IN_SYSTEM_HEADER (decl)
2714 && ! DECL_EXTERNAL (decl)
2715 && ! TREE_PUBLIC (decl)
2716 && ! TREE_USED (decl)
2717 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2718 /* The TREE_USED bit for file-scope decls
2719 is kept in the identifier, to handle multiple
2720 external decls in different scopes. */
2721 && ! TREE_USED (DECL_NAME (decl)))
2722 warning_with_decl (decl, "`%s' defined but not used");
2724 #ifdef SDB_DEBUGGING_INFO
2725 /* The COFF linker can move initialized global vars to the end.
2726 And that can screw up the symbol ordering.
2727 By putting the symbols in that order to begin with,
2728 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2729 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2730 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2731 && ! DECL_EXTERNAL (decl)
2732 && DECL_RTL (decl) != 0)
2733 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2735 /* Output COFF information for non-global
2736 file-scope initialized variables. */
2737 if (write_symbols == SDB_DEBUG
2738 && TREE_CODE (decl) == VAR_DECL
2739 && DECL_INITIAL (decl)
2740 && ! DECL_EXTERNAL (decl)
2741 && DECL_RTL (decl) != 0
2742 && GET_CODE (DECL_RTL (decl)) == MEM)
2743 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2744 #endif /* SDB_DEBUGGING_INFO */
2745 #ifdef DWARF_DEBUGGING_INFO
2746 /* Output DWARF information for file-scope tentative data object
2747 declarations, file-scope (extern) function declarations (which
2748 had no corresponding body) and file-scope tagged type declarations
2749 and definitions which have not yet been forced out. */
2751 if (write_symbols == DWARF_DEBUG
2752 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2753 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2755 #ifdef DWARF2_DEBUGGING_INFO
2756 /* Output DWARF2 information for file-scope tentative data object
2757 declarations, file-scope (extern) function declarations (which
2758 had no corresponding body) and file-scope tagged type declarations
2759 and definitions which have not yet been forced out. */
2761 if (write_symbols == DWARF2_DEBUG
2762 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2763 TIMEVAR (symout_time, dwarf2out_decl (decl));
2768 /* Write out any pending weak symbol declarations. */
2772 /* Do dbx symbols */
2773 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2774 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2775 TIMEVAR (symout_time,
2777 dbxout_finish (asm_out_file, main_input_filename);
2781 #ifdef DWARF_DEBUGGING_INFO
2782 if (write_symbols == DWARF_DEBUG)
2783 TIMEVAR (symout_time,
2789 #ifdef DWARF2_UNWIND_INFO
2790 if (dwarf2out_do_frame ())
2791 dwarf2out_frame_finish ();
2794 #ifdef DWARF2_DEBUGGING_INFO
2795 if (write_symbols == DWARF2_DEBUG)
2796 TIMEVAR (symout_time,
2798 dwarf2out_finish ();
2802 /* Output some stuff at end of file if nec. */
2804 end_final (dump_base_name);
2806 if (branch_prob_dump)
2807 open_dump_file (".bp", NULL);
2809 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2811 if (branch_prob_dump)
2812 close_dump_file (NULL, NULL_RTX);
2815 ASM_FILE_END (asm_out_file);
2818 /* Language-specific end of compilation actions. */
2822 /* Close the dump files. */
2824 if (flag_gen_aux_info)
2826 fclose (aux_info_file);
2828 unlink (aux_info_file_name);
2833 open_dump_file (".combine", NULL);
2834 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2835 close_dump_file (NULL, NULL_RTX);
2838 /* Close non-debugging input and output files. Take special care to note
2839 whether fclose returns an error, since the pages might still be on the
2840 buffer chain while the file is open. */
2847 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2848 fatal_io_error (asm_file_name);
2850 /* Print the times. */
2854 fprintf (stderr,"\n");
2855 print_time ("parse", parse_time);
2857 print_time ("integration", integration_time);
2858 print_time ("jump", jump_time);
2859 print_time ("cse", cse_time);
2860 print_time ("loop", loop_time);
2861 print_time ("cse2", cse2_time);
2862 print_time ("branch-prob", branch_prob_time);
2863 print_time ("flow", flow_time);
2864 print_time ("combine", combine_time);
2865 print_time ("regmove", regmove_time);
2866 print_time ("sched", sched_time);
2867 print_time ("local-alloc", local_alloc_time);
2868 print_time ("global-alloc", global_alloc_time);
2869 print_time ("sched2", sched2_time);
2871 print_time ("dbranch", dbr_sched_time);
2873 print_time ("shorten-branch", shorten_branch_time);
2874 print_time ("stack-reg", stack_reg_time);
2875 print_time ("final", final_time);
2876 print_time ("varconst", varconst_time);
2877 print_time ("symout", symout_time);
2878 print_time ("dump", dump_time);
2882 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2883 and TYPE_DECL nodes.
2885 This does nothing for local (non-static) variables.
2886 Otherwise, it sets up the RTL and outputs any assembler code
2887 (label definition, storage allocation and initialization).
2889 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2890 the assembler symbol name to be used. TOP_LEVEL is nonzero
2891 if this declaration is not within a function. */
2894 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2900 /* Declarations of variables, and of functions defined elsewhere. */
2902 /* The most obvious approach, to put an #ifndef around where
2903 this macro is used, doesn't work since it's inside a macro call. */
2904 #ifndef ASM_FINISH_DECLARE_OBJECT
2905 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2908 /* Forward declarations for nested functions are not "external",
2909 but we need to treat them as if they were. */
2910 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2911 || TREE_CODE (decl) == FUNCTION_DECL)
2912 TIMEVAR (varconst_time,
2914 make_decl_rtl (decl, asmspec, top_level);
2915 /* Initialized extern variable exists to be replaced
2916 with its value, or represents something that will be
2917 output in another file. */
2918 if (! (TREE_CODE (decl) == VAR_DECL
2919 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2920 && DECL_INITIAL (decl) != 0
2921 && DECL_INITIAL (decl) != error_mark_node))
2922 /* Don't output anything
2923 when a tentative file-scope definition is seen.
2924 But at end of compilation, do output code for them. */
2925 if (! (! at_end && top_level
2926 && (DECL_INITIAL (decl) == 0
2927 || DECL_INITIAL (decl) == error_mark_node)))
2928 assemble_variable (decl, top_level, at_end, 0);
2929 if (decl == last_assemble_variable_decl)
2931 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2935 else if (DECL_REGISTER (decl) && asmspec != 0)
2937 if (decode_reg_name (asmspec) >= 0)
2939 DECL_RTL (decl) = 0;
2940 make_decl_rtl (decl, asmspec, top_level);
2943 error ("invalid register name `%s' for register variable", asmspec);
2945 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2946 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2947 && TREE_CODE (decl) == TYPE_DECL)
2948 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2950 #ifdef SDB_DEBUGGING_INFO
2951 else if (write_symbols == SDB_DEBUG && top_level
2952 && TREE_CODE (decl) == TYPE_DECL)
2953 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2957 /* Called after finishing a record, union or enumeral type. */
2960 rest_of_type_compilation (type, toplev)
2964 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2965 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2966 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2968 #ifdef SDB_DEBUGGING_INFO
2969 if (write_symbols == SDB_DEBUG)
2970 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2974 /* This is called from finish_function (within yyparse)
2975 after each top-level definition is parsed.
2976 It is supposed to compile that function or variable
2977 and output the assembler code for it.
2978 After we return, the tree storage is freed. */
2981 rest_of_compilation (decl)
2985 int start_time = get_run_time ();
2987 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2988 to be restored after we finish compiling the function
2989 (for use when compiling inline calls to this function). */
2990 tree saved_block_tree = 0;
2991 /* Likewise, for DECL_ARGUMENTS. */
2992 tree saved_arguments = 0;
2995 /* If we are reconsidering an inline function
2996 at the end of compilation, skip the stuff for making it inline. */
2998 if (DECL_SAVED_INSNS (decl) == 0)
3003 /* If requested, consider whether to make this function inline. */
3004 if (DECL_INLINE (decl) || flag_inline_functions)
3005 TIMEVAR (integration_time,
3007 lose = function_cannot_inline_p (decl);
3008 if (lose || ! optimize)
3010 if (warn_inline && DECL_INLINE (decl))
3011 warning_with_decl (decl, lose);
3012 DECL_ABSTRACT_ORIGIN (decl) = 0;
3013 /* Don't really compile an extern inline function.
3014 If we can't make it inline, pretend
3015 it was only declared. */
3016 if (DECL_EXTERNAL (decl))
3018 DECL_INITIAL (decl) = 0;
3019 goto exit_rest_of_compilation;
3023 /* ??? Note that this has the effect of making it look
3024 like "inline" was specified for a function if we choose
3025 to inline it. This isn't quite right, but it's
3026 probably not worth the trouble to fix. */
3027 inlinable = DECL_INLINE (decl) = 1;
3030 insns = get_insns ();
3032 /* Dump the rtl code if we are dumping rtl. */
3036 open_dump_file (".rtl", decl_printable_name (decl, 2));
3038 if (DECL_SAVED_INSNS (decl))
3039 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3041 close_dump_file (print_rtl, insns);
3044 /* If we can, defer compiling inlines until EOF.
3045 save_for_inline_copying can be extremely expensive. */
3046 if (inlinable && ! decl_function_context (decl))
3047 DECL_DEFER_OUTPUT (decl) = 1;
3049 /* If function is inline, and we don't yet know whether to
3050 compile it by itself, defer decision till end of compilation.
3051 finish_compilation will call rest_of_compilation again
3052 for those functions that need to be output. Also defer those
3053 functions that we are supposed to defer. We cannot defer
3054 functions containing nested functions since the nested function
3055 data is in our non-saved obstack. */
3057 /* If this is a nested inline, remove ADDRESSOF now so we can
3058 finish compiling ourselves. Otherwise, wait until EOF.
3059 We have to do this because the purge_addressof transformation
3060 changes the DECL_RTL for many variables, which confuses integrate. */
3063 if (decl_function_context (decl))
3064 purge_addressof (insns);
3066 DECL_DEFER_OUTPUT (decl) = 1;
3069 if (! current_function_contains_functions
3070 && (DECL_DEFER_OUTPUT (decl)
3071 || (DECL_INLINE (decl)
3072 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3073 && ! flag_keep_inline_functions)
3074 || DECL_EXTERNAL (decl)))))
3076 DECL_DEFER_OUTPUT (decl) = 1;
3078 /* If -Wreturn-type, we have to do a bit of compilation.
3079 However, if we just fall through we will call
3080 save_for_inline_copying() which results in excessive
3081 memory use. Instead, we just want to call
3082 jump_optimize() to figure out whether or not we can fall
3083 off the end of the function; we do the minimum amount of
3084 work necessary to make that safe. And, we set optimize
3085 to zero to keep jump_optimize from working too hard. */
3086 if (warn_return_type)
3088 int saved_optimize = optimize;
3090 find_exception_handler_labels ();
3091 jump_optimize (get_insns(), 0, 0, 0);
3092 optimize = saved_optimize;
3095 #ifdef DWARF_DEBUGGING_INFO
3096 /* Generate the DWARF info for the "abstract" instance
3097 of a function which we may later generate inlined and/or
3098 out-of-line instances of. */
3099 if (write_symbols == DWARF_DEBUG)
3101 set_decl_abstract_flags (decl, 1);
3102 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3103 set_decl_abstract_flags (decl, 0);
3106 #ifdef DWARF2_DEBUGGING_INFO
3107 /* Generate the DWARF2 info for the "abstract" instance
3108 of a function which we may later generate inlined and/or
3109 out-of-line instances of. */
3110 if (write_symbols == DWARF2_DEBUG)
3112 set_decl_abstract_flags (decl, 1);
3113 TIMEVAR (symout_time, dwarf2out_decl (decl));
3114 set_decl_abstract_flags (decl, 0);
3117 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3118 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3119 goto exit_rest_of_compilation;
3122 /* If we have to compile the function now, save its rtl and subdecls
3123 so that its compilation will not affect what others get. */
3124 if (inlinable || DECL_DEFER_OUTPUT (decl))
3126 #ifdef DWARF_DEBUGGING_INFO
3127 /* Generate the DWARF info for the "abstract" instance of
3128 a function which we will generate an out-of-line instance
3129 of almost immediately (and which we may also later generate
3130 various inlined instances of). */
3131 if (write_symbols == DWARF_DEBUG)
3133 set_decl_abstract_flags (decl, 1);
3134 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3135 set_decl_abstract_flags (decl, 0);
3138 #ifdef DWARF2_DEBUGGING_INFO
3139 /* Generate the DWARF2 info for the "abstract" instance of
3140 a function which we will generate an out-of-line instance
3141 of almost immediately (and which we may also later generate
3142 various inlined instances of). */
3143 if (write_symbols == DWARF2_DEBUG)
3145 set_decl_abstract_flags (decl, 1);
3146 TIMEVAR (symout_time, dwarf2out_decl (decl));
3147 set_decl_abstract_flags (decl, 0);
3150 saved_block_tree = DECL_INITIAL (decl);
3151 saved_arguments = DECL_ARGUMENTS (decl);
3152 TIMEVAR (integration_time, save_for_inline_copying (decl));
3153 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3156 /* If specified extern inline but we aren't inlining it, we are
3158 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3159 goto exit_rest_of_compilation;
3162 if (! DECL_DEFER_OUTPUT (decl))
3163 TREE_ASM_WRITTEN (decl) = 1;
3165 /* Now that integrate will no longer see our rtl, we need not distinguish
3166 between the return value of this function and the return value of called
3168 rtx_equal_function_value_matters = 0;
3170 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3171 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3173 goto exit_rest_of_compilation;
3176 /* Emit code to get eh context, if needed. */
3180 /* If we are doing position-independent code generation, now
3181 is the time to output special prologues and epilogues.
3182 We do not want to do this earlier, because it just clutters
3183 up inline functions with meaningless insns. */
3188 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3189 Note that that may have been done above, in save_for_inline_copying.
3190 The call to resume_temporary_allocation near the end of this function
3191 goes back to the usual state of affairs. This must be done after
3192 we've built up any unwinders for exception handling, and done
3193 the FINALIZE_PIC work, if necessary. */
3195 rtl_in_current_obstack ();
3197 insns = get_insns ();
3199 /* Copy any shared structure that should not be shared. */
3201 unshare_all_rtl (insns);
3203 #ifdef SETJMP_VIA_SAVE_AREA
3204 /* This must be performed before virutal register instantiation. */
3205 if (current_function_calls_alloca)
3206 optimize_save_area_alloca (insns);
3209 /* Instantiate all virtual registers. */
3211 instantiate_virtual_regs (current_function_decl, get_insns ());
3213 /* See if we have allocated stack slots that are not directly addressable.
3214 If so, scan all the insns and create explicit address computation
3215 for all references to such slots. */
3216 /* fixup_stack_slots (); */
3218 /* Find all the EH handlers. */
3219 find_exception_handler_labels ();
3221 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3222 are initialized and to compute whether control can drop off the end
3224 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3225 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3227 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3228 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3229 goto exit_rest_of_compilation;
3231 /* Dump rtl code after jump, if we are doing that. */
3234 dump_rtl (".jump", decl, print_rtl, insns);
3236 /* Perform common subexpression elimination.
3237 Nonzero value from `cse_main' means that jumps were simplified
3238 and some code may now be unreachable, so do
3239 jump optimization again. */
3244 open_dump_file (".cse", decl_printable_name (decl, 2));
3246 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3248 if (flag_thread_jumps)
3249 /* Hacks by tiemann & kenner. */
3250 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3252 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3254 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3256 if (tem || optimize > 1)
3257 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3259 /* Dump rtl code after cse, if we are doing that. */
3262 close_dump_file (print_rtl, insns);
3265 purge_addressof (insns);
3266 reg_scan (insns, max_reg_num (), 1);
3269 dump_rtl (".addressof", decl, print_rtl, insns);
3271 /* Move constant computations out of loops. */
3276 open_dump_file (".loop", decl_printable_name (decl, 2));
3281 if (flag_rerun_loop_opt)
3283 /* We only want to perform unrolling once. */
3285 loop_optimize (insns, rtl_dump_file, 0);
3287 /* The regscan pass may not be necessary, but let's
3288 be safe until we can prove otherwise. */
3289 reg_scan (insns, max_reg_num (), 1);
3291 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3294 /* Dump rtl code after loop opt, if we are doing that. */
3297 close_dump_file (print_rtl, insns);
3303 open_dump_file (".cse2", decl_printable_name (decl, 2));
3305 if (flag_rerun_cse_after_loop)
3307 /* Running another jump optimization pass before the second
3308 cse pass sometimes simplifies the RTL enough to allow
3309 the second CSE pass to do a better job. Jump_optimize can change
3310 max_reg_num so we must rerun reg_scan afterwards.
3311 ??? Rework to not call reg_scan so often. */
3312 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3313 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3315 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3316 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3319 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3322 if (flag_thread_jumps)
3324 /* This pass of jump threading straightens out code
3325 that was kinked by loop optimization. */
3326 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3327 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3330 /* Dump rtl code after cse, if we are doing that. */
3333 close_dump_file (print_rtl, insns);
3336 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3338 if (branch_prob_dump)
3339 open_dump_file (".bp", decl_printable_name (decl, 2));
3344 branch_prob (insns, rtl_dump_file);
3347 if (branch_prob_dump)
3348 close_dump_file (print_rtl, insns);
3351 /* We are no longer anticipating cse in this function, at least. */
3353 cse_not_expected = 1;
3355 /* Now we choose between stupid (pcc-like) register allocation
3356 (if we got the -noreg switch and not -opt)
3357 and smart register allocation. */
3359 if (optimize > 0) /* Stupid allocation probably won't work */
3360 obey_regdecls = 0; /* if optimizations being done. */
3364 /* Print function header into flow dump now
3365 because doing the flow analysis makes some of the dump. */
3368 open_dump_file (".flow", decl_printable_name (decl, 2));
3374 regclass (insns, max_reg_num ());
3375 stupid_life_analysis (insns, max_reg_num (),
3381 /* Do control and data flow analysis,
3382 and write some of the results to dump file. */
3384 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3386 if (warn_uninitialized)
3388 uninitialized_vars_warning (DECL_INITIAL (decl));
3389 setjmp_args_warning ();
3393 /* Dump rtl after flow analysis. */
3396 close_dump_file (print_rtl_with_bb, insns);
3398 /* If -opt, try combining insns through substitution. */
3402 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3404 /* Dump rtl code after insn combination. */
3407 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3410 /* Register allocation pre-pass, to reduce number of moves
3411 necessary for two-address machines. */
3412 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3415 open_dump_file (".regmove", decl_printable_name (decl, 2));
3417 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3421 close_dump_file (print_rtl_with_bb, insns);
3424 /* Print function header into sched dump now
3425 because doing the sched analysis makes some of the dump. */
3427 if (optimize > 0 && flag_schedule_insns)
3430 open_dump_file (".sched", decl_printable_name (decl, 2));
3432 /* Do control and data sched analysis,
3433 and write some of the results to dump file. */
3435 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3437 /* Dump rtl after instruction scheduling. */
3440 close_dump_file (print_rtl_with_bb, insns);
3443 /* Unless we did stupid register allocation,
3444 allocate pseudo-regs that are used only within 1 basic block. */
3447 TIMEVAR (local_alloc_time,
3449 regclass (insns, max_reg_num ());
3453 /* Dump rtl code after allocating regs within basic blocks. */
3457 open_dump_file (".lreg", decl_printable_name (decl, 2));
3459 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3460 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3462 close_dump_file (print_rtl_with_bb, insns);
3465 if (global_reg_dump)
3466 open_dump_file (".greg", decl_printable_name (decl, 2));
3468 /* Save the last label number used so far, so reorg can tell
3469 when it's safe to kill spill regs. */
3470 max_label_num_after_reload = max_label_num ();
3472 /* Unless we did stupid register allocation,
3473 allocate remaining pseudo-regs, then do the reload pass
3474 fixing up any insns that are invalid. */
3476 TIMEVAR (global_alloc_time,
3479 failure = global_alloc (rtl_dump_file);
3481 failure = reload (insns, 0, rtl_dump_file);
3484 if (global_reg_dump)
3486 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3487 close_dump_file (print_rtl_with_bb, insns);
3491 goto exit_rest_of_compilation;
3493 reload_completed = 1;
3495 /* Do a very simple CSE pass over just the hard registers. */
3497 reload_cse_regs (insns);
3499 /* On some machines, the prologue and epilogue code, or parts thereof,
3500 can be represented as RTL. Doing so lets us schedule insns between
3501 it and the rest of the code and also allows delayed branch
3502 scheduling to operate in the epilogue. */
3504 thread_prologue_and_epilogue_insns (insns);
3506 if (optimize > 0 && flag_schedule_insns_after_reload)
3509 open_dump_file (".sched2", decl_printable_name (decl, 2));
3511 /* Do control and data sched analysis again,
3512 and write some more of the results to dump file. */
3514 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3516 /* Dump rtl after post-reorder instruction scheduling. */
3519 close_dump_file (print_rtl_with_bb, insns);
3522 #ifdef LEAF_REGISTERS
3524 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3528 /* One more attempt to remove jumps to .+1
3529 left by dead-store-elimination.
3530 Also do cross-jumping this time
3531 and delete no-op move insns. */
3535 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3537 /* Dump rtl code after jump, if we are doing that. */
3540 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3543 /* If a machine dependent reorganization is needed, call it. */
3544 #ifdef MACHINE_DEPENDENT_REORG
3545 MACHINE_DEPENDENT_REORG (insns);
3547 if (mach_dep_reorg_dump)
3548 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3551 /* If a scheduling pass for delayed branches is to be done,
3552 call the scheduling code. */
3555 if (optimize > 0 && flag_delayed_branch)
3557 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file));
3560 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3564 /* Shorten branches. */
3565 TIMEVAR (shorten_branch_time,
3567 shorten_branches (get_insns ());
3571 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3574 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3577 /* Now turn the rtl into assembler code. */
3579 TIMEVAR (final_time,
3584 /* Get the function's name, as described by its RTL.
3585 This may be different from the DECL_NAME name used
3586 in the source file. */
3588 x = DECL_RTL (decl);
3589 if (GET_CODE (x) != MEM)
3592 if (GET_CODE (x) != SYMBOL_REF)
3594 fnname = XSTR (x, 0);
3596 assemble_start_function (decl, fnname);
3597 final_start_function (insns, asm_out_file, optimize);
3598 final (insns, asm_out_file, optimize, 0);
3599 final_end_function (insns, asm_out_file, optimize);
3600 assemble_end_function (decl, fnname);
3601 fflush (asm_out_file);
3603 /* Release all memory held by regsets now */
3604 regset_release_memory ();
3607 /* Write DBX symbols if requested */
3609 /* Note that for those inline functions where we don't initially
3610 know for certain that we will be generating an out-of-line copy,
3611 the first invocation of this routine (rest_of_compilation) will
3612 skip over this code by doing a `goto exit_rest_of_compilation;'.
3613 Later on, finish_compilation will call rest_of_compilation again
3614 for those inline functions that need to have out-of-line copies
3615 generated. During that call, we *will* be routed past here. */
3617 #ifdef DBX_DEBUGGING_INFO
3618 if (write_symbols == DBX_DEBUG)
3619 TIMEVAR (symout_time, dbxout_function (decl));
3622 #ifdef DWARF_DEBUGGING_INFO
3623 if (write_symbols == DWARF_DEBUG)
3624 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3627 #ifdef DWARF2_DEBUGGING_INFO
3628 if (write_symbols == DWARF2_DEBUG)
3629 TIMEVAR (symout_time, dwarf2out_decl (decl));
3632 exit_rest_of_compilation:
3634 /* In case the function was not output,
3635 don't leave any temporary anonymous types
3636 queued up for sdb output. */
3637 #ifdef SDB_DEBUGGING_INFO
3638 if (write_symbols == SDB_DEBUG)
3639 sdbout_types (NULL_TREE);
3642 /* Put back the tree of subblocks and list of arguments
3643 from before we copied them.
3644 Code generation and the output of debugging info may have modified
3645 the copy, but the original is unchanged. */
3647 if (saved_block_tree != 0)
3649 DECL_INITIAL (decl) = saved_block_tree;
3650 DECL_ARGUMENTS (decl) = saved_arguments;
3651 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3654 reload_completed = 0;
3656 /* Clear out the insn_length contents now that they are no longer valid. */
3657 init_insn_lengths ();
3659 /* Clear out the real_constant_chain before some of the rtx's
3660 it runs through become garbage. */
3662 clear_const_double_mem ();
3664 /* Cancel the effect of rtl_in_current_obstack. */
3666 resume_temporary_allocation ();
3668 /* Show no temporary slots allocated. */
3672 /* The parsing time is all the time spent in yyparse
3673 *except* what is spent in this function. */
3675 parse_time -= get_run_time () - start_time;
3678 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3679 Exit code is 35 if can't open files, 34 if fatal error,
3680 33 if had nonfatal errors, else success. */
3683 main (argc, argv, envp)
3690 int flag_print_mem = 0;
3691 int version_flag = 0;
3694 /* save in case md file wants to emit args as a comment. */
3698 p = argv[0] + strlen (argv[0]);
3699 while (p != argv[0] && p[-1] != '/'
3700 #ifdef DIR_SEPARATOR
3701 && p[-1] != DIR_SEPARATOR
3707 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3708 /* Get rid of any avoidable limit on stack size. */
3712 /* Set the stack limit huge so that alloca does not fail. */
3713 getrlimit (RLIMIT_STACK, &rlim);
3714 rlim.rlim_cur = rlim.rlim_max;
3715 setrlimit (RLIMIT_STACK, &rlim);
3719 signal (SIGFPE, float_signal);
3722 signal (SIGPIPE, pipe_closed);
3725 decl_printable_name = decl_name;
3726 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3728 /* Initialize whether `char' is signed. */
3729 flag_signed_char = DEFAULT_SIGNED_CHAR;
3730 #ifdef DEFAULT_SHORT_ENUMS
3731 /* Initialize how much space enums occupy, by default. */
3732 flag_short_enums = DEFAULT_SHORT_ENUMS;
3735 /* Scan to see what optimization level has been specified. That will
3736 determine the default value of many flags. */
3737 for (i = 1; i < argc; i++)
3739 if (!strcmp (argv[i], "-O"))
3743 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3745 /* Handle -Os, -O2, -O3, -O69, ... */
3746 char *p = &argv[i][2];
3749 if ((p[0] == 's') && (p[1] == 0))
3754 if (! (c >= '0' && c <= '9'))
3757 optimize = atoi (&argv[i][2]);
3762 /* Optimizing for size forces optimize to be no less than 2. */
3763 if (optimize_size && (optimize < 2))
3766 obey_regdecls = (optimize == 0);
3771 flag_thread_jumps = 1;
3773 flag_delayed_branch = 1;
3775 #ifdef CAN_DEBUG_WITHOUT_FP
3776 flag_omit_frame_pointer = 1;
3782 flag_cse_follow_jumps = 1;
3783 flag_cse_skip_blocks = 1;
3784 flag_expensive_optimizations = 1;
3785 flag_strength_reduce = 1;
3786 flag_rerun_cse_after_loop = 1;
3787 flag_rerun_loop_opt = 1;
3788 flag_caller_saves = 1;
3790 #ifdef INSN_SCHEDULING
3791 flag_schedule_insns = 1;
3792 flag_schedule_insns_after_reload = 1;
3799 flag_inline_functions = 1;
3802 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3805 set_target_switch ("");
3807 #ifdef OPTIMIZATION_OPTIONS
3808 /* Allow default optimizations to be specified on a per-machine basis. */
3809 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3812 /* Initialize register usage now so switches may override. */
3815 for (i = 1; i < argc; i++)
3818 /* If this is a language-specific option,
3819 decode it in a language-specific way. */
3820 for (j = 0; lang_options[j] != 0; j++)
3821 if (!strncmp (argv[i], lang_options[j],
3822 strlen (lang_options[j])))
3824 if (lang_options[j] != 0)
3825 /* If the option is valid for *some* language,
3826 treat it as valid even if this language doesn't understand it. */
3827 lang_decode_option (argv[i]);
3828 else if (argv[i][0] == '-' && argv[i][1] != 0)
3830 register char *str = argv[i] + 1;
3835 set_target_switch (&str[1]);
3836 else if (!strcmp (str, "dumpbase"))
3838 dump_base_name = argv[++i];
3840 else if (str[0] == 'd')
3842 register char *p = &str[1];
3847 branch_prob_dump = 1;
3853 global_reg_dump = 1;
3861 cse_dump = 1, cse2_dump = 1;
3867 #ifdef MACHINE_DEPENDENT_REORG
3868 mach_dep_reorg_dump = 1;
3872 branch_prob_dump = 1;
3891 global_reg_dump = 1;
3911 #ifdef MACHINE_DEPENDENT_REORG
3913 mach_dep_reorg_dump = 1;
3917 flag_print_asm_name = 1;
3941 rtl_dump_and_exit = 1;
3947 warning ("unrecognised gcc debugging option: %c", p[-1]);
3951 else if (str[0] == 'f')
3953 register char *p = &str[1];
3956 /* Some kind of -f option.
3957 P's value is the option sans `-f'.
3958 Search for it in the table of options. */
3961 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3964 if (!strcmp (p, f_options[j].string))
3966 *f_options[j].variable = f_options[j].on_value;
3967 /* A goto here would be cleaner,
3968 but breaks the vax pcc. */
3971 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3972 && ! strcmp (p+3, f_options[j].string))
3974 *f_options[j].variable = ! f_options[j].on_value;
3982 #ifdef INSN_SCHEDULING
3983 else if (!strncmp (p, "sched-verbose-",14))
3984 fix_sched_param("verbose",&p[14]);
3985 else if (!strncmp (p, "sched-max-",10))
3986 fix_sched_param("max",&p[10]);
3987 else if (!strncmp (p, "sched-inter-max-b-",18))
3988 fix_sched_param("interblock-max-blocks",&p[18]);
3989 else if (!strncmp (p, "sched-inter-max-i-",18))
3990 fix_sched_param("interblock-max-insns",&p[18]);
3993 else if (!strncmp (p, "fixed-", 6))
3994 fix_register (&p[6], 1, 1);
3995 else if (!strncmp (p, "call-used-", 10))
3996 fix_register (&p[10], 0, 1);
3997 else if (!strncmp (p, "call-saved-", 11))
3998 fix_register (&p[11], 0, 0);
4000 error ("Invalid option `%s'", argv[i]);
4002 else if (str[0] == 'O')
4004 register char *p = str+1;
4008 while (*p && *p >= '0' && *p <= '9')
4013 error ("Invalid option `%s'", argv[i]);
4015 else if (!strcmp (str, "pedantic"))
4017 else if (!strcmp (str, "pedantic-errors"))
4018 flag_pedantic_errors = pedantic = 1;
4019 else if (!strcmp (str, "quiet"))
4021 else if (!strcmp (str, "version"))
4023 else if (!strcmp (str, "w"))
4024 inhibit_warnings = 1;
4025 else if (!strcmp (str, "W"))
4028 /* We save the value of warn_uninitialized, since if they put
4029 -Wuninitialized on the command line, we need to generate a
4030 warning about not using it without also specifying -O. */
4031 if (warn_uninitialized != 1)
4032 warn_uninitialized = 2;
4034 else if (str[0] == 'W')
4036 register char *p = &str[1];
4039 /* Some kind of -W option.
4040 P's value is the option sans `-W'.
4041 Search for it in the table of options. */
4044 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4047 if (!strcmp (p, W_options[j].string))
4049 *W_options[j].variable = W_options[j].on_value;
4050 /* A goto here would be cleaner,
4051 but breaks the vax pcc. */
4054 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4055 && ! strcmp (p+3, W_options[j].string))
4057 *W_options[j].variable = ! W_options[j].on_value;
4064 else if (!strncmp (p, "id-clash-", 9))
4070 if (*endp >= '0' && *endp <= '9')
4074 error ("Invalid option `%s'", argv[i]);
4079 id_clash_len = atoi (str + 10);
4082 else if (!strncmp (p, "larger-than-", 12))
4084 char *endp = p + 12;
4088 if (*endp >= '0' && *endp <= '9')
4092 error ("Invalid option `%s'", argv[i]);
4093 goto larger_than_lose;
4096 warn_larger_than = 1;
4097 larger_than_size = atoi (str + 13);
4101 error ("Invalid option `%s'", argv[i]);
4103 else if (!strcmp (str, "p"))
4107 else if (!strcmp (str, "a"))
4109 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4110 warning ("`-a' option (basic block profile) not supported");
4112 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4115 else if (!strcmp (str, "ax"))
4117 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4118 warning ("`-ax' option (jump profiling) not supported");
4120 profile_block_flag = (!profile_block_flag
4121 || profile_block_flag == 2) ? 2 : 3;
4124 else if (str[0] == 'g')
4128 /* A lot of code assumes write_symbols == NO_DEBUG if the
4129 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4130 of what debugging type has been selected). This records the
4131 selected type. It is an error to specify more than one
4133 static enum debug_info_type selected_debug_type = NO_DEBUG;
4134 /* Non-zero if debugging format has been explicitly set.
4135 -g and -ggdb don't explicitly set the debugging format so
4136 -gdwarf -g3 is equivalent to -gdwarf3. */
4137 static int type_explicitly_set_p = 0;
4138 /* Table of supported debugging formats. */
4141 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4142 constant expression, we use NO_DEBUG in its place. */
4143 enum debug_info_type debug_type;
4144 int use_extensions_p;
4145 } *da, debug_args[] = {
4146 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4147 { "ggdb", NO_DEBUG, 1 },
4148 #ifdef DBX_DEBUGGING_INFO
4149 { "gstabs", DBX_DEBUG, 0 },
4150 { "gstabs+", DBX_DEBUG, 1 },
4152 #ifdef DWARF_DEBUGGING_INFO
4153 { "gdwarf", DWARF_DEBUG, 0 },
4154 { "gdwarf+", DWARF_DEBUG, 1 },
4156 #ifdef DWARF2_DEBUGGING_INFO
4157 { "gdwarf-2", DWARF2_DEBUG, 0 },
4159 #ifdef XCOFF_DEBUGGING_INFO
4160 { "gxcoff", XCOFF_DEBUG, 0 },
4161 { "gxcoff+", XCOFF_DEBUG, 1 },
4163 #ifdef SDB_DEBUGGING_INFO
4164 { "gcoff", SDB_DEBUG, 0 },
4168 /* Indexed by enum debug_info_type. */
4169 static char *debug_type_names[] = {
4170 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4173 /* Look up STR in the table. */
4174 for (da = debug_args; da->arg; da++)
4176 if (! strncmp (str, da->arg, strlen (da->arg)))
4178 enum debug_info_type type = da->debug_type;
4181 p = str + strlen (da->arg);
4182 if (*p && (*p < '0' || *p > '9'))
4186 while (*q && (*q >= '0' && *q <= '9'))
4191 if (len > 1 && !strncmp (str, "gdwarf", len))
4193 error ("use -gdwarf -g%d for DWARF v1, level %d",
4196 error ("use -gdwarf-2 for DWARF v2");
4200 level = 2; /* default debugging info level */
4201 if (*q || level > 3)
4203 warning ("invalid debug level specification in option: `-%s'",
4205 /* ??? This error message is incorrect in the case of
4207 warning ("no debugging information will be generated");
4211 if (type == NO_DEBUG)
4213 type = PREFERRED_DEBUGGING_TYPE;
4214 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4216 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4217 type = DWARF2_DEBUG;
4219 #ifdef DBX_DEBUGGING_INFO
4226 if (type == NO_DEBUG)
4227 warning ("`-%s' not supported by this configuration of GCC",
4230 /* Does it conflict with an already selected type? */
4231 if (type_explicitly_set_p
4232 /* -g/-ggdb don't conflict with anything */
4233 && da->debug_type != NO_DEBUG
4234 && type != selected_debug_type)
4235 warning ("`-%s' ignored, conflicts with `-g%s'",
4236 str, debug_type_names[(int) selected_debug_type]);
4239 /* If the format has already been set, -g/-ggdb
4240 only change the debug level. */
4241 if (type_explicitly_set_p
4242 && da->debug_type == NO_DEBUG)
4243 ; /* don't change debugging type */
4246 selected_debug_type = type;
4247 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4249 write_symbols = (level == 0
4251 : selected_debug_type);
4252 use_gnu_debug_info_extensions = da->use_extensions_p;
4253 debug_info_level = (enum debug_info_level) level;
4259 warning ("`-%s' not supported by this configuration of GCC",
4262 else if (!strcmp (str, "o"))
4264 asm_file_name = argv[++i];
4266 else if (str[0] == 'G')
4268 g_switch_set = TRUE;
4269 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4271 else if (!strncmp (str, "aux-info", 8))
4273 flag_gen_aux_info = 1;
4274 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4277 error ("Invalid option `%s'", argv[i]);
4279 else if (argv[i][0] == '+')
4280 error ("Invalid option `%s'", argv[i]);
4285 /* Checker uses the frame pointer. */
4286 if (flag_check_memory_usage)
4287 flag_omit_frame_pointer = 0;
4291 /* Inlining does not work if not optimizing,
4292 so force it not to be done. */
4296 /* The c_decode_option and lang_decode_option functions set
4297 this to `2' if -Wall is used, so we can avoid giving out
4298 lots of errors for people who don't realize what -Wall does. */
4299 if (warn_uninitialized == 1)
4300 warning ("-Wuninitialized is not supported without -O");
4303 #ifdef OVERRIDE_OPTIONS
4304 /* Some machines may reject certain combinations of options. */
4308 if (exceptions_via_longjmp == 2)
4310 #ifdef DWARF2_UNWIND_INFO
4311 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4313 exceptions_via_longjmp = 1;
4317 if (profile_block_flag == 3)
4319 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4320 profile_block_flag = 2;
4323 /* Unrolling all loops implies that standard loop unrolling must also
4325 if (flag_unroll_all_loops)
4326 flag_unroll_loops = 1;
4327 /* Loop unrolling requires that strength_reduction be on also. Silently
4328 turn on strength reduction here if it isn't already on. Also, the loop
4329 unrolling code assumes that cse will be run after loop, so that must
4330 be turned on also. */
4331 if (flag_unroll_loops)
4333 flag_strength_reduce = 1;
4334 flag_rerun_cse_after_loop = 1;
4337 /* Warn about options that are not supported on this machine. */
4338 #ifndef INSN_SCHEDULING
4339 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4340 warning ("instruction scheduling not supported on this target machine");
4343 if (flag_delayed_branch)
4344 warning ("this target machine does not have delayed branches");
4347 /* If we are in verbose mode, write out the version and maybe all the
4348 option flags in use. */
4351 print_version (stderr, "");
4353 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4356 compile_file (filename);
4358 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4361 char *lim = (char *) sbrk (0);
4363 fprintf (stderr, "Data size %d.\n",
4364 lim - (char *) &environ);
4369 system ("ps -l 1>&2");
4372 #endif /* not USG */
4375 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4378 exit (FATAL_EXIT_CODE);
4380 exit (FATAL_EXIT_CODE);
4381 exit (SUCCESS_EXIT_CODE);
4385 /* Decode -m switches. */
4387 /* Here is a table, controlled by the tm.h file, listing each -m switch
4388 and which bits in `target_switches' it should set or clear.
4389 If VALUE is positive, it is bits to set.
4390 If VALUE is negative, -VALUE is bits to clear.
4391 (The sign bit is not used so there is no confusion.) */
4393 struct {char *name; int value;} target_switches []
4396 /* This table is similar, but allows the switch to have a value. */
4398 #ifdef TARGET_OPTIONS
4399 struct {char *prefix; char ** variable;} target_options []
4403 /* Decode the switch -mNAME. */
4406 set_target_switch (name)
4412 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4413 if (!strcmp (target_switches[j].name, name))
4415 if (target_switches[j].value < 0)
4416 target_flags &= ~-target_switches[j].value;
4418 target_flags |= target_switches[j].value;
4422 #ifdef TARGET_OPTIONS
4424 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4426 int len = strlen (target_options[j].prefix);
4427 if (!strncmp (target_options[j].prefix, name, len))
4429 *target_options[j].variable = name + len;
4436 error ("Invalid option `%s'", name);
4439 /* Print version information to FILE.
4440 Each line begins with INDENT (for the case where FILE is the
4441 assembler output file). */
4444 print_version (file, indent)
4448 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4449 language_string, version_string);
4450 fprintf (file, " (%s)", TARGET_NAME);
4453 #define __VERSION__ "[unknown]"
4455 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4457 fprintf (file, " compiled by CC.\n");
4461 /* Print an option value and return the adjusted position in the line.
4462 ??? We don't handle error returns from fprintf (disk full); presumably
4463 other code will catch a disk full though. */
4466 print_single_switch (file, pos, max, indent, sep, term, type, name)
4469 char *indent, *sep, *term, *type, *name;
4471 /* The ultrix fprintf returns 0 on success, so compute the result we want
4472 here since we need it for the following test. */
4473 int len = strlen (sep) + strlen (type) + strlen (name);
4478 fprintf (file, "%s", term);
4483 fprintf (file, "%s", indent);
4484 pos = strlen (indent);
4486 fprintf (file, "%s%s%s", sep, type, name);
4491 /* Print active target switches to FILE.
4492 POS is the current cursor position and MAX is the size of a "line".
4493 Each line begins with INDENT and ends with TERM.
4494 Each switch is separated from the next by SEP. */
4497 print_switch_values (file, pos, max, indent, sep, term)
4500 char *indent, *sep, *term;
4505 /* Print the options as passed. */
4507 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4508 "options passed: ", "");
4510 for (p = &save_argv[1]; *p != NULL; p++)
4514 if (strcmp (*p, "-o") == 0)
4520 if (strcmp (*p, "-quiet") == 0)
4522 if (strcmp (*p, "-version") == 0)
4527 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4530 fprintf (file, "%s", term);
4532 /* Print the -f and -m options that have been enabled.
4533 We don't handle language specific options but printing argv
4536 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4537 "options enabled: ", "");
4539 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4540 if (*f_options[j].variable == f_options[j].on_value)
4541 pos = print_single_switch (file, pos, max, indent, sep, term,
4542 "-f", f_options[j].string);
4544 /* Print target specific options. */
4546 flags = target_flags;
4547 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4548 if (target_switches[j].name[0] != '\0'
4549 && target_switches[j].value > 0
4550 && ((target_switches[j].value & target_flags)
4551 == target_switches[j].value))
4553 pos = print_single_switch (file, pos, max, indent, sep, term,
4554 "-m", target_switches[j].name);
4555 flags &= ~ target_switches[j].value;
4558 #ifdef TARGET_OPTIONS
4559 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4560 if (*target_options[j].variable != NULL)
4563 sprintf (prefix, "-m%s", target_options[j].prefix);
4564 pos = print_single_switch (file, pos, max, indent, sep, term,
4565 prefix, *target_options[j].variable);
4569 fprintf (file, "%s", term);
4572 /* Record the beginning of a new source file, named FILENAME. */
4575 debug_start_source_file (filename)
4576 register char *filename;
4578 #ifdef DBX_DEBUGGING_INFO
4579 if (write_symbols == DBX_DEBUG)
4580 dbxout_start_new_source_file (filename);
4582 #ifdef DWARF_DEBUGGING_INFO
4583 if (debug_info_level == DINFO_LEVEL_VERBOSE
4584 && write_symbols == DWARF_DEBUG)
4585 dwarfout_start_new_source_file (filename);
4586 #endif /* DWARF_DEBUGGING_INFO */
4587 #ifdef DWARF2_DEBUGGING_INFO
4588 if (debug_info_level == DINFO_LEVEL_VERBOSE
4589 && write_symbols == DWARF2_DEBUG)
4590 dwarf2out_start_source_file (filename);
4591 #endif /* DWARF2_DEBUGGING_INFO */
4592 #ifdef SDB_DEBUGGING_INFO
4593 if (write_symbols == SDB_DEBUG)
4594 sdbout_start_new_source_file (filename);
4598 /* Record the resumption of a source file. LINENO is the line number in
4599 the source file we are returning to. */
4602 debug_end_source_file (lineno)
4603 register unsigned lineno;
4605 #ifdef DBX_DEBUGGING_INFO
4606 if (write_symbols == DBX_DEBUG)
4607 dbxout_resume_previous_source_file ();
4609 #ifdef DWARF_DEBUGGING_INFO
4610 if (debug_info_level == DINFO_LEVEL_VERBOSE
4611 && write_symbols == DWARF_DEBUG)
4612 dwarfout_resume_previous_source_file (lineno);
4613 #endif /* DWARF_DEBUGGING_INFO */
4614 #ifdef DWARF2_DEBUGGING_INFO
4615 if (debug_info_level == DINFO_LEVEL_VERBOSE
4616 && write_symbols == DWARF2_DEBUG)
4617 dwarf2out_end_source_file ();
4618 #endif /* DWARF2_DEBUGGING_INFO */
4619 #ifdef SDB_DEBUGGING_INFO
4620 if (write_symbols == SDB_DEBUG)
4621 sdbout_resume_previous_source_file ();
4625 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4626 the tail part of the directive line, i.e. the part which is past the
4627 initial whitespace, #, whitespace, directive-name, whitespace part. */
4630 debug_define (lineno, buffer)
4631 register unsigned lineno;
4632 register char *buffer;
4634 #ifdef DWARF_DEBUGGING_INFO
4635 if (debug_info_level == DINFO_LEVEL_VERBOSE
4636 && write_symbols == DWARF_DEBUG)
4637 dwarfout_define (lineno, buffer);
4638 #endif /* DWARF_DEBUGGING_INFO */
4639 #ifdef DWARF2_DEBUGGING_INFO
4640 if (debug_info_level == DINFO_LEVEL_VERBOSE
4641 && write_symbols == DWARF2_DEBUG)
4642 dwarf2out_define (lineno, buffer);
4643 #endif /* DWARF2_DEBUGGING_INFO */
4646 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4647 the tail part of the directive line, i.e. the part which is past the
4648 initial whitespace, #, whitespace, directive-name, whitespace part. */
4651 debug_undef (lineno, buffer)
4652 register unsigned lineno;
4653 register char *buffer;
4655 #ifdef DWARF_DEBUGGING_INFO
4656 if (debug_info_level == DINFO_LEVEL_VERBOSE
4657 && write_symbols == DWARF_DEBUG)
4658 dwarfout_undef (lineno, buffer);
4659 #endif /* DWARF_DEBUGGING_INFO */
4660 #ifdef DWARF2_DEBUGGING_INFO
4661 if (debug_info_level == DINFO_LEVEL_VERBOSE
4662 && write_symbols == DWARF2_DEBUG)
4663 dwarf2out_undef (lineno, buffer);
4664 #endif /* DWARF2_DEBUGGING_INFO */