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>
46 #undef FLOAT /* This is for hpux. They should change hpux. */
47 #undef FFS /* Some systems define this in param.h. */
49 #ifdef TIME_WITH_SYS_TIME
50 # include <sys/time.h>
54 # include <sys/time.h>
60 #ifdef HAVE_SYS_RESOURCE_H
61 # include <sys/resource.h>
64 #ifdef HAVE_SYS_TIMES_H
65 # include <sys/times.h>
72 #include "insn-attr.h"
77 #ifdef XCOFF_DEBUGGING_INFO
82 /* The extra parameters substantially improve the I/O performance. */
84 vms_fopen (fname, type)
88 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
89 fixed arguments, which matches ANSI's specification but not VAXCRTL's
90 pre-ANSI implementation. This hack circumvents the mismatch problem. */
91 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
94 return (*vmslib_fopen) (fname, type, "mbc=32",
95 "deq=64", "fop=tef", "shr=nil");
97 return (*vmslib_fopen) (fname, type, "mbc=32");
99 #define fopen vms_fopen
102 #ifndef DEFAULT_GDB_EXTENSIONS
103 #define DEFAULT_GDB_EXTENSIONS 1
106 /* If more than one debugging type is supported, you must define
107 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
109 This is one long line cause VAXC can't handle a \-newline. */
110 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
111 #ifndef PREFERRED_DEBUGGING_TYPE
112 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
113 #endif /* no PREFERRED_DEBUGGING_TYPE */
114 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
115 so the following code needn't care. */
116 #ifdef DBX_DEBUGGING_INFO
117 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
119 #ifdef SDB_DEBUGGING_INFO
120 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
122 #ifdef DWARF_DEBUGGING_INFO
123 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
125 #ifdef DWARF2_DEBUGGING_INFO
126 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
128 #ifdef XCOFF_DEBUGGING_INFO
129 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
131 #endif /* More than one debugger format enabled. */
133 /* If still not defined, must have been because no debugging formats
135 #ifndef PREFERRED_DEBUGGING_TYPE
136 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
139 extern int rtx_equal_function_value_matters;
141 #if ! (defined (VMS) || defined (OS2))
142 extern char **environ;
144 extern char *version_string, *language_string;
146 /* Carry information from ASM_DECLARE_OBJECT_NAME
147 to ASM_FINISH_DECLARE_OBJECT. */
149 extern int size_directive_output;
150 extern tree last_assemble_variable_decl;
152 extern void init_lex ();
153 extern void init_decl_processing ();
154 extern void init_obstacks ();
155 extern void init_tree_codes ();
156 extern void init_rtl ();
157 extern void init_regs ();
158 extern void init_optabs ();
159 extern void init_stmt ();
160 extern void init_reg_sets ();
161 extern void dump_flow_info ();
162 extern void dump_sched_info ();
163 extern void dump_local_alloc ();
164 extern void regset_release_memory ();
166 extern void print_rtl ();
167 extern void print_rtl_with_bb ();
169 void rest_of_decl_compilation ();
170 void error_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
171 void error_with_decl PVPROTO((tree decl, char *s, ...));
172 void error_for_asm PVPROTO((rtx insn, char *s, ...));
173 void error PVPROTO((char *s, ...));
174 void fatal PVPROTO((char *s, ...));
175 void warning_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
176 void warning_with_decl PVPROTO((tree decl, char *s, ...));
177 void warning_for_asm PVPROTO((rtx insn, char *s, ...));
178 void warning PVPROTO((char *s, ...));
179 void pedwarn PVPROTO((char *s, ...));
180 void pedwarn_with_decl PVPROTO((tree decl, char *s, ...));
181 void pedwarn_with_file_and_line PVPROTO((char *file, int line, char *s, ...));
182 void sorry PVPROTO((char *s, ...));
183 void really_sorry PVPROTO((char *s, ...));
188 void set_target_switch ();
189 static char *decl_name ();
191 void print_version ();
192 int print_single_switch ();
193 void print_switch_values ();
194 /* Length of line when printing switch values. */
197 #ifdef NEED_DECLARATION_SBRK
198 extern char *sbrk ();
201 /* Name of program invoked, sans directories. */
205 /* Copy of arguments to main. */
209 /* Name of current original source file (what was input to cpp).
210 This comes from each #-command in the actual input. */
212 char *input_filename;
214 /* Name of top-level original source file (what was input to cpp).
215 This comes from the #-command at the beginning of the actual input.
216 If there isn't any there, then this is the cc1 input file name. */
218 char *main_input_filename;
221 /* Stream for reading from the input file. */
225 /* Current line number in real source file. */
229 /* Stack of currently pending input files. */
231 struct file_stack *input_file_stack;
233 /* Incremented on each change to input_file_stack. */
234 int input_file_stack_tick;
236 /* FUNCTION_DECL for function now being parsed or compiled. */
238 extern tree current_function_decl;
240 /* Name to use as base of names for dump output files. */
242 char *dump_base_name;
244 /* Bit flags that specify the machine subtype we are compiling for.
245 Bits are tested using macros TARGET_... defined in the tm.h file
246 and set by `-m...' switches. Must be defined in rtlanal.c. */
248 extern int target_flags;
250 /* Flags saying which kinds of debugging dump have been requested. */
253 int rtl_dump_and_exit = 0;
254 int jump_opt_dump = 0;
255 int addressof_dump = 0;
259 int branch_prob_dump = 0;
261 int combine_dump = 0;
262 int regmove_dump = 0;
264 int local_reg_dump = 0;
265 int global_reg_dump = 0;
267 int jump2_opt_dump = 0;
268 int dbr_sched_dump = 0;
269 int flag_print_asm_name = 0;
271 int stack_reg_dump = 0;
273 #ifdef MACHINE_DEPENDENT_REORG
274 int mach_dep_reorg_dump = 0;
277 /* Name for output file of assembly code, specified with -o. */
281 /* Value of the -G xx switch, and whether it was passed or not. */
285 /* Type(s) of debugging information we are producing (if any).
286 See flags.h for the definitions of the different possible
287 types of debugging information. */
288 enum debug_info_type write_symbols = NO_DEBUG;
290 /* Level of debugging information we are producing. See flags.h
291 for the definitions of the different possible levels. */
292 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
294 /* Nonzero means use GNU-only extensions in the generated symbolic
295 debugging information. */
296 /* Currently, this only has an effect when write_symbols is set to
297 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
298 int use_gnu_debug_info_extensions = 0;
300 /* Nonzero means do optimizations. -O.
301 Particular numeric values stand for particular amounts of optimization;
302 thus, -O2 stores 2 here. However, the optimizations beyond the basic
303 ones are not controlled directly by this variable. Instead, they are
304 controlled by individual `flag_...' variables that are defaulted
305 based on this variable. */
309 /* Nonzero means optimize for size. -Os.
310 The only valid values are zero and non-zero. When optimize_size is
311 non-zero, optimize defaults to 2, but certain individual code
312 bloating optimizations are disabled. */
314 int optimize_size = 0;
316 /* Number of error messages and warning messages so far. */
319 int warningcount = 0;
322 /* Pointer to function to compute the name to use to print a declaration.
323 DECL is the declaration in question.
324 VERBOSITY determines what information will be printed:
325 0: DECL_NAME, demangled as necessary.
326 1: and scope information.
327 2: and any other information that might be interesting, such as function
328 parameter types in C++. */
330 char *(*decl_printable_name) (/* tree decl, int verbosity */);
332 /* Pointer to function to compute rtl for a language-specific tree code. */
334 struct rtx_def *(*lang_expand_expr) ();
336 /* Pointer to function to finish handling an incomplete decl at the
337 end of compilation. */
339 void (*incomplete_decl_finalize_hook) () = 0;
341 /* Highest label number used at the end of reload. */
343 int max_label_num_after_reload;
345 /* Nonzero if generating code to do profiling. */
347 int profile_flag = 0;
349 /* Nonzero if generating code to do profiling on a line-by-line basis. */
351 int profile_block_flag;
353 /* Nonzero if generating code to profile program flow graph arcs. */
355 int profile_arc_flag = 0;
357 /* Nonzero if generating info for gcov to calculate line test coverage. */
359 int flag_test_coverage = 0;
361 /* Nonzero indicates that branch taken probabilities should be calculated. */
363 int flag_branch_probabilities = 0;
365 /* Nonzero for -pedantic switch: warn about anything
366 that standard spec forbids. */
370 /* Temporarily suppress certain warnings.
371 This is set while reading code from a system header file. */
373 int in_system_header = 0;
375 /* Nonzero means do stupid register allocation.
376 Currently, this is 1 if `optimize' is 0. */
378 int obey_regdecls = 0;
380 /* Don't print functions as they are compiled and don't print
381 times taken by the various passes. -quiet. */
387 /* Nonzero means `char' should be signed. */
389 int flag_signed_char;
391 /* Nonzero means give an enum type only as many bytes as it needs. */
393 int flag_short_enums;
395 /* Nonzero for -fcaller-saves: allocate values in regs that need to
396 be saved across function calls, if that produces overall better code.
397 Optional now, so people can test it. */
399 #ifdef DEFAULT_CALLER_SAVES
400 int flag_caller_saves = 1;
402 int flag_caller_saves = 0;
405 /* Nonzero if structures and unions should be returned in memory.
407 This should only be defined if compatibility with another compiler or
408 with an ABI is needed, because it results in slower code. */
410 #ifndef DEFAULT_PCC_STRUCT_RETURN
411 #define DEFAULT_PCC_STRUCT_RETURN 1
414 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
416 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
418 /* Nonzero for -fforce-mem: load memory value into a register
419 before arithmetic on it. This makes better cse but slower compilation. */
421 int flag_force_mem = 0;
423 /* Nonzero for -fforce-addr: load memory address into a register before
424 reference to memory. This makes better cse but slower compilation. */
426 int flag_force_addr = 0;
428 /* Nonzero for -fdefer-pop: don't pop args after each function call;
429 instead save them up to pop many calls' args with one insns. */
431 int flag_defer_pop = 0;
433 /* Nonzero for -ffloat-store: don't allocate floats and doubles
434 in extended-precision registers. */
436 int flag_float_store = 0;
438 /* Nonzero for -fcse-follow-jumps:
439 have cse follow jumps to do a more extensive job. */
441 int flag_cse_follow_jumps;
443 /* Nonzero for -fcse-skip-blocks:
444 have cse follow a branch around a block. */
445 int flag_cse_skip_blocks;
447 /* Nonzero for -fexpensive-optimizations:
448 perform miscellaneous relatively-expensive optimizations. */
449 int flag_expensive_optimizations;
451 /* Nonzero for -fthread-jumps:
452 have jump optimize output of loop. */
454 int flag_thread_jumps;
456 /* Nonzero enables strength-reduction in loop.c. */
458 int flag_strength_reduce = 0;
460 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
461 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
462 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
465 int flag_unroll_loops;
467 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
468 This is generally not a win. */
470 int flag_unroll_all_loops;
472 /* Nonzero forces all invariant computations in loops to be moved
475 int flag_move_all_movables = 0;
477 /* Nonzero forces all general induction variables in loops to be
480 int flag_reduce_all_givs = 0;
482 /* Nonzero for -fwritable-strings:
483 store string constants in data segment and don't uniquize them. */
485 int flag_writable_strings = 0;
487 /* Nonzero means don't put addresses of constant functions in registers.
488 Used for compiling the Unix kernel, where strange substitutions are
489 done on the assembly output. */
491 int flag_no_function_cse = 0;
493 /* Nonzero for -fomit-frame-pointer:
494 don't make a frame pointer in simple functions that don't require one. */
496 int flag_omit_frame_pointer = 0;
498 /* Nonzero means place each function into its own section on those platforms
499 which support arbitrary section names and unlimited numbers of sections. */
501 int flag_function_sections = 0;
503 /* Nonzero to inhibit use of define_optimization peephole opts. */
505 int flag_no_peephole = 0;
507 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
508 operations in the interest of optimization. For example it allows
509 GCC to assume arguments to sqrt are nonnegative numbers, allowing
510 faster code for sqrt to be generated. */
512 int flag_fast_math = 0;
514 /* Nonzero means all references through pointers are volatile. */
518 /* Nonzero means treat all global and extern variables as global. */
520 int flag_volatile_global;
522 /* Nonzero means just do syntax checking; don't output anything. */
524 int flag_syntax_only = 0;
526 /* Nonzero means to rerun cse after loop optimization. This increases
527 compilation time about 20% and picks up a few more common expressions. */
529 static int flag_rerun_cse_after_loop;
531 /* Nonzero means to run loop optimizations twice. */
533 int flag_rerun_loop_opt;
535 /* Nonzero for -finline-functions: ok to inline functions that look like
536 good inline candidates. */
538 int flag_inline_functions;
540 /* Nonzero for -fkeep-inline-functions: even if we make a function
541 go inline everywhere, keep its definition around for debugging
544 int flag_keep_inline_functions;
546 /* Nonzero means that functions will not be inlined. */
550 /* Nonzero means that we should emit static const variables
551 regardless of whether or not optimization is turned on. */
553 int flag_keep_static_consts = 1;
555 /* Nonzero means we should be saving declaration info into a .X file. */
557 int flag_gen_aux_info = 0;
559 /* Specified name of aux-info file. */
561 static char *aux_info_file_name;
563 /* Nonzero means make the text shared if supported. */
565 int flag_shared_data;
567 /* Nonzero means schedule into delayed branch slots if supported. */
569 int flag_delayed_branch;
571 /* Nonzero if we are compiling pure (sharable) code.
572 Value is 1 if we are doing reasonable (i.e. simple
573 offset into offset table) pic. Value is 2 if we can
574 only perform register offsets. */
578 /* Nonzero means generate extra code for exception handling and enable
579 exception handling. */
581 int flag_exceptions = 2;
583 /* Nonzero means don't place uninitialized global data in common storage
588 /* Nonzero means pretend it is OK to examine bits of target floats,
589 even if that isn't true. The resulting code will have incorrect constants,
590 but the same series of instructions that the native compiler would make. */
592 int flag_pretend_float;
594 /* Nonzero means change certain warnings into errors.
595 Usually these are warnings about failure to conform to some standard. */
597 int flag_pedantic_errors = 0;
599 /* flag_schedule_insns means schedule insns within basic blocks (before
601 flag_schedule_insns_after_reload means schedule insns after
604 int flag_schedule_insns = 0;
605 int flag_schedule_insns_after_reload = 0;
608 /* The following flags have effect only for scheduling before register
611 flag_schedule_interblock means schedule insns accross basic blocks.
612 flag_schedule_speculative means allow speculative motion of non-load insns.
613 flag_schedule_speculative_load means allow speculative motion of some
615 flag_schedule_speculative_load_dangerous allows speculative motion of more
617 flag_schedule_reverse_before_reload means try to reverse original order
619 flag_schedule_reverse_after_reload means try to reverse original order
622 int flag_schedule_interblock = 1;
623 int flag_schedule_speculative = 1;
624 int flag_schedule_speculative_load = 0;
625 int flag_schedule_speculative_load_dangerous = 0;
626 int flag_schedule_reverse_before_reload = 0;
627 int flag_schedule_reverse_after_reload = 0;
630 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
631 by a cheaper branch, on a count register. */
632 int flag_branch_on_count_reg;
636 /* -finhibit-size-directive inhibits output of .size for ELF.
637 This is used only for compiling crtstuff.c,
638 and it may be extended to other effects
639 needed for crtstuff.c on other systems. */
640 int flag_inhibit_size_directive = 0;
642 /* -fverbose-asm causes extra commentary information to be produced in
643 the generated assembly code (to make it more readable). This option
644 is generally only of use to those who actually need to read the
645 generated assembly code (perhaps while debugging the compiler itself).
646 -fno-verbose-asm, the default, causes the extra information
647 to be omitted and is useful when comparing two assembler files. */
649 int flag_verbose_asm = 0;
651 /* -dA causes debug commentary information to be produced in
652 the generated assembly code (to make it more readable). This option
653 is generally only of use to those who actually need to read the
654 generated assembly code (perhaps while debugging the compiler itself).
655 Currently, this switch is only used by dwarfout.c; however, it is intended
656 to be a catchall for printing debug information in the assembler file. */
658 int flag_debug_asm = 0;
660 /* -fgnu-linker specifies use of the GNU linker for initializations.
661 (Or, more generally, a linker that handles initializations.)
662 -fno-gnu-linker says that collect2 will be used. */
664 int flag_gnu_linker = 0;
666 int flag_gnu_linker = 1;
669 /* Tag all structures with __attribute__(packed) */
670 int flag_pack_struct = 0;
672 /* Emit code to check for stack overflow; also may cause large objects
673 to be allocated dynamically. */
674 int flag_stack_check;
676 /* -fcheck-memory-usage causes extra code to be generated in order to check
677 memory accesses. This is used by a detector of bad memory accesses such
679 int flag_check_memory_usage = 0;
681 /* -fprefix-function-name causes function name to be prefixed. This
682 can be used with -fcheck-memory-usage to isolate code compiled with
683 -fcheck-memory-usage. */
684 int flag_prefix_function_name = 0;
686 int flag_regmove = 0;
688 /* 0 if pointer arguments may alias each other. True in C.
689 1 if pointer arguments may not alias each other but may alias
691 2 if pointer arguments may not alias each other and may not
692 alias global variables. True in Fortran.
693 This defaults to 0 for C. */
694 int flag_argument_noalias = 0;
696 /* Table of language-independent -f options.
697 STRING is the option name. VARIABLE is the address of the variable.
698 ON_VALUE is the value to store in VARIABLE
699 if `-fSTRING' is seen as an option.
700 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
702 struct { char *string; int *variable; int on_value;} f_options[] =
704 {"float-store", &flag_float_store, 1},
705 {"volatile", &flag_volatile, 1},
706 {"volatile-global", &flag_volatile_global, 1},
707 {"defer-pop", &flag_defer_pop, 1},
708 {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
709 {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
710 {"cse-skip-blocks", &flag_cse_skip_blocks, 1},
711 {"expensive-optimizations", &flag_expensive_optimizations, 1},
712 {"thread-jumps", &flag_thread_jumps, 1},
713 {"strength-reduce", &flag_strength_reduce, 1},
714 {"unroll-loops", &flag_unroll_loops, 1},
715 {"unroll-all-loops", &flag_unroll_all_loops, 1},
716 {"move-all-movables", &flag_move_all_movables, 1},
717 {"reduce-all-givs", &flag_reduce_all_givs, 1},
718 {"writable-strings", &flag_writable_strings, 1},
719 {"peephole", &flag_no_peephole, 0},
720 {"force-mem", &flag_force_mem, 1},
721 {"force-addr", &flag_force_addr, 1},
722 {"function-cse", &flag_no_function_cse, 0},
723 {"inline-functions", &flag_inline_functions, 1},
724 {"keep-inline-functions", &flag_keep_inline_functions, 1},
725 {"inline", &flag_no_inline, 0},
726 {"keep-static-consts", &flag_keep_static_consts, 1},
727 {"syntax-only", &flag_syntax_only, 1},
728 {"shared-data", &flag_shared_data, 1},
729 {"caller-saves", &flag_caller_saves, 1},
730 {"pcc-struct-return", &flag_pcc_struct_return, 1},
731 {"reg-struct-return", &flag_pcc_struct_return, 0},
732 {"delayed-branch", &flag_delayed_branch, 1},
733 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1},
734 {"rerun-loop-opt", &flag_rerun_loop_opt, 1},
735 {"pretend-float", &flag_pretend_float, 1},
736 {"schedule-insns", &flag_schedule_insns, 1},
737 {"schedule-insns2", &flag_schedule_insns_after_reload, 1},
739 {"sched-interblock",&flag_schedule_interblock, 1},
740 {"sched-spec",&flag_schedule_speculative, 1},
741 {"sched-spec-load",&flag_schedule_speculative_load, 1},
742 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1},
743 {"sched-reverse-S",&flag_schedule_reverse_before_reload, 1},
744 {"sched-reverse-R",&flag_schedule_reverse_after_reload, 1},
745 {"branch-count-reg",&flag_branch_on_count_reg, 1},
747 {"pic", &flag_pic, 1},
748 {"PIC", &flag_pic, 2},
749 {"exceptions", &flag_exceptions, 1},
750 {"sjlj-exceptions", &exceptions_via_longjmp, 1},
751 {"asynchronous-exceptions", &asynchronous_exceptions, 1},
752 {"profile-arcs", &profile_arc_flag, 1},
753 {"test-coverage", &flag_test_coverage, 1},
754 {"branch-probabilities", &flag_branch_probabilities, 1},
755 {"fast-math", &flag_fast_math, 1},
756 {"common", &flag_no_common, 0},
757 {"inhibit-size-directive", &flag_inhibit_size_directive, 1},
758 {"function-sections", &flag_function_sections, 1},
759 {"verbose-asm", &flag_verbose_asm, 1},
760 {"gnu-linker", &flag_gnu_linker, 1},
761 {"regmove", &flag_regmove, 1},
762 {"pack-struct", &flag_pack_struct, 1},
763 {"stack-check", &flag_stack_check, 1},
764 {"argument-alias", &flag_argument_noalias, 0},
765 {"argument-noalias", &flag_argument_noalias, 1},
766 {"argument-noalias-global", &flag_argument_noalias, 2},
767 {"check-memory-usage", &flag_check_memory_usage, 1},
768 {"prefix-function-name", &flag_prefix_function_name, 1}
771 /* Table of language-specific options. */
773 char *lang_options[] =
776 "-fallow-single-precision",
778 "-fsigned-bitfields",
779 "-funsigned-bitfields",
780 "-fno-signed-bitfields",
781 "-fno-unsigned-bitfields",
785 "-fno-unsigned-char",
801 "-fno-cond-mismatch",
802 "-fdollars-in-identifiers",
803 "-fno-dollars-in-identifiers",
812 "-Wbad-function-cast",
813 "-Wno-bad-function-cast",
817 "-Wno-char-subscripts",
828 "-Wimplicit-function-declaration",
829 "-Wno-implicit-function-declaration",
830 "-Werror-implicit-function-declaration",
838 "-Wno-missing-braces",
839 "-Wmissing-declarations",
840 "-Wno-missing-declarations",
841 "-Wmissing-prototypes",
842 "-Wno-missing-prototypes",
844 "-Wno-nested-externs",
848 "-Wno-pointer-arith",
850 "-Wno-redundant-decls",
854 "-Wno-unknown-pragmas",
855 "-Wstrict-prototypes",
856 "-Wno-strict-prototypes",
864 "-Wno-write-strings",
866 /* these are for obj c */
877 "-print-objc-runtime-info",
883 /* Options controlling warnings */
885 /* Don't print warning messages. -w. */
887 int inhibit_warnings = 0;
889 /* Print various extra warnings. -W. */
891 int extra_warnings = 0;
893 /* Treat warnings as errors. -Werror. */
895 int warnings_are_errors = 0;
897 /* Nonzero to warn about unused local variables. */
901 /* Nonzero to warn about variables used before they are initialized. */
903 int warn_uninitialized;
905 /* Nonzero means warn about all declarations which shadow others. */
909 /* Warn if a switch on an enum fails to have a case for every enum value. */
913 /* Nonzero means warn about function definitions that default the return type
914 or that use a null return and have a return-type other than void. */
916 int warn_return_type;
918 /* Nonzero means warn about pointer casts that increase the required
919 alignment of the target type (and might therefore lead to a crash
920 due to a misaligned access). */
924 /* Nonzero means warn about any identifiers that match in the first N
925 characters. The value N is in `id_clash_len'. */
928 unsigned id_clash_len;
930 /* Nonzero means warn about any objects definitions whose size is larger
931 than N bytes. Also want about function definitions whose returned
932 values are larger than N bytes. The value N is in `larger_than_size'. */
934 int warn_larger_than;
935 unsigned larger_than_size;
937 /* Nonzero means warn if inline function is too large. */
941 /* Warn if a function returns an aggregate,
942 since there are often incompatible calling conventions for doing this. */
944 int warn_aggregate_return;
946 /* Likewise for -W. */
948 struct { char *string; int *variable; int on_value;} W_options[] =
950 {"unused", &warn_unused, 1},
951 {"error", &warnings_are_errors, 1},
952 {"shadow", &warn_shadow, 1},
953 {"switch", &warn_switch, 1},
954 {"aggregate-return", &warn_aggregate_return, 1},
955 {"cast-align", &warn_cast_align, 1},
956 {"uninitialized", &warn_uninitialized, 1},
957 {"inline", &warn_inline, 1}
960 /* Output files for assembler code (real compiler output)
961 and debugging dumps. */
965 FILE *rtl_dump_file = NULL;
967 /* Time accumulators, to count the total time spent in various passes. */
971 int integration_time;
976 int branch_prob_time;
981 int local_alloc_time;
982 int global_alloc_time;
985 int shorten_branch_time;
991 /* Return time used so far, in microseconds. */
1001 #else /* not BeOS */
1002 #if defined (_WIN32) && !defined (__CYGWIN32__)
1006 return (clock() * 1000);
1007 #else /* not _WIN32 */
1013 tick = 1000000 / sysconf(_SC_CLK_TCK);
1015 return (tms.tms_utime + tms.tms_stime) * tick;
1022 return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
1027 struct rusage rusage;
1028 getrusage (0, &rusage);
1029 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1030 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1037 int proc_system_time;
1038 int child_user_time;
1039 int child_system_time;
1041 times ((void *) &vms_times);
1042 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1046 #endif /* _SC_CLK_TCK */
1048 #endif /* __BEOS__ */
1051 #define TIMEVAR(VAR, BODY) \
1052 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1055 print_time (str, total)
1060 "time in %s: %d.%06d\n",
1061 str, total / 1000000, total % 1000000);
1064 /* Count an error or warning. Return 1 if the message should be printed. */
1067 count_error (warningp)
1070 if (warningp && inhibit_warnings)
1073 if (warningp && !warnings_are_errors)
1077 static int warning_message = 0;
1079 if (warningp && !warning_message)
1081 fprintf (stderr, "%s: warnings being treated as errors\n", progname);
1082 warning_message = 1;
1090 /* Print a fatal error message. NAME is the text.
1091 Also include a system error message based on `errno'. */
1094 pfatal_with_name (name)
1097 fprintf (stderr, "%s: ", progname);
1099 exit (FATAL_EXIT_CODE);
1103 fatal_io_error (name)
1106 fprintf (stderr, "%s: %s: I/O error\n", progname, name);
1107 exit (FATAL_EXIT_CODE);
1110 /* Called to give a better error message for a bad insn rather than
1111 just calling abort(). */
1114 fatal_insn (message, insn)
1121 fflush (asm_out_file);
1123 fflush (aux_info_file);
1124 if (rtl_dump_file != NULL)
1125 fflush (rtl_dump_file);
1131 /* Called to give a better error message when we don't have an insn to match
1132 what we are looking for or if the insn's constraints aren't satisfied,
1133 rather than just calling abort(). */
1136 fatal_insn_not_found (insn)
1139 if (INSN_CODE (insn) < 0)
1140 fatal_insn ("internal error--unrecognizable insn:", insn);
1142 fatal_insn ("internal error--insn does not satisfy its constraints:", insn);
1145 /* This is the default decl_printable_name function. */
1148 decl_name (decl, verbosity)
1152 return IDENTIFIER_POINTER (DECL_NAME (decl));
1155 static int need_error_newline;
1157 /* Function of last error message;
1158 more generally, function such that if next error message is in it
1159 then we don't have to mention the function name. */
1160 static tree last_error_function = NULL;
1162 /* Used to detect when input_file_stack has changed since last described. */
1163 static int last_error_tick;
1165 /* Called when the start of a function definition is parsed,
1166 this function prints on stderr the name of the function. */
1169 announce_function (decl)
1174 if (rtl_dump_and_exit)
1175 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1177 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1179 need_error_newline = 1;
1180 last_error_function = current_function_decl;
1184 /* The default function to print out name of current function that caused
1188 default_print_error_function (file)
1191 if (last_error_function != current_function_decl)
1193 char *kind = "function";
1194 if (current_function_decl != 0
1195 && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1199 fprintf (stderr, "%s: ", file);
1201 if (current_function_decl == NULL)
1202 fprintf (stderr, "At top level:\n");
1205 char *name = (*decl_printable_name) (current_function_decl, 2);
1206 fprintf (stderr, "In %s `%s':\n", kind, name);
1209 last_error_function = current_function_decl;
1213 /* Called by report_error_function to print out function name.
1214 * Default may be overridden by language front-ends. */
1216 void (*print_error_function) PROTO((char *)) = default_print_error_function;
1218 /* Prints out, if necessary, the name of the current function
1219 that caused an error. Called from all error and warning functions. */
1222 report_error_function (file)
1225 struct file_stack *p;
1227 if (need_error_newline)
1229 fprintf (stderr, "\n");
1230 need_error_newline = 0;
1233 (*print_error_function) (file);
1235 if (input_file_stack && input_file_stack->next != 0
1236 && input_file_stack_tick != last_error_tick
1237 && file == input_filename)
1239 fprintf (stderr, "In file included");
1240 for (p = input_file_stack->next; p; p = p->next)
1242 fprintf (stderr, " from %s:%d", p->name, p->line);
1244 fprintf (stderr, ",\n ");
1246 fprintf (stderr, ":\n");
1247 last_error_tick = input_file_stack_tick;
1251 /* Print a message. */
1254 vmessage (prefix, s, ap)
1260 fprintf (stderr, "%s: ", prefix);
1263 vfprintf (stderr, s, ap);
1266 HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
1267 HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
1268 HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
1269 HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
1270 fprintf (stderr, s, v1, v2, v3, v4);
1275 /* Print a message relevant to line LINE of file FILE. */
1278 v_message_with_file_and_line (file, line, prefix, s, ap)
1286 fprintf (stderr, "%s:%d: ", file, line);
1288 fprintf (stderr, "%s: ", progname);
1290 vmessage (prefix, s, ap);
1291 fputc ('\n', stderr);
1294 /* Print a message relevant to the given DECL. */
1297 v_message_with_decl (decl, prefix, s, ap)
1305 fprintf (stderr, "%s:%d: ",
1306 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1309 fprintf (stderr, "%s: ", prefix);
1311 /* Do magic to get around lack of varargs support for insertion
1312 of arguments into existing list. We know that the decl is first;
1313 we ass_u_me that it will be printed with "%s". */
1315 for (p = s; *p; ++p)
1319 if (*(p + 1) == '%')
1326 if (p > s) /* Print the left-hand substring. */
1328 char fmt[sizeof "%.255s"];
1331 if (width > 255L) width = 255L; /* arbitrary */
1332 sprintf (fmt, "%%.%lds", width);
1333 fprintf (stderr, fmt, s);
1336 if (*p == '%') /* Print the name. */
1338 char *n = (DECL_NAME (decl)
1339 ? (*decl_printable_name) (decl, 2)
1345 if (isalpha (*(p - 1) & 0xFF))
1350 if (*p) /* Print the rest of the message. */
1351 vmessage ((char *)NULL, p, ap);
1353 fputc ('\n', stderr);
1356 /* Figure file and line of the given INSN. */
1359 file_and_line_for_asm (insn, pfile, pline)
1364 rtx body = PATTERN (insn);
1367 /* Find the (or one of the) ASM_OPERANDS in the insn. */
1368 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1369 asmop = SET_SRC (body);
1370 else if (GET_CODE (body) == ASM_OPERANDS)
1372 else if (GET_CODE (body) == PARALLEL
1373 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
1374 asmop = SET_SRC (XVECEXP (body, 0, 0));
1375 else if (GET_CODE (body) == PARALLEL
1376 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1377 asmop = XVECEXP (body, 0, 0);
1383 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
1384 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
1388 *pfile = input_filename;
1393 /* Report an error at line LINE of file FILE. */
1396 v_error_with_file_and_line (file, line, s, ap)
1403 report_error_function (file);
1404 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1408 error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1420 file = va_arg (ap, char *);
1421 line = va_arg (ap, int);
1422 s = va_arg (ap, char *);
1425 v_error_with_file_and_line (file, line, s, ap);
1429 /* Report an error at the declaration DECL.
1430 S is a format string which uses %s to substitute the declaration
1431 name; subsequent substitutions are a la printf. */
1434 v_error_with_decl (decl, s, ap)
1440 report_error_function (DECL_SOURCE_FILE (decl));
1441 v_message_with_decl (decl, (char *)NULL, s, ap);
1445 error_with_decl VPROTO((tree decl, char *s, ...))
1456 decl = va_arg (ap, tree);
1457 s = va_arg (ap, char *);
1460 v_error_with_decl (decl, s, ap);
1464 /* Report an error at the line number of the insn INSN.
1465 This is used only when INSN is an `asm' with operands,
1466 and each ASM_OPERANDS records its own source file and line. */
1469 v_error_for_asm (insn, s, ap)
1478 file_and_line_for_asm (insn, &file, &line);
1479 report_error_function (file);
1480 v_message_with_file_and_line (file, line, (char *)NULL, s, ap);
1484 error_for_asm VPROTO((rtx insn, char *s, ...))
1495 insn = va_arg (ap, rtx);
1496 s = va_arg (ap, char *);
1499 v_error_for_asm (insn, s, ap);
1503 /* Report an error at the current line number. */
1510 v_error_with_file_and_line (input_filename, lineno, s, ap);
1514 error VPROTO((char *s, ...))
1524 s = va_arg (ap, char *);
1531 /* Report a fatal error at the current line number. */
1539 exit (FATAL_EXIT_CODE);
1543 fatal VPROTO((char *s, ...))
1553 s = va_arg (ap, char *);
1560 /* Report a warning at line LINE of file FILE. */
1563 v_warning_with_file_and_line (file, line, s, ap)
1569 if (count_error (1))
1571 report_error_function (file);
1572 v_message_with_file_and_line (file, line, "warning", s, ap);
1577 warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1589 file = va_arg (ap, char *);
1590 line = va_arg (ap, int);
1591 s = va_arg (ap, char *);
1594 v_warning_with_file_and_line (file, line, s, ap);
1598 /* Report a warning at the declaration DECL.
1599 S is a format string which uses %s to substitute the declaration
1600 name; subsequent substitutions are a la printf. */
1603 v_warning_with_decl (decl, s, ap)
1608 if (count_error (1))
1610 report_error_function (DECL_SOURCE_FILE (decl));
1611 v_message_with_decl (decl, "warning", s, ap);
1616 warning_with_decl VPROTO((tree decl, char *s, ...))
1627 decl = va_arg (ap, tree);
1628 s = va_arg (ap, char *);
1631 v_warning_with_decl (decl, s, ap);
1635 /* Report a warning at the line number of the insn INSN.
1636 This is used only when INSN is an `asm' with operands,
1637 and each ASM_OPERANDS records its own source file and line. */
1640 v_warning_for_asm (insn, s, ap)
1645 if (count_error (1))
1650 file_and_line_for_asm (insn, &file, &line);
1651 report_error_function (file);
1652 v_message_with_file_and_line (file, line, "warning", s, ap);
1657 warning_for_asm VPROTO((rtx insn, char *s, ...))
1668 insn = va_arg (ap, rtx);
1669 s = va_arg (ap, char *);
1672 v_warning_for_asm (insn, s, ap);
1676 /* Report a warning at the current line number. */
1683 v_warning_with_file_and_line (input_filename, lineno, s, ap);
1687 warning VPROTO((char *s, ...))
1697 s = va_arg (ap, char *);
1704 /* These functions issue either warnings or errors depending on
1705 -pedantic-errors. */
1712 if (flag_pedantic_errors)
1719 pedwarn VPROTO((char *s, ...))
1729 s = va_arg (ap, char *);
1737 v_pedwarn_with_decl (decl, s, ap)
1742 /* We don't want -pedantic-errors to cause the compilation to fail from
1743 "errors" in system header files. Sometimes fixincludes can't fix what's
1744 broken (eg: unsigned char bitfields - fixing it may change the alignment
1745 which will cause programs to mysteriously fail because the C library
1746 or kernel uses the original layout). There's no point in issuing a
1747 warning either, it's just unnecessary noise. */
1749 if (! DECL_IN_SYSTEM_HEADER (decl))
1751 if (flag_pedantic_errors)
1752 v_error_with_decl (decl, s, ap);
1754 v_warning_with_decl (decl, s, ap);
1759 pedwarn_with_decl VPROTO((tree decl, char *s, ...))
1770 decl = va_arg (ap, tree);
1771 s = va_arg (ap, char *);
1774 v_pedwarn_with_decl (decl, s, ap);
1779 v_pedwarn_with_file_and_line (file, line, s, ap)
1785 if (flag_pedantic_errors)
1786 v_error_with_file_and_line (file, line, s, ap);
1788 v_warning_with_file_and_line (file, line, s, ap);
1792 pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
1804 file = va_arg (ap, char *);
1805 line = va_arg (ap, int);
1806 s = va_arg (ap, char *);
1809 v_pedwarn_with_file_and_line (file, line, s, ap);
1813 /* Apologize for not implementing some feature. */
1822 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1824 fprintf (stderr, "%s: ", progname);
1825 vmessage ("sorry, not implemented", s, ap);
1826 fputc ('\n', stderr);
1830 sorry VPROTO((char *s, ...))
1840 s = va_arg (ap, char *);
1847 /* Apologize for not implementing some feature, then quit. */
1850 v_really_sorry (s, ap)
1856 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1858 fprintf (stderr, "%s: ", progname);
1859 vmessage ("sorry, not implemented", s, ap);
1860 fatal (" (fatal)\n");
1864 really_sorry VPROTO((char *s, ...))
1874 s = va_arg (ap, char *);
1877 v_really_sorry (s, ap);
1881 /* More 'friendly' abort that prints the line and file.
1882 config.h can #define abort fancy_abort if you like that sort of thing.
1884 I don't think this is actually a good idea.
1885 Other sorts of crashes will look a certain way.
1886 It is a good thing if crashes from calling abort look the same way.
1892 fatal ("internal gcc abort");
1895 /* This calls abort and is used to avoid problems when abort if a macro.
1896 It is used when we need to pass the address of abort. */
1904 /* When `malloc.c' is compiled with `rcheck' defined,
1905 it calls this function to report clobberage. */
1913 /* Same as `malloc' but report error if no memory available. */
1919 register char *value = (char *) malloc (size);
1920 if (value == 0 && size != 0)
1921 fatal ("virtual memory exhausted");
1925 /* Same as `realloc' but report error if no memory available.
1926 Also handle null PTR even if the vendor realloc gets it wrong. */
1929 xrealloc (ptr, size)
1934 ? (char *) realloc (ptr, size)
1935 : (char *) malloc (size));
1937 fatal ("virtual memory exhausted");
1941 /* Same as `strdup' but report error if no memory available. */
1947 register char *result = (char *) malloc (strlen (s) + 1);
1950 fatal ("virtual memory exhausted");
1955 /* Return the logarithm of X, base 2, considering X unsigned,
1956 if X is a power of 2. Otherwise, returns -1.
1958 This should be used via the `exact_log2' macro. */
1962 register unsigned HOST_WIDE_INT x;
1964 register int log = 0;
1965 /* Test for 0 or a power of 2. */
1966 if (x == 0 || x != (x & -x))
1968 while ((x >>= 1) != 0)
1973 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1974 If X is 0, return -1.
1976 This should be used via the floor_log2 macro. */
1980 register unsigned HOST_WIDE_INT x;
1982 register int log = -1;
1989 static int float_handler_set;
1991 jmp_buf float_handler;
1993 /* Signals actually come here. */
1996 float_signal (signo)
1997 /* If this is missing, some compilers complain. */
2000 if (float_handled == 0)
2002 #if defined (USG) || defined (hpux)
2003 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
2006 signal (SIGFPE, float_signal);
2007 longjmp (float_handler, 1);
2010 /* Specify where to longjmp to when a floating arithmetic error happens.
2011 If HANDLER is 0, it means don't handle the errors any more. */
2014 set_float_handler (handler)
2017 float_handled = (handler != 0);
2019 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2021 if (float_handled && ! float_handler_set)
2023 signal (SIGFPE, float_signal);
2024 float_handler_set = 1;
2028 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
2029 error happens, pushing the previous specification into OLD_HANDLER.
2030 Return an indication of whether there was a previous handler in effect. */
2033 push_float_handler (handler, old_handler)
2034 jmp_buf handler, old_handler;
2036 int was_handled = float_handled;
2040 bcopy ((char *) float_handler, (char *) old_handler,
2041 sizeof (float_handler));
2043 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2047 /* Restore the previous specification of whether and where to longjmp to
2048 when a floating arithmetic error happens. */
2051 pop_float_handler (handled, handler)
2055 float_handled = handled;
2057 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
2060 /* Handler for SIGPIPE. */
2064 /* If this is missing, some compilers complain. */
2067 fatal ("output pipe has been closed");
2070 /* Strip off a legitimate source ending from the input string NAME of
2071 length LEN. Rather than having to know the names used by all of
2072 our front ends, we strip off an ending of a period followed by one,
2073 two, or three characters. */
2076 strip_off_ending (name, len)
2080 if (len > 2 && name[len - 2] == '.')
2081 name[len - 2] = '\0';
2082 else if (len > 3 && name[len - 3] == '.')
2083 name[len - 3] = '\0';
2084 else if (len > 4 && name[len - 4] == '.')
2085 name[len - 4] = '\0';
2088 /* Output a quoted string. */
2091 output_quoted_string (asm_file, string)
2095 #ifdef OUTPUT_QUOTED_STRING
2096 OUTPUT_QUOTED_STRING (asm_file, string);
2100 putc ('\"', asm_file);
2101 while ((c = *string++) != 0)
2103 if (c == '\"' || c == '\\')
2104 putc ('\\', asm_file);
2107 putc ('\"', asm_file);
2111 /* Output a file name in the form wanted by System V. */
2114 output_file_directive (asm_file, input_name)
2118 int len = strlen (input_name);
2119 char *na = input_name + len;
2121 /* NA gets INPUT_NAME sans directory names. */
2122 while (na > input_name)
2129 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
2130 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
2132 #ifdef ASM_OUTPUT_SOURCE_FILENAME
2133 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
2135 fprintf (asm_file, "\t.file\t");
2136 output_quoted_string (asm_file, na);
2137 fputc ('\n', asm_file);
2142 /* Routine to build language identifier for object file. */
2145 output_lang_identify (asm_out_file)
2148 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
2149 char *s = (char *) alloca (len);
2150 sprintf (s, "__gnu_compiled_%s", lang_identify ());
2151 ASM_OUTPUT_LABEL (asm_out_file, s);
2154 /* Routine to open a dump file. */
2156 open_dump_file (suffix, function_name)
2158 char *function_name;
2165 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2167 if (rtl_dump_file != NULL)
2168 fclose (rtl_dump_file);
2170 strcpy (dumpname, dump_base_name);
2171 strcat (dumpname, suffix);
2173 rtl_dump_file = fopen (dumpname, "a");
2175 if (rtl_dump_file == NULL)
2176 pfatal_with_name (dumpname);
2181 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name);
2187 /* Routine to close a dump file. */
2189 close_dump_file (func, insns)
2190 void (*func)(FILE *, rtx);
2197 func (rtl_dump_file, insns);
2199 fflush (rtl_dump_file);
2200 fclose (rtl_dump_file);
2202 rtl_dump_file = NULL;
2208 /* Routine to dump rtl into a file. */
2210 dump_rtl (suffix, decl, func, insns)
2213 void (*func)(FILE *, rtx);
2216 open_dump_file (suffix, decl_printable_name (decl, 2));
2217 close_dump_file (func, insns);
2220 /* Routine to empty a dump file. */
2222 clean_dump_file (suffix)
2227 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
2229 strcpy (dumpname, dump_base_name);
2230 strcat (dumpname, suffix);
2232 rtl_dump_file = fopen (dumpname, "w");
2234 if (rtl_dump_file == NULL)
2235 pfatal_with_name (dumpname);
2239 fclose (rtl_dump_file);
2240 rtl_dump_file = NULL;
2246 /* Compile an entire file of output from cpp, named NAME.
2247 Write a file of assembly output and various debugging dumps. */
2256 int name_specified = name != 0;
2258 if (dump_base_name == 0)
2259 dump_base_name = name ? name : "gccdump";
2263 integration_time = 0;
2268 branch_prob_time = 0;
2273 local_alloc_time = 0;
2274 global_alloc_time = 0;
2277 shorten_branch_time = 0;
2284 /* Open input file. */
2286 if (name == 0 || !strcmp (name, "-"))
2292 finput = fopen (name, "r");
2294 pfatal_with_name (name);
2296 #ifdef IO_BUFFER_SIZE
2297 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
2299 #endif /* !USE_CPPLIB */
2301 /* Initialize data in various passes. */
2311 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2312 || debug_info_level == DINFO_LEVEL_VERBOSE
2313 || flag_test_coverage);
2315 init_decl_processing ();
2324 if (flag_caller_saves)
2325 init_caller_save ();
2327 /* If auxiliary info generation is desired, open the output file.
2328 This goes in the same directory as the source file--unlike
2329 all the other output files. */
2330 if (flag_gen_aux_info)
2332 aux_info_file = fopen (aux_info_file_name, "w");
2333 if (aux_info_file == 0)
2334 pfatal_with_name (aux_info_file_name);
2337 /* Clear the dump files file. */
2339 clean_dump_file (".rtl");
2341 clean_dump_file (".jump");
2343 clean_dump_file (".addressof");
2345 clean_dump_file (".cse");
2347 clean_dump_file (".loop");
2349 clean_dump_file (".cse2");
2350 if (branch_prob_dump)
2351 clean_dump_file (".bp");
2353 clean_dump_file (".flow");
2355 clean_dump_file (".combine");
2357 clean_dump_file (".regmove");
2359 clean_dump_file (".sched");
2361 clean_dump_file (".lreg");
2362 if (global_reg_dump)
2363 clean_dump_file (".greg");
2365 clean_dump_file (".sched2");
2367 clean_dump_file (".jump2");
2369 clean_dump_file (".dbr");
2372 clean_dump_file (".stack");
2374 #ifdef MACHINE_DEPENDENT_REORG
2375 if (mach_dep_reorg_dump)
2376 clean_dump_file (".mach");
2379 /* Open assembler code output file. */
2381 if (! name_specified && asm_file_name == 0)
2382 asm_out_file = stdout;
2385 int len = strlen (dump_base_name);
2386 register char *dumpname = (char *) xmalloc (len + 6);
2387 strcpy (dumpname, dump_base_name);
2388 strip_off_ending (dumpname, len);
2389 strcat (dumpname, ".s");
2390 if (asm_file_name == 0)
2392 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
2393 strcpy (asm_file_name, dumpname);
2395 if (!strcmp (asm_file_name, "-"))
2396 asm_out_file = stdout;
2398 asm_out_file = fopen (asm_file_name, "w");
2399 if (asm_out_file == 0)
2400 pfatal_with_name (asm_file_name);
2403 #ifdef IO_BUFFER_SIZE
2404 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2405 _IOFBF, IO_BUFFER_SIZE);
2408 input_filename = name;
2410 /* Put an entry on the input file stack for the main input file. */
2412 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2413 input_file_stack->next = 0;
2414 input_file_stack->name = input_filename;
2416 /* Gross. Gross. lang_init is (I think) the first callback into
2417 the language front end, and is thus the first opportunity to
2418 have the selected language override the default value for any
2421 So the default value for flag_exceptions is 2 (uninitialized).
2422 If we encounter -fno-exceptions or -fexceptions, then flag_exceptions
2423 will be set to zero or one respectively.
2425 flag_exceptions can also be set by lang_init to something other
2426 than the default "uninitialized" value of 2.
2428 After lang_init, if the value is still 2, then we default to
2429 -fno-exceptions (value will be reset to zero).
2431 When our EH mechanism is low enough overhead that we can enable
2432 it by default for languages other than C++, then all this braindamage
2435 /* Perform language-specific initialization.
2436 This may set main_input_filename. */
2439 if (flag_exceptions == 2)
2440 flag_exceptions = 0;
2442 /* If the input doesn't start with a #line, use the input name
2443 as the official input file name. */
2444 if (main_input_filename == 0)
2445 main_input_filename = name;
2447 ASM_FILE_START (asm_out_file);
2449 #ifdef ASM_COMMENT_START
2450 if (flag_verbose_asm)
2452 /* Print the list of options in effect. */
2453 print_version (asm_out_file, ASM_COMMENT_START);
2454 print_switch_values (asm_out_file, 0, MAX_LINE,
2455 ASM_COMMENT_START, " ", "\n");
2456 /* Add a blank line here so it appears in assembler output but not
2458 fprintf (asm_out_file, "\n");
2462 /* Output something to inform GDB that this compilation was by GCC. */
2463 #ifndef ASM_IDENTIFY_GCC
2464 fprintf (asm_out_file, "gcc2_compiled.:\n");
2466 ASM_IDENTIFY_GCC (asm_out_file);
2469 /* Output something to identify which front-end produced this file. */
2470 #ifdef ASM_IDENTIFY_LANGUAGE
2471 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2474 #ifndef ASM_OUTPUT_SECTION_NAME
2475 if (flag_function_sections)
2477 warning ("-ffunction-sections not supported for this target.");
2478 flag_function_sections = 0;
2482 if (flag_function_sections
2483 && (profile_flag || profile_block_flag))
2485 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2486 flag_function_sections = 0;
2489 if (flag_function_sections && write_symbols != NO_DEBUG)
2490 warning ("-ffunction-sections may affect debugging on some targets.");
2492 /* ??? Note: There used to be a conditional here
2493 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2494 This was to guarantee separation between gcc_compiled. and
2495 the first function, for the sake of dbx on Suns.
2496 However, having the extra zero here confused the Emacs
2497 code for unexec, and might confuse other programs too.
2498 Therefore, I took out that change.
2499 In future versions we should find another way to solve
2500 that dbx problem. -- rms, 23 May 93. */
2502 /* Don't let the first function fall at the same address
2503 as gcc_compiled., if profiling. */
2504 if (profile_flag || profile_block_flag)
2505 assemble_zeros (UNITS_PER_WORD);
2507 /* If dbx symbol table desired, initialize writing it
2508 and output the predefined types. */
2509 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2510 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2511 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2514 #ifdef SDB_DEBUGGING_INFO
2515 if (write_symbols == SDB_DEBUG)
2516 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2519 #ifdef DWARF_DEBUGGING_INFO
2520 if (write_symbols == DWARF_DEBUG)
2521 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2523 #ifdef DWARF2_UNWIND_INFO
2524 if (dwarf2out_do_frame ())
2525 dwarf2out_frame_init ();
2527 #ifdef DWARF2_DEBUGGING_INFO
2528 if (write_symbols == DWARF2_DEBUG)
2529 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2532 /* Initialize yet another pass. */
2534 init_final (main_input_filename);
2535 init_branch_prob (dump_base_name);
2537 start_time = get_run_time ();
2539 /* Call the parser, which parses the entire file
2540 (calling rest_of_compilation for each function). */
2542 if (yyparse () != 0)
2544 if (errorcount == 0)
2545 fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
2547 /* In case there were missing closebraces,
2548 get us back to the global binding level. */
2549 while (! global_bindings_p ())
2553 output_func_start_profiler ();
2555 /* Compilation is now finished except for writing
2556 what's left of the symbol table output. */
2558 parse_time += get_run_time () - start_time;
2560 parse_time -= integration_time;
2561 parse_time -= varconst_time;
2563 globals = getdecls ();
2565 /* Really define vars that have had only a tentative definition.
2566 Really output inline functions that must actually be callable
2567 and have not been output so far. */
2570 int len = list_length (globals);
2571 tree *vec = (tree *) alloca (sizeof (tree) * len);
2576 /* Process the decls in reverse order--earliest first.
2577 Put them into VEC from back to front, then take out from front. */
2579 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2580 vec[len - i - 1] = decl;
2582 for (i = 0; i < len; i++)
2586 /* We're not deferring this any longer. */
2587 DECL_DEFER_OUTPUT (decl) = 0;
2589 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
2590 && incomplete_decl_finalize_hook != 0)
2591 (*incomplete_decl_finalize_hook) (decl);
2594 /* Now emit any global variables or functions that we have been putting
2595 off. We need to loop in case one of the things emitted here
2596 references another one which comes earlier in the list. */
2600 for (i = 0; i < len; i++)
2604 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
2607 /* Don't write out static consts, unless we still need them.
2609 We also keep static consts if not optimizing (for debugging),
2610 unless the user specified -fno-keep-static-consts.
2611 ??? They might be better written into the debug information.
2612 This is possible when using DWARF.
2614 A language processor that wants static constants to be always
2615 written out (even if it is not used) is responsible for
2616 calling rest_of_decl_compilation itself. E.g. the C front-end
2617 calls rest_of_decl_compilation from finish_decl.
2618 One motivation for this is that is conventional in some
2619 environments to write things like:
2620 static const char rcsid[] = "... version string ...";
2621 intending to force the string to be in the executable.
2623 A language processor that would prefer to have unneeded
2624 static constants "optimized away" would just defer writing
2625 them out until here. E.g. C++ does this, because static
2626 constants are often defined in header files.
2628 ??? A tempting alternative (for both C and C++) would be
2629 to force a constant to be written if and only if it is
2630 defined in a main file, as opposed to an include file. */
2632 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2633 && (! TREE_READONLY (decl)
2634 || TREE_PUBLIC (decl)
2635 || (!optimize && flag_keep_static_consts)
2636 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2639 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
2642 if (TREE_CODE (decl) == FUNCTION_DECL
2643 && DECL_INITIAL (decl) != 0
2644 && DECL_SAVED_INSNS (decl) != 0
2645 && (flag_keep_inline_functions
2646 || TREE_PUBLIC (decl)
2647 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2650 temporary_allocation ();
2651 output_inline_function (decl);
2652 permanent_allocation (1);
2657 /* Now that all possible functions have been output, we can dump
2658 the exception table. */
2660 output_exception_table ();
2662 for (i = 0; i < len; i++)
2666 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2667 && ! TREE_ASM_WRITTEN (decl))
2668 /* Cancel the RTL for this decl so that, if debugging info
2669 output for global variables is still to come,
2670 this one will be omitted. */
2671 DECL_RTL (decl) = NULL;
2673 /* Warn about any function
2674 declared static but not defined.
2675 We don't warn about variables,
2676 because many programs have static variables
2677 that exist only to get some text into the object file. */
2678 if (TREE_CODE (decl) == FUNCTION_DECL
2680 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2681 && DECL_INITIAL (decl) == 0
2682 && DECL_EXTERNAL (decl)
2683 && ! DECL_ARTIFICIAL (decl)
2684 && ! TREE_PUBLIC (decl))
2686 pedwarn_with_decl (decl,
2687 "`%s' declared `static' but never defined");
2688 /* This symbol is effectively an "extern" declaration now. */
2689 TREE_PUBLIC (decl) = 1;
2690 assemble_external (decl);
2693 /* Warn about static fns or vars defined but not used,
2694 but not about inline functions or static consts
2695 since defining those in header files is normal practice. */
2697 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2698 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2699 && ! DECL_IN_SYSTEM_HEADER (decl)
2700 && ! DECL_EXTERNAL (decl)
2701 && ! TREE_PUBLIC (decl)
2702 && ! TREE_USED (decl)
2703 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2704 /* The TREE_USED bit for file-scope decls
2705 is kept in the identifier, to handle multiple
2706 external decls in different scopes. */
2707 && ! TREE_USED (DECL_NAME (decl)))
2708 warning_with_decl (decl, "`%s' defined but not used");
2710 #ifdef SDB_DEBUGGING_INFO
2711 /* The COFF linker can move initialized global vars to the end.
2712 And that can screw up the symbol ordering.
2713 By putting the symbols in that order to begin with,
2714 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2715 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2716 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2717 && ! DECL_EXTERNAL (decl)
2718 && DECL_RTL (decl) != 0)
2719 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2721 /* Output COFF information for non-global
2722 file-scope initialized variables. */
2723 if (write_symbols == SDB_DEBUG
2724 && TREE_CODE (decl) == VAR_DECL
2725 && DECL_INITIAL (decl)
2726 && ! DECL_EXTERNAL (decl)
2727 && DECL_RTL (decl) != 0
2728 && GET_CODE (DECL_RTL (decl)) == MEM)
2729 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2730 #endif /* SDB_DEBUGGING_INFO */
2731 #ifdef DWARF_DEBUGGING_INFO
2732 /* Output DWARF information for file-scope tentative data object
2733 declarations, file-scope (extern) function declarations (which
2734 had no corresponding body) and file-scope tagged type declarations
2735 and definitions which have not yet been forced out. */
2737 if (write_symbols == DWARF_DEBUG
2738 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2739 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2741 #ifdef DWARF2_DEBUGGING_INFO
2742 /* Output DWARF2 information for file-scope tentative data object
2743 declarations, file-scope (extern) function declarations (which
2744 had no corresponding body) and file-scope tagged type declarations
2745 and definitions which have not yet been forced out. */
2747 if (write_symbols == DWARF2_DEBUG
2748 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2749 TIMEVAR (symout_time, dwarf2out_decl (decl));
2754 /* Write out any pending weak symbol declarations. */
2758 /* Do dbx symbols */
2759 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2760 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2761 TIMEVAR (symout_time,
2763 dbxout_finish (asm_out_file, main_input_filename);
2767 #ifdef DWARF_DEBUGGING_INFO
2768 if (write_symbols == DWARF_DEBUG)
2769 TIMEVAR (symout_time,
2775 #ifdef DWARF2_UNWIND_INFO
2776 if (dwarf2out_do_frame ())
2777 dwarf2out_frame_finish ();
2780 #ifdef DWARF2_DEBUGGING_INFO
2781 if (write_symbols == DWARF2_DEBUG)
2782 TIMEVAR (symout_time,
2784 dwarf2out_finish ();
2788 /* Output some stuff at end of file if nec. */
2790 end_final (dump_base_name);
2792 if (branch_prob_dump)
2793 open_dump_file (".bp", NULL);
2795 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2797 if (branch_prob_dump)
2798 close_dump_file (NULL, NULL_RTX);
2801 ASM_FILE_END (asm_out_file);
2804 /* Language-specific end of compilation actions. */
2808 /* Close the dump files. */
2810 if (flag_gen_aux_info)
2812 fclose (aux_info_file);
2814 unlink (aux_info_file_name);
2819 open_dump_file (".combine", NULL);
2820 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2821 close_dump_file (NULL, NULL_RTX);
2824 /* Close non-debugging input and output files. Take special care to note
2825 whether fclose returns an error, since the pages might still be on the
2826 buffer chain while the file is open. */
2833 if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
2834 fatal_io_error (asm_file_name);
2836 /* Print the times. */
2840 fprintf (stderr,"\n");
2841 print_time ("parse", parse_time);
2843 print_time ("integration", integration_time);
2844 print_time ("jump", jump_time);
2845 print_time ("cse", cse_time);
2846 print_time ("loop", loop_time);
2847 print_time ("cse2", cse2_time);
2848 print_time ("branch-prob", branch_prob_time);
2849 print_time ("flow", flow_time);
2850 print_time ("combine", combine_time);
2851 print_time ("regmove", regmove_time);
2852 print_time ("sched", sched_time);
2853 print_time ("local-alloc", local_alloc_time);
2854 print_time ("global-alloc", global_alloc_time);
2855 print_time ("sched2", sched2_time);
2856 print_time ("dbranch", dbr_sched_time);
2857 print_time ("shorten-branch", shorten_branch_time);
2858 print_time ("stack-reg", stack_reg_time);
2859 print_time ("final", final_time);
2860 print_time ("varconst", varconst_time);
2861 print_time ("symout", symout_time);
2862 print_time ("dump", dump_time);
2866 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2867 and TYPE_DECL nodes.
2869 This does nothing for local (non-static) variables.
2870 Otherwise, it sets up the RTL and outputs any assembler code
2871 (label definition, storage allocation and initialization).
2873 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2874 the assembler symbol name to be used. TOP_LEVEL is nonzero
2875 if this declaration is not within a function. */
2878 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2884 /* Declarations of variables, and of functions defined elsewhere. */
2886 /* The most obvious approach, to put an #ifndef around where
2887 this macro is used, doesn't work since it's inside a macro call. */
2888 #ifndef ASM_FINISH_DECLARE_OBJECT
2889 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2892 /* Forward declarations for nested functions are not "external",
2893 but we need to treat them as if they were. */
2894 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2895 || TREE_CODE (decl) == FUNCTION_DECL)
2896 TIMEVAR (varconst_time,
2898 make_decl_rtl (decl, asmspec, top_level);
2899 /* Initialized extern variable exists to be replaced
2900 with its value, or represents something that will be
2901 output in another file. */
2902 if (! (TREE_CODE (decl) == VAR_DECL
2903 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2904 && DECL_INITIAL (decl) != 0
2905 && DECL_INITIAL (decl) != error_mark_node))
2906 /* Don't output anything
2907 when a tentative file-scope definition is seen.
2908 But at end of compilation, do output code for them. */
2909 if (! (! at_end && top_level
2910 && (DECL_INITIAL (decl) == 0
2911 || DECL_INITIAL (decl) == error_mark_node)))
2912 assemble_variable (decl, top_level, at_end, 0);
2913 if (decl == last_assemble_variable_decl)
2915 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2919 else if (DECL_REGISTER (decl) && asmspec != 0)
2921 if (decode_reg_name (asmspec) >= 0)
2923 DECL_RTL (decl) = 0;
2924 make_decl_rtl (decl, asmspec, top_level);
2927 error ("invalid register name `%s' for register variable", asmspec);
2929 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2930 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2931 && TREE_CODE (decl) == TYPE_DECL)
2932 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2934 #ifdef SDB_DEBUGGING_INFO
2935 else if (write_symbols == SDB_DEBUG && top_level
2936 && TREE_CODE (decl) == TYPE_DECL)
2937 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2941 /* Called after finishing a record, union or enumeral type. */
2944 rest_of_type_compilation (type, toplev)
2948 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2949 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2950 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2952 #ifdef SDB_DEBUGGING_INFO
2953 if (write_symbols == SDB_DEBUG)
2954 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2958 /* This is called from finish_function (within yyparse)
2959 after each top-level definition is parsed.
2960 It is supposed to compile that function or variable
2961 and output the assembler code for it.
2962 After we return, the tree storage is freed. */
2965 rest_of_compilation (decl)
2969 int start_time = get_run_time ();
2971 /* Nonzero if we have saved the original DECL_INITIAL of the function,
2972 to be restored after we finish compiling the function
2973 (for use when compiling inline calls to this function). */
2974 tree saved_block_tree = 0;
2975 /* Likewise, for DECL_ARGUMENTS. */
2976 tree saved_arguments = 0;
2979 /* If we are reconsidering an inline function
2980 at the end of compilation, skip the stuff for making it inline. */
2982 if (DECL_SAVED_INSNS (decl) == 0)
2987 /* If requested, consider whether to make this function inline. */
2988 if (DECL_INLINE (decl) || flag_inline_functions)
2989 TIMEVAR (integration_time,
2991 lose = function_cannot_inline_p (decl);
2992 if (lose || ! optimize)
2994 if (warn_inline && DECL_INLINE (decl))
2995 warning_with_decl (decl, lose);
2996 DECL_ABSTRACT_ORIGIN (decl) = 0;
2997 /* Don't really compile an extern inline function.
2998 If we can't make it inline, pretend
2999 it was only declared. */
3000 if (DECL_EXTERNAL (decl))
3002 DECL_INITIAL (decl) = 0;
3003 goto exit_rest_of_compilation;
3007 /* ??? Note that this has the effect of making it look
3008 like "inline" was specified for a function if we choose
3009 to inline it. This isn't quite right, but it's
3010 probably not worth the trouble to fix. */
3011 inlinable = DECL_INLINE (decl) = 1;
3014 insns = get_insns ();
3016 /* Dump the rtl code if we are dumping rtl. */
3020 open_dump_file (".rtl", decl_printable_name (decl, 2));
3022 if (DECL_SAVED_INSNS (decl))
3023 fprintf (rtl_dump_file, ";; (integrable)\n\n");
3025 close_dump_file (print_rtl, insns);
3028 /* If we can, defer compiling inlines until EOF.
3029 save_for_inline_copying can be extremely expensive. */
3030 if (inlinable && ! decl_function_context (decl))
3031 DECL_DEFER_OUTPUT (decl) = 1;
3033 /* If function is inline, and we don't yet know whether to
3034 compile it by itself, defer decision till end of compilation.
3035 finish_compilation will call rest_of_compilation again
3036 for those functions that need to be output. Also defer those
3037 functions that we are supposed to defer. We cannot defer
3038 functions containing nested functions since the nested function
3039 data is in our non-saved obstack. */
3041 /* If this is a nested inline, remove ADDRESSOF now so we can
3042 finish compiling ourselves. Otherwise, wait until EOF.
3043 We have to do this because the purge_addressof transformation
3044 changes the DECL_RTL for many variables, which confuses integrate. */
3047 if (decl_function_context (decl))
3048 purge_addressof (insns);
3050 DECL_DEFER_OUTPUT (decl) = 1;
3053 if (! current_function_contains_functions
3054 && (DECL_DEFER_OUTPUT (decl)
3055 || (DECL_INLINE (decl)
3056 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
3057 && ! flag_keep_inline_functions)
3058 || DECL_EXTERNAL (decl)))))
3060 DECL_DEFER_OUTPUT (decl) = 1;
3062 /* If -Wreturn-type, we have to do a bit of compilation.
3063 However, if we just fall through we will call
3064 save_for_inline_copying() which results in excessive
3065 memory use. Instead, we just want to call
3066 jump_optimize() to figure out whether or not we can fall
3067 off the end of the function; we do the minimum amount of
3068 work necessary to make that safe. And, we set optimize
3069 to zero to keep jump_optimize from working too hard. */
3070 if (warn_return_type)
3072 int saved_optimize = optimize;
3074 find_exception_handler_labels ();
3075 jump_optimize (get_insns(), 0, 0, 0);
3076 optimize = saved_optimize;
3079 #ifdef DWARF_DEBUGGING_INFO
3080 /* Generate the DWARF info for the "abstract" instance
3081 of a function which we may later generate inlined and/or
3082 out-of-line instances of. */
3083 if (write_symbols == DWARF_DEBUG)
3085 set_decl_abstract_flags (decl, 1);
3086 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3087 set_decl_abstract_flags (decl, 0);
3090 #ifdef DWARF2_DEBUGGING_INFO
3091 /* Generate the DWARF2 info for the "abstract" instance
3092 of a function which we may later generate inlined and/or
3093 out-of-line instances of. */
3094 if (write_symbols == DWARF2_DEBUG)
3096 set_decl_abstract_flags (decl, 1);
3097 TIMEVAR (symout_time, dwarf2out_decl (decl));
3098 set_decl_abstract_flags (decl, 0);
3101 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
3102 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3103 goto exit_rest_of_compilation;
3106 /* If we have to compile the function now, save its rtl and subdecls
3107 so that its compilation will not affect what others get. */
3108 if (inlinable || DECL_DEFER_OUTPUT (decl))
3110 #ifdef DWARF_DEBUGGING_INFO
3111 /* Generate the DWARF info for the "abstract" instance of
3112 a function which we will generate an out-of-line instance
3113 of almost immediately (and which we may also later generate
3114 various inlined instances of). */
3115 if (write_symbols == DWARF_DEBUG)
3117 set_decl_abstract_flags (decl, 1);
3118 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3119 set_decl_abstract_flags (decl, 0);
3122 #ifdef DWARF2_DEBUGGING_INFO
3123 /* Generate the DWARF2 info for the "abstract" instance of
3124 a function which we will generate an out-of-line instance
3125 of almost immediately (and which we may also later generate
3126 various inlined instances of). */
3127 if (write_symbols == DWARF2_DEBUG)
3129 set_decl_abstract_flags (decl, 1);
3130 TIMEVAR (symout_time, dwarf2out_decl (decl));
3131 set_decl_abstract_flags (decl, 0);
3134 saved_block_tree = DECL_INITIAL (decl);
3135 saved_arguments = DECL_ARGUMENTS (decl);
3136 TIMEVAR (integration_time, save_for_inline_copying (decl));
3137 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable;
3140 /* If specified extern inline but we aren't inlining it, we are
3142 if (DECL_INLINE (decl) && DECL_EXTERNAL (decl))
3143 goto exit_rest_of_compilation;
3146 if (! DECL_DEFER_OUTPUT (decl))
3147 TREE_ASM_WRITTEN (decl) = 1;
3149 /* Now that integrate will no longer see our rtl, we need not distinguish
3150 between the return value of this function and the return value of called
3152 rtx_equal_function_value_matters = 0;
3154 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
3155 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3157 goto exit_rest_of_compilation;
3160 /* Emit code to get eh context, if needed. */
3164 /* If we are doing position-independent code generation, now
3165 is the time to output special prologues and epilogues.
3166 We do not want to do this earlier, because it just clutters
3167 up inline functions with meaningless insns. */
3172 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
3173 Note that that may have been done above, in save_for_inline_copying.
3174 The call to resume_temporary_allocation near the end of this function
3175 goes back to the usual state of affairs. This must be done after
3176 we've built up any unwinders for exception handling, and done
3177 the FINALIZE_PIC work, if necessary. */
3179 rtl_in_current_obstack ();
3181 insns = get_insns ();
3183 /* Copy any shared structure that should not be shared. */
3185 unshare_all_rtl (insns);
3187 #ifdef SETJMP_VIA_SAVE_AREA
3188 /* This must be performed before virutal register instantiation. */
3189 if (current_function_calls_alloca)
3190 optimize_save_area_alloca (insns);
3193 /* Instantiate all virtual registers. */
3195 instantiate_virtual_regs (current_function_decl, get_insns ());
3197 /* See if we have allocated stack slots that are not directly addressable.
3198 If so, scan all the insns and create explicit address computation
3199 for all references to such slots. */
3200 /* fixup_stack_slots (); */
3202 /* Find all the EH handlers. */
3203 find_exception_handler_labels ();
3205 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3206 are initialized and to compute whether control can drop off the end
3208 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3209 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3211 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3212 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3213 goto exit_rest_of_compilation;
3215 /* Dump rtl code after jump, if we are doing that. */
3218 dump_rtl (".jump", decl, print_rtl, insns);
3220 /* Perform common subexpression elimination.
3221 Nonzero value from `cse_main' means that jumps were simplified
3222 and some code may now be unreachable, so do
3223 jump optimization again. */
3228 open_dump_file (".cse", decl_printable_name (decl, 2));
3230 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
3232 if (flag_thread_jumps)
3233 /* Hacks by tiemann & kenner. */
3234 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3236 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3238 TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ()));
3240 if (tem || optimize > 1)
3241 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3243 /* Dump rtl code after cse, if we are doing that. */
3246 close_dump_file (print_rtl, insns);
3249 purge_addressof (insns);
3250 reg_scan (insns, max_reg_num (), 1);
3253 dump_rtl (".addressof", decl, print_rtl, insns);
3255 /* Move constant computations out of loops. */
3260 open_dump_file (".loop", decl_printable_name (decl, 2));
3265 if (flag_rerun_loop_opt)
3267 /* We only want to perform unrolling once. */
3269 loop_optimize (insns, rtl_dump_file, 0);
3271 /* The regscan pass may not be necessary, but let's
3272 be safe until we can prove otherwise. */
3273 reg_scan (insns, max_reg_num (), 1);
3275 loop_optimize (insns, rtl_dump_file, flag_unroll_loops);
3278 /* Dump rtl code after loop opt, if we are doing that. */
3281 close_dump_file (print_rtl, insns);
3287 open_dump_file (".cse2", decl_printable_name (decl, 2));
3289 if (flag_rerun_cse_after_loop)
3291 /* Running another jump optimization pass before the second
3292 cse pass sometimes simplifies the RTL enough to allow
3293 the second CSE pass to do a better job. Jump_optimize can change
3294 max_reg_num so we must rerun reg_scan afterwards.
3295 ??? Rework to not call reg_scan so often. */
3296 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3297 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1));
3299 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3300 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3303 TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0));
3306 if (flag_thread_jumps)
3308 /* This pass of jump threading straightens out code
3309 that was kinked by loop optimization. */
3310 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3311 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3314 /* Dump rtl code after cse, if we are doing that. */
3317 close_dump_file (print_rtl, insns);
3320 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3322 if (branch_prob_dump)
3323 open_dump_file (".bp", decl_printable_name (decl, 2));
3328 branch_prob (insns, rtl_dump_file);
3331 if (branch_prob_dump)
3332 close_dump_file (print_rtl, insns);
3335 /* We are no longer anticipating cse in this function, at least. */
3337 cse_not_expected = 1;
3339 /* Now we choose between stupid (pcc-like) register allocation
3340 (if we got the -noreg switch and not -opt)
3341 and smart register allocation. */
3343 if (optimize > 0) /* Stupid allocation probably won't work */
3344 obey_regdecls = 0; /* if optimizations being done. */
3348 /* Print function header into flow dump now
3349 because doing the flow analysis makes some of the dump. */
3352 open_dump_file (".flow", decl_printable_name (decl, 2));
3358 regclass (insns, max_reg_num ());
3359 stupid_life_analysis (insns, max_reg_num (),
3365 /* Do control and data flow analysis,
3366 and write some of the results to dump file. */
3368 TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
3370 if (warn_uninitialized)
3372 uninitialized_vars_warning (DECL_INITIAL (decl));
3373 setjmp_args_warning ();
3377 /* Dump rtl after flow analysis. */
3380 close_dump_file (print_rtl_with_bb, insns);
3382 /* If -opt, try combining insns through substitution. */
3386 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
3388 /* Dump rtl code after insn combination. */
3391 dump_rtl (".combine", decl, print_rtl_with_bb, insns);
3394 /* Register allocation pre-pass, to reduce number of moves
3395 necessary for two-address machines. */
3396 if (optimize > 0 && flag_regmove)
3399 open_dump_file (".regmove", decl_printable_name (decl, 2));
3401 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3405 close_dump_file (print_rtl_with_bb, insns);
3408 /* Print function header into sched dump now
3409 because doing the sched analysis makes some of the dump. */
3411 if (optimize > 0 && flag_schedule_insns)
3414 open_dump_file (".sched", decl_printable_name (decl, 2));
3416 /* Do control and data sched analysis,
3417 and write some of the results to dump file. */
3419 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3421 /* Dump rtl after instruction scheduling. */
3424 close_dump_file (print_rtl_with_bb, insns);
3427 /* Unless we did stupid register allocation,
3428 allocate pseudo-regs that are used only within 1 basic block. */
3431 TIMEVAR (local_alloc_time,
3433 regclass (insns, max_reg_num ());
3437 /* Dump rtl code after allocating regs within basic blocks. */
3441 open_dump_file (".lreg", decl_printable_name (decl, 2));
3443 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3444 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3446 close_dump_file (print_rtl_with_bb, insns);
3449 if (global_reg_dump)
3450 open_dump_file (".greg", decl_printable_name (decl, 2));
3452 /* Save the last label number used so far, so reorg can tell
3453 when it's safe to kill spill regs. */
3454 max_label_num_after_reload = max_label_num ();
3456 /* Unless we did stupid register allocation,
3457 allocate remaining pseudo-regs, then do the reload pass
3458 fixing up any insns that are invalid. */
3460 TIMEVAR (global_alloc_time,
3463 failure = global_alloc (rtl_dump_file);
3465 failure = reload (insns, 0, rtl_dump_file);
3468 if (global_reg_dump)
3470 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3471 close_dump_file (print_rtl_with_bb, insns);
3475 goto exit_rest_of_compilation;
3477 reload_completed = 1;
3479 /* Do a very simple CSE pass over just the hard registers. */
3481 reload_cse_regs (insns);
3483 /* On some machines, the prologue and epilogue code, or parts thereof,
3484 can be represented as RTL. Doing so lets us schedule insns between
3485 it and the rest of the code and also allows delayed branch
3486 scheduling to operate in the epilogue. */
3488 thread_prologue_and_epilogue_insns (insns);
3490 if (optimize > 0 && flag_schedule_insns_after_reload)
3493 open_dump_file (".sched2", decl_printable_name (decl, 2));
3495 /* Do control and data sched analysis again,
3496 and write some more of the results to dump file. */
3498 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3500 /* Dump rtl after post-reorder instruction scheduling. */
3503 close_dump_file (print_rtl_with_bb, insns);
3506 #ifdef LEAF_REGISTERS
3508 if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
3512 /* One more attempt to remove jumps to .+1
3513 left by dead-store-elimination.
3514 Also do cross-jumping this time
3515 and delete no-op move insns. */
3519 TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0));
3521 /* Dump rtl code after jump, if we are doing that. */
3524 dump_rtl (".jump2", decl, print_rtl_with_bb, insns);
3527 /* If a machine dependent reorganization is needed, call it. */
3528 #ifdef MACHINE_DEPENDENT_REORG
3529 MACHINE_DEPENDENT_REORG (insns);
3531 if (mach_dep_reorg_dump)
3532 dump_rtl (".mach", decl, print_rtl_with_bb, insns);
3535 /* If a scheduling pass for delayed branches is to be done,
3536 call the scheduling code. */
3539 if (optimize > 0 && flag_delayed_branch)
3541 TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
3544 dump_rtl (".dbr", decl, print_rtl_with_bb, insns);
3548 /* Shorten branches. */
3549 TIMEVAR (shorten_branch_time,
3551 shorten_branches (get_insns ());
3555 TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file));
3558 dump_rtl (".stack", decl, print_rtl_with_bb, insns);
3561 /* Now turn the rtl into assembler code. */
3563 TIMEVAR (final_time,
3568 /* Get the function's name, as described by its RTL.
3569 This may be different from the DECL_NAME name used
3570 in the source file. */
3572 x = DECL_RTL (decl);
3573 if (GET_CODE (x) != MEM)
3576 if (GET_CODE (x) != SYMBOL_REF)
3578 fnname = XSTR (x, 0);
3580 assemble_start_function (decl, fnname);
3581 final_start_function (insns, asm_out_file, optimize);
3582 final (insns, asm_out_file, optimize, 0);
3583 final_end_function (insns, asm_out_file, optimize);
3584 assemble_end_function (decl, fnname);
3585 fflush (asm_out_file);
3587 /* Release all memory held by regsets now */
3588 regset_release_memory ();
3591 /* Write DBX symbols if requested */
3593 /* Note that for those inline functions where we don't initially
3594 know for certain that we will be generating an out-of-line copy,
3595 the first invocation of this routine (rest_of_compilation) will
3596 skip over this code by doing a `goto exit_rest_of_compilation;'.
3597 Later on, finish_compilation will call rest_of_compilation again
3598 for those inline functions that need to have out-of-line copies
3599 generated. During that call, we *will* be routed past here. */
3601 #ifdef DBX_DEBUGGING_INFO
3602 if (write_symbols == DBX_DEBUG)
3603 TIMEVAR (symout_time, dbxout_function (decl));
3606 #ifdef DWARF_DEBUGGING_INFO
3607 if (write_symbols == DWARF_DEBUG)
3608 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3611 #ifdef DWARF2_DEBUGGING_INFO
3612 if (write_symbols == DWARF2_DEBUG)
3613 TIMEVAR (symout_time, dwarf2out_decl (decl));
3616 exit_rest_of_compilation:
3618 /* In case the function was not output,
3619 don't leave any temporary anonymous types
3620 queued up for sdb output. */
3621 #ifdef SDB_DEBUGGING_INFO
3622 if (write_symbols == SDB_DEBUG)
3623 sdbout_types (NULL_TREE);
3626 /* Put back the tree of subblocks and list of arguments
3627 from before we copied them.
3628 Code generation and the output of debugging info may have modified
3629 the copy, but the original is unchanged. */
3631 if (saved_block_tree != 0)
3633 DECL_INITIAL (decl) = saved_block_tree;
3634 DECL_ARGUMENTS (decl) = saved_arguments;
3635 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
3638 reload_completed = 0;
3640 /* Clear out the insn_length contents now that they are no longer valid. */
3641 init_insn_lengths ();
3643 /* Clear out the real_constant_chain before some of the rtx's
3644 it runs through become garbage. */
3646 clear_const_double_mem ();
3648 /* Cancel the effect of rtl_in_current_obstack. */
3650 resume_temporary_allocation ();
3652 /* Show no temporary slots allocated. */
3656 /* The parsing time is all the time spent in yyparse
3657 *except* what is spent in this function. */
3659 parse_time -= get_run_time () - start_time;
3662 /* Entry point of cc1/c++. Decode command args, then call compile_file.
3663 Exit code is 35 if can't open files, 34 if fatal error,
3664 33 if had nonfatal errors, else success. */
3667 main (argc, argv, envp)
3674 int flag_print_mem = 0;
3675 int version_flag = 0;
3678 /* save in case md file wants to emit args as a comment. */
3682 p = argv[0] + strlen (argv[0]);
3683 while (p != argv[0] && p[-1] != '/'
3684 #ifdef DIR_SEPARATOR
3685 && p[-1] != DIR_SEPARATOR
3691 #if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT)
3692 /* Get rid of any avoidable limit on stack size. */
3696 /* Set the stack limit huge so that alloca does not fail. */
3697 getrlimit (RLIMIT_STACK, &rlim);
3698 rlim.rlim_cur = rlim.rlim_max;
3699 setrlimit (RLIMIT_STACK, &rlim);
3703 signal (SIGFPE, float_signal);
3706 signal (SIGPIPE, pipe_closed);
3709 decl_printable_name = decl_name;
3710 lang_expand_expr = (struct rtx_def *(*)()) do_abort;
3712 /* Initialize whether `char' is signed. */
3713 flag_signed_char = DEFAULT_SIGNED_CHAR;
3714 #ifdef DEFAULT_SHORT_ENUMS
3715 /* Initialize how much space enums occupy, by default. */
3716 flag_short_enums = DEFAULT_SHORT_ENUMS;
3719 /* Scan to see what optimization level has been specified. That will
3720 determine the default value of many flags. */
3721 for (i = 1; i < argc; i++)
3723 if (!strcmp (argv[i], "-O"))
3727 else if (argv[i][0] == '-' && argv[i][1] == 'O')
3729 /* Handle -Os, -O2, -O3, -O69, ... */
3730 char *p = &argv[i][2];
3733 if ((p[0] == 's') && (p[1] == 0))
3738 if (! (c >= '0' && c <= '9'))
3741 optimize = atoi (&argv[i][2]);
3746 /* Optimizing for size forces optimize to be no less than 2. */
3747 if (optimize_size && (optimize < 2))
3750 obey_regdecls = (optimize == 0);
3755 flag_thread_jumps = 1;
3757 flag_delayed_branch = 1;
3759 #ifdef CAN_DEBUG_WITHOUT_FP
3760 flag_omit_frame_pointer = 1;
3766 flag_cse_follow_jumps = 1;
3767 flag_cse_skip_blocks = 1;
3768 flag_expensive_optimizations = 1;
3769 flag_strength_reduce = 1;
3770 flag_rerun_cse_after_loop = 1;
3771 flag_rerun_loop_opt = 1;
3772 flag_caller_saves = 1;
3774 #ifdef INSN_SCHEDULING
3775 flag_schedule_insns = 1;
3776 flag_schedule_insns_after_reload = 1;
3783 flag_inline_functions = 1;
3786 /* Disable code bloating optimizations if optimizing for size. */
3789 flag_inline_functions = 0;
3792 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
3795 set_target_switch ("");
3797 #ifdef OPTIMIZATION_OPTIONS
3798 /* Allow default optimizations to be specified on a per-machine basis. */
3799 OPTIMIZATION_OPTIONS (optimize, optimize_size);
3802 /* Initialize register usage now so switches may override. */
3805 for (i = 1; i < argc; i++)
3808 /* If this is a language-specific option,
3809 decode it in a language-specific way. */
3810 for (j = 0; lang_options[j] != 0; j++)
3811 if (!strncmp (argv[i], lang_options[j],
3812 strlen (lang_options[j])))
3814 if (lang_options[j] != 0)
3815 /* If the option is valid for *some* language,
3816 treat it as valid even if this language doesn't understand it. */
3817 lang_decode_option (argv[i]);
3818 else if (argv[i][0] == '-' && argv[i][1] != 0)
3820 register char *str = argv[i] + 1;
3825 set_target_switch (&str[1]);
3826 else if (!strcmp (str, "dumpbase"))
3828 dump_base_name = argv[++i];
3830 else if (str[0] == 'd')
3832 register char *p = &str[1];
3837 branch_prob_dump = 1;
3841 global_reg_dump = 1;
3849 cse_dump = 1, cse2_dump = 1;
3855 #ifdef MACHINE_DEPENDENT_REORG
3856 mach_dep_reorg_dump = 1;
3860 branch_prob_dump = 1;
3877 global_reg_dump = 1;
3897 #ifdef MACHINE_DEPENDENT_REORG
3899 mach_dep_reorg_dump = 1;
3903 flag_print_asm_name = 1;
3927 rtl_dump_and_exit = 1;
3933 warning ("unrecognised gcc debugging option: %c", p[-1]);
3937 else if (str[0] == 'f')
3939 register char *p = &str[1];
3942 /* Some kind of -f option.
3943 P's value is the option sans `-f'.
3944 Search for it in the table of options. */
3947 !found && j < sizeof (f_options) / sizeof (f_options[0]);
3950 if (!strcmp (p, f_options[j].string))
3952 *f_options[j].variable = f_options[j].on_value;
3953 /* A goto here would be cleaner,
3954 but breaks the vax pcc. */
3957 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
3958 && ! strcmp (p+3, f_options[j].string))
3960 *f_options[j].variable = ! f_options[j].on_value;
3968 #ifdef INSN_SCHEDULING
3969 else if (!strncmp (p, "sched-verbose-",14))
3970 fix_sched_param("verbose",&p[14]);
3971 else if (!strncmp (p, "sched-max-",10))
3972 fix_sched_param("max",&p[10]);
3973 else if (!strncmp (p, "sched-inter-max-b-",18))
3974 fix_sched_param("interblock-max-blocks",&p[18]);
3975 else if (!strncmp (p, "sched-inter-max-i-",18))
3976 fix_sched_param("interblock-max-insns",&p[18]);
3979 else if (!strncmp (p, "fixed-", 6))
3980 fix_register (&p[6], 1, 1);
3981 else if (!strncmp (p, "call-used-", 10))
3982 fix_register (&p[10], 0, 1);
3983 else if (!strncmp (p, "call-saved-", 11))
3984 fix_register (&p[11], 0, 0);
3986 error ("Invalid option `%s'", argv[i]);
3988 else if (str[0] == 'O')
3990 register char *p = str+1;
3994 while (*p && *p >= '0' && *p <= '9')
3999 error ("Invalid option `%s'", argv[i]);
4001 else if (!strcmp (str, "pedantic"))
4003 else if (!strcmp (str, "pedantic-errors"))
4004 flag_pedantic_errors = pedantic = 1;
4005 else if (!strcmp (str, "quiet"))
4007 else if (!strcmp (str, "version"))
4009 else if (!strcmp (str, "w"))
4010 inhibit_warnings = 1;
4011 else if (!strcmp (str, "W"))
4014 /* We save the value of warn_uninitialized, since if they put
4015 -Wuninitialized on the command line, we need to generate a
4016 warning about not using it without also specifying -O. */
4017 if (warn_uninitialized != 1)
4018 warn_uninitialized = 2;
4020 else if (str[0] == 'W')
4022 register char *p = &str[1];
4025 /* Some kind of -W option.
4026 P's value is the option sans `-W'.
4027 Search for it in the table of options. */
4030 !found && j < sizeof (W_options) / sizeof (W_options[0]);
4033 if (!strcmp (p, W_options[j].string))
4035 *W_options[j].variable = W_options[j].on_value;
4036 /* A goto here would be cleaner,
4037 but breaks the vax pcc. */
4040 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
4041 && ! strcmp (p+3, W_options[j].string))
4043 *W_options[j].variable = ! W_options[j].on_value;
4050 else if (!strncmp (p, "id-clash-", 9))
4056 if (*endp >= '0' && *endp <= '9')
4060 error ("Invalid option `%s'", argv[i]);
4065 id_clash_len = atoi (str + 10);
4068 else if (!strncmp (p, "larger-than-", 12))
4070 char *endp = p + 12;
4074 if (*endp >= '0' && *endp <= '9')
4078 error ("Invalid option `%s'", argv[i]);
4079 goto larger_than_lose;
4082 warn_larger_than = 1;
4083 larger_than_size = atoi (str + 13);
4087 error ("Invalid option `%s'", argv[i]);
4089 else if (!strcmp (str, "p"))
4093 else if (!strcmp (str, "a"))
4095 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4096 warning ("`-a' option (basic block profile) not supported");
4098 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4101 else if (!strcmp (str, "ax"))
4103 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4104 warning ("`-ax' option (jump profiling) not supported");
4106 profile_block_flag = (!profile_block_flag
4107 || profile_block_flag == 2) ? 2 : 3;
4110 else if (str[0] == 'g')
4114 /* A lot of code assumes write_symbols == NO_DEBUG if the
4115 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4116 of what debugging type has been selected). This records the
4117 selected type. It is an error to specify more than one
4119 static enum debug_info_type selected_debug_type = NO_DEBUG;
4120 /* Non-zero if debugging format has been explicitly set.
4121 -g and -ggdb don't explicitly set the debugging format so
4122 -gdwarf -g3 is equivalent to -gdwarf3. */
4123 static int type_explicitly_set_p = 0;
4124 /* Table of supported debugging formats. */
4127 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
4128 constant expression, we use NO_DEBUG in its place. */
4129 enum debug_info_type debug_type;
4130 int use_extensions_p;
4131 } *da, debug_args[] = {
4132 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS },
4133 { "ggdb", NO_DEBUG, 1 },
4134 #ifdef DBX_DEBUGGING_INFO
4135 { "gstabs", DBX_DEBUG, 0 },
4136 { "gstabs+", DBX_DEBUG, 1 },
4138 #ifdef DWARF_DEBUGGING_INFO
4139 { "gdwarf", DWARF_DEBUG, 0 },
4140 { "gdwarf+", DWARF_DEBUG, 1 },
4142 #ifdef DWARF2_DEBUGGING_INFO
4143 { "gdwarf-2", DWARF2_DEBUG, 0 },
4145 #ifdef XCOFF_DEBUGGING_INFO
4146 { "gxcoff", XCOFF_DEBUG, 0 },
4147 { "gxcoff+", XCOFF_DEBUG, 1 },
4149 #ifdef SDB_DEBUGGING_INFO
4150 { "gcoff", SDB_DEBUG, 0 },
4154 /* Indexed by enum debug_info_type. */
4155 static char *debug_type_names[] = {
4156 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4159 /* Look up STR in the table. */
4160 for (da = debug_args; da->arg; da++)
4162 if (! strncmp (str, da->arg, strlen (da->arg)))
4164 enum debug_info_type type = da->debug_type;
4167 p = str + strlen (da->arg);
4168 if (*p && (*p < '0' || *p > '9'))
4172 while (*q && (*q >= '0' && *q <= '9'))
4177 if (len > 1 && !strncmp (str, "gdwarf", len))
4179 error ("use -gdwarf -g%d for DWARF v1, level %d",
4182 error ("use -gdwarf-2 for DWARF v2");
4186 level = 2; /* default debugging info level */
4187 if (*q || level > 3)
4189 warning ("invalid debug level specification in option: `-%s'",
4191 /* ??? This error message is incorrect in the case of
4193 warning ("no debugging information will be generated");
4197 if (type == NO_DEBUG)
4199 type = PREFERRED_DEBUGGING_TYPE;
4200 if (len > 1 && strncmp (str, "ggdb", len) == 0)
4202 #ifdef DWARF2_DEBUGGING_INFO
4203 type = DWARF2_DEBUG;
4205 #ifdef DBX_DEBUGGING_INFO
4212 if (type == NO_DEBUG)
4213 warning ("`-%s' not supported by this configuration of GCC",
4216 /* Does it conflict with an already selected type? */
4217 if (type_explicitly_set_p
4218 /* -g/-ggdb don't conflict with anything */
4219 && da->debug_type != NO_DEBUG
4220 && type != selected_debug_type)
4221 warning ("`-%s' ignored, conflicts with `-g%s'",
4222 str, debug_type_names[(int) selected_debug_type]);
4225 /* If the format has already been set, -g/-ggdb
4226 only change the debug level. */
4227 if (type_explicitly_set_p
4228 && da->debug_type == NO_DEBUG)
4229 ; /* don't change debugging type */
4232 selected_debug_type = type;
4233 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4235 write_symbols = (level == 0
4237 : selected_debug_type);
4238 use_gnu_debug_info_extensions = da->use_extensions_p;
4239 debug_info_level = (enum debug_info_level) level;
4245 warning ("`-%s' not supported by this configuration of GCC",
4248 else if (!strcmp (str, "o"))
4250 asm_file_name = argv[++i];
4252 else if (str[0] == 'G')
4254 g_switch_set = TRUE;
4255 g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]);
4257 else if (!strncmp (str, "aux-info", 8))
4259 flag_gen_aux_info = 1;
4260 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]);
4263 error ("Invalid option `%s'", argv[i]);
4265 else if (argv[i][0] == '+')
4266 error ("Invalid option `%s'", argv[i]);
4271 /* Checker uses the frame pointer. */
4272 if (flag_check_memory_usage)
4273 flag_omit_frame_pointer = 0;
4277 /* Inlining does not work if not optimizing,
4278 so force it not to be done. */
4282 /* The c_decode_option and lang_decode_option functions set
4283 this to `2' if -Wall is used, so we can avoid giving out
4284 lots of errors for people who don't realize what -Wall does. */
4285 if (warn_uninitialized == 1)
4286 warning ("-Wuninitialized is not supported without -O");
4289 #ifdef OVERRIDE_OPTIONS
4290 /* Some machines may reject certain combinations of options. */
4294 if (exceptions_via_longjmp == 2)
4296 #ifdef DWARF2_UNWIND_INFO
4297 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4299 exceptions_via_longjmp = 1;
4303 if (profile_block_flag == 3)
4305 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4306 profile_block_flag = 2;
4309 /* Unrolling all loops implies that standard loop unrolling must also
4311 if (flag_unroll_all_loops)
4312 flag_unroll_loops = 1;
4313 /* Loop unrolling requires that strength_reduction be on also. Silently
4314 turn on strength reduction here if it isn't already on. Also, the loop
4315 unrolling code assumes that cse will be run after loop, so that must
4316 be turned on also. */
4317 if (flag_unroll_loops)
4319 flag_strength_reduce = 1;
4320 flag_rerun_cse_after_loop = 1;
4323 /* Warn about options that are not supported on this machine. */
4324 #ifndef INSN_SCHEDULING
4325 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4326 warning ("instruction scheduling not supported on this target machine");
4329 if (flag_delayed_branch)
4330 warning ("this target machine does not have delayed branches");
4333 /* If we are in verbose mode, write out the version and maybe all the
4334 option flags in use. */
4337 print_version (stderr, "");
4339 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4342 compile_file (filename);
4344 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN32__))
4347 char *lim = (char *) sbrk (0);
4349 fprintf (stderr, "Data size %d.\n",
4350 lim - (char *) &environ);
4355 system ("ps -l 1>&2");
4358 #endif /* not USG */
4361 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN32) */
4364 exit (FATAL_EXIT_CODE);
4366 exit (FATAL_EXIT_CODE);
4367 exit (SUCCESS_EXIT_CODE);
4371 /* Decode -m switches. */
4373 /* Here is a table, controlled by the tm.h file, listing each -m switch
4374 and which bits in `target_switches' it should set or clear.
4375 If VALUE is positive, it is bits to set.
4376 If VALUE is negative, -VALUE is bits to clear.
4377 (The sign bit is not used so there is no confusion.) */
4379 struct {char *name; int value;} target_switches []
4382 /* This table is similar, but allows the switch to have a value. */
4384 #ifdef TARGET_OPTIONS
4385 struct {char *prefix; char ** variable;} target_options []
4389 /* Decode the switch -mNAME. */
4392 set_target_switch (name)
4398 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4399 if (!strcmp (target_switches[j].name, name))
4401 if (target_switches[j].value < 0)
4402 target_flags &= ~-target_switches[j].value;
4404 target_flags |= target_switches[j].value;
4408 #ifdef TARGET_OPTIONS
4410 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4412 int len = strlen (target_options[j].prefix);
4413 if (!strncmp (target_options[j].prefix, name, len))
4415 *target_options[j].variable = name + len;
4422 error ("Invalid option `%s'", name);
4425 /* Print version information to FILE.
4426 Each line begins with INDENT (for the case where FILE is the
4427 assembler output file). */
4430 print_version (file, indent)
4434 fprintf (file, "%s%s%s version %s", indent, *indent != 0 ? " " : "",
4435 language_string, version_string);
4436 fprintf (file, " (%s)", TARGET_NAME);
4439 #define __VERSION__ "[unknown]"
4441 fprintf (file, " compiled by GNU C version %s.\n", __VERSION__);
4443 fprintf (file, " compiled by CC.\n");
4447 /* Print an option value and return the adjusted position in the line.
4448 ??? We don't handle error returns from fprintf (disk full); presumably
4449 other code will catch a disk full though. */
4452 print_single_switch (file, pos, max, indent, sep, term, type, name)
4455 char *indent, *sep, *term, *type, *name;
4457 /* The ultrix fprintf returns 0 on success, so compute the result we want
4458 here since we need it for the following test. */
4459 int len = strlen (sep) + strlen (type) + strlen (name);
4464 fprintf (file, "%s", term);
4469 fprintf (file, "%s", indent);
4470 pos = strlen (indent);
4472 fprintf (file, "%s%s%s", sep, type, name);
4477 /* Print active target switches to FILE.
4478 POS is the current cursor position and MAX is the size of a "line".
4479 Each line begins with INDENT and ends with TERM.
4480 Each switch is separated from the next by SEP. */
4483 print_switch_values (file, pos, max, indent, sep, term)
4486 char *indent, *sep, *term;
4491 /* Print the options as passed. */
4493 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4494 "options passed: ", "");
4496 for (p = &save_argv[1]; *p != NULL; p++)
4500 if (strcmp (*p, "-o") == 0)
4506 if (strcmp (*p, "-quiet") == 0)
4508 if (strcmp (*p, "-version") == 0)
4513 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4516 fprintf (file, "%s", term);
4518 /* Print the -f and -m options that have been enabled.
4519 We don't handle language specific options but printing argv
4522 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4523 "options enabled: ", "");
4525 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4526 if (*f_options[j].variable == f_options[j].on_value)
4527 pos = print_single_switch (file, pos, max, indent, sep, term,
4528 "-f", f_options[j].string);
4530 /* Print target specific options. */
4532 flags = target_flags;
4533 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4534 if (target_switches[j].name[0] != '\0'
4535 && target_switches[j].value > 0
4536 && ((target_switches[j].value & target_flags)
4537 == target_switches[j].value))
4539 pos = print_single_switch (file, pos, max, indent, sep, term,
4540 "-m", target_switches[j].name);
4541 flags &= ~ target_switches[j].value;
4544 #ifdef TARGET_OPTIONS
4545 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4546 if (*target_options[j].variable != NULL)
4549 sprintf (prefix, "-m%s", target_options[j].prefix);
4550 pos = print_single_switch (file, pos, max, indent, sep, term,
4551 prefix, *target_options[j].variable);
4555 fprintf (file, "%s", term);
4558 /* Record the beginning of a new source file, named FILENAME. */
4561 debug_start_source_file (filename)
4562 register char *filename;
4564 #ifdef DBX_DEBUGGING_INFO
4565 if (write_symbols == DBX_DEBUG)
4566 dbxout_start_new_source_file (filename);
4568 #ifdef DWARF_DEBUGGING_INFO
4569 if (debug_info_level == DINFO_LEVEL_VERBOSE
4570 && write_symbols == DWARF_DEBUG)
4571 dwarfout_start_new_source_file (filename);
4572 #endif /* DWARF_DEBUGGING_INFO */
4573 #ifdef DWARF2_DEBUGGING_INFO
4574 if (debug_info_level == DINFO_LEVEL_VERBOSE
4575 && write_symbols == DWARF2_DEBUG)
4576 dwarf2out_start_source_file (filename);
4577 #endif /* DWARF2_DEBUGGING_INFO */
4578 #ifdef SDB_DEBUGGING_INFO
4579 if (write_symbols == SDB_DEBUG)
4580 sdbout_start_new_source_file (filename);
4584 /* Record the resumption of a source file. LINENO is the line number in
4585 the source file we are returning to. */
4588 debug_end_source_file (lineno)
4589 register unsigned lineno;
4591 #ifdef DBX_DEBUGGING_INFO
4592 if (write_symbols == DBX_DEBUG)
4593 dbxout_resume_previous_source_file ();
4595 #ifdef DWARF_DEBUGGING_INFO
4596 if (debug_info_level == DINFO_LEVEL_VERBOSE
4597 && write_symbols == DWARF_DEBUG)
4598 dwarfout_resume_previous_source_file (lineno);
4599 #endif /* DWARF_DEBUGGING_INFO */
4600 #ifdef DWARF2_DEBUGGING_INFO
4601 if (debug_info_level == DINFO_LEVEL_VERBOSE
4602 && write_symbols == DWARF2_DEBUG)
4603 dwarf2out_end_source_file ();
4604 #endif /* DWARF2_DEBUGGING_INFO */
4605 #ifdef SDB_DEBUGGING_INFO
4606 if (write_symbols == SDB_DEBUG)
4607 sdbout_resume_previous_source_file ();
4611 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4612 the tail part of the directive line, i.e. the part which is past the
4613 initial whitespace, #, whitespace, directive-name, whitespace part. */
4616 debug_define (lineno, buffer)
4617 register unsigned lineno;
4618 register char *buffer;
4620 #ifdef DWARF_DEBUGGING_INFO
4621 if (debug_info_level == DINFO_LEVEL_VERBOSE
4622 && write_symbols == DWARF_DEBUG)
4623 dwarfout_define (lineno, buffer);
4624 #endif /* DWARF_DEBUGGING_INFO */
4625 #ifdef DWARF2_DEBUGGING_INFO
4626 if (debug_info_level == DINFO_LEVEL_VERBOSE
4627 && write_symbols == DWARF2_DEBUG)
4628 dwarf2out_define (lineno, buffer);
4629 #endif /* DWARF2_DEBUGGING_INFO */
4632 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4633 the tail part of the directive line, i.e. the part which is past the
4634 initial whitespace, #, whitespace, directive-name, whitespace part. */
4637 debug_undef (lineno, buffer)
4638 register unsigned lineno;
4639 register char *buffer;
4641 #ifdef DWARF_DEBUGGING_INFO
4642 if (debug_info_level == DINFO_LEVEL_VERBOSE
4643 && write_symbols == DWARF_DEBUG)
4644 dwarfout_undef (lineno, buffer);
4645 #endif /* DWARF_DEBUGGING_INFO */
4646 #ifdef DWARF2_DEBUGGING_INFO
4647 if (debug_info_level == DINFO_LEVEL_VERBOSE
4648 && write_symbols == DWARF2_DEBUG)
4649 dwarf2out_undef (lineno, buffer);
4650 #endif /* DWARF2_DEBUGGING_INFO */