1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
47 #include "insn-attr.h"
48 #include "insn-codes.h"
49 #include "insn-config.h"
57 #include "basic-block.h"
64 #ifndef ACCUMULATE_OUTGOING_ARGS
65 #define ACCUMULATE_OUTGOING_ARGS 0
68 #ifdef DWARF_DEBUGGING_INFO
72 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
73 #include "dwarf2out.h"
76 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
80 #ifdef SDB_DEBUGGING_INFO
84 #ifdef XCOFF_DEBUGGING_INFO
89 /* The extra parameters substantially improve the I/O performance. */
91 vms_fopen (fname, type)
95 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
96 fixed arguments, which matches ANSI's specification but not VAXCRTL's
97 pre-ANSI implementation. This hack circumvents the mismatch problem. */
98 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
101 return (*vmslib_fopen) (fname, type, "mbc=32",
102 "deq=64", "fop=tef", "shr=nil");
104 return (*vmslib_fopen) (fname, type, "mbc=32");
106 #define fopen vms_fopen
109 #ifndef DEFAULT_GDB_EXTENSIONS
110 #define DEFAULT_GDB_EXTENSIONS 1
113 /* If more than one debugging type is supported, you must define
114 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
116 This is one long line cause VAXC can't handle a \-newline. */
117 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
118 #ifndef PREFERRED_DEBUGGING_TYPE
119 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
120 #endif /* no PREFERRED_DEBUGGING_TYPE */
121 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
122 so the following code needn't care. */
123 #ifdef DBX_DEBUGGING_INFO
124 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
126 #ifdef SDB_DEBUGGING_INFO
127 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
129 #ifdef DWARF_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
132 #ifdef DWARF2_DEBUGGING_INFO
133 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
135 #ifdef XCOFF_DEBUGGING_INFO
136 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
138 #endif /* More than one debugger format enabled. */
140 /* If still not defined, must have been because no debugging formats
142 #ifndef PREFERRED_DEBUGGING_TYPE
143 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
146 #ifdef NEED_DECLARATION_ENVIRON
147 extern char **environ;
150 /* Carry information from ASM_DECLARE_OBJECT_NAME
151 to ASM_FINISH_DECLARE_OBJECT. */
153 extern int size_directive_output;
154 extern tree last_assemble_variable_decl;
156 static void set_target_switch PARAMS ((const char *));
157 static const char *decl_name PARAMS ((tree, int));
159 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
160 static void pipe_closed PARAMS ((int)) ATTRIBUTE_NORETURN;
161 #ifdef ASM_IDENTIFY_LANGUAGE
162 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
163 static void output_lang_identify PARAMS ((FILE *)) ATTRIBUTE_UNUSED;
165 static void compile_file PARAMS ((char *));
166 static void display_help PARAMS ((void));
167 static void mark_file_stack PARAMS ((void *));
169 static void decode_d_option PARAMS ((const char *));
170 static int decode_f_option PARAMS ((const char *));
171 static int decode_W_option PARAMS ((const char *));
172 static int decode_g_option PARAMS ((const char *));
173 static unsigned int independent_decode_option PARAMS ((int, char **,
176 static void print_version PARAMS ((FILE *, const char *));
177 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
178 const char *, const char *,
179 const char *, const char *));
180 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
181 const char *, const char *));
183 /* Length of line when printing switch values. */
186 /* Name of program invoked, sans directories. */
188 const char *progname;
190 /* Copy of arguments to main. */
194 /* Name of current original source file (what was input to cpp).
195 This comes from each #-command in the actual input. */
197 char *input_filename;
199 /* Name of top-level original source file (what was input to cpp).
200 This comes from the #-command at the beginning of the actual input.
201 If there isn't any there, then this is the cc1 input file name. */
203 char *main_input_filename;
205 /* Current line number in real source file. */
209 /* Nonzero if it is unsafe to create any new pseudo registers. */
212 /* Stack of currently pending input files. */
214 struct file_stack *input_file_stack;
216 /* Incremented on each change to input_file_stack. */
217 int input_file_stack_tick;
219 /* Name to use as base of names for dump output files. */
221 const char *dump_base_name;
223 /* Bit flags that specify the machine subtype we are compiling for.
224 Bits are tested using macros TARGET_... defined in the tm.h file
225 and set by `-m...' switches. Must be defined in rtlanal.c. */
227 extern int target_flags;
229 /* Describes a dump file. */
231 struct dump_file_info
233 /* The unique extension to apply, e.g. ".jump". */
234 const char * const extension;
236 /* The -d<c> character that enables this dump file. */
237 char const debug_switch;
239 /* True if there is a corresponding graph dump file. */
240 char const graph_dump_p;
242 /* True if the user selected this dump. */
245 /* True if the files have been initialized (ie truncated). */
249 /* Enumerate the extant dump files. */
281 /* Describes all the dump files. Should be kept in order of the
282 pass and in sync with dump_file_index above. */
284 struct dump_file_info dump_file[DFI_MAX] =
286 { "rtl", 'r', 0, 0, 0 },
287 { "jump", 'j', 0, 0, 0 },
288 { "cse", 's', 0, 0, 0 },
289 { "addressof", 'F', 0, 0, 0 },
290 { "ssa", 'e', 1, 0, 0 },
291 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
292 { "gcse", 'G', 1, 0, 0 },
293 { "loop", 'L', 1, 0, 0 },
294 { "cse2", 't', 1, 0, 0 },
295 { "bp", 'b', 1, 0, 0 },
296 { "flow", 'f', 1, 0, 0 },
297 { "combine", 'c', 1, 0, 0 },
298 { "regmove", 'N', 1, 0, 0 },
299 { "sched", 'S', 1, 0, 0 },
300 { "lreg", 'l', 1, 0, 0 },
301 { "greg", 'g', 1, 0, 0 },
302 { "flow2", 'w', 1, 0, 0 },
303 { "peephole2", 'z', 1, 0, 0 },
304 { "sched2", 'R', 1, 0, 0 },
305 { "bbro", 'B', 1, 0, 0 },
306 { "rnreg", 'n', 1, 0, 0 },
307 { "jump2", 'J', 1, 0, 0 },
308 { "mach", 'M', 1, 0, 0 },
309 { "dbr", 'd', 0, 0, 0 },
310 { "stack", 'k', 1, 0, 0 },
313 static int open_dump_file PARAMS ((enum dump_file_index, tree));
314 static void close_dump_file PARAMS ((enum dump_file_index,
315 void (*) (FILE *, rtx), rtx));
317 /* Other flags saying which kinds of debugging dump have been requested. */
319 int rtl_dump_and_exit;
320 int flag_print_asm_name;
321 static int flag_print_mem;
322 static int version_flag;
323 static char * filename;
324 enum graph_dump_types graph_dump_format;
326 /* Name for output file of assembly code, specified with -o. */
330 /* Value of the -G xx switch, and whether it was passed or not. */
334 /* Type(s) of debugging information we are producing (if any).
335 See flags.h for the definitions of the different possible
336 types of debugging information. */
337 enum debug_info_type write_symbols = NO_DEBUG;
339 /* Level of debugging information we are producing. See flags.h
340 for the definitions of the different possible levels. */
341 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
343 /* Nonzero means use GNU-only extensions in the generated symbolic
344 debugging information. */
345 /* Currently, this only has an effect when write_symbols is set to
346 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
347 int use_gnu_debug_info_extensions = 0;
349 /* Nonzero means do optimizations. -O.
350 Particular numeric values stand for particular amounts of optimization;
351 thus, -O2 stores 2 here. However, the optimizations beyond the basic
352 ones are not controlled directly by this variable. Instead, they are
353 controlled by individual `flag_...' variables that are defaulted
354 based on this variable. */
358 /* Nonzero means optimize for size. -Os.
359 The only valid values are zero and non-zero. When optimize_size is
360 non-zero, optimize defaults to 2, but certain individual code
361 bloating optimizations are disabled. */
363 int optimize_size = 0;
365 /* Number of error messages and warning messages so far. */
368 int warningcount = 0;
371 /* The FUNCTION_DECL for the function currently being compiled,
372 or 0 if between functions. */
373 tree current_function_decl;
375 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
377 tree current_function_func_begin_label;
379 /* Pointer to function to compute the name to use to print a declaration.
380 DECL is the declaration in question.
381 VERBOSITY determines what information will be printed:
382 0: DECL_NAME, demangled as necessary.
383 1: and scope information.
384 2: and any other information that might be interesting, such as function
385 parameter types in C++. */
387 const char *(*decl_printable_name) PARAMS ((tree, int));
389 /* Pointer to function to compute rtl for a language-specific tree code. */
391 typedef rtx (*lang_expand_expr_t)
392 PARAMS ((union tree_node *, rtx, enum machine_mode,
393 enum expand_modifier modifier));
395 lang_expand_expr_t lang_expand_expr = 0;
397 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
399 /* Pointer to function to finish handling an incomplete decl at the
400 end of compilation. */
402 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
404 /* Nonzero if generating code to do profiling. */
406 int profile_flag = 0;
408 /* Nonzero if generating code to do profiling on a line-by-line basis. */
410 int profile_block_flag;
412 /* Nonzero if generating code to profile program flow graph arcs. */
414 int profile_arc_flag = 0;
416 /* Nonzero if generating info for gcov to calculate line test coverage. */
418 int flag_test_coverage = 0;
420 /* Nonzero indicates that branch taken probabilities should be calculated. */
422 int flag_branch_probabilities = 0;
424 /* Nonzero if basic blocks should be reordered. */
426 int flag_reorder_blocks = 0;
428 /* Nonzero if registers should be renamed */
430 int flag_rename_registers = 0;
432 /* Nonzero for -pedantic switch: warn about anything
433 that standard spec forbids. */
437 /* Temporarily suppress certain warnings.
438 This is set while reading code from a system header file. */
440 int in_system_header = 0;
442 /* Don't print functions as they are compiled and don't print
443 times taken by the various passes. -quiet. */
449 /* Nonzero means `char' should be signed. */
451 int flag_signed_char;
453 /* Nonzero means give an enum type only as many bytes as it needs. */
455 int flag_short_enums;
457 /* Nonzero for -fcaller-saves: allocate values in regs that need to
458 be saved across function calls, if that produces overall better code.
459 Optional now, so people can test it. */
461 #ifdef DEFAULT_CALLER_SAVES
462 int flag_caller_saves = 1;
464 int flag_caller_saves = 0;
467 /* Nonzero if structures and unions should be returned in memory.
469 This should only be defined if compatibility with another compiler or
470 with an ABI is needed, because it results in slower code. */
472 #ifndef DEFAULT_PCC_STRUCT_RETURN
473 #define DEFAULT_PCC_STRUCT_RETURN 1
476 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
478 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
480 /* Nonzero for -fforce-mem: load memory value into a register
481 before arithmetic on it. This makes better cse but slower compilation. */
483 int flag_force_mem = 0;
485 /* Nonzero for -fforce-addr: load memory address into a register before
486 reference to memory. This makes better cse but slower compilation. */
488 int flag_force_addr = 0;
490 /* Nonzero for -fdefer-pop: don't pop args after each function call;
491 instead save them up to pop many calls' args with one insns. */
493 int flag_defer_pop = 0;
495 /* Nonzero for -ffloat-store: don't allocate floats and doubles
496 in extended-precision registers. */
498 int flag_float_store = 0;
500 /* Nonzero for -fcse-follow-jumps:
501 have cse follow jumps to do a more extensive job. */
503 int flag_cse_follow_jumps;
505 /* Nonzero for -fcse-skip-blocks:
506 have cse follow a branch around a block. */
507 int flag_cse_skip_blocks;
509 /* Nonzero for -fexpensive-optimizations:
510 perform miscellaneous relatively-expensive optimizations. */
511 int flag_expensive_optimizations;
513 /* Nonzero for -fthread-jumps:
514 have jump optimize output of loop. */
516 int flag_thread_jumps;
518 /* Nonzero enables strength-reduction in loop.c. */
520 int flag_strength_reduce = 0;
522 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
523 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
524 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
527 int flag_unroll_loops;
529 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
530 This is generally not a win. */
532 int flag_unroll_all_loops;
534 /* Nonzero forces all invariant computations in loops to be moved
537 int flag_move_all_movables = 0;
539 /* Nonzero forces all general induction variables in loops to be
542 int flag_reduce_all_givs = 0;
544 /* Nonzero to perform full register move optimization passes. This is the
547 int flag_regmove = 0;
549 /* Nonzero for -fwritable-strings:
550 store string constants in data segment and don't uniquize them. */
552 int flag_writable_strings = 0;
554 /* Nonzero means don't put addresses of constant functions in registers.
555 Used for compiling the Unix kernel, where strange substitutions are
556 done on the assembly output. */
558 int flag_no_function_cse = 0;
560 /* Nonzero for -fomit-frame-pointer:
561 don't make a frame pointer in simple functions that don't require one. */
563 int flag_omit_frame_pointer = 0;
565 /* Nonzero means place each function into its own section on those platforms
566 which support arbitrary section names and unlimited numbers of sections. */
568 int flag_function_sections = 0;
570 /* ... and similar for data. */
572 int flag_data_sections = 0;
574 /* Nonzero to inhibit use of define_optimization peephole opts. */
576 int flag_no_peephole = 0;
578 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
579 operations in the interest of optimization. For example it allows
580 GCC to assume arguments to sqrt are nonnegative numbers, allowing
581 faster code for sqrt to be generated. */
583 int flag_fast_math = 0;
585 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
587 int flag_optimize_sibling_calls = 0;
589 /* Nonzero means the front end generally wants `errno' maintained by math
590 operations, like built-in SQRT, unless overridden by flag_fast_math. */
592 int flag_errno_math = 1;
594 /* 0 means straightforward implementation of complex divide acceptable.
595 1 means wide ranges of inputs must work for complex divide.
596 2 means C9X-like requirements for complex divide (not yet implemented). */
598 int flag_complex_divide_method = 0;
600 /* Nonzero means all references through pointers are volatile. */
604 /* Nonzero means treat all global and extern variables as volatile. */
606 int flag_volatile_global;
608 /* Nonzero means treat all static variables as volatile. */
610 int flag_volatile_static;
612 /* Nonzero means just do syntax checking; don't output anything. */
614 int flag_syntax_only = 0;
616 /* Nonzero means perform global cse. */
618 static int flag_gcse;
620 /* Nonzero means to use global dataflow analysis to eliminate
621 useless null pointer tests. */
623 static int flag_delete_null_pointer_checks;
625 /* Nonzero means to rerun cse after loop optimization. This increases
626 compilation time about 20% and picks up a few more common expressions. */
628 static int flag_rerun_cse_after_loop;
630 /* Nonzero means to run loop optimizations twice. */
632 int flag_rerun_loop_opt;
634 /* Nonzero for -finline-functions: ok to inline functions that look like
635 good inline candidates. */
637 int flag_inline_functions;
639 /* Nonzero for -fkeep-inline-functions: even if we make a function
640 go inline everywhere, keep its definition around for debugging
643 int flag_keep_inline_functions;
645 /* Nonzero means that functions will not be inlined. */
649 /* Nonzero means that we should emit static const variables
650 regardless of whether or not optimization is turned on. */
652 int flag_keep_static_consts = 1;
654 /* Nonzero means we should be saving declaration info into a .X file. */
656 int flag_gen_aux_info = 0;
658 /* Specified name of aux-info file. */
660 static char *aux_info_file_name;
662 /* Nonzero means make the text shared if supported. */
664 int flag_shared_data;
666 /* Nonzero means schedule into delayed branch slots if supported. */
668 int flag_delayed_branch;
670 /* Nonzero if we are compiling pure (sharable) code.
671 Value is 1 if we are doing reasonable (i.e. simple
672 offset into offset table) pic. Value is 2 if we can
673 only perform register offsets. */
677 /* Nonzero means generate extra code for exception handling and enable
678 exception handling. */
682 /* Nonzero means use the new model for exception handling. Replaces
683 -DNEW_EH_MODEL as a compile option. */
685 int flag_new_exceptions = 1;
687 /* Nonzero means generate frame unwind info table when supported */
689 int flag_unwind_tables = 0;
691 /* Nonzero means don't place uninitialized global data in common storage
696 /* Nonzero means pretend it is OK to examine bits of target floats,
697 even if that isn't true. The resulting code will have incorrect constants,
698 but the same series of instructions that the native compiler would make. */
700 int flag_pretend_float;
702 /* Nonzero means change certain warnings into errors.
703 Usually these are warnings about failure to conform to some standard. */
705 int flag_pedantic_errors = 0;
707 /* flag_schedule_insns means schedule insns within basic blocks (before
709 flag_schedule_insns_after_reload means schedule insns after
712 int flag_schedule_insns = 0;
713 int flag_schedule_insns_after_reload = 0;
715 /* The following flags have effect only for scheduling before register
718 flag_schedule_interblock means schedule insns accross basic blocks.
719 flag_schedule_speculative means allow speculative motion of non-load insns.
720 flag_schedule_speculative_load means allow speculative motion of some
722 flag_schedule_speculative_load_dangerous allows speculative motion of more
725 int flag_schedule_interblock = 1;
726 int flag_schedule_speculative = 1;
727 int flag_schedule_speculative_load = 0;
728 int flag_schedule_speculative_load_dangerous = 0;
730 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
731 by a cheaper branch, on a count register. */
732 int flag_branch_on_count_reg;
734 /* -finhibit-size-directive inhibits output of .size for ELF.
735 This is used only for compiling crtstuff.c,
736 and it may be extended to other effects
737 needed for crtstuff.c on other systems. */
738 int flag_inhibit_size_directive = 0;
740 /* -fverbose-asm causes extra commentary information to be produced in
741 the generated assembly code (to make it more readable). This option
742 is generally only of use to those who actually need to read the
743 generated assembly code (perhaps while debugging the compiler itself).
744 -fno-verbose-asm, the default, causes the extra information
745 to be omitted and is useful when comparing two assembler files. */
747 int flag_verbose_asm = 0;
749 /* -dA causes debug commentary information to be produced in
750 the generated assembly code (to make it more readable). This option
751 is generally only of use to those who actually need to read the
752 generated assembly code (perhaps while debugging the compiler itself).
753 Currently, this switch is only used by dwarfout.c; however, it is intended
754 to be a catchall for printing debug information in the assembler file. */
756 int flag_debug_asm = 0;
758 /* -fgnu-linker specifies use of the GNU linker for initializations.
759 (Or, more generally, a linker that handles initializations.)
760 -fno-gnu-linker says that collect2 will be used. */
762 int flag_gnu_linker = 0;
764 int flag_gnu_linker = 1;
770 /* Tag all structures with __attribute__(packed) */
771 int flag_pack_struct = 0;
773 /* Emit code to check for stack overflow; also may cause large objects
774 to be allocated dynamically. */
775 int flag_stack_check;
777 /* When non-NULL, indicates that whenever space is allocated on the
778 stack, the resulting stack pointer must not pass this
779 address---that is, for stacks that grow downward, the stack pointer
780 must always be greater than or equal to this address; for stacks
781 that grow upward, the stack pointer must be less than this address.
782 At present, the rtx may be either a REG or a SYMBOL_REF, although
783 the support provided depends on the backend. */
786 /* -fcheck-memory-usage causes extra code to be generated in order to check
787 memory accesses. This is used by a detector of bad memory accesses such
789 int flag_check_memory_usage = 0;
791 /* -fprefix-function-name causes function name to be prefixed. This
792 can be used with -fcheck-memory-usage to isolate code compiled with
793 -fcheck-memory-usage. */
794 int flag_prefix_function_name = 0;
796 /* 0 if pointer arguments may alias each other. True in C.
797 1 if pointer arguments may not alias each other but may alias
799 2 if pointer arguments may not alias each other and may not
800 alias global variables. True in Fortran.
801 This defaults to 0 for C. */
802 int flag_argument_noalias = 0;
804 /* Nonzero if we should do (language-dependent) alias analysis.
805 Typically, this analysis will assume that expressions of certain
806 types do not alias expressions of certain other types. Only used
807 if alias analysis (in general) is enabled. */
808 int flag_strict_aliasing = 0;
810 /* Instrument functions with calls at entry and exit, for profiling. */
811 int flag_instrument_function_entry_exit = 0;
813 /* Nonzero means ignore `#ident' directives. 0 means handle them.
814 On SVR4 targets, it also controls whether or not to emit a
815 string identifying the compiler. */
817 int flag_no_ident = 0;
819 /* This will perform a peephole pass before sched2. */
820 int flag_peephole2 = 0;
822 /* -fbounded-pointers causes gcc to compile pointers as composite
823 objects occupying three words: the pointer value, the base address
824 of the referent object, and the address immediately beyond the end
825 of the referent object. The base and extent allow us to perform
826 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
827 int flag_bounded_pointers = 0;
829 /* -fcheck-bounds causes gcc to generate array bounds checks.
830 For C, C++: defaults to value of flag_bounded_pointers.
831 For ObjC: defaults to off.
832 For Java: defaults to on.
833 For Fortran: defaults to off.
834 For CHILL: defaults to off. */
835 int flag_bounds_check = 0;
837 /* If one, renumber instruction UIDs to reduce the number of
838 unused UIDs if there are a lot of instructions. If greater than
839 one, unconditionally renumber instruction UIDs. */
840 int flag_renumber_insns = 1;
842 /* Values of the -falign-* flags: how much to align labels in code.
843 0 means `use default', 1 means `don't align'.
844 For each variable, there is an _log variant which is the power
845 of two not less than the variable, for .align output. */
852 int align_labels_log;
854 int align_functions_log;
856 /* Table of supported debugging formats. */
860 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
861 constant expression, we use NO_DEBUG in its place. */
862 enum debug_info_type debug_type;
863 int use_extensions_p;
864 const char * description;
868 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
869 "Generate default debug format output" },
870 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
871 #ifdef DBX_DEBUGGING_INFO
872 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
873 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
875 #ifdef DWARF_DEBUGGING_INFO
876 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
877 { "dwarf+", DWARF_DEBUG, 1,
878 "Generated extended DWARF-1 format debug output" },
880 #ifdef DWARF2_DEBUGGING_INFO
881 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
883 #ifdef XCOFF_DEBUGGING_INFO
884 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
885 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
887 #ifdef SDB_DEBUGGING_INFO
888 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
898 const char * description;
900 lang_independent_options;
902 /* Add or remove a leading underscore from user symbols. */
903 int flag_leading_underscore = -1;
905 /* The user symbol prefix after having resolved same. */
906 const char *user_label_prefix;
908 /* A default for same. */
909 #ifndef USER_LABEL_PREFIX
910 #define USER_LABEL_PREFIX ""
913 /* Table of language-independent -f options.
914 STRING is the option name. VARIABLE is the address of the variable.
915 ON_VALUE is the value to store in VARIABLE
916 if `-fSTRING' is seen as an option.
917 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
919 lang_independent_options f_options[] =
921 {"float-store", &flag_float_store, 1,
922 "Do not store floats in registers" },
923 {"volatile", &flag_volatile, 1,
924 "Consider all mem refs through pointers as volatile"},
925 {"volatile-global", &flag_volatile_global, 1,
926 "Consider all mem refs to global data to be volatile" },
927 {"volatile-static", &flag_volatile_static, 1,
928 "Consider all mem refs to static data to be volatile" },
929 {"defer-pop", &flag_defer_pop, 1,
930 "Defer popping functions args from stack until later" },
931 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
932 "When possible do not generate stack frames"},
933 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
934 "Optimize sibling and tail recursive calls" },
935 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
936 "When running CSE, follow jumps to their targets" },
937 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
938 "When running CSE, follow conditional jumps" },
939 {"expensive-optimizations", &flag_expensive_optimizations, 1,
940 "Perform a number of minor, expensive optimisations" },
941 {"thread-jumps", &flag_thread_jumps, 1,
942 "Perform jump threading optimisations"},
943 {"strength-reduce", &flag_strength_reduce, 1,
944 "Perform strength reduction optimisations" },
945 {"unroll-loops", &flag_unroll_loops, 1,
946 "Perform loop unrolling when iteration count is known" },
947 {"unroll-all-loops", &flag_unroll_all_loops, 1,
948 "Perform loop unrolling for all loops" },
949 {"move-all-movables", &flag_move_all_movables, 1,
950 "Force all loop invariant computations out of loops" },
951 {"reduce-all-givs", &flag_reduce_all_givs, 1,
952 "Strength reduce all loop general induction variables" },
953 {"writable-strings", &flag_writable_strings, 1,
954 "Store strings in writable data section" },
955 {"peephole", &flag_no_peephole, 0,
956 "Enable machine specific peephole optimisations" },
957 {"force-mem", &flag_force_mem, 1,
958 "Copy memory operands into registers before using" },
959 {"force-addr", &flag_force_addr, 1,
960 "Copy memory address constants into regs before using" },
961 {"function-cse", &flag_no_function_cse, 0,
962 "Allow function addresses to be held in registers" },
963 {"inline-functions", &flag_inline_functions, 1,
964 "Integrate simple functions into their callers" },
965 {"keep-inline-functions", &flag_keep_inline_functions, 1,
966 "Generate code for funcs even if they are fully inlined" },
967 {"inline", &flag_no_inline, 0,
968 "Pay attention to the 'inline' keyword"},
969 {"keep-static-consts", &flag_keep_static_consts, 1,
970 "Emit static const variables even if they are not used" },
971 {"syntax-only", &flag_syntax_only, 1,
972 "Check for syntax errors, then stop" },
973 {"shared-data", &flag_shared_data, 1,
974 "Mark data as shared rather than private" },
975 {"caller-saves", &flag_caller_saves, 1,
976 "Enable saving registers around function calls" },
977 {"pcc-struct-return", &flag_pcc_struct_return, 1,
978 "Return 'short' aggregates in memory, not registers" },
979 {"reg-struct-return", &flag_pcc_struct_return, 0,
980 "Return 'short' aggregates in registers" },
981 {"delayed-branch", &flag_delayed_branch, 1,
982 "Attempt to fill delay slots of branch instructions" },
983 {"gcse", &flag_gcse, 1,
984 "Perform the global common subexpression elimination" },
985 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
986 "Run CSE pass after loop optimisations"},
987 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
988 "Run the loop optimiser twice"},
989 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
990 "Delete useless null pointer checks" },
991 {"pretend-float", &flag_pretend_float, 1,
992 "Pretend that host and target use the same FP format"},
993 {"schedule-insns", &flag_schedule_insns, 1,
994 "Reschedule instructions to avoid pipeline stalls"},
995 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
996 "Run two passes of the instruction scheduler"},
997 {"sched-interblock",&flag_schedule_interblock, 1,
998 "Enable scheduling across basic blocks" },
999 {"sched-spec",&flag_schedule_speculative, 1,
1000 "Allow speculative motion of non-loads" },
1001 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1002 "Allow speculative motion of some loads" },
1003 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1004 "Allow speculative motion of more loads" },
1005 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1006 "Replace add,compare,branch with branch on count reg"},
1007 {"pic", &flag_pic, 1,
1008 "Generate position independent code, if possible"},
1009 {"PIC", &flag_pic, 2, ""},
1010 {"exceptions", &flag_exceptions, 1,
1011 "Enable exception handling" },
1012 {"new-exceptions", &flag_new_exceptions, 1,
1013 "Use the new model for exception handling" },
1014 {"unwind-tables", &flag_unwind_tables, 1,
1015 "Just generate unwind tables for exception handling" },
1016 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1017 "Use setjmp/longjmp to handle exceptions" },
1018 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1019 "Support asynchronous exceptions" },
1020 {"profile-arcs", &profile_arc_flag, 1,
1021 "Insert arc based program profiling code" },
1022 {"test-coverage", &flag_test_coverage, 1,
1023 "Create data files needed by gcov" },
1024 {"branch-probabilities", &flag_branch_probabilities, 1,
1025 "Use profiling information for branch probabilities" },
1026 {"reorder-blocks", &flag_reorder_blocks, 1,
1027 "Reorder basic blocks to improve code placement" },
1028 {"rename-registers", &flag_rename_registers, 1,
1029 "Do the register renaming optimization pass"},
1030 {"fast-math", &flag_fast_math, 1,
1031 "Improve FP speed by violating ANSI & IEEE rules" },
1032 {"common", &flag_no_common, 0,
1033 "Do not put unitialised globals in the common section" },
1034 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1035 "Do not generate .size directives" },
1036 {"function-sections", &flag_function_sections, 1,
1037 "place each function into its own section" },
1038 {"data-sections", &flag_data_sections, 1,
1039 "place data items into their own section" },
1040 {"verbose-asm", &flag_verbose_asm, 1,
1041 "Add extra commentry to assembler output"},
1042 {"gnu-linker", &flag_gnu_linker, 1,
1043 "Output GNU ld formatted global initialisers"},
1044 {"regmove", &flag_regmove, 1,
1045 "Enables a register move optimisation"},
1046 {"optimize-register-move", &flag_regmove, 1,
1047 "Do the full regmove optimization pass"},
1048 {"pack-struct", &flag_pack_struct, 1,
1049 "Pack structure members together without holes" },
1050 {"stack-check", &flag_stack_check, 1,
1051 "Insert stack checking code into the program" },
1052 {"argument-alias", &flag_argument_noalias, 0,
1053 "Specify that arguments may alias each other & globals"},
1054 {"argument-noalias", &flag_argument_noalias, 1,
1055 "Assume arguments may alias globals but not each other"},
1056 {"argument-noalias-global", &flag_argument_noalias, 2,
1057 "Assume arguments do not alias each other or globals" },
1058 {"strict-aliasing", &flag_strict_aliasing, 1,
1059 "Assume strict aliasing rules apply" },
1060 {"align-loops", &align_loops, 0,
1061 "Align the start of loops" },
1062 {"align-jumps", &align_jumps, 0,
1063 "Align labels which are only reached by jumping" },
1064 {"align-labels", &align_labels, 0,
1065 "Align all labels" },
1066 {"align-functions", &align_functions, 0,
1067 "Align the start of functions" },
1068 {"check-memory-usage", &flag_check_memory_usage, 1,
1069 "Generate code to check every memory access" },
1070 {"prefix-function-name", &flag_prefix_function_name, 1,
1071 "Add a prefix to all function names" },
1072 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1073 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1074 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1075 "Instrument function entry/exit with profiling calls"},
1076 {"ssa", &flag_ssa, 1,
1077 "Enable SSA optimizations" },
1078 {"leading-underscore", &flag_leading_underscore, 1,
1079 "External symbols have a leading underscore" },
1080 {"ident", &flag_no_ident, 0,
1081 "Process #ident directives"},
1082 { "peephole2", &flag_peephole2, 1,
1083 "Enables an rtl peephole pass run before sched2" },
1084 {"math-errno", &flag_errno_math, 1,
1085 "Set errno after built-in math functions"},
1086 {"bounded-pointers", &flag_bounded_pointers, 1,
1087 "Compile pointers as triples: value, base & end" },
1088 {"bounds-check", &flag_bounds_check, 1,
1089 "Generate code to check bounds before dereferencing pointers and arrays" }
1092 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1094 /* Table of language-specific options. */
1096 static struct lang_opt
1098 const char * option;
1099 const char * description;
1101 documented_lang_options[] =
1103 /* In order not to overload the --help output, the convention
1104 used here is to only describe those options which are not
1105 enabled by default. */
1107 { "-ansi", "Compile just for ANSI C" },
1108 { "-fallow-single-precision",
1109 "Do not promote floats to double if using -traditional" },
1110 { "-std= ", "Determine language standard"},
1112 { "-fsigned-bitfields", "" },
1113 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1114 { "-fno-signed-bitfields", "" },
1115 { "-fno-unsigned-bitfields","" },
1116 { "-fsigned-char", "Make 'char' be signed by default"},
1117 { "-funsigned-char", "Make 'char' be unsigned by default"},
1118 { "-fno-signed-char", "" },
1119 { "-fno-unsigned-char", "" },
1121 { "-ftraditional", "" },
1122 { "-traditional", "Attempt to support traditional K&R style C"},
1123 { "-fnotraditional", "" },
1124 { "-fno-traditional", "" },
1127 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1128 { "-fbuiltin", "" },
1129 { "-fno-builtin", "Do not recognise any built in functions" },
1130 { "-fhosted", "Assume normal C execution environment" },
1131 { "-fno-hosted", "" },
1133 "Assume that standard libraries & main might not exist" },
1134 { "-fno-freestanding", "" },
1135 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1136 { "-fno-cond-mismatch", "" },
1137 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1138 { "-fno-dollars-in-identifiers", "" },
1139 { "-fpreprocessed", "" },
1140 { "-fno-preprocessed", "" },
1141 { "-fshort-double", "Use the same size for double as for float" },
1142 { "-fno-short-double", "" },
1143 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1144 { "-fno-short-enums", "" },
1145 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1146 { "-fno-short-wchar", "" },
1148 { "-Wall", "Enable most warning messages" },
1149 { "-Wbad-function-cast",
1150 "Warn about casting functions to incompatible types" },
1151 { "-Wno-bad-function-cast", "" },
1152 { "-Wmissing-noreturn",
1153 "Warn about functions which might be candidates for attribute noreturn" },
1154 { "-Wno-missing-noreturn", "" },
1155 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1156 { "-Wno-cast-qual", "" },
1157 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1158 { "-Wno-char-subscripts", "" },
1159 { "-Wcomment", "Warn if nested comments are detected" },
1160 { "-Wno-comment", "" },
1161 { "-Wcomments", "Warn if nested comments are detected" },
1162 { "-Wno-comments", "" },
1163 { "-Wconversion", "Warn about possibly confusing type conversions" },
1164 { "-Wno-conversion", "" },
1165 { "-Wformat", "Warn about printf format anomalies" },
1166 { "-Wno-format", "" },
1167 { "-Wimplicit-function-declaration",
1168 "Warn about implicit function declarations" },
1169 { "-Wno-implicit-function-declaration", "" },
1170 { "-Werror-implicit-function-declaration", "" },
1171 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1172 { "-Wno-implicit-int", "" },
1173 { "-Wimplicit", "" },
1174 { "-Wno-implicit", "" },
1175 { "-Wimport", "Warn about the use of the #import directive" },
1176 { "-Wno-import", "" },
1177 { "-Wlong-long","" },
1178 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1179 { "-Wmain", "Warn about suspicious declarations of main" },
1180 { "-Wno-main", "" },
1181 { "-Wmissing-braces",
1182 "Warn about possibly missing braces around initialisers" },
1183 { "-Wno-missing-braces", "" },
1184 { "-Wmissing-declarations",
1185 "Warn about global funcs without previous declarations"},
1186 { "-Wno-missing-declarations", "" },
1187 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1188 { "-Wno-missing-prototypes", "" },
1189 { "-Wmultichar", "Warn about use of multicharacter literals"},
1190 { "-Wno-multichar", "" },
1191 { "-Wnested-externs", "Warn about externs not at file scope level" },
1192 { "-Wno-nested-externs", "" },
1193 { "-Wparentheses", "Warn about possible missing parentheses" },
1194 { "-Wno-parentheses", "" },
1195 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1196 { "-Wno-pointer-arith", "" },
1197 { "-Wredundant-decls",
1198 "Warn about multiple declarations of the same object" },
1199 { "-Wno-redundant-decls", "" },
1200 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1201 { "-Wno-sign-compare", "" },
1202 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1203 { "-Wno-float-equal", "" },
1204 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1205 { "-Wno-unknown-pragmas", "" },
1206 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1207 { "-Wno-strict-prototypes", "" },
1208 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1209 { "-Wno-traditional", "" },
1210 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1211 { "-Wno-trigraphs", "" },
1213 { "-Wno-undef", "" },
1214 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1215 { "-Wno-write-strings", "" },
1217 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1219 /* These are for Objective C. */
1220 DEFINE_LANG_NAME ("Objective C")
1222 { "-lang-objc", "" },
1223 { "-gen-decls", "Dump decls to a .decl file" },
1224 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1225 { "-fno-gnu-runtime", "" },
1226 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1227 { "-fno-next-runtime", "" },
1228 { "-Wselector", "Warn if a selector has multiple methods" },
1229 { "-Wno-selector", "" },
1230 { "-Wprotocol", "" },
1231 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1232 { "-print-objc-runtime-info",
1233 "Generate C header of platform specific features" },
1235 #include "options.h"
1239 /* Here is a table, controlled by the tm.h file, listing each -m switch
1240 and which bits in `target_switches' it should set or clear.
1241 If VALUE is positive, it is bits to set.
1242 If VALUE is negative, -VALUE is bits to clear.
1243 (The sign bit is not used so there is no confusion.) */
1249 const char * description;
1251 target_switches [] = TARGET_SWITCHES;
1253 /* This table is similar, but allows the switch to have a value. */
1255 #ifdef TARGET_OPTIONS
1258 const char * prefix;
1259 const char ** variable;
1260 const char * description;
1262 target_options [] = TARGET_OPTIONS;
1265 /* Options controlling warnings */
1267 /* Don't print warning messages. -w. */
1269 int inhibit_warnings = 0;
1271 /* Print various extra warnings. -W. */
1273 int extra_warnings = 0;
1275 /* Treat warnings as errors. -Werror. */
1277 int warnings_are_errors = 0;
1279 /* Nonzero to warn about unused local variables. */
1283 /* Nonzero to warn about code which is never reached. */
1285 int warn_notreached;
1287 /* Nonzero to warn about variables used before they are initialized. */
1289 int warn_uninitialized;
1291 /* Nonzero means warn about all declarations which shadow others. */
1295 /* Warn if a switch on an enum fails to have a case for every enum value. */
1299 /* Nonzero means warn about function definitions that default the return type
1300 or that use a null return and have a return-type other than void. */
1302 int warn_return_type;
1304 /* Nonzero means warn about pointer casts that increase the required
1305 alignment of the target type (and might therefore lead to a crash
1306 due to a misaligned access). */
1308 int warn_cast_align;
1310 /* Nonzero means warn about any identifiers that match in the first N
1311 characters. The value N is in `id_clash_len'. */
1316 /* Nonzero means warn about any objects definitions whose size is larger
1317 than N bytes. Also want about function definitions whose returned
1318 values are larger than N bytes. The value N is in `larger_than_size'. */
1320 int warn_larger_than;
1321 HOST_WIDE_INT larger_than_size;
1323 /* Nonzero means warn if inline function is too large. */
1327 /* Warn if a function returns an aggregate,
1328 since there are often incompatible calling conventions for doing this. */
1330 int warn_aggregate_return;
1332 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1336 /* Warn when gcc pads a structure to an alignment boundary. */
1340 /* Likewise for -W. */
1342 lang_independent_options W_options[] =
1344 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1345 {"error", &warnings_are_errors, 1, ""},
1346 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1347 {"switch", &warn_switch, 1,
1348 "Warn about enumerated switches missing a specific case" },
1349 {"aggregate-return", &warn_aggregate_return, 1,
1350 "Warn about returning structures, unions or arrays" },
1351 {"cast-align", &warn_cast_align, 1,
1352 "Warn about pointer casts which increase alignment" },
1353 {"unreachable-code", &warn_notreached, 1,
1354 "Warn about code that will never be executed" },
1355 {"uninitialized", &warn_uninitialized, 1,
1356 "Warn about unitialized automatic variables"},
1357 {"inline", &warn_inline, 1,
1358 "Warn when an inlined function cannot be inlined"},
1359 {"packed", &warn_packed, 1,
1360 "Warn when the packed attribute has no effect on struct layout"},
1361 {"padded", &warn_padded, 1,
1362 "Warn when padding is required to align struct members"}
1365 /* Output files for assembler code (real compiler output)
1366 and debugging dumps. */
1369 FILE *aux_info_file;
1370 FILE *rtl_dump_file = NULL;
1372 /* Decode the string P as an integral parameter.
1373 If the string is indeed an integer return its numeric value else
1374 issue an Invalid Option error for the option PNAME and return DEFVAL.
1375 If PNAME is zero just return DEFVAL, do not call error. */
1378 read_integral_parameter (p, pname, defval)
1383 const char *endp = p;
1387 if (*endp >= '0' && *endp <= '9')
1396 error ("Invalid option `%s'", pname);
1404 /* Time accumulators, to count the total time spent in various passes. */
1408 int integration_time;
1414 int branch_prob_time;
1419 int local_alloc_time;
1420 int global_alloc_time;
1425 int reorder_blocks_time;
1426 int rename_registers_time;
1427 int shorten_branch_time;
1437 /* Return time used so far, in microseconds. */
1447 #else /* not BeOS */
1448 #if defined (_WIN32) && !defined (__CYGWIN__)
1452 return (clock() * 1000);
1453 #else /* not _WIN32 */
1459 tick = 1000000 / sysconf(_SC_CLK_TCK);
1461 return (tms.tms_utime + tms.tms_stime) * tick;
1467 # if HAVE_SYSCONF && defined _SC_CLK_TCK
1468 # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
1471 # define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
1473 # define TICKS_PER_SECOND HZ /* traditional UNIX */
1477 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND);
1482 struct rusage rusage;
1483 getrusage (0, &rusage);
1484 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
1485 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
1492 int proc_system_time;
1493 int child_user_time;
1494 int child_system_time;
1496 times ((void *) &vms_times);
1497 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
1501 #endif /* _SC_CLK_TCK */
1503 #endif /* __BEOS__ */
1506 #define TIMEVAR(VAR, BODY) \
1507 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
1510 print_time (str, total)
1515 "time in %s: %d.%06d (%d%%)\n",
1516 str, total / 1000000, total % 1000000,
1517 all_time == 0 ? 0 : (100 * total) / all_time);
1520 /* This is the default decl_printable_name function. */
1523 decl_name (decl, verbosity)
1525 int verbosity ATTRIBUTE_UNUSED;
1527 return IDENTIFIER_POINTER (DECL_NAME (decl));
1530 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1535 struct file_stack *stack = *(struct file_stack **)p;
1537 /* We're only called for input_file_stack, so we can mark the current
1538 input_filename here as well. */
1539 ggc_mark_string (main_input_filename);
1540 ggc_mark_string (input_filename);
1544 ggc_mark_string (stack->name);
1545 stack = stack->next;
1550 /* This calls abort and is used to avoid problems when abort if a macro.
1551 It is used when we need to pass the address of abort. */
1559 /* When `malloc.c' is compiled with `rcheck' defined,
1560 it calls this function to report clobberage. */
1564 const char * s ATTRIBUTE_UNUSED;
1569 /* Return the logarithm of X, base 2, considering X unsigned,
1570 if X is a power of 2. Otherwise, returns -1.
1572 This should be used via the `exact_log2' macro. */
1576 register unsigned HOST_WIDE_INT x;
1578 register int log = 0;
1579 /* Test for 0 or a power of 2. */
1580 if (x == 0 || x != (x & -x))
1582 while ((x >>= 1) != 0)
1587 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1588 If X is 0, return -1.
1590 This should be used via the floor_log2 macro. */
1594 register unsigned HOST_WIDE_INT x;
1596 register int log = -1;
1603 static int float_handler_set;
1605 jmp_buf float_handler;
1607 /* Signals actually come here. */
1610 float_signal (signo)
1611 /* If this is missing, some compilers complain. */
1612 int signo ATTRIBUTE_UNUSED;
1614 if (float_handled == 0)
1616 #if defined (USG) || defined (hpux)
1617 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1620 signal (SIGFPE, float_signal);
1621 longjmp (float_handler, 1);
1624 /* Specify where to longjmp to when a floating arithmetic error happens.
1625 If HANDLER is 0, it means don't handle the errors any more. */
1628 set_float_handler (handler)
1631 float_handled = (handler != 0);
1633 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1635 if (float_handled && ! float_handler_set)
1637 signal (SIGFPE, float_signal);
1638 float_handler_set = 1;
1642 /* This is a wrapper function for code which might elicit an
1643 arithmetic exception. That code should be passed in as a function
1644 pointer FN, and one argument DATA. DATA is usually a struct which
1645 contains the real input and output for function FN. This function
1646 returns 0 (failure) if longjmp was called (i.e. an exception
1647 occured.) It returns 1 (success) otherwise. */
1650 do_float_handler (fn, data)
1651 void (*fn) PARAMS ((PTR));
1658 /* We got here via longjmp() caused by an exception in function fn() */
1659 set_float_handler (NULL);
1663 set_float_handler (buf);
1665 set_float_handler (NULL);
1669 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1670 error happens, pushing the previous specification into OLD_HANDLER.
1671 Return an indication of whether there was a previous handler in effect. */
1674 push_float_handler (handler, old_handler)
1675 jmp_buf handler, old_handler;
1677 int was_handled = float_handled;
1681 memcpy ((char *) old_handler, (char *) float_handler,
1682 sizeof (float_handler));
1684 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1688 /* Restore the previous specification of whether and where to longjmp to
1689 when a floating arithmetic error happens. */
1692 pop_float_handler (handled, handler)
1696 float_handled = handled;
1698 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1701 /* Handler for SIGPIPE. */
1705 /* If this is missing, some compilers complain. */
1706 int signo ATTRIBUTE_UNUSED;
1708 fatal ("output pipe has been closed");
1711 /* Strip off a legitimate source ending from the input string NAME of
1712 length LEN. Rather than having to know the names used by all of
1713 our front ends, we strip off an ending of a period followed by
1714 up to five characters. (Java uses ".class".) */
1717 strip_off_ending (name, len)
1722 for (i = 2; i < 6 && len > i; i++)
1724 if (name[len - i] == '.')
1726 name[len - i] = '\0';
1732 /* Output a quoted string. */
1735 output_quoted_string (asm_file, string)
1739 #ifdef OUTPUT_QUOTED_STRING
1740 OUTPUT_QUOTED_STRING (asm_file, string);
1744 putc ('\"', asm_file);
1745 while ((c = *string++) != 0)
1747 if (c == '\"' || c == '\\')
1748 putc ('\\', asm_file);
1751 putc ('\"', asm_file);
1755 /* Output a file name in the form wanted by System V. */
1758 output_file_directive (asm_file, input_name)
1760 const char *input_name;
1762 int len = strlen (input_name);
1763 const char *na = input_name + len;
1765 /* NA gets INPUT_NAME sans directory names. */
1766 while (na > input_name)
1770 #ifdef DIR_SEPARATOR
1771 if (na[-1] == DIR_SEPARATOR)
1777 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1778 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1780 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1781 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1783 fprintf (asm_file, "\t.file\t");
1784 output_quoted_string (asm_file, na);
1785 fputc ('\n', asm_file);
1790 #ifdef ASM_IDENTIFY_LANGUAGE
1791 /* Routine to build language identifier for object file. */
1793 output_lang_identify (asm_out_file)
1796 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1797 char *s = (char *) alloca (len);
1798 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1799 ASM_OUTPUT_LABEL (asm_out_file, s);
1803 /* Routine to open a dump file. Return true if the dump file is enabled. */
1806 open_dump_file (index, decl)
1807 enum dump_file_index index;
1811 const char *open_arg;
1814 if (! dump_file[index].enabled)
1820 if (rtl_dump_file != NULL)
1821 fclose (rtl_dump_file);
1823 sprintf (seq, ".%02d.", index);
1825 if (! dump_file[index].initialized)
1827 /* If we've not initialized the files, do so now. */
1828 if (graph_dump_format != no_graph
1829 && dump_file[index].graph_dump_p)
1831 dump_name = concat (seq, dump_file[index].extension, NULL);
1832 clean_graph_dump_file (dump_base_name, dump_name);
1835 dump_file[index].initialized = 1;
1841 dump_name = concat (dump_base_name, seq,
1842 dump_file[index].extension, NULL);
1844 rtl_dump_file = fopen (dump_name, open_arg);
1845 if (rtl_dump_file == NULL)
1846 pfatal_with_name (dump_name);
1851 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1852 decl_printable_name (decl, 2));
1858 /* Routine to close a dump file. */
1861 close_dump_file (index, func, insns)
1862 enum dump_file_index index;
1863 void (*func) PARAMS ((FILE *, rtx));
1866 if (! rtl_dump_file)
1873 && graph_dump_format != no_graph
1874 && dump_file[index].graph_dump_p)
1879 sprintf (seq, ".%02d.", index);
1880 suffix = concat (seq, dump_file[index].extension, NULL);
1881 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1886 func (rtl_dump_file, insns);
1888 fflush (rtl_dump_file);
1889 fclose (rtl_dump_file);
1891 rtl_dump_file = NULL;
1895 /* Do any final processing required for the declarations in VEC, of
1896 which there are LEN. We write out inline functions and variables
1897 that have been deferred until this point, but which are required.
1898 Returns non-zero if anything was put out. */
1900 wrapup_global_declarations (vec, len)
1907 int output_something = 0;
1909 for (i = 0; i < len; i++)
1913 /* We're not deferring this any longer. */
1914 DECL_DEFER_OUTPUT (decl) = 0;
1916 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1917 && incomplete_decl_finalize_hook != 0)
1918 (*incomplete_decl_finalize_hook) (decl);
1921 /* Now emit any global variables or functions that we have been
1922 putting off. We need to loop in case one of the things emitted
1923 here references another one which comes earlier in the list. */
1927 for (i = 0; i < len; i++)
1931 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1934 /* Don't write out static consts, unless we still need them.
1936 We also keep static consts if not optimizing (for debugging),
1937 unless the user specified -fno-keep-static-consts.
1938 ??? They might be better written into the debug information.
1939 This is possible when using DWARF.
1941 A language processor that wants static constants to be always
1942 written out (even if it is not used) is responsible for
1943 calling rest_of_decl_compilation itself. E.g. the C front-end
1944 calls rest_of_decl_compilation from finish_decl.
1945 One motivation for this is that is conventional in some
1946 environments to write things like:
1947 static const char rcsid[] = "... version string ...";
1948 intending to force the string to be in the executable.
1950 A language processor that would prefer to have unneeded
1951 static constants "optimized away" would just defer writing
1952 them out until here. E.g. C++ does this, because static
1953 constants are often defined in header files.
1955 ??? A tempting alternative (for both C and C++) would be
1956 to force a constant to be written if and only if it is
1957 defined in a main file, as opposed to an include file. */
1959 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1960 && (! TREE_READONLY (decl)
1961 || TREE_PUBLIC (decl)
1962 || (!optimize && flag_keep_static_consts)
1963 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1966 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1969 if (TREE_CODE (decl) == FUNCTION_DECL
1970 && DECL_INITIAL (decl) != 0
1971 && DECL_SAVED_INSNS (decl) != 0
1972 && (flag_keep_inline_functions
1973 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1974 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1977 temporary_allocation ();
1978 output_inline_function (decl);
1979 permanent_allocation (1);
1984 output_something = 1;
1988 return output_something;
1991 /* Issue appropriate warnings for the global declarations in VEC (of
1992 which there are LEN). Output debugging information for them. */
1994 check_global_declarations (vec, len)
2001 for (i = 0; i < len; i++)
2005 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2006 && ! TREE_ASM_WRITTEN (decl))
2007 /* Cancel the RTL for this decl so that, if debugging info
2008 output for global variables is still to come,
2009 this one will be omitted. */
2010 DECL_RTL (decl) = NULL;
2012 /* Warn about any function
2013 declared static but not defined.
2014 We don't warn about variables,
2015 because many programs have static variables
2016 that exist only to get some text into the object file. */
2017 if (TREE_CODE (decl) == FUNCTION_DECL
2019 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2020 && DECL_INITIAL (decl) == 0
2021 && DECL_EXTERNAL (decl)
2022 && ! DECL_ARTIFICIAL (decl)
2023 && ! TREE_PUBLIC (decl))
2025 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2026 pedwarn_with_decl (decl,
2027 "`%s' used but never defined");
2029 warning_with_decl (decl,
2030 "`%s' declared `static' but never defined");
2031 /* This symbol is effectively an "extern" declaration now. */
2032 TREE_PUBLIC (decl) = 1;
2033 assemble_external (decl);
2036 /* Warn about static fns or vars defined but not used,
2037 but not about inline functions or static consts
2038 since defining those in header files is normal practice. */
2040 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2041 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2042 && ! DECL_IN_SYSTEM_HEADER (decl)
2043 && ! DECL_EXTERNAL (decl)
2044 && ! TREE_PUBLIC (decl)
2045 && ! TREE_USED (decl)
2046 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2047 /* The TREE_USED bit for file-scope decls
2048 is kept in the identifier, to handle multiple
2049 external decls in different scopes. */
2050 && ! TREE_USED (DECL_NAME (decl)))
2051 warning_with_decl (decl, "`%s' defined but not used");
2053 #ifdef SDB_DEBUGGING_INFO
2054 /* The COFF linker can move initialized global vars to the end.
2055 And that can screw up the symbol ordering.
2056 By putting the symbols in that order to begin with,
2057 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2058 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
2059 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
2060 && ! DECL_EXTERNAL (decl)
2061 && DECL_RTL (decl) != 0)
2062 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2064 /* Output COFF information for non-global
2065 file-scope initialized variables. */
2066 if (write_symbols == SDB_DEBUG
2067 && TREE_CODE (decl) == VAR_DECL
2068 && DECL_INITIAL (decl)
2069 && ! DECL_EXTERNAL (decl)
2070 && DECL_RTL (decl) != 0
2071 && GET_CODE (DECL_RTL (decl)) == MEM)
2072 TIMEVAR (symout_time, sdbout_toplevel_data (decl));
2073 #endif /* SDB_DEBUGGING_INFO */
2074 #ifdef DWARF_DEBUGGING_INFO
2075 /* Output DWARF information for file-scope tentative data object
2076 declarations, file-scope (extern) function declarations (which
2077 had no corresponding body) and file-scope tagged type declarations
2078 and definitions which have not yet been forced out. */
2080 if (write_symbols == DWARF_DEBUG
2081 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2082 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
2084 #ifdef DWARF2_DEBUGGING_INFO
2085 /* Output DWARF2 information for file-scope tentative data object
2086 declarations, file-scope (extern) function declarations (which
2087 had no corresponding body) and file-scope tagged type declarations
2088 and definitions which have not yet been forced out. */
2090 if (write_symbols == DWARF2_DEBUG
2091 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
2092 TIMEVAR (symout_time, dwarf2out_decl (decl));
2097 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2098 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2099 INPUT_FILENAME and LINENO accordingly. */
2102 push_srcloc (file, line)
2106 struct file_stack *fs;
2108 if (input_file_stack)
2110 input_file_stack->name = input_filename;
2111 input_file_stack->line = lineno;
2114 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2115 fs->name = input_filename = file;
2116 fs->line = lineno = line;
2117 fs->indent_level = 0;
2118 fs->next = input_file_stack;
2119 input_file_stack = fs;
2120 input_file_stack_tick++;
2123 /* Pop the top entry off the stack of presently open source files.
2124 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2130 struct file_stack *fs;
2132 fs = input_file_stack;
2133 input_file_stack = fs->next;
2135 input_file_stack_tick++;
2136 /* The initial souce file is never popped. */
2137 if (!input_file_stack)
2139 input_filename = input_file_stack->name;
2140 lineno = input_file_stack->line;
2143 /* Compile an entire file of output from cpp, named NAME.
2144 Write a file of assembly output and various debugging dumps. */
2153 int name_specified = name != 0;
2155 if (dump_base_name == 0)
2156 dump_base_name = name ? name : "gccdump";
2160 integration_time = 0;
2166 branch_prob_time = 0;
2171 local_alloc_time = 0;
2172 global_alloc_time = 0;
2177 reorder_blocks_time = 0;
2178 rename_registers_time = 0;
2179 shorten_branch_time = 0;
2187 /* Initialize data in various passes. */
2191 name = init_parse (name);
2192 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2193 || debug_info_level == DINFO_LEVEL_VERBOSE
2194 || flag_test_coverage
2195 || warn_notreached);
2197 init_decl_processing ();
2204 init_function_once ();
2205 init_stor_layout_once ();
2206 init_varasm_once ();
2208 /* The following initialization functions need to generate rtl, so
2209 provide a dummy function context for them. */
2210 init_dummy_function_start ();
2213 if (flag_caller_saves)
2214 init_caller_save ();
2215 expand_dummy_function_end ();
2217 /* If auxiliary info generation is desired, open the output file.
2218 This goes in the same directory as the source file--unlike
2219 all the other output files. */
2220 if (flag_gen_aux_info)
2222 aux_info_file = fopen (aux_info_file_name, "w");
2223 if (aux_info_file == 0)
2224 pfatal_with_name (aux_info_file_name);
2227 /* Open assembler code output file. */
2229 if (flag_syntax_only)
2230 asm_out_file = NULL;
2233 if (! name_specified && asm_file_name == 0)
2234 asm_out_file = stdout;
2237 if (asm_file_name == 0)
2239 int len = strlen (dump_base_name);
2240 char *dumpname = (char *) xmalloc (len + 6);
2241 memcpy (dumpname, dump_base_name, len + 1);
2242 strip_off_ending (dumpname, len);
2243 strcat (dumpname, ".s");
2244 asm_file_name = dumpname;
2246 if (!strcmp (asm_file_name, "-"))
2247 asm_out_file = stdout;
2249 asm_out_file = fopen (asm_file_name, "w");
2250 if (asm_out_file == 0)
2251 pfatal_with_name (asm_file_name);
2254 #ifdef IO_BUFFER_SIZE
2255 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2256 _IOFBF, IO_BUFFER_SIZE);
2261 name = ggc_alloc_string (name, strlen (name));
2262 input_filename = name;
2264 /* Put an entry on the input file stack for the main input file. */
2265 push_srcloc (input_filename, 0);
2267 /* Perform language-specific initialization.
2268 This may set main_input_filename. */
2271 /* If the input doesn't start with a #line, use the input name
2272 as the official input file name. */
2273 if (main_input_filename == 0)
2274 main_input_filename = name;
2276 if (flag_syntax_only)
2278 write_symbols = NO_DEBUG;
2280 profile_block_flag = 0;
2284 ASM_FILE_START (asm_out_file);
2286 #ifdef ASM_COMMENT_START
2287 if (flag_verbose_asm)
2289 /* Print the list of options in effect. */
2290 print_version (asm_out_file, ASM_COMMENT_START);
2291 print_switch_values (asm_out_file, 0, MAX_LINE,
2292 ASM_COMMENT_START, " ", "\n");
2293 /* Add a blank line here so it appears in assembler output but not
2295 fprintf (asm_out_file, "\n");
2299 /* Output something to inform GDB that this compilation was by GCC. */
2300 #ifndef ASM_IDENTIFY_GCC
2301 fprintf (asm_out_file, "gcc2_compiled.:\n");
2303 ASM_IDENTIFY_GCC (asm_out_file);
2306 /* Output something to identify which front-end produced this file. */
2307 #ifdef ASM_IDENTIFY_LANGUAGE
2308 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2310 } /* ! flag_syntax_only */
2312 #ifndef ASM_OUTPUT_SECTION_NAME
2313 if (flag_function_sections)
2315 warning ("-ffunction-sections not supported for this target.");
2316 flag_function_sections = 0;
2318 if (flag_data_sections)
2320 warning ("-fdata-sections not supported for this target.");
2321 flag_data_sections = 0;
2325 if (flag_function_sections
2326 && (profile_flag || profile_block_flag))
2328 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2329 flag_function_sections = 0;
2332 #ifndef OBJECT_FORMAT_ELF
2333 if (flag_function_sections && write_symbols != NO_DEBUG)
2334 warning ("-ffunction-sections may affect debugging on some targets.");
2337 /* ??? Note: There used to be a conditional here
2338 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2339 This was to guarantee separation between gcc_compiled. and
2340 the first function, for the sake of dbx on Suns.
2341 However, having the extra zero here confused the Emacs
2342 code for unexec, and might confuse other programs too.
2343 Therefore, I took out that change.
2344 In future versions we should find another way to solve
2345 that dbx problem. -- rms, 23 May 93. */
2347 /* Don't let the first function fall at the same address
2348 as gcc_compiled., if profiling. */
2349 if (profile_flag || profile_block_flag)
2351 /* It's best if we can write a nop here since some
2352 assemblers don't tolerate zeros in the text section. */
2353 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
2356 /* If dbx symbol table desired, initialize writing it
2357 and output the predefined types. */
2358 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2359 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2360 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename,
2363 #ifdef SDB_DEBUGGING_INFO
2364 if (write_symbols == SDB_DEBUG)
2365 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename,
2368 #ifdef DWARF_DEBUGGING_INFO
2369 if (write_symbols == DWARF_DEBUG)
2370 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
2372 #ifdef DWARF2_UNWIND_INFO
2373 if (dwarf2out_do_frame ())
2374 dwarf2out_frame_init ();
2376 #ifdef DWARF2_DEBUGGING_INFO
2377 if (write_symbols == DWARF2_DEBUG)
2378 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
2381 /* Initialize yet another pass. */
2383 init_final (main_input_filename);
2384 init_branch_prob (dump_base_name);
2386 start_time = get_run_time ();
2388 /* Call the parser, which parses the entire file
2389 (calling rest_of_compilation for each function). */
2391 if (yyparse () != 0)
2393 if (errorcount == 0)
2394 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2396 /* In case there were missing closebraces,
2397 get us back to the global binding level. */
2398 while (! global_bindings_p ())
2402 /* Compilation is now finished except for writing
2403 what's left of the symbol table output. */
2405 parse_time += get_run_time () - start_time;
2407 parse_time -= integration_time;
2408 parse_time -= varconst_time;
2410 if (flag_syntax_only)
2413 globals = getdecls ();
2415 /* Really define vars that have had only a tentative definition.
2416 Really output inline functions that must actually be callable
2417 and have not been output so far. */
2420 int len = list_length (globals);
2421 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2425 /* Process the decls in reverse order--earliest first.
2426 Put them into VEC from back to front, then take out from front. */
2428 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2429 vec[len - i - 1] = decl;
2431 wrapup_global_declarations (vec, len);
2433 /* This must occur after the loop to output deferred functions. Else
2434 the profiler initializer would not be emitted if all the functions
2435 in this compilation unit were deferred.
2437 output_func_start_profiler can not cause any additional functions or
2438 data to need to be output, so it need not be in the deferred function
2440 output_func_start_profiler ();
2442 /* Now that all possible functions have been output, we can dump
2443 the exception table. */
2445 output_exception_table ();
2447 check_global_declarations (vec, len);
2453 /* Write out any pending weak symbol declarations. */
2457 /* Do dbx symbols */
2458 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2459 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2460 TIMEVAR (symout_time,
2462 dbxout_finish (asm_out_file, main_input_filename);
2466 #ifdef DWARF_DEBUGGING_INFO
2467 if (write_symbols == DWARF_DEBUG)
2468 TIMEVAR (symout_time,
2474 #ifdef DWARF2_UNWIND_INFO
2475 if (dwarf2out_do_frame ())
2476 dwarf2out_frame_finish ();
2479 #ifdef DWARF2_DEBUGGING_INFO
2480 if (write_symbols == DWARF2_DEBUG)
2481 TIMEVAR (symout_time,
2483 dwarf2out_finish ();
2487 /* Output some stuff at end of file if nec. */
2489 end_final (dump_base_name);
2491 if (flag_test_coverage || flag_branch_probabilities)
2493 open_dump_file (DFI_bp, NULL);
2495 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file));
2497 close_dump_file (DFI_bp, NULL, NULL_RTX);
2501 ASM_FILE_END (asm_out_file);
2504 /* Language-specific end of compilation actions. */
2508 /* Close the dump files. */
2510 if (flag_gen_aux_info)
2512 fclose (aux_info_file);
2514 unlink (aux_info_file_name);
2517 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2519 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file));
2520 close_dump_file (DFI_combine, NULL, NULL_RTX);
2523 /* Close non-debugging input and output files. Take special care to note
2524 whether fclose returns an error, since the pages might still be on the
2525 buffer chain while the file is open. */
2529 if (! flag_syntax_only
2530 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
2531 fatal_io_error (asm_file_name);
2533 /* Do whatever is necessary to finish printing the graphs. */
2534 if (graph_dump_format != no_graph)
2538 for (i = 0; i < DFI_MAX; ++i)
2539 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2544 sprintf (seq, ".%02d.", i);
2545 suffix = concat (seq, dump_file[i].extension, NULL);
2546 finish_graph_dump_file (dump_base_name, suffix);
2551 /* Free up memory for the benefit of leak detectors. */
2554 /* Print the times. */
2558 all_time = get_run_time ();
2560 fprintf (stderr,"\n");
2562 print_time ("parse", parse_time);
2563 print_time ("integration", integration_time);
2564 print_time ("jump", jump_time);
2565 print_time ("cse", cse_time);
2566 print_time ("to ssa", to_ssa_time);
2567 print_time ("from ssa", from_ssa_time);
2568 print_time ("gcse", gcse_time);
2569 print_time ("loop", loop_time);
2570 print_time ("cse2", cse2_time);
2571 print_time ("branch-prob", branch_prob_time);
2572 print_time ("flow", flow_time);
2573 print_time ("combine", combine_time);
2574 print_time ("regmove", regmove_time);
2575 #ifdef INSN_SCHEDULING
2576 print_time ("sched", sched_time);
2578 print_time ("local-alloc", local_alloc_time);
2579 print_time ("global-alloc", global_alloc_time);
2580 print_time ("flow2", flow2_time);
2581 #ifdef HAVE_peephole2
2582 print_time ("peephole2", peephole2_time);
2584 #ifdef INSN_SCHEDULING
2585 print_time ("sched2", sched2_time);
2588 print_time ("dbranch", dbr_sched_time);
2590 print_time ("bbro", reorder_blocks_time);
2591 print_time ("rnreg", rename_registers_time);
2592 print_time ("shorten-branch", shorten_branch_time);
2594 print_time ("stack-reg", stack_reg_time);
2596 print_time ("final", final_time);
2597 print_time ("varconst", varconst_time);
2598 print_time ("symout", symout_time);
2599 print_time ("dump", dump_time);
2601 print_time ("gc", gc_time);
2605 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2606 and TYPE_DECL nodes.
2608 This does nothing for local (non-static) variables, unless the
2609 variable is a register variable with an ASMSPEC. In that case, or
2610 if the variable is not an automatice, it sets up the RTL and
2611 outputs any assembler code (label definition, storage allocation
2612 and initialization).
2614 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2615 the assembler symbol name to be used. TOP_LEVEL is nonzero
2616 if this declaration is not within a function. */
2619 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2621 const char *asmspec;
2625 /* Declarations of variables, and of functions defined elsewhere. */
2627 /* The most obvious approach, to put an #ifndef around where
2628 this macro is used, doesn't work since it's inside a macro call. */
2629 #ifndef ASM_FINISH_DECLARE_OBJECT
2630 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2633 /* Forward declarations for nested functions are not "external",
2634 but we need to treat them as if they were. */
2635 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2636 || TREE_CODE (decl) == FUNCTION_DECL)
2637 TIMEVAR (varconst_time,
2639 make_decl_rtl (decl, asmspec, top_level);
2640 /* Initialized extern variable exists to be replaced
2641 with its value, or represents something that will be
2642 output in another file. */
2643 if (! (TREE_CODE (decl) == VAR_DECL
2644 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2645 && DECL_INITIAL (decl) != 0
2646 && DECL_INITIAL (decl) != error_mark_node))
2647 /* Don't output anything
2648 when a tentative file-scope definition is seen.
2649 But at end of compilation, do output code for them. */
2650 if (! (! at_end && top_level
2651 && (DECL_INITIAL (decl) == 0
2652 || DECL_INITIAL (decl) == error_mark_node)))
2653 assemble_variable (decl, top_level, at_end, 0);
2654 if (decl == last_assemble_variable_decl)
2656 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2660 else if (DECL_REGISTER (decl) && asmspec != 0)
2662 if (decode_reg_name (asmspec) >= 0)
2664 DECL_RTL (decl) = 0;
2665 make_decl_rtl (decl, asmspec, top_level);
2668 error ("invalid register name `%s' for register variable", asmspec);
2670 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2671 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2672 && TREE_CODE (decl) == TYPE_DECL)
2673 TIMEVAR (symout_time, dbxout_symbol (decl, 0));
2675 #ifdef SDB_DEBUGGING_INFO
2676 else if (write_symbols == SDB_DEBUG && top_level
2677 && TREE_CODE (decl) == TYPE_DECL)
2678 TIMEVAR (symout_time, sdbout_symbol (decl, 0));
2682 /* Called after finishing a record, union or enumeral type. */
2685 rest_of_type_compilation (type, toplev)
2686 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2690 tree type ATTRIBUTE_UNUSED;
2691 int toplev ATTRIBUTE_UNUSED;
2694 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2695 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2696 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev));
2698 #ifdef SDB_DEBUGGING_INFO
2699 if (write_symbols == SDB_DEBUG)
2700 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
2704 /* DECL is an inline function, whose body is present, but which is not
2705 being output at this point. (We're putting that off until we need
2706 to do it.) If there are any actions that need to take place,
2707 including the emission of debugging information for the function,
2708 this is where they should go. This function may be called by
2709 language-dependent code for front-ends that do not even generate
2710 RTL for functions that don't need to be put out. */
2713 note_deferral_of_defined_inline_function (decl)
2714 tree decl ATTRIBUTE_UNUSED;
2716 #ifdef DWARF_DEBUGGING_INFO
2717 /* Generate the DWARF info for the "abstract" instance of a function
2718 which we may later generate inlined and/or out-of-line instances
2720 if (write_symbols == DWARF_DEBUG)
2722 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2723 DWARF code expects it to be set in this case. Intuitively,
2724 DECL is the function we just finished defining, so setting
2725 CURRENT_FUNCTION_DECL is sensible. */
2726 tree saved_cfd = current_function_decl;
2727 current_function_decl = decl;
2729 /* Let the DWARF code do its work. */
2730 set_decl_abstract_flags (decl, 1);
2731 dwarfout_file_scope_decl (decl, 0);
2732 set_decl_abstract_flags (decl, 0);
2734 /* Reset CURRENT_FUNCTION_DECL. */
2735 current_function_decl = saved_cfd;
2740 /* This is called from finish_function (within yyparse)
2741 after each top-level definition is parsed.
2742 It is supposed to compile that function or variable
2743 and output the assembler code for it.
2744 After we return, the tree storage is freed. */
2747 rest_of_compilation (decl)
2751 int start_time = get_run_time ();
2754 int rebuild_label_notes_after_reload;
2756 /* When processing delayed functions, prepare_function_start() won't
2757 have been run to re-initialize it. */
2758 cse_not_expected = ! optimize;
2760 /* First, make sure that NOTE_BLOCK is set correctly for each
2761 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2762 if (!cfun->x_whole_function_mode_p)
2765 /* Then remove any notes we don't need. That will make iterating
2766 over the instruction sequence faster, and allow the garbage
2767 collector to reclaim the memory used by the notes. */
2768 remove_unncessary_notes ();
2770 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2771 tree in sensible shape. So, we just recalculate it here. */
2772 if (cfun->x_whole_function_mode_p)
2775 /* If we are reconsidering an inline function
2776 at the end of compilation, skip the stuff for making it inline. */
2778 if (DECL_SAVED_INSNS (decl) == 0)
2784 /* If this is nested inside an inlined external function, pretend
2785 it was only declared. Since we cannot inline such functions,
2786 generating code for this one is not only not necessary but will
2787 confuse some debugging output writers. */
2788 for (parent = DECL_CONTEXT (current_function_decl);
2789 parent != NULL_TREE;
2790 parent = get_containing_scope (parent))
2791 if (TREE_CODE (parent) == FUNCTION_DECL
2792 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2794 DECL_INITIAL (decl) = 0;
2795 goto exit_rest_of_compilation;
2798 /* If requested, consider whether to make this function inline. */
2799 if (DECL_INLINE (decl) || flag_inline_functions)
2800 TIMEVAR (integration_time,
2802 lose = function_cannot_inline_p (decl);
2803 if (lose || ! optimize)
2805 if (warn_inline && DECL_INLINE (decl))
2806 warning_with_decl (decl, lose);
2807 DECL_ABSTRACT_ORIGIN (decl) = 0;
2808 /* Don't really compile an extern inline function.
2809 If we can't make it inline, pretend
2810 it was only declared. */
2811 if (DECL_EXTERNAL (decl))
2813 DECL_INITIAL (decl) = 0;
2814 goto exit_rest_of_compilation;
2818 /* ??? Note that this has the effect of making it look
2819 like "inline" was specified for a function if we choose
2820 to inline it. This isn't quite right, but it's
2821 probably not worth the trouble to fix. */
2822 inlinable = DECL_INLINE (decl) = 1;
2825 insns = get_insns ();
2827 /* Dump the rtl code if we are dumping rtl. */
2829 if (open_dump_file (DFI_rtl, decl))
2831 if (DECL_SAVED_INSNS (decl))
2832 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2833 close_dump_file (DFI_rtl, print_rtl, insns);
2836 /* If function is inline, and we don't yet know whether to
2837 compile it by itself, defer decision till end of compilation.
2838 finish_compilation will call rest_of_compilation again
2839 for those functions that need to be output. Also defer those
2840 functions that we are supposed to defer. */
2843 || (DECL_INLINE (decl)
2844 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2845 && ! flag_keep_inline_functions)
2846 || DECL_EXTERNAL (decl))))
2847 DECL_DEFER_OUTPUT (decl) = 1;
2849 if (DECL_DEFER_OUTPUT (decl))
2851 /* If -Wreturn-type, we have to do a bit of compilation.
2852 However, if we just fall through we will call
2853 save_for_inline_copying() which results in excessive
2854 memory use. Instead, we just want to call
2855 jump_optimize() to figure out whether or not we can fall
2856 off the end of the function; we do the minimum amount of
2857 work necessary to make that safe. And, we set optimize
2858 to zero to keep jump_optimize from working too hard. */
2859 if (warn_return_type)
2861 int saved_optimize = optimize;
2863 find_exception_handler_labels ();
2864 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2865 !JUMP_AFTER_REGSCAN);
2866 optimize = saved_optimize;
2869 current_function_nothrow = nothrow_function_p ();
2870 if (current_function_nothrow)
2871 /* Now we know that this can't throw; set the flag for the benefit
2872 of other functions later in this translation unit. */
2873 TREE_NOTHROW (current_function_decl) = 1;
2875 note_deferral_of_defined_inline_function (decl);
2876 TIMEVAR (integration_time, save_for_inline_nocopy (decl));
2877 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2878 goto exit_rest_of_compilation;
2881 /* If specified extern inline but we aren't inlining it, we are
2882 done. This goes for anything that gets here with DECL_EXTERNAL
2883 set, not just things with DECL_INLINE. */
2884 if (DECL_EXTERNAL (decl))
2885 goto exit_rest_of_compilation;
2888 /* We may have potential sibling or tail recursion sites. Select one
2889 (of possibly multiple) methods of performing the call. */
2890 init_EXPR_INSN_LIST_cache ();
2891 if (flag_optimize_sibling_calls)
2892 optimize_sibling_and_tail_recursive_calls ();
2897 /* Initialize some variables used by the optimizers. */
2898 init_function_for_compilation ();
2900 if (! DECL_DEFER_OUTPUT (decl))
2901 TREE_ASM_WRITTEN (decl) = 1;
2903 /* Now that integrate will no longer see our rtl, we need not distinguish
2904 between the return value of this function and the return value of called
2906 rtx_equal_function_value_matters = 0;
2908 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2909 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2911 goto exit_rest_of_compilation;
2914 /* Emit code to get eh context, if needed. */
2918 /* If we are doing position-independent code generation, now
2919 is the time to output special prologues and epilogues.
2920 We do not want to do this earlier, because it just clutters
2921 up inline functions with meaningless insns. */
2926 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2927 Note that that may have been done above, in save_for_inline_copying.
2928 The call to resume_temporary_allocation near the end of this function
2929 goes back to the usual state of affairs. This must be done after
2930 we've built up any unwinders for exception handling, and done
2931 the FINALIZE_PIC work, if necessary. */
2933 rtl_in_current_obstack ();
2935 insns = get_insns ();
2937 /* Copy any shared structure that should not be shared. */
2939 unshare_all_rtl (current_function_decl, insns);
2941 #ifdef SETJMP_VIA_SAVE_AREA
2942 /* This must be performed before virutal register instantiation. */
2943 if (current_function_calls_alloca)
2944 optimize_save_area_alloca (insns);
2947 /* Instantiate all virtual registers. */
2949 instantiate_virtual_regs (current_function_decl, get_insns ());
2951 /* See if we have allocated stack slots that are not directly addressable.
2952 If so, scan all the insns and create explicit address computation
2953 for all references to such slots. */
2954 /* fixup_stack_slots (); */
2956 /* Find all the EH handlers. */
2957 find_exception_handler_labels ();
2959 open_dump_file (DFI_jump, decl);
2961 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2962 are initialized and to compute whether control can drop off the end
2964 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
2965 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2966 JUMP_AFTER_REGSCAN));
2968 /* Jump optimization, and the removal of NULL pointer checks, may
2969 have reduced the number of instructions substantially. CSE, and
2970 future passes, allocate arrays whose dimensions involve the maximum
2971 instruction UID, so if we can reduce the maximum UID we'll save big on
2973 renumber_insns (rtl_dump_file);
2975 close_dump_file (DFI_jump, print_rtl, insns);
2977 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2978 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2979 goto exit_rest_of_compilation;
2981 /* Try to identify useless null pointer tests and delete them. */
2982 if (flag_delete_null_pointer_checks)
2983 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
2988 /* Perform common subexpression elimination.
2989 Nonzero value from `cse_main' means that jumps were simplified
2990 and some code may now be unreachable, so do
2991 jump optimization again. */
2995 open_dump_file (DFI_cse, decl);
2997 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1));
2999 if (flag_thread_jumps)
3000 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1));
3002 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (),
3004 /* If we are not running the second CSE pass, then we are no longer
3005 expecting CSE to be run. */
3006 cse_not_expected = !flag_rerun_cse_after_loop;
3008 if (tem || optimize > 1)
3009 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3011 !JUMP_AFTER_REGSCAN));
3013 /* Run this after jump optmizations remove all the unreachable code
3014 so that unreachable code will not keep values live. */
3015 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ()));
3017 /* Try to identify useless null pointer tests and delete them. */
3018 if (flag_delete_null_pointer_checks)
3019 TIMEVAR (jump_time, delete_null_pointer_checks (get_insns ()));
3021 /* The second pass of jump optimization is likely to have
3022 removed a bunch more instructions. */
3023 renumber_insns (rtl_dump_file);
3025 close_dump_file (DFI_cse, print_rtl, insns);
3028 open_dump_file (DFI_addressof, decl);
3030 purge_addressof (insns);
3031 reg_scan (insns, max_reg_num (), 1);
3033 close_dump_file (DFI_addressof, print_rtl, insns);
3040 open_dump_file (DFI_ssa, decl);
3041 TIMEVAR (to_ssa_time, convert_to_ssa ());
3042 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
3044 open_dump_file (DFI_ussa, decl);
3045 TIMEVAR (from_ssa_time, convert_from_ssa ());
3046 /* New registers have been created. Rescan their usage. */
3047 reg_scan (insns, max_reg_num (), 1);
3048 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3050 /* Life analysis used in SSA adds log_links but these shouldn't
3051 be there until the flow stage, so clear them away. */
3052 clear_log_links (insns);
3058 /* Perform global cse. */
3060 if (optimize > 0 && flag_gcse)
3062 open_dump_file (DFI_gcse, decl);
3064 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file));
3066 /* If gcse altered any jumps, rerun jump optimizations to clean
3070 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3072 !JUMP_AFTER_REGSCAN));
3075 close_dump_file (DFI_gcse, print_rtl, insns);
3080 /* Move constant computations out of loops. */
3084 open_dump_file (DFI_loop, decl);
3089 if (flag_rerun_loop_opt)
3091 /* We only want to perform unrolling once. */
3093 loop_optimize (insns, rtl_dump_file, 0, 0);
3096 /* The first call to loop_optimize makes some instructions
3097 trivially dead. We delete those instructions now in the
3098 hope that doing so will make the heuristics in loop work
3099 better and possibly speed up compilation. */
3100 delete_trivially_dead_insns (insns, max_reg_num ());
3102 /* The regscan pass is currently necessary as the alias
3103 analysis code depends on this information. */
3104 reg_scan (insns, max_reg_num (), 1);
3106 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
3109 close_dump_file (DFI_loop, print_rtl, insns);
3115 /* ??? Well, nearly. If HAVE_conditional_arithmetic, jump_optimize
3116 has put off all if-conversion until "after CSE". If we put this
3117 off any longer we may miss out doing if-conversion entirely. */
3118 cse_not_expected = 1;
3122 open_dump_file (DFI_cse2, decl);
3124 if (flag_rerun_cse_after_loop)
3126 /* Running another jump optimization pass before the second
3127 cse pass sometimes simplifies the RTL enough to allow
3128 the second CSE pass to do a better job. Jump_optimize can change
3129 max_reg_num so we must rerun reg_scan afterwards.
3130 ??? Rework to not call reg_scan so often. */
3131 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3132 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3134 JUMP_AFTER_REGSCAN));
3136 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0));
3137 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (),
3140 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP,
3142 !JUMP_AFTER_REGSCAN));
3145 if (flag_thread_jumps)
3147 /* This pass of jump threading straightens out code
3148 that was kinked by loop optimization. */
3149 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
3150 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
3153 close_dump_file (DFI_cse2, print_rtl, insns);
3159 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3161 open_dump_file (DFI_bp, decl);
3166 branch_prob (insns, rtl_dump_file);
3169 close_dump_file (DFI_bp, print_rtl, insns);
3177 /* Print function header into flow dump now
3178 because doing the flow analysis makes some of the dump. */
3180 open_dump_file (DFI_flow, decl);
3182 /* Do control and data flow analysis; wrote some of the results to
3188 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3189 cleanup_cfg (insns);
3191 calculate_loop_depth (rtl_dump_file);
3192 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3193 mark_constant_function ();
3196 if (warn_uninitialized || extra_warnings)
3198 uninitialized_vars_warning (DECL_INITIAL (decl));
3200 setjmp_args_warning ();
3203 close_dump_file (DFI_flow, print_rtl_with_bb, insns);
3208 /* The first life analysis pass has finished. From now on we can not
3209 generate any new pseudos. */
3212 /* If -opt, try combining insns through substitution. */
3216 int rebuild_jump_labels_after_combine = 0;
3218 open_dump_file (DFI_combine, decl);
3220 TIMEVAR (combine_time,
3222 rebuild_jump_labels_after_combine
3223 = combine_instructions (insns, max_reg_num ());
3226 /* Combining insns may have turned an indirect jump into a
3227 direct jump. Rebuid the JUMP_LABEL fields of jumping
3229 if (rebuild_jump_labels_after_combine)
3231 TIMEVAR (jump_time, rebuild_jump_labels (insns));
3234 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3240 /* Register allocation pre-pass, to reduce number of moves
3241 necessary for two-address machines. */
3242 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3244 open_dump_file (DFI_regmove, decl);
3246 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (),
3249 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3255 if (optimize && n_basic_blocks)
3257 TIMEVAR (gcse_time, optimize_mode_switching (NULL_PTR));
3260 #ifdef INSN_SCHEDULING
3262 /* Print function header into sched dump now
3263 because doing the sched analysis makes some of the dump. */
3264 if (optimize > 0 && flag_schedule_insns)
3266 open_dump_file (DFI_sched, decl);
3268 /* Do control and data sched analysis,
3269 and write some of the results to dump file. */
3271 TIMEVAR (sched_time, schedule_insns (rtl_dump_file));
3273 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3280 /* Determine if the current function is a leaf before running reload
3281 since this can impact optimizations done by the prologue and
3282 epilogue thus changing register elimination offsets. */
3283 current_function_is_leaf = leaf_function_p ();
3285 open_dump_file (DFI_lreg, decl);
3287 /* Allocate pseudo-regs that are used only within 1 basic block.
3289 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3290 jump optimizer after register allocation and reloading are finished. */
3292 TIMEVAR (local_alloc_time,
3294 /* We recomputed reg usage as part of updating the rest
3295 of life info during sched. */
3296 if (! flag_schedule_insns)
3297 recompute_reg_usage (insns, ! optimize_size);
3298 regclass (insns, max_reg_num (), rtl_dump_file);
3299 rebuild_label_notes_after_reload = local_alloc ();
3302 if (dump_file[DFI_lreg].enabled)
3304 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file));
3305 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file));
3307 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3313 open_dump_file (DFI_greg, decl);
3315 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3316 pass fixing up any insns that are invalid. */
3318 TIMEVAR (global_alloc_time,
3321 failure = global_alloc (rtl_dump_file);
3324 build_insn_chain (insns);
3325 failure = reload (insns, 0, rtl_dump_file);
3330 goto exit_rest_of_compilation;
3335 /* Do a very simple CSE pass over just the hard registers. */
3337 reload_cse_regs (insns);
3339 /* If optimizing and we are performing instruction scheduling after
3340 reload, then go ahead and split insns now since we are about to
3341 recompute flow information anyway.
3343 reload_cse_regs may expose more splitting opportunities, expecially
3344 for double-word operations. */
3345 if (optimize > 0 && flag_schedule_insns_after_reload)
3346 split_all_insns (0);
3348 /* Register allocation and reloading may have turned an indirect jump into
3349 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3350 jumping instructions. */
3351 if (rebuild_label_notes_after_reload)
3352 TIMEVAR (jump_time, rebuild_jump_labels (insns));
3354 if (dump_file[DFI_greg].enabled)
3356 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file));
3357 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3360 /* Re-create the death notes which were deleted during reload. */
3361 open_dump_file (DFI_flow2, decl);
3363 TIMEVAR (flow2_time,
3365 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3368 /* On some machines, the prologue and epilogue code, or parts thereof,
3369 can be represented as RTL. Doing so lets us schedule insns between
3370 it and the rest of the code and also allows delayed branch
3371 scheduling to operate in the epilogue. */
3372 thread_prologue_and_epilogue_insns (insns);
3376 TIMEVAR (flow2_time,
3378 cleanup_cfg (insns);
3379 life_analysis (insns, max_reg_num (), rtl_dump_file, 1);
3382 /* This is kind of heruistics. We need to run combine_stack_adjustments
3383 even for machines with possibly nonzero RETURN_POPS_ARGS
3384 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3385 push instructions will have popping returns. */
3386 #ifndef PUSH_ROUNDING
3387 if (!ACCUMULATE_OUTGOING_ARGS)
3389 TIMEVAR (flow2_time, { combine_stack_adjustments (); });
3395 flow2_completed = 1;
3397 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3399 #ifdef HAVE_peephole2
3400 if (optimize > 0 && flag_peephole2)
3402 open_dump_file (DFI_peephole2, decl);
3404 TIMEVAR (peephole2_time, peephole2_optimize (rtl_dump_file));
3406 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3410 #ifdef INSN_SCHEDULING
3411 if (optimize > 0 && flag_schedule_insns_after_reload)
3413 open_dump_file (DFI_sched2, decl);
3415 /* Do control and data sched analysis again,
3416 and write some more of the results to dump file. */
3418 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file));
3420 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3427 #ifdef LEAF_REGISTERS
3428 current_function_uses_only_leaf_regs
3429 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3432 if (optimize > 0 && flag_reorder_blocks)
3434 open_dump_file (DFI_bbro, decl);
3436 TIMEVAR (reorder_blocks_time, reorder_basic_blocks ());
3438 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3441 if (optimize > 0 && flag_rename_registers)
3443 open_dump_file (DFI_rnreg, decl);
3445 TIMEVAR (rename_registers_time, regrename_optimize ());
3447 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3450 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3451 Also do cross-jumping this time and delete no-op move insns. */
3455 open_dump_file (DFI_jump2, decl);
3457 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP,
3459 !JUMP_AFTER_REGSCAN));
3461 close_dump_file (DFI_jump2, print_rtl_with_bb, insns);
3464 /* If a machine dependent reorganization is needed, call it. */
3465 #ifdef MACHINE_DEPENDENT_REORG
3466 open_dump_file (DFI_mach, decl);
3468 MACHINE_DEPENDENT_REORG (insns);
3470 close_dump_file (DFI_mach, print_rtl_with_bb, insns);
3476 /* If a scheduling pass for delayed branches is to be done,
3477 call the scheduling code. */
3480 if (optimize > 0 && flag_delayed_branch)
3482 open_dump_file (DFI_dbr, decl);
3487 dbr_schedule (insns, rtl_dump_file);
3490 close_dump_file (DFI_dbr, print_rtl_with_bb, insns);
3497 /* Shorten branches.
3499 Note this must run before reg-stack because of death note (ab)use
3500 in the ia32 backend. */
3501 TIMEVAR (shorten_branch_time,
3503 shorten_branches (get_insns ());
3507 open_dump_file (DFI_stack, decl);
3509 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file));
3511 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3517 current_function_nothrow = nothrow_function_p ();
3518 if (current_function_nothrow)
3519 /* Now we know that this can't throw; set the flag for the benefit
3520 of other functions later in this translation unit. */
3521 TREE_NOTHROW (current_function_decl) = 1;
3523 /* Now turn the rtl into assembler code. */
3525 TIMEVAR (final_time,
3530 /* Get the function's name, as described by its RTL.
3531 This may be different from the DECL_NAME name used
3532 in the source file. */
3534 x = DECL_RTL (decl);
3535 if (GET_CODE (x) != MEM)
3538 if (GET_CODE (x) != SYMBOL_REF)
3540 fnname = XSTR (x, 0);
3542 assemble_start_function (decl, fnname);
3543 final_start_function (insns, asm_out_file, optimize);
3544 final (insns, asm_out_file, optimize, 0);
3545 final_end_function (insns, asm_out_file, optimize);
3546 assemble_end_function (decl, fnname);
3548 fflush (asm_out_file);
3550 /* Release all memory allocated by flow. */
3551 free_basic_block_vars (0);
3553 /* Release all memory held by regsets now */
3554 regset_release_memory ();
3560 /* Write DBX symbols if requested */
3562 /* Note that for those inline functions where we don't initially
3563 know for certain that we will be generating an out-of-line copy,
3564 the first invocation of this routine (rest_of_compilation) will
3565 skip over this code by doing a `goto exit_rest_of_compilation;'.
3566 Later on, finish_compilation will call rest_of_compilation again
3567 for those inline functions that need to have out-of-line copies
3568 generated. During that call, we *will* be routed past here. */
3570 #ifdef DBX_DEBUGGING_INFO
3571 if (write_symbols == DBX_DEBUG)
3572 TIMEVAR (symout_time, dbxout_function (decl));
3575 #ifdef DWARF_DEBUGGING_INFO
3576 if (write_symbols == DWARF_DEBUG)
3577 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
3580 #ifdef DWARF2_DEBUGGING_INFO
3581 if (write_symbols == DWARF2_DEBUG)
3582 TIMEVAR (symout_time, dwarf2out_decl (decl));
3585 exit_rest_of_compilation:
3587 /* In case the function was not output,
3588 don't leave any temporary anonymous types
3589 queued up for sdb output. */
3590 #ifdef SDB_DEBUGGING_INFO
3591 if (write_symbols == SDB_DEBUG)
3592 sdbout_types (NULL_TREE);
3595 reload_completed = 0;
3596 flow2_completed = 0;
3599 TIMEVAR (final_time,
3601 /* Clear out the insn_length contents now that they are no
3603 init_insn_lengths ();
3605 /* Clear out the real_constant_chain before some of the rtx's
3606 it runs through become garbage. */
3607 clear_const_double_mem ();
3609 /* Cancel the effect of rtl_in_current_obstack. */
3610 resume_temporary_allocation ();
3612 /* Show no temporary slots allocated. */
3615 free_basic_block_vars (0);
3618 /* Make sure volatile mem refs aren't considered valid operands for
3619 arithmetic insns. We must call this here if this is a nested inline
3620 function, since the above code leaves us in the init_recog state
3621 (from final.c), and the function context push/pop code does not
3622 save/restore volatile_ok.
3624 ??? Maybe it isn't necessary for expand_start_function to call this
3625 anymore if we do it here? */
3627 init_recog_no_volatile ();
3629 /* We're done with this function. Free up memory if we can. */
3630 free_after_parsing (cfun);
3631 if (! DECL_DEFER_OUTPUT (decl))
3632 free_after_compilation (cfun);
3638 /* The parsing time is all the time spent in yyparse
3639 *except* what is spent in this function. */
3641 parse_time -= get_run_time () - start_time;
3652 printf ("Usage: %s input [switches]\n", progname);
3653 printf ("Switches:\n");
3655 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
3656 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
3657 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3658 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
3660 for (i = NUM_ELEM (f_options); i--;)
3662 const char * description = f_options[i].description;
3664 if (description != NULL && * description != 0)
3665 printf (" -f%-21s %s\n",
3666 f_options[i].string, description);
3669 printf (" -O[number] Set optimisation level to [number]\n");
3670 printf (" -Os Optimise for space rather than speed\n");
3671 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
3672 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
3673 printf (" -w Suppress warnings\n");
3674 printf (" -W Enable extra warnings\n");
3676 for (i = NUM_ELEM (W_options); i--;)
3678 const char * description = W_options[i].description;
3680 if (description != NULL && * description != 0)
3681 printf (" -W%-21s %s\n",
3682 W_options[i].string, description);
3685 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
3686 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
3687 printf (" -p Enable function profiling\n");
3688 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3689 printf (" -a Enable block profiling \n");
3691 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3692 printf (" -ax Enable jump profiling \n");
3694 printf (" -o <file> Place output into <file> \n");
3695 printf (" -G <number> Put global and static data smaller than <number>\n");
3696 printf (" bytes into a special section (on some targets)\n");
3698 for (i = NUM_ELEM (debug_args); i--;)
3700 if (debug_args[i].description != NULL)
3701 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
3704 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
3705 printf (" -quiet Do not display functions compiled or elapsed time\n");
3706 printf (" -version Display the compiler's version\n");
3707 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
3708 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
3709 #if defined INSN_SCHEDULING
3710 printf (" -sched-verbose=<number> Set the verbosity level of the scheduler\n");
3712 printf (" --help Display this information\n");
3717 /* Display descriptions of language specific options.
3718 If there is no description, note that there is an undocumented option.
3719 If the description is empty, do not display anything. (This allows
3720 options to be deliberately undocumented, for whatever reason).
3721 If the option string is missing, then this is a marker, indicating
3722 that the description string is in fact the name of a language, whose
3723 language specific options are to follow. */
3725 if (NUM_ELEM (documented_lang_options) > 1)
3727 printf ("\nLanguage specific options:\n");
3729 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
3731 const char * description = documented_lang_options[i].description;
3732 const char * option = documented_lang_options[i].option;
3734 if (description == NULL)
3739 printf (" %-23.23s [undocumented]\n", option);
3741 else if (* description == 0)
3743 else if (option == NULL)
3747 ("\nThere are undocumented %s specific options as well.\n",
3751 printf ("\n Options for %s:\n", description);
3756 printf (" %-23.23s %s\n", option, description);
3761 printf ("\nThere are undocumented %s specific options as well.\n", lang);
3763 if (NUM_ELEM (target_switches) > 1
3764 #ifdef TARGET_OPTIONS
3765 || NUM_ELEM (target_options) > 1
3773 printf ("\nTarget specific options:\n");
3775 for (i = NUM_ELEM (target_switches); i--;)
3777 const char * option = target_switches[i].name;
3778 const char * description = target_switches[i].description;
3780 if (option == NULL || * option == 0)
3782 else if (description == NULL)
3787 printf (" -m%-21.21s [undocumented]\n", option);
3789 else if (* description != 0)
3790 doc += printf (" -m%-21.21s %s\n", option, description);
3793 #ifdef TARGET_OPTIONS
3794 for (i = NUM_ELEM (target_options); i--;)
3796 const char * option = target_options[i].prefix;
3797 const char * description = target_options[i].description;
3799 if (option == NULL || * option == 0)
3801 else if (description == NULL)
3806 printf (" -m%-21.21s [undocumented]\n", option);
3808 else if (* description != 0)
3809 doc += printf (" -m%-21.21s %s\n", option, description);
3815 printf ("\nThere are undocumented target specific options as well.\n");
3817 printf (" They exist, but they are not documented.\n");
3822 /* Parse a -d... comand line switch. */
3825 decode_d_option (arg)
3834 for (i = 0; i < DFI_MAX; ++i)
3835 dump_file[i].enabled = 1;
3844 flag_print_asm_name = 1;
3847 graph_dump_format = vcg;
3850 rtl_dump_and_exit = 1;
3855 case 'D': /* These are handled by the preprocessor. */
3861 for (i = 0; i < DFI_MAX; ++i)
3862 if (c == dump_file[i].debug_switch)
3864 dump_file[i].enabled = 1;
3869 warning ("unrecognized gcc debugging option: %c", c);
3874 /* Parse a -f... comand line switch. ARG is the value after the -f.
3875 It is safe to access 'ARG - 2' to generate the full switch name.
3876 Return the number of strings consumed. */
3879 decode_f_option (arg)
3884 /* Search for the option in the table of binary f options. */
3885 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
3887 if (!strcmp (arg, f_options[j].string))
3889 *f_options[j].variable = f_options[j].on_value;
3893 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3894 && ! strcmp (arg + 3, f_options[j].string))
3896 *f_options[j].variable = ! f_options[j].on_value;
3901 if (!strncmp (arg, "inline-limit-", 13)
3902 || !strncmp (arg, "inline-limit=", 13))
3904 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
3905 #ifdef INSN_SCHEDULING
3906 else if (!strncmp (arg, "sched-verbose=", 14))
3907 fix_sched_param ("verbose", (const char *)(arg + 14));
3909 else if (!strncmp (arg, "fixed-", 6))
3910 fix_register ((const char *)(arg + 6), 1, 1);
3911 else if (!strncmp (arg, "call-used-", 10))
3912 fix_register ((const char *)(arg + 10), 0, 1);
3913 else if (!strncmp (arg, "call-saved-", 11))
3914 fix_register ((const char *)(arg + 11), 0, 0);
3915 else if (!strncmp (arg, "align-loops=", 12))
3916 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
3917 else if (!strncmp (arg, "align-functions=", 16))
3919 = read_integral_parameter (arg + 16, arg - 2, align_functions);
3920 else if (!strncmp (arg, "align-jumps=", 12))
3921 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
3922 else if (!strncmp (arg, "align-labels=", 13))
3923 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
3924 else if (!strncmp (arg, "stack-limit-register=", 21))
3926 int reg = decode_reg_name (arg + 21);
3928 error ("unrecognized register name `%s'", arg + 21);
3930 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3932 else if (!strncmp (arg, "stack-limit-symbol=", 19))
3936 nm = ggc_alloc_string (arg + 19, strlen (arg + 19));
3938 nm = xstrdup (arg + 19);
3939 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3941 else if (!strcmp (arg, "no-stack-limit"))
3942 stack_limit_rtx = NULL_RTX;
3943 else if (!strcmp (arg, "preprocessed"))
3944 /* Recognise this switch but do nothing. This prevents warnings
3945 about an unrecognized switch if cpplib has not been linked in. */
3953 /* Parse a -W... comand line switch. ARG is the value after the -W.
3954 It is safe to access 'ARG - 2' to generate the full switch name.
3955 Return the number of strings consumed. */
3958 decode_W_option (arg)
3963 /* Search for the option in the table of binary W options. */
3965 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
3967 if (!strcmp (arg, W_options[j].string))
3969 *W_options[j].variable = W_options[j].on_value;
3973 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3974 && ! strcmp (arg + 3, W_options[j].string))
3976 *W_options[j].variable = ! W_options[j].on_value;
3981 if (!strncmp (arg, "id-clash-", 9))
3983 id_clash_len = read_integral_parameter (arg + 9, arg - 2, -1);
3985 if (id_clash_len != -1)
3988 else if (!strncmp (arg, "larger-than-", 12))
3990 larger_than_size = read_integral_parameter (arg + 12, arg - 2, -1);
3992 if (larger_than_size != -1)
3993 warn_larger_than = 1;
4001 /* Parse a -g... comand line switch. ARG is the value after the -g.
4002 It is safe to access 'ARG - 2' to generate the full switch name.
4003 Return the number of strings consumed. */
4006 decode_g_option (arg)
4010 /* A lot of code assumes write_symbols == NO_DEBUG if the
4011 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4012 of what debugging type has been selected). This records the
4013 selected type. It is an error to specify more than one
4015 static enum debug_info_type selected_debug_type = NO_DEBUG;
4016 /* Non-zero if debugging format has been explicitly set.
4017 -g and -ggdb don't explicitly set the debugging format so
4018 -gdwarf -g3 is equivalent to -gdwarf3. */
4019 static int type_explicitly_set_p = 0;
4020 /* Indexed by enum debug_info_type. */
4021 static const char * debug_type_names[] =
4023 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4026 /* The maximum admissible debug level value. */
4027 static const unsigned max_debug_level = 3;
4029 /* Look up ARG in the table. */
4030 for (da = debug_args; da->arg; da++)
4032 const int da_len = strlen (da->arg);
4034 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4036 enum debug_info_type type = da->debug_type;
4037 const char * p = arg + da_len;
4039 if (*p && (*p < '0' || *p > '9'))
4042 /* A debug flag without a level defaults to level 2.
4043 Note we do not want to call read_integral_parameter
4044 for that case since it will call atoi which
4047 ??? We may want to generalize the interface to
4048 read_integral_parameter to better handle this case
4049 if this case shows up often. */
4051 level = read_integral_parameter (p, 0, max_debug_level + 1);
4055 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4057 error ("use -gdwarf -g%d for DWARF v1, level %d",
4060 error ("use -gdwarf-2 for DWARF v2");
4063 if (level > max_debug_level)
4066 ignoring option `%s' due to invalid debug level specification",
4068 level = debug_info_level;
4071 if (type == NO_DEBUG)
4073 type = PREFERRED_DEBUGGING_TYPE;
4075 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4077 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4078 type = DWARF2_DEBUG;
4080 #ifdef DBX_DEBUGGING_INFO
4087 if (type == NO_DEBUG)
4088 warning ("`%s': unknown or unsupported -g option", arg - 2);
4090 /* Does it conflict with an already selected type? */
4091 if (type_explicitly_set_p
4092 /* -g/-ggdb don't conflict with anything */
4093 && da->debug_type != NO_DEBUG
4094 && type != selected_debug_type)
4095 warning ("`%s' ignored, conflicts with `-g%s'",
4096 arg - 2, debug_type_names[(int) selected_debug_type]);
4099 /* If the format has already been set, -g/-ggdb
4100 only change the debug level. */
4101 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4102 ; /* don't change debugging type */
4105 selected_debug_type = type;
4106 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4109 write_symbols = (level == 0
4111 : selected_debug_type);
4112 use_gnu_debug_info_extensions = da->use_extensions_p;
4113 debug_info_level = (enum debug_info_level) level;
4121 warning ("`%s': unknown or unsupported -g option", arg - 2);
4126 /* Decode the first argument in the argv as a language-independent option.
4127 Return the number of strings consumed. 'strings_processed' is the
4128 number of strings that have already been decoded in a language
4129 specific fashion before this function was invoked. */
4132 independent_decode_option (argc, argv, strings_processed)
4135 unsigned int strings_processed;
4137 char *arg = argv[0];
4139 if (arg[0] != '-' || arg[1] == 0)
4151 if (!strcmp (arg, "-help"))
4166 /* Already been treated in main (). Do nothing. */
4170 set_target_switch (arg + 1);
4174 return decode_f_option (arg + 1);
4177 if (strings_processed == 0)
4178 return decode_g_option (arg + 1);
4180 return strings_processed;
4183 if (!strcmp (arg, "dumpbase"))
4188 dump_base_name = argv[1];
4192 decode_d_option (arg + 1);
4196 if (!strcmp (arg, "pedantic"))
4198 else if (!strcmp (arg, "pedantic-errors"))
4199 flag_pedantic_errors = pedantic = 1;
4200 else if (arg[1] == 0)
4207 if (!strcmp (arg, "quiet"))
4214 if (!strcmp (arg, "version"))
4222 inhibit_warnings = 1;
4231 /* We save the value of warn_uninitialized, since if they put
4232 -Wuninitialized on the command line, we need to generate a
4233 warning about not using it without also specifying -O. */
4234 if (warn_uninitialized != 1)
4235 warn_uninitialized = 2;
4238 return decode_W_option (arg + 1);
4244 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4245 warning ("`-a' option (basic block profile) not supported");
4247 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4250 else if (!strcmp (arg, "ax"))
4252 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4253 warning ("`-ax' option (jump profiling) not supported");
4255 profile_block_flag = (!profile_block_flag
4256 || profile_block_flag == 2) ? 2 : 3;
4259 else if (!strncmp (arg, "aux-info", 8))
4261 flag_gen_aux_info = 1;
4267 aux_info_file_name = argv[1];
4271 aux_info_file_name = arg + 8;
4283 asm_file_name = argv[1];
4298 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4303 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4307 if (g_switch_val == -1)
4311 g_switch_set = TRUE;
4312 g_switch_value = g_switch_val;
4322 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4323 Exit code is 35 if can't open files, 34 if fatal error,
4324 33 if had nonfatal errors, else success. */
4326 extern int main PARAMS ((int, char **));
4336 /* save in case md file wants to emit args as a comment. */
4340 p = argv[0] + strlen (argv[0]);
4341 while (p != argv[0] && p[-1] != '/'
4342 #ifdef DIR_SEPARATOR
4343 && p[-1] != DIR_SEPARATOR
4349 #ifdef HAVE_LC_MESSAGES
4350 setlocale (LC_MESSAGES, "");
4352 (void) bindtextdomain (PACKAGE, localedir);
4353 (void) textdomain (PACKAGE);
4355 signal (SIGFPE, float_signal);
4358 signal (SIGPIPE, pipe_closed);
4361 decl_printable_name = decl_name;
4362 lang_expand_expr = (lang_expand_expr_t) do_abort;
4364 /* Initialize whether `char' is signed. */
4365 flag_signed_char = DEFAULT_SIGNED_CHAR;
4366 #ifdef DEFAULT_SHORT_ENUMS
4367 /* Initialize how much space enums occupy, by default. */
4368 flag_short_enums = DEFAULT_SHORT_ENUMS;
4371 /* Initialize the garbage-collector. */
4373 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
4375 ggc_add_rtx_root (&stack_limit_rtx, 1);
4376 ggc_add_tree_root (¤t_function_decl, 1);
4377 ggc_add_tree_root (¤t_function_func_begin_label, 1);
4379 /* Perform language-specific options intialization. */
4380 lang_init_options ();
4382 /* Scan to see what optimization level has been specified. That will
4383 determine the default value of many flags. */
4384 for (i = 1; i < argc; i++)
4386 if (!strcmp (argv[i], "-O"))
4391 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4393 /* Handle -Os, -O2, -O3, -O69, ... */
4394 char *p = &argv[i][2];
4396 if ((p[0] == 's') && (p[1] == 0))
4400 /* Optimizing for size forces optimize to be 2. */
4405 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4406 if (optimize_val != -1)
4408 optimize = optimize_val;
4418 flag_thread_jumps = 1;
4420 flag_delayed_branch = 1;
4422 #ifdef CAN_DEBUG_WITHOUT_FP
4423 flag_omit_frame_pointer = 1;
4429 flag_optimize_sibling_calls = 1;
4430 flag_cse_follow_jumps = 1;
4431 flag_cse_skip_blocks = 1;
4433 flag_expensive_optimizations = 1;
4434 flag_strength_reduce = 1;
4435 flag_rerun_cse_after_loop = 1;
4436 flag_rerun_loop_opt = 1;
4437 flag_caller_saves = 1;
4440 #ifdef INSN_SCHEDULING
4441 flag_schedule_insns = 1;
4442 flag_schedule_insns_after_reload = 1;
4445 flag_strict_aliasing = 1;
4446 flag_delete_null_pointer_checks = 1;
4451 flag_inline_functions = 1;
4454 if (optimize < 2 || optimize_size)
4459 align_functions = 1;
4462 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4465 set_target_switch ("");
4467 #ifdef OPTIMIZATION_OPTIONS
4468 /* Allow default optimizations to be specified on a per-machine basis. */
4469 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4472 /* Initialize register usage now so switches may override. */
4475 /* Perform normal command line switch decoding. */
4476 for (i = 1; i < argc;)
4478 unsigned int lang_processed;
4479 unsigned int indep_processed;
4481 /* Give the language a chance to decode the option for itself. */
4482 lang_processed = lang_decode_option (argc - i, argv + i);
4484 /* Now see if the option also has a language independent meaning.
4485 Some options are both language specific and language independent,
4486 eg --help. It is possible that there might be options that should
4487 only be decoded in a language independent way if they were not
4488 decoded in a langauge specific way, which is why 'lang_processed'
4490 indep_processed = independent_decode_option (argc - i, argv + i,
4493 if (lang_processed || indep_processed)
4494 i += (lang_processed > indep_processed
4495 ? lang_processed : indep_processed);
4498 const char * option = NULL;
4499 const char * lang = NULL;
4502 /* It is possible that the command line switch is not valid for the
4503 current language, but it is valid for another language. In order
4504 to be compatible with previous versions of the compiler (which
4505 did not issue an error message in this case) we check for this
4506 possibilty here. If we do find a match, then if extra_warnings
4507 is set we generate a warning message, otherwise we will just
4508 ignore the option. */
4509 for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
4511 option = documented_lang_options[j].option;
4514 lang = documented_lang_options[j].description;
4515 else if (! strncmp (argv[i], option, strlen (option)))
4519 if (j != NUM_ELEM (documented_lang_options))
4523 warning ("Ignoring command line option '%s'", argv[i]);
4526 (It is valid for %s but not the selected langauge)", lang);
4530 error ("Unrecognized option `%s'", argv[i]);
4536 /* Checker uses the frame pointer. */
4537 if (flag_check_memory_usage)
4538 flag_omit_frame_pointer = 0;
4542 /* Inlining does not work if not optimizing,
4543 so force it not to be done. */
4547 /* The c_decode_option and lang_decode_option functions set
4548 this to `2' if -Wall is used, so we can avoid giving out
4549 lots of errors for people who don't realize what -Wall does. */
4550 if (warn_uninitialized == 1)
4551 warning ("-Wuninitialized is not supported without -O");
4554 #ifdef OVERRIDE_OPTIONS
4555 /* Some machines may reject certain combinations of options. */
4559 if (exceptions_via_longjmp == 2)
4561 #ifdef DWARF2_UNWIND_INFO
4562 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4564 exceptions_via_longjmp = 1;
4568 /* Set up the align_*_log variables, defaulting them to 1 if they
4569 were still unset. */
4570 if (align_loops <= 0) align_loops = 1;
4571 align_loops_log = floor_log2 (align_loops*2-1);
4572 if (align_jumps <= 0) align_jumps = 1;
4573 align_jumps_log = floor_log2 (align_jumps*2-1);
4574 if (align_labels <= 0) align_labels = 1;
4575 align_labels_log = floor_log2 (align_labels*2-1);
4576 if (align_functions <= 0) align_functions = 1;
4577 align_functions_log = floor_log2 (align_functions*2-1);
4579 if (profile_block_flag == 3)
4581 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4582 profile_block_flag = 2;
4585 /* Unrolling all loops implies that standard loop unrolling must also
4587 if (flag_unroll_all_loops)
4588 flag_unroll_loops = 1;
4589 /* Loop unrolling requires that strength_reduction be on also. Silently
4590 turn on strength reduction here if it isn't already on. Also, the loop
4591 unrolling code assumes that cse will be run after loop, so that must
4592 be turned on also. */
4593 if (flag_unroll_loops)
4595 flag_strength_reduce = 1;
4596 flag_rerun_cse_after_loop = 1;
4599 /* Warn about options that are not supported on this machine. */
4600 #ifndef INSN_SCHEDULING
4601 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4602 warning ("instruction scheduling not supported on this target machine");
4605 if (flag_delayed_branch)
4606 warning ("this target machine does not have delayed branches");
4609 user_label_prefix = USER_LABEL_PREFIX;
4610 if (flag_leading_underscore != -1)
4612 /* If the default prefix is more complicated than "" or "_",
4613 issue a warning and ignore this option. */
4614 if (user_label_prefix[0] == 0 ||
4615 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4617 user_label_prefix = flag_leading_underscore ? "_" : "";
4620 warning ("-f%sleading-underscore not supported on this target machine",
4621 flag_leading_underscore ? "" : "no-");
4624 /* If we are in verbose mode, write out the version and maybe all the
4625 option flags in use. */
4628 print_version (stderr, "");
4630 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4633 compile_file (filename);
4635 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4638 char *lim = (char *) sbrk (0);
4640 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4645 system ("ps -l 1>&2");
4648 #endif /* not USG */
4651 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4654 return (FATAL_EXIT_CODE);
4656 return (FATAL_EXIT_CODE);
4657 return (SUCCESS_EXIT_CODE);
4660 /* Decode -m switches. */
4661 /* Decode the switch -mNAME. */
4664 set_target_switch (name)
4668 int valid_target_option = 0;
4670 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4671 if (!strcmp (target_switches[j].name, name))
4673 if (target_switches[j].value < 0)
4674 target_flags &= ~-target_switches[j].value;
4676 target_flags |= target_switches[j].value;
4677 valid_target_option = 1;
4680 #ifdef TARGET_OPTIONS
4681 if (!valid_target_option)
4682 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4684 int len = strlen (target_options[j].prefix);
4685 if (!strncmp (target_options[j].prefix, name, len))
4687 *target_options[j].variable = name + len;
4688 valid_target_option = 1;
4693 if (!valid_target_option)
4694 error ("Invalid option `%s'", name);
4697 /* Print version information to FILE.
4698 Each line begins with INDENT (for the case where FILE is the
4699 assembler output file). */
4702 print_version (file, indent)
4707 #define __VERSION__ "[?]"
4711 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4713 "%s%s%s version %s (%s) compiled by CC.\n"
4715 , indent, *indent != 0 ? " " : "",
4716 language_string, version_string, TARGET_NAME, __VERSION__);
4719 /* Print an option value and return the adjusted position in the line.
4720 ??? We don't handle error returns from fprintf (disk full); presumably
4721 other code will catch a disk full though. */
4724 print_single_switch (file, pos, max, indent, sep, term, type, name)
4727 const char *indent, *sep, *term, *type, *name;
4729 /* The ultrix fprintf returns 0 on success, so compute the result we want
4730 here since we need it for the following test. */
4731 int len = strlen (sep) + strlen (type) + strlen (name);
4736 fprintf (file, "%s", term);
4741 fprintf (file, "%s", indent);
4742 pos = strlen (indent);
4744 fprintf (file, "%s%s%s", sep, type, name);
4749 /* Print active target switches to FILE.
4750 POS is the current cursor position and MAX is the size of a "line".
4751 Each line begins with INDENT and ends with TERM.
4752 Each switch is separated from the next by SEP. */
4755 print_switch_values (file, pos, max, indent, sep, term)
4758 const char *indent, *sep, *term;
4763 /* Print the options as passed. */
4765 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4766 _("options passed: "), "");
4768 for (p = &save_argv[1]; *p != NULL; p++)
4772 if (strcmp (*p, "-o") == 0)
4778 if (strcmp (*p, "-quiet") == 0)
4780 if (strcmp (*p, "-version") == 0)
4785 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4788 fprintf (file, "%s", term);
4790 /* Print the -f and -m options that have been enabled.
4791 We don't handle language specific options but printing argv
4794 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4795 _("options enabled: "), "");
4797 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4798 if (*f_options[j].variable == f_options[j].on_value)
4799 pos = print_single_switch (file, pos, max, indent, sep, term,
4800 "-f", f_options[j].string);
4802 /* Print target specific options. */
4804 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4805 if (target_switches[j].name[0] != '\0'
4806 && target_switches[j].value > 0
4807 && ((target_switches[j].value & target_flags)
4808 == target_switches[j].value))
4810 pos = print_single_switch (file, pos, max, indent, sep, term,
4811 "-m", target_switches[j].name);
4814 #ifdef TARGET_OPTIONS
4815 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4816 if (*target_options[j].variable != NULL)
4819 sprintf (prefix, "-m%s", target_options[j].prefix);
4820 pos = print_single_switch (file, pos, max, indent, sep, term,
4821 prefix, *target_options[j].variable);
4825 fprintf (file, "%s", term);
4828 /* Record the beginning of a new source file, named FILENAME. */
4831 debug_start_source_file (filename)
4832 register char *filename ATTRIBUTE_UNUSED;
4834 #ifdef DBX_DEBUGGING_INFO
4835 if (write_symbols == DBX_DEBUG)
4836 dbxout_start_new_source_file (filename);
4838 #ifdef DWARF_DEBUGGING_INFO
4839 if (debug_info_level == DINFO_LEVEL_VERBOSE
4840 && write_symbols == DWARF_DEBUG)
4841 dwarfout_start_new_source_file (filename);
4842 #endif /* DWARF_DEBUGGING_INFO */
4843 #ifdef DWARF2_DEBUGGING_INFO
4844 if (debug_info_level == DINFO_LEVEL_VERBOSE
4845 && write_symbols == DWARF2_DEBUG)
4846 dwarf2out_start_source_file (filename);
4847 #endif /* DWARF2_DEBUGGING_INFO */
4848 #ifdef SDB_DEBUGGING_INFO
4849 if (write_symbols == SDB_DEBUG)
4850 sdbout_start_new_source_file (filename);
4854 /* Record the resumption of a source file. LINENO is the line number in
4855 the source file we are returning to. */
4858 debug_end_source_file (lineno)
4859 register unsigned lineno ATTRIBUTE_UNUSED;
4861 #ifdef DBX_DEBUGGING_INFO
4862 if (write_symbols == DBX_DEBUG)
4863 dbxout_resume_previous_source_file ();
4865 #ifdef DWARF_DEBUGGING_INFO
4866 if (debug_info_level == DINFO_LEVEL_VERBOSE
4867 && write_symbols == DWARF_DEBUG)
4868 dwarfout_resume_previous_source_file (lineno);
4869 #endif /* DWARF_DEBUGGING_INFO */
4870 #ifdef DWARF2_DEBUGGING_INFO
4871 if (debug_info_level == DINFO_LEVEL_VERBOSE
4872 && write_symbols == DWARF2_DEBUG)
4873 dwarf2out_end_source_file ();
4874 #endif /* DWARF2_DEBUGGING_INFO */
4875 #ifdef SDB_DEBUGGING_INFO
4876 if (write_symbols == SDB_DEBUG)
4877 sdbout_resume_previous_source_file ();
4881 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4882 the tail part of the directive line, i.e. the part which is past the
4883 initial whitespace, #, whitespace, directive-name, whitespace part. */
4886 debug_define (lineno, buffer)
4887 register unsigned lineno ATTRIBUTE_UNUSED;
4888 register char *buffer ATTRIBUTE_UNUSED;
4890 #ifdef DWARF_DEBUGGING_INFO
4891 if (debug_info_level == DINFO_LEVEL_VERBOSE
4892 && write_symbols == DWARF_DEBUG)
4893 dwarfout_define (lineno, buffer);
4894 #endif /* DWARF_DEBUGGING_INFO */
4895 #ifdef DWARF2_DEBUGGING_INFO
4896 if (debug_info_level == DINFO_LEVEL_VERBOSE
4897 && write_symbols == DWARF2_DEBUG)
4898 dwarf2out_define (lineno, buffer);
4899 #endif /* DWARF2_DEBUGGING_INFO */
4902 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4903 the tail part of the directive line, i.e. the part which is past the
4904 initial whitespace, #, whitespace, directive-name, whitespace part. */
4907 debug_undef (lineno, buffer)
4908 register unsigned lineno ATTRIBUTE_UNUSED;
4909 register char *buffer ATTRIBUTE_UNUSED;
4911 #ifdef DWARF_DEBUGGING_INFO
4912 if (debug_info_level == DINFO_LEVEL_VERBOSE
4913 && write_symbols == DWARF_DEBUG)
4914 dwarfout_undef (lineno, buffer);
4915 #endif /* DWARF_DEBUGGING_INFO */
4916 #ifdef DWARF2_DEBUGGING_INFO
4917 if (debug_info_level == DINFO_LEVEL_VERBOSE
4918 && write_symbols == DWARF2_DEBUG)
4919 dwarf2out_undef (lineno, buffer);
4920 #endif /* DWARF2_DEBUGGING_INFO */
4923 /* Tell the debugging backend that we've decided not to emit any
4924 debugging information for BLOCK, so it can clean up after any local
4925 classes or nested functions. */
4928 debug_ignore_block (block)
4929 tree block ATTRIBUTE_UNUSED;
4931 #ifdef DWARF2_DEBUGGING_INFO
4932 if (write_symbols == DWARF2_DEBUG)
4933 dwarf2out_ignore_block (block);