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"
65 #ifndef ACCUMULATE_OUTGOING_ARGS
66 #define ACCUMULATE_OUTGOING_ARGS 0
69 #ifdef DWARF_DEBUGGING_INFO
73 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
74 #include "dwarf2out.h"
77 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
81 #ifdef SDB_DEBUGGING_INFO
85 #ifdef XCOFF_DEBUGGING_INFO
90 /* The extra parameters substantially improve the I/O performance. */
92 vms_fopen (fname, type)
96 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
97 fixed arguments, which matches ANSI's specification but not VAXCRTL's
98 pre-ANSI implementation. This hack circumvents the mismatch problem. */
99 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
102 return (*vmslib_fopen) (fname, type, "mbc=32",
103 "deq=64", "fop=tef", "shr=nil");
105 return (*vmslib_fopen) (fname, type, "mbc=32");
107 #define fopen vms_fopen
110 #ifndef DEFAULT_GDB_EXTENSIONS
111 #define DEFAULT_GDB_EXTENSIONS 1
114 /* If more than one debugging type is supported, you must define
115 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
117 This is one long line cause VAXC can't handle a \-newline. */
118 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
119 #ifndef PREFERRED_DEBUGGING_TYPE
120 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
121 #endif /* no PREFERRED_DEBUGGING_TYPE */
122 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
123 so the following code needn't care. */
124 #ifdef DBX_DEBUGGING_INFO
125 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
127 #ifdef SDB_DEBUGGING_INFO
128 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
130 #ifdef DWARF_DEBUGGING_INFO
131 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
133 #ifdef DWARF2_DEBUGGING_INFO
134 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
136 #ifdef XCOFF_DEBUGGING_INFO
137 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
139 #endif /* More than one debugger format enabled. */
141 /* If still not defined, must have been because no debugging formats
143 #ifndef PREFERRED_DEBUGGING_TYPE
144 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
147 #ifdef NEED_DECLARATION_ENVIRON
148 extern char **environ;
151 /* Carry information from ASM_DECLARE_OBJECT_NAME
152 to ASM_FINISH_DECLARE_OBJECT. */
154 extern int size_directive_output;
155 extern tree last_assemble_variable_decl;
157 static void set_target_switch PARAMS ((const char *));
158 static const char *decl_name PARAMS ((tree, int));
160 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
161 static void pipe_closed PARAMS ((int)) ATTRIBUTE_NORETURN;
162 #ifdef ASM_IDENTIFY_LANGUAGE
163 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
164 static void output_lang_identify PARAMS ((FILE *)) ATTRIBUTE_UNUSED;
166 static void compile_file PARAMS ((char *));
167 static void display_help PARAMS ((void));
168 static void mark_file_stack PARAMS ((void *));
170 static void decode_d_option PARAMS ((const char *));
171 static int decode_f_option PARAMS ((const char *));
172 static int decode_W_option PARAMS ((const char *));
173 static int decode_g_option PARAMS ((const char *));
174 static unsigned int independent_decode_option PARAMS ((int, char **,
177 static void print_version PARAMS ((FILE *, const char *));
178 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
179 const char *, const char *,
180 const char *, const char *));
181 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
182 const char *, const char *));
184 /* Length of line when printing switch values. */
187 /* Name of program invoked, sans directories. */
189 const char *progname;
191 /* Copy of arguments to main. */
195 /* Name of current original source file (what was input to cpp).
196 This comes from each #-command in the actual input. */
198 char *input_filename;
200 /* Name of top-level original source file (what was input to cpp).
201 This comes from the #-command at the beginning of the actual input.
202 If there isn't any there, then this is the cc1 input file name. */
204 char *main_input_filename;
206 /* Current line number in real source file. */
210 /* Nonzero if it is unsafe to create any new pseudo registers. */
213 /* Stack of currently pending input files. */
215 struct file_stack *input_file_stack;
217 /* Incremented on each change to input_file_stack. */
218 int input_file_stack_tick;
220 /* Name to use as base of names for dump output files. */
222 const char *dump_base_name;
224 /* Bit flags that specify the machine subtype we are compiling for.
225 Bits are tested using macros TARGET_... defined in the tm.h file
226 and set by `-m...' switches. Must be defined in rtlanal.c. */
228 extern int target_flags;
230 /* Describes a dump file. */
232 struct dump_file_info
234 /* The unique extension to apply, e.g. ".jump". */
235 const char * const extension;
237 /* The -d<c> character that enables this dump file. */
238 char const debug_switch;
240 /* True if there is a corresponding graph dump file. */
241 char const graph_dump_p;
243 /* True if the user selected this dump. */
246 /* True if the files have been initialized (ie truncated). */
250 /* Enumerate the extant dump files. */
283 /* Describes all the dump files. Should be kept in order of the
284 pass and in sync with dump_file_index above. */
286 struct dump_file_info dump_file[DFI_MAX] =
288 { "rtl", 'r', 0, 0, 0 },
289 { "sibling", 'i', 0, 0, 0 },
290 { "jump", 'j', 0, 0, 0 },
291 { "cse", 's', 0, 0, 0 },
292 { "addressof", 'F', 0, 0, 0 },
293 { "ssa", 'e', 1, 0, 0 },
294 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
295 { "gcse", 'G', 1, 0, 0 },
296 { "loop", 'L', 1, 0, 0 },
297 { "cse2", 't', 1, 0, 0 },
298 { "bp", 'b', 1, 0, 0 },
299 { "flow", 'f', 1, 0, 0 },
300 { "combine", 'c', 1, 0, 0 },
301 { "regmove", 'N', 1, 0, 0 },
302 { "sched", 'S', 1, 0, 0 },
303 { "lreg", 'l', 1, 0, 0 },
304 { "greg", 'g', 1, 0, 0 },
305 { "flow2", 'w', 1, 0, 0 },
306 { "peephole2", 'z', 1, 0, 0 },
307 { "sched2", 'R', 1, 0, 0 },
308 { "bbro", 'B', 1, 0, 0 },
309 { "rnreg", 'n', 1, 0, 0 },
310 { "jump2", 'J', 1, 0, 0 },
311 { "mach", 'M', 1, 0, 0 },
312 { "dbr", 'd', 0, 0, 0 },
313 { "stack", 'k', 1, 0, 0 },
316 static int open_dump_file PARAMS ((enum dump_file_index, tree));
317 static void close_dump_file PARAMS ((enum dump_file_index,
318 void (*) (FILE *, rtx), rtx));
320 /* Other flags saying which kinds of debugging dump have been requested. */
322 int rtl_dump_and_exit;
323 int flag_print_asm_name;
324 static int flag_print_mem;
325 static int version_flag;
326 static char * filename;
327 enum graph_dump_types graph_dump_format;
329 /* Name for output file of assembly code, specified with -o. */
333 /* Value of the -G xx switch, and whether it was passed or not. */
337 /* Type(s) of debugging information we are producing (if any).
338 See flags.h for the definitions of the different possible
339 types of debugging information. */
340 enum debug_info_type write_symbols = NO_DEBUG;
342 /* Level of debugging information we are producing. See flags.h
343 for the definitions of the different possible levels. */
344 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
346 /* Nonzero means use GNU-only extensions in the generated symbolic
347 debugging information. */
348 /* Currently, this only has an effect when write_symbols is set to
349 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
350 int use_gnu_debug_info_extensions = 0;
352 /* Nonzero means do optimizations. -O.
353 Particular numeric values stand for particular amounts of optimization;
354 thus, -O2 stores 2 here. However, the optimizations beyond the basic
355 ones are not controlled directly by this variable. Instead, they are
356 controlled by individual `flag_...' variables that are defaulted
357 based on this variable. */
361 /* Nonzero means optimize for size. -Os.
362 The only valid values are zero and non-zero. When optimize_size is
363 non-zero, optimize defaults to 2, but certain individual code
364 bloating optimizations are disabled. */
366 int optimize_size = 0;
368 /* Number of error messages and warning messages so far. */
371 int warningcount = 0;
374 /* The FUNCTION_DECL for the function currently being compiled,
375 or 0 if between functions. */
376 tree current_function_decl;
378 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
380 tree current_function_func_begin_label;
382 /* Pointer to function to compute the name to use to print a declaration.
383 DECL is the declaration in question.
384 VERBOSITY determines what information will be printed:
385 0: DECL_NAME, demangled as necessary.
386 1: and scope information.
387 2: and any other information that might be interesting, such as function
388 parameter types in C++. */
390 const char *(*decl_printable_name) PARAMS ((tree, int));
392 /* Pointer to function to compute rtl for a language-specific tree code. */
394 typedef rtx (*lang_expand_expr_t)
395 PARAMS ((union tree_node *, rtx, enum machine_mode,
396 enum expand_modifier modifier));
398 lang_expand_expr_t lang_expand_expr = 0;
400 tree (*lang_expand_constant) PARAMS ((tree)) = 0;
402 /* Pointer to function to finish handling an incomplete decl at the
403 end of compilation. */
405 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
407 /* Nonzero if generating code to do profiling. */
409 int profile_flag = 0;
411 /* Nonzero if generating code to do profiling on a line-by-line basis. */
413 int profile_block_flag;
415 /* Nonzero if generating code to profile program flow graph arcs. */
417 int profile_arc_flag = 0;
419 /* Nonzero if generating info for gcov to calculate line test coverage. */
421 int flag_test_coverage = 0;
423 /* Nonzero indicates that branch taken probabilities should be calculated. */
425 int flag_branch_probabilities = 0;
427 /* Nonzero if basic blocks should be reordered. */
429 int flag_reorder_blocks = 0;
431 /* Nonzero if registers should be renamed */
433 int flag_rename_registers = 0;
435 /* Nonzero for -pedantic switch: warn about anything
436 that standard spec forbids. */
440 /* Temporarily suppress certain warnings.
441 This is set while reading code from a system header file. */
443 int in_system_header = 0;
445 /* Don't print functions as they are compiled and don't print
446 times taken by the various passes. -quiet. */
452 /* Nonzero means `char' should be signed. */
454 int flag_signed_char;
456 /* Nonzero means give an enum type only as many bytes as it needs. */
458 int flag_short_enums;
460 /* Nonzero for -fcaller-saves: allocate values in regs that need to
461 be saved across function calls, if that produces overall better code.
462 Optional now, so people can test it. */
464 #ifdef DEFAULT_CALLER_SAVES
465 int flag_caller_saves = 1;
467 int flag_caller_saves = 0;
470 /* Nonzero if structures and unions should be returned in memory.
472 This should only be defined if compatibility with another compiler or
473 with an ABI is needed, because it results in slower code. */
475 #ifndef DEFAULT_PCC_STRUCT_RETURN
476 #define DEFAULT_PCC_STRUCT_RETURN 1
479 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
481 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
483 /* Nonzero for -fforce-mem: load memory value into a register
484 before arithmetic on it. This makes better cse but slower compilation. */
486 int flag_force_mem = 0;
488 /* Nonzero for -fforce-addr: load memory address into a register before
489 reference to memory. This makes better cse but slower compilation. */
491 int flag_force_addr = 0;
493 /* Nonzero for -fdefer-pop: don't pop args after each function call;
494 instead save them up to pop many calls' args with one insns. */
496 int flag_defer_pop = 0;
498 /* Nonzero for -ffloat-store: don't allocate floats and doubles
499 in extended-precision registers. */
501 int flag_float_store = 0;
503 /* Nonzero for -fcse-follow-jumps:
504 have cse follow jumps to do a more extensive job. */
506 int flag_cse_follow_jumps;
508 /* Nonzero for -fcse-skip-blocks:
509 have cse follow a branch around a block. */
510 int flag_cse_skip_blocks;
512 /* Nonzero for -fexpensive-optimizations:
513 perform miscellaneous relatively-expensive optimizations. */
514 int flag_expensive_optimizations;
516 /* Nonzero for -fthread-jumps:
517 have jump optimize output of loop. */
519 int flag_thread_jumps;
521 /* Nonzero enables strength-reduction in loop.c. */
523 int flag_strength_reduce = 0;
525 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
526 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
527 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
530 int flag_unroll_loops;
532 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
533 This is generally not a win. */
535 int flag_unroll_all_loops;
537 /* Nonzero forces all invariant computations in loops to be moved
540 int flag_move_all_movables = 0;
542 /* Nonzero forces all general induction variables in loops to be
545 int flag_reduce_all_givs = 0;
547 /* Nonzero to perform full register move optimization passes. This is the
550 int flag_regmove = 0;
552 /* Nonzero for -fwritable-strings:
553 store string constants in data segment and don't uniquize them. */
555 int flag_writable_strings = 0;
557 /* Nonzero means don't put addresses of constant functions in registers.
558 Used for compiling the Unix kernel, where strange substitutions are
559 done on the assembly output. */
561 int flag_no_function_cse = 0;
563 /* Nonzero for -fomit-frame-pointer:
564 don't make a frame pointer in simple functions that don't require one. */
566 int flag_omit_frame_pointer = 0;
568 /* Nonzero means place each function into its own section on those platforms
569 which support arbitrary section names and unlimited numbers of sections. */
571 int flag_function_sections = 0;
573 /* ... and similar for data. */
575 int flag_data_sections = 0;
577 /* Nonzero to inhibit use of define_optimization peephole opts. */
579 int flag_no_peephole = 0;
581 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
582 operations in the interest of optimization. For example it allows
583 GCC to assume arguments to sqrt are nonnegative numbers, allowing
584 faster code for sqrt to be generated. */
586 int flag_fast_math = 0;
588 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
590 int flag_optimize_sibling_calls = 0;
592 /* Nonzero means the front end generally wants `errno' maintained by math
593 operations, like built-in SQRT, unless overridden by flag_fast_math. */
595 int flag_errno_math = 1;
597 /* 0 means straightforward implementation of complex divide acceptable.
598 1 means wide ranges of inputs must work for complex divide.
599 2 means C9X-like requirements for complex divide (not yet implemented). */
601 int flag_complex_divide_method = 0;
603 /* Nonzero means all references through pointers are volatile. */
607 /* Nonzero means treat all global and extern variables as volatile. */
609 int flag_volatile_global;
611 /* Nonzero means treat all static variables as volatile. */
613 int flag_volatile_static;
615 /* Nonzero means just do syntax checking; don't output anything. */
617 int flag_syntax_only = 0;
619 /* Nonzero means perform global cse. */
621 static int flag_gcse;
623 /* Nonzero means to use global dataflow analysis to eliminate
624 useless null pointer tests. */
626 static int flag_delete_null_pointer_checks;
628 /* Nonzero means to rerun cse after loop optimization. This increases
629 compilation time about 20% and picks up a few more common expressions. */
631 static int flag_rerun_cse_after_loop;
633 /* Nonzero means to run loop optimizations twice. */
635 int flag_rerun_loop_opt;
637 /* Nonzero for -finline-functions: ok to inline functions that look like
638 good inline candidates. */
640 int flag_inline_functions;
642 /* Nonzero for -fkeep-inline-functions: even if we make a function
643 go inline everywhere, keep its definition around for debugging
646 int flag_keep_inline_functions;
648 /* Nonzero means that functions will not be inlined. */
652 /* Nonzero means that we should emit static const variables
653 regardless of whether or not optimization is turned on. */
655 int flag_keep_static_consts = 1;
657 /* Nonzero means we should be saving declaration info into a .X file. */
659 int flag_gen_aux_info = 0;
661 /* Specified name of aux-info file. */
663 static char *aux_info_file_name;
665 /* Nonzero means make the text shared if supported. */
667 int flag_shared_data;
669 /* Nonzero means schedule into delayed branch slots if supported. */
671 int flag_delayed_branch;
673 /* Nonzero if we are compiling pure (sharable) code.
674 Value is 1 if we are doing reasonable (i.e. simple
675 offset into offset table) pic. Value is 2 if we can
676 only perform register offsets. */
680 /* Nonzero means generate extra code for exception handling and enable
681 exception handling. */
685 /* Nonzero means use the new model for exception handling. Replaces
686 -DNEW_EH_MODEL as a compile option. */
688 int flag_new_exceptions = 1;
690 /* Nonzero means generate frame unwind info table when supported */
692 int flag_unwind_tables = 0;
694 /* Nonzero means don't place uninitialized global data in common storage
699 /* Nonzero means pretend it is OK to examine bits of target floats,
700 even if that isn't true. The resulting code will have incorrect constants,
701 but the same series of instructions that the native compiler would make. */
703 int flag_pretend_float;
705 /* Nonzero means change certain warnings into errors.
706 Usually these are warnings about failure to conform to some standard. */
708 int flag_pedantic_errors = 0;
710 /* flag_schedule_insns means schedule insns within basic blocks (before
712 flag_schedule_insns_after_reload means schedule insns after
715 int flag_schedule_insns = 0;
716 int flag_schedule_insns_after_reload = 0;
718 /* The following flags have effect only for scheduling before register
721 flag_schedule_interblock means schedule insns accross basic blocks.
722 flag_schedule_speculative means allow speculative motion of non-load insns.
723 flag_schedule_speculative_load means allow speculative motion of some
725 flag_schedule_speculative_load_dangerous allows speculative motion of more
728 int flag_schedule_interblock = 1;
729 int flag_schedule_speculative = 1;
730 int flag_schedule_speculative_load = 0;
731 int flag_schedule_speculative_load_dangerous = 0;
733 /* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple
734 by a cheaper branch, on a count register. */
735 int flag_branch_on_count_reg;
737 /* -finhibit-size-directive inhibits output of .size for ELF.
738 This is used only for compiling crtstuff.c,
739 and it may be extended to other effects
740 needed for crtstuff.c on other systems. */
741 int flag_inhibit_size_directive = 0;
743 /* -fverbose-asm causes extra commentary information to be produced in
744 the generated assembly code (to make it more readable). This option
745 is generally only of use to those who actually need to read the
746 generated assembly code (perhaps while debugging the compiler itself).
747 -fno-verbose-asm, the default, causes the extra information
748 to be omitted and is useful when comparing two assembler files. */
750 int flag_verbose_asm = 0;
752 /* -dA causes debug commentary information to be produced in
753 the generated assembly code (to make it more readable). This option
754 is generally only of use to those who actually need to read the
755 generated assembly code (perhaps while debugging the compiler itself).
756 Currently, this switch is only used by dwarfout.c; however, it is intended
757 to be a catchall for printing debug information in the assembler file. */
759 int flag_debug_asm = 0;
761 /* -fgnu-linker specifies use of the GNU linker for initializations.
762 (Or, more generally, a linker that handles initializations.)
763 -fno-gnu-linker says that collect2 will be used. */
765 int flag_gnu_linker = 0;
767 int flag_gnu_linker = 1;
773 /* Tag all structures with __attribute__(packed) */
774 int flag_pack_struct = 0;
776 /* Emit code to check for stack overflow; also may cause large objects
777 to be allocated dynamically. */
778 int flag_stack_check;
780 /* When non-NULL, indicates that whenever space is allocated on the
781 stack, the resulting stack pointer must not pass this
782 address---that is, for stacks that grow downward, the stack pointer
783 must always be greater than or equal to this address; for stacks
784 that grow upward, the stack pointer must be less than this address.
785 At present, the rtx may be either a REG or a SYMBOL_REF, although
786 the support provided depends on the backend. */
789 /* -fcheck-memory-usage causes extra code to be generated in order to check
790 memory accesses. This is used by a detector of bad memory accesses such
792 int flag_check_memory_usage = 0;
794 /* -fprefix-function-name causes function name to be prefixed. This
795 can be used with -fcheck-memory-usage to isolate code compiled with
796 -fcheck-memory-usage. */
797 int flag_prefix_function_name = 0;
799 /* 0 if pointer arguments may alias each other. True in C.
800 1 if pointer arguments may not alias each other but may alias
802 2 if pointer arguments may not alias each other and may not
803 alias global variables. True in Fortran.
804 This defaults to 0 for C. */
805 int flag_argument_noalias = 0;
807 /* Nonzero if we should do (language-dependent) alias analysis.
808 Typically, this analysis will assume that expressions of certain
809 types do not alias expressions of certain other types. Only used
810 if alias analysis (in general) is enabled. */
811 int flag_strict_aliasing = 0;
813 /* Instrument functions with calls at entry and exit, for profiling. */
814 int flag_instrument_function_entry_exit = 0;
816 /* Nonzero means ignore `#ident' directives. 0 means handle them.
817 On SVR4 targets, it also controls whether or not to emit a
818 string identifying the compiler. */
820 int flag_no_ident = 0;
822 /* This will perform a peephole pass before sched2. */
823 int flag_peephole2 = 0;
825 /* -fbounded-pointers causes gcc to compile pointers as composite
826 objects occupying three words: the pointer value, the base address
827 of the referent object, and the address immediately beyond the end
828 of the referent object. The base and extent allow us to perform
829 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
830 int flag_bounded_pointers = 0;
832 /* -fcheck-bounds causes gcc to generate array bounds checks.
833 For C, C++: defaults to value of flag_bounded_pointers.
834 For ObjC: defaults to off.
835 For Java: defaults to on.
836 For Fortran: defaults to off.
837 For CHILL: defaults to off. */
838 int flag_bounds_check = 0;
840 /* If one, renumber instruction UIDs to reduce the number of
841 unused UIDs if there are a lot of instructions. If greater than
842 one, unconditionally renumber instruction UIDs. */
843 int flag_renumber_insns = 1;
845 /* Values of the -falign-* flags: how much to align labels in code.
846 0 means `use default', 1 means `don't align'.
847 For each variable, there is an _log variant which is the power
848 of two not less than the variable, for .align output. */
855 int align_labels_log;
857 int align_functions_log;
859 /* Table of supported debugging formats. */
863 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
864 constant expression, we use NO_DEBUG in its place. */
865 enum debug_info_type debug_type;
866 int use_extensions_p;
867 const char * description;
871 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
872 "Generate default debug format output" },
873 { "gdb", NO_DEBUG, 1, "Generate default extended debug format output" },
874 #ifdef DBX_DEBUGGING_INFO
875 { "stabs", DBX_DEBUG, 0, "Generate STABS format debug output" },
876 { "stabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" },
878 #ifdef DWARF_DEBUGGING_INFO
879 { "dwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"},
880 { "dwarf+", DWARF_DEBUG, 1,
881 "Generated extended DWARF-1 format debug output" },
883 #ifdef DWARF2_DEBUGGING_INFO
884 { "dwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" },
886 #ifdef XCOFF_DEBUGGING_INFO
887 { "xcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" },
888 { "xcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" },
890 #ifdef SDB_DEBUGGING_INFO
891 { "coff", SDB_DEBUG, 0, "Generate COFF format debug output" },
901 const char * description;
903 lang_independent_options;
905 /* Add or remove a leading underscore from user symbols. */
906 int flag_leading_underscore = -1;
908 /* The user symbol prefix after having resolved same. */
909 const char *user_label_prefix;
911 /* A default for same. */
912 #ifndef USER_LABEL_PREFIX
913 #define USER_LABEL_PREFIX ""
916 /* Table of language-independent -f options.
917 STRING is the option name. VARIABLE is the address of the variable.
918 ON_VALUE is the value to store in VARIABLE
919 if `-fSTRING' is seen as an option.
920 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
922 lang_independent_options f_options[] =
924 {"float-store", &flag_float_store, 1,
925 "Do not store floats in registers" },
926 {"volatile", &flag_volatile, 1,
927 "Consider all mem refs through pointers as volatile"},
928 {"volatile-global", &flag_volatile_global, 1,
929 "Consider all mem refs to global data to be volatile" },
930 {"volatile-static", &flag_volatile_static, 1,
931 "Consider all mem refs to static data to be volatile" },
932 {"defer-pop", &flag_defer_pop, 1,
933 "Defer popping functions args from stack until later" },
934 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
935 "When possible do not generate stack frames"},
936 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
937 "Optimize sibling and tail recursive calls" },
938 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
939 "When running CSE, follow jumps to their targets" },
940 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
941 "When running CSE, follow conditional jumps" },
942 {"expensive-optimizations", &flag_expensive_optimizations, 1,
943 "Perform a number of minor, expensive optimisations" },
944 {"thread-jumps", &flag_thread_jumps, 1,
945 "Perform jump threading optimisations"},
946 {"strength-reduce", &flag_strength_reduce, 1,
947 "Perform strength reduction optimisations" },
948 {"unroll-loops", &flag_unroll_loops, 1,
949 "Perform loop unrolling when iteration count is known" },
950 {"unroll-all-loops", &flag_unroll_all_loops, 1,
951 "Perform loop unrolling for all loops" },
952 {"move-all-movables", &flag_move_all_movables, 1,
953 "Force all loop invariant computations out of loops" },
954 {"reduce-all-givs", &flag_reduce_all_givs, 1,
955 "Strength reduce all loop general induction variables" },
956 {"writable-strings", &flag_writable_strings, 1,
957 "Store strings in writable data section" },
958 {"peephole", &flag_no_peephole, 0,
959 "Enable machine specific peephole optimisations" },
960 {"force-mem", &flag_force_mem, 1,
961 "Copy memory operands into registers before using" },
962 {"force-addr", &flag_force_addr, 1,
963 "Copy memory address constants into regs before using" },
964 {"function-cse", &flag_no_function_cse, 0,
965 "Allow function addresses to be held in registers" },
966 {"inline-functions", &flag_inline_functions, 1,
967 "Integrate simple functions into their callers" },
968 {"keep-inline-functions", &flag_keep_inline_functions, 1,
969 "Generate code for funcs even if they are fully inlined" },
970 {"inline", &flag_no_inline, 0,
971 "Pay attention to the 'inline' keyword"},
972 {"keep-static-consts", &flag_keep_static_consts, 1,
973 "Emit static const variables even if they are not used" },
974 {"syntax-only", &flag_syntax_only, 1,
975 "Check for syntax errors, then stop" },
976 {"shared-data", &flag_shared_data, 1,
977 "Mark data as shared rather than private" },
978 {"caller-saves", &flag_caller_saves, 1,
979 "Enable saving registers around function calls" },
980 {"pcc-struct-return", &flag_pcc_struct_return, 1,
981 "Return 'short' aggregates in memory, not registers" },
982 {"reg-struct-return", &flag_pcc_struct_return, 0,
983 "Return 'short' aggregates in registers" },
984 {"delayed-branch", &flag_delayed_branch, 1,
985 "Attempt to fill delay slots of branch instructions" },
986 {"gcse", &flag_gcse, 1,
987 "Perform the global common subexpression elimination" },
988 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
989 "Run CSE pass after loop optimisations"},
990 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
991 "Run the loop optimiser twice"},
992 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
993 "Delete useless null pointer checks" },
994 {"pretend-float", &flag_pretend_float, 1,
995 "Pretend that host and target use the same FP format"},
996 {"schedule-insns", &flag_schedule_insns, 1,
997 "Reschedule instructions to avoid pipeline stalls"},
998 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
999 "Run two passes of the instruction scheduler"},
1000 {"sched-interblock",&flag_schedule_interblock, 1,
1001 "Enable scheduling across basic blocks" },
1002 {"sched-spec",&flag_schedule_speculative, 1,
1003 "Allow speculative motion of non-loads" },
1004 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1005 "Allow speculative motion of some loads" },
1006 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1007 "Allow speculative motion of more loads" },
1008 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1009 "Replace add,compare,branch with branch on count reg"},
1010 {"pic", &flag_pic, 1,
1011 "Generate position independent code, if possible"},
1012 {"PIC", &flag_pic, 2, ""},
1013 {"exceptions", &flag_exceptions, 1,
1014 "Enable exception handling" },
1015 {"new-exceptions", &flag_new_exceptions, 1,
1016 "Use the new model for exception handling" },
1017 {"unwind-tables", &flag_unwind_tables, 1,
1018 "Just generate unwind tables for exception handling" },
1019 {"sjlj-exceptions", &exceptions_via_longjmp, 1,
1020 "Use setjmp/longjmp to handle exceptions" },
1021 {"asynchronous-exceptions", &asynchronous_exceptions, 1,
1022 "Support asynchronous exceptions" },
1023 {"profile-arcs", &profile_arc_flag, 1,
1024 "Insert arc based program profiling code" },
1025 {"test-coverage", &flag_test_coverage, 1,
1026 "Create data files needed by gcov" },
1027 {"branch-probabilities", &flag_branch_probabilities, 1,
1028 "Use profiling information for branch probabilities" },
1029 {"reorder-blocks", &flag_reorder_blocks, 1,
1030 "Reorder basic blocks to improve code placement" },
1031 {"rename-registers", &flag_rename_registers, 1,
1032 "Do the register renaming optimization pass"},
1033 {"fast-math", &flag_fast_math, 1,
1034 "Improve FP speed by violating ANSI & IEEE rules" },
1035 {"common", &flag_no_common, 0,
1036 "Do not put unitialised globals in the common section" },
1037 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1038 "Do not generate .size directives" },
1039 {"function-sections", &flag_function_sections, 1,
1040 "place each function into its own section" },
1041 {"data-sections", &flag_data_sections, 1,
1042 "place data items into their own section" },
1043 {"verbose-asm", &flag_verbose_asm, 1,
1044 "Add extra commentry to assembler output"},
1045 {"gnu-linker", &flag_gnu_linker, 1,
1046 "Output GNU ld formatted global initialisers"},
1047 {"regmove", &flag_regmove, 1,
1048 "Enables a register move optimisation"},
1049 {"optimize-register-move", &flag_regmove, 1,
1050 "Do the full regmove optimization pass"},
1051 {"pack-struct", &flag_pack_struct, 1,
1052 "Pack structure members together without holes" },
1053 {"stack-check", &flag_stack_check, 1,
1054 "Insert stack checking code into the program" },
1055 {"argument-alias", &flag_argument_noalias, 0,
1056 "Specify that arguments may alias each other & globals"},
1057 {"argument-noalias", &flag_argument_noalias, 1,
1058 "Assume arguments may alias globals but not each other"},
1059 {"argument-noalias-global", &flag_argument_noalias, 2,
1060 "Assume arguments do not alias each other or globals" },
1061 {"strict-aliasing", &flag_strict_aliasing, 1,
1062 "Assume strict aliasing rules apply" },
1063 {"align-loops", &align_loops, 0,
1064 "Align the start of loops" },
1065 {"align-jumps", &align_jumps, 0,
1066 "Align labels which are only reached by jumping" },
1067 {"align-labels", &align_labels, 0,
1068 "Align all labels" },
1069 {"align-functions", &align_functions, 0,
1070 "Align the start of functions" },
1071 {"check-memory-usage", &flag_check_memory_usage, 1,
1072 "Generate code to check every memory access" },
1073 {"prefix-function-name", &flag_prefix_function_name, 1,
1074 "Add a prefix to all function names" },
1075 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1076 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1077 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1078 "Instrument function entry/exit with profiling calls"},
1079 {"ssa", &flag_ssa, 1,
1080 "Enable SSA optimizations" },
1081 {"leading-underscore", &flag_leading_underscore, 1,
1082 "External symbols have a leading underscore" },
1083 {"ident", &flag_no_ident, 0,
1084 "Process #ident directives"},
1085 { "peephole2", &flag_peephole2, 1,
1086 "Enables an rtl peephole pass run before sched2" },
1087 {"math-errno", &flag_errno_math, 1,
1088 "Set errno after built-in math functions"},
1089 {"bounded-pointers", &flag_bounded_pointers, 1,
1090 "Compile pointers as triples: value, base & end" },
1091 {"bounds-check", &flag_bounds_check, 1,
1092 "Generate code to check bounds before dereferencing pointers and arrays" }
1095 #define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
1097 /* Table of language-specific options. */
1099 static struct lang_opt
1101 const char * option;
1102 const char * description;
1104 documented_lang_options[] =
1106 /* In order not to overload the --help output, the convention
1107 used here is to only describe those options which are not
1108 enabled by default. */
1110 { "-ansi", "Compile just for ANSI C" },
1111 { "-fallow-single-precision",
1112 "Do not promote floats to double if using -traditional" },
1113 { "-std= ", "Determine language standard"},
1115 { "-fsigned-bitfields", "" },
1116 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1117 { "-fno-signed-bitfields", "" },
1118 { "-fno-unsigned-bitfields","" },
1119 { "-fsigned-char", "Make 'char' be signed by default"},
1120 { "-funsigned-char", "Make 'char' be unsigned by default"},
1121 { "-fno-signed-char", "" },
1122 { "-fno-unsigned-char", "" },
1124 { "-ftraditional", "" },
1125 { "-traditional", "Attempt to support traditional K&R style C"},
1126 { "-fnotraditional", "" },
1127 { "-fno-traditional", "" },
1130 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1131 { "-fbuiltin", "" },
1132 { "-fno-builtin", "Do not recognise any built in functions" },
1133 { "-fhosted", "Assume normal C execution environment" },
1134 { "-fno-hosted", "" },
1136 "Assume that standard libraries & main might not exist" },
1137 { "-fno-freestanding", "" },
1138 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1139 { "-fno-cond-mismatch", "" },
1140 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1141 { "-fno-dollars-in-identifiers", "" },
1142 { "-fpreprocessed", "" },
1143 { "-fno-preprocessed", "" },
1144 { "-fshort-double", "Use the same size for double as for float" },
1145 { "-fno-short-double", "" },
1146 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1147 { "-fno-short-enums", "" },
1148 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1149 { "-fno-short-wchar", "" },
1151 { "-Wall", "Enable most warning messages" },
1152 { "-Wbad-function-cast",
1153 "Warn about casting functions to incompatible types" },
1154 { "-Wno-bad-function-cast", "" },
1155 { "-Wmissing-noreturn",
1156 "Warn about functions which might be candidates for attribute noreturn" },
1157 { "-Wno-missing-noreturn", "" },
1158 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1159 { "-Wno-cast-qual", "" },
1160 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1161 { "-Wno-char-subscripts", "" },
1162 { "-Wcomment", "Warn if nested comments are detected" },
1163 { "-Wno-comment", "" },
1164 { "-Wcomments", "Warn if nested comments are detected" },
1165 { "-Wno-comments", "" },
1166 { "-Wconversion", "Warn about possibly confusing type conversions" },
1167 { "-Wno-conversion", "" },
1168 { "-Wformat", "Warn about printf format anomalies" },
1169 { "-Wno-format", "" },
1170 { "-Wimplicit-function-declaration",
1171 "Warn about implicit function declarations" },
1172 { "-Wno-implicit-function-declaration", "" },
1173 { "-Werror-implicit-function-declaration", "" },
1174 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1175 { "-Wno-implicit-int", "" },
1176 { "-Wimplicit", "" },
1177 { "-Wno-implicit", "" },
1178 { "-Wimport", "Warn about the use of the #import directive" },
1179 { "-Wno-import", "" },
1180 { "-Wlong-long","" },
1181 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1182 { "-Wmain", "Warn about suspicious declarations of main" },
1183 { "-Wno-main", "" },
1184 { "-Wmissing-braces",
1185 "Warn about possibly missing braces around initialisers" },
1186 { "-Wno-missing-braces", "" },
1187 { "-Wmissing-declarations",
1188 "Warn about global funcs without previous declarations"},
1189 { "-Wno-missing-declarations", "" },
1190 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1191 { "-Wno-missing-prototypes", "" },
1192 { "-Wmultichar", "Warn about use of multicharacter literals"},
1193 { "-Wno-multichar", "" },
1194 { "-Wnested-externs", "Warn about externs not at file scope level" },
1195 { "-Wno-nested-externs", "" },
1196 { "-Wparentheses", "Warn about possible missing parentheses" },
1197 { "-Wno-parentheses", "" },
1198 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1199 { "-Wno-pointer-arith", "" },
1200 { "-Wredundant-decls",
1201 "Warn about multiple declarations of the same object" },
1202 { "-Wno-redundant-decls", "" },
1203 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1204 { "-Wno-sign-compare", "" },
1205 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1206 { "-Wno-float-equal", "" },
1207 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1208 { "-Wno-unknown-pragmas", "" },
1209 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1210 { "-Wno-strict-prototypes", "" },
1211 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"},
1212 { "-Wno-traditional", "" },
1213 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1214 { "-Wno-trigraphs", "" },
1216 { "-Wno-undef", "" },
1217 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1218 { "-Wno-write-strings", "" },
1220 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1222 /* These are for Objective C. */
1223 DEFINE_LANG_NAME ("Objective C")
1225 { "-lang-objc", "" },
1226 { "-gen-decls", "Dump decls to a .decl file" },
1227 { "-fgnu-runtime", "Generate code for GNU runtime environment" },
1228 { "-fno-gnu-runtime", "" },
1229 { "-fnext-runtime", "Generate code for NeXT runtime environment" },
1230 { "-fno-next-runtime", "" },
1231 { "-Wselector", "Warn if a selector has multiple methods" },
1232 { "-Wno-selector", "" },
1233 { "-Wprotocol", "" },
1234 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
1235 { "-print-objc-runtime-info",
1236 "Generate C header of platform specific features" },
1238 #include "options.h"
1242 /* Here is a table, controlled by the tm.h file, listing each -m switch
1243 and which bits in `target_switches' it should set or clear.
1244 If VALUE is positive, it is bits to set.
1245 If VALUE is negative, -VALUE is bits to clear.
1246 (The sign bit is not used so there is no confusion.) */
1252 const char * description;
1254 target_switches [] = TARGET_SWITCHES;
1256 /* This table is similar, but allows the switch to have a value. */
1258 #ifdef TARGET_OPTIONS
1261 const char * prefix;
1262 const char ** variable;
1263 const char * description;
1265 target_options [] = TARGET_OPTIONS;
1268 /* Options controlling warnings */
1270 /* Don't print warning messages. -w. */
1272 int inhibit_warnings = 0;
1274 /* Print various extra warnings. -W. */
1276 int extra_warnings = 0;
1278 /* Treat warnings as errors. -Werror. */
1280 int warnings_are_errors = 0;
1282 /* Nonzero to warn about unused local variables. */
1286 /* Nonzero to warn about code which is never reached. */
1288 int warn_notreached;
1290 /* Nonzero to warn about variables used before they are initialized. */
1292 int warn_uninitialized;
1294 /* Nonzero means warn about all declarations which shadow others. */
1298 /* Warn if a switch on an enum fails to have a case for every enum value. */
1302 /* Nonzero means warn about function definitions that default the return type
1303 or that use a null return and have a return-type other than void. */
1305 int warn_return_type;
1307 /* Nonzero means warn about pointer casts that increase the required
1308 alignment of the target type (and might therefore lead to a crash
1309 due to a misaligned access). */
1311 int warn_cast_align;
1313 /* Nonzero means warn about any identifiers that match in the first N
1314 characters. The value N is in `id_clash_len'. */
1319 /* Nonzero means warn about any objects definitions whose size is larger
1320 than N bytes. Also want about function definitions whose returned
1321 values are larger than N bytes. The value N is in `larger_than_size'. */
1323 int warn_larger_than;
1324 HOST_WIDE_INT larger_than_size;
1326 /* Nonzero means warn if inline function is too large. */
1330 /* Warn if a function returns an aggregate,
1331 since there are often incompatible calling conventions for doing this. */
1333 int warn_aggregate_return;
1335 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1339 /* Warn when gcc pads a structure to an alignment boundary. */
1343 /* Likewise for -W. */
1345 lang_independent_options W_options[] =
1347 {"unused", &warn_unused, 1, "Warn when a variable is unused" },
1348 {"error", &warnings_are_errors, 1, ""},
1349 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" },
1350 {"switch", &warn_switch, 1,
1351 "Warn about enumerated switches missing a specific case" },
1352 {"aggregate-return", &warn_aggregate_return, 1,
1353 "Warn about returning structures, unions or arrays" },
1354 {"cast-align", &warn_cast_align, 1,
1355 "Warn about pointer casts which increase alignment" },
1356 {"unreachable-code", &warn_notreached, 1,
1357 "Warn about code that will never be executed" },
1358 {"uninitialized", &warn_uninitialized, 1,
1359 "Warn about unitialized automatic variables"},
1360 {"inline", &warn_inline, 1,
1361 "Warn when an inlined function cannot be inlined"},
1362 {"packed", &warn_packed, 1,
1363 "Warn when the packed attribute has no effect on struct layout"},
1364 {"padded", &warn_padded, 1,
1365 "Warn when padding is required to align struct members"}
1368 /* Output files for assembler code (real compiler output)
1369 and debugging dumps. */
1372 FILE *aux_info_file;
1373 FILE *rtl_dump_file = NULL;
1375 /* Decode the string P as an integral parameter.
1376 If the string is indeed an integer return its numeric value else
1377 issue an Invalid Option error for the option PNAME and return DEFVAL.
1378 If PNAME is zero just return DEFVAL, do not call error. */
1381 read_integral_parameter (p, pname, defval)
1386 const char *endp = p;
1390 if (*endp >= '0' && *endp <= '9')
1399 error ("Invalid option `%s'", pname);
1407 /* This is the default decl_printable_name function. */
1410 decl_name (decl, verbosity)
1412 int verbosity ATTRIBUTE_UNUSED;
1414 return IDENTIFIER_POINTER (DECL_NAME (decl));
1417 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1423 struct file_stack *stack = *(struct file_stack **)p;
1425 /* We're only called for input_file_stack, so we can mark the current
1426 input_filename here as well. */
1427 ggc_mark_string (main_input_filename);
1428 ggc_mark_string (input_filename);
1432 ggc_mark_string (stack->name);
1433 stack = stack->next;
1438 /* This calls abort and is used to avoid problems when abort if a macro.
1439 It is used when we need to pass the address of abort. */
1447 /* When `malloc.c' is compiled with `rcheck' defined,
1448 it calls this function to report clobberage. */
1452 const char * s ATTRIBUTE_UNUSED;
1457 /* Return the logarithm of X, base 2, considering X unsigned,
1458 if X is a power of 2. Otherwise, returns -1.
1460 This should be used via the `exact_log2' macro. */
1464 register unsigned HOST_WIDE_INT x;
1466 register int log = 0;
1467 /* Test for 0 or a power of 2. */
1468 if (x == 0 || x != (x & -x))
1470 while ((x >>= 1) != 0)
1475 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1476 If X is 0, return -1.
1478 This should be used via the floor_log2 macro. */
1482 register unsigned HOST_WIDE_INT x;
1484 register int log = -1;
1491 static int float_handler_set;
1493 jmp_buf float_handler;
1495 /* Signals actually come here. */
1498 float_signal (signo)
1499 /* If this is missing, some compilers complain. */
1500 int signo ATTRIBUTE_UNUSED;
1502 if (float_handled == 0)
1504 #if defined (USG) || defined (hpux)
1505 signal (SIGFPE, float_signal); /* re-enable the signal catcher */
1508 signal (SIGFPE, float_signal);
1509 longjmp (float_handler, 1);
1512 /* Specify where to longjmp to when a floating arithmetic error happens.
1513 If HANDLER is 0, it means don't handle the errors any more. */
1516 set_float_handler (handler)
1519 float_handled = (handler != 0);
1521 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1523 if (float_handled && ! float_handler_set)
1525 signal (SIGFPE, float_signal);
1526 float_handler_set = 1;
1530 /* This is a wrapper function for code which might elicit an
1531 arithmetic exception. That code should be passed in as a function
1532 pointer FN, and one argument DATA. DATA is usually a struct which
1533 contains the real input and output for function FN. This function
1534 returns 0 (failure) if longjmp was called (i.e. an exception
1535 occured.) It returns 1 (success) otherwise. */
1538 do_float_handler (fn, data)
1539 void (*fn) PARAMS ((PTR));
1546 /* We got here via longjmp() caused by an exception in function fn() */
1547 set_float_handler (NULL);
1551 set_float_handler (buf);
1553 set_float_handler (NULL);
1557 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1558 error happens, pushing the previous specification into OLD_HANDLER.
1559 Return an indication of whether there was a previous handler in effect. */
1562 push_float_handler (handler, old_handler)
1563 jmp_buf handler, old_handler;
1565 int was_handled = float_handled;
1569 memcpy ((char *) old_handler, (char *) float_handler,
1570 sizeof (float_handler));
1572 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler));
1576 /* Restore the previous specification of whether and where to longjmp to
1577 when a floating arithmetic error happens. */
1580 pop_float_handler (handled, handler)
1584 float_handled = handled;
1586 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
1589 /* Handler for SIGPIPE. */
1593 /* If this is missing, some compilers complain. */
1594 int signo ATTRIBUTE_UNUSED;
1596 fatal ("output pipe has been closed");
1599 /* Strip off a legitimate source ending from the input string NAME of
1600 length LEN. Rather than having to know the names used by all of
1601 our front ends, we strip off an ending of a period followed by
1602 up to five characters. (Java uses ".class".) */
1605 strip_off_ending (name, len)
1610 for (i = 2; i < 6 && len > i; i++)
1612 if (name[len - i] == '.')
1614 name[len - i] = '\0';
1620 /* Output a quoted string. */
1623 output_quoted_string (asm_file, string)
1627 #ifdef OUTPUT_QUOTED_STRING
1628 OUTPUT_QUOTED_STRING (asm_file, string);
1632 putc ('\"', asm_file);
1633 while ((c = *string++) != 0)
1635 if (c == '\"' || c == '\\')
1636 putc ('\\', asm_file);
1639 putc ('\"', asm_file);
1643 /* Output a file name in the form wanted by System V. */
1646 output_file_directive (asm_file, input_name)
1648 const char *input_name;
1650 int len = strlen (input_name);
1651 const char *na = input_name + len;
1653 /* NA gets INPUT_NAME sans directory names. */
1654 while (na > input_name)
1658 #ifdef DIR_SEPARATOR
1659 if (na[-1] == DIR_SEPARATOR)
1665 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1666 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1668 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1669 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1671 fprintf (asm_file, "\t.file\t");
1672 output_quoted_string (asm_file, na);
1673 fputc ('\n', asm_file);
1678 #ifdef ASM_IDENTIFY_LANGUAGE
1679 /* Routine to build language identifier for object file. */
1681 output_lang_identify (asm_out_file)
1684 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1685 char *s = (char *) alloca (len);
1686 sprintf (s, "__gnu_compiled_%s", lang_identify ());
1687 ASM_OUTPUT_LABEL (asm_out_file, s);
1691 /* Routine to open a dump file. Return true if the dump file is enabled. */
1694 open_dump_file (index, decl)
1695 enum dump_file_index index;
1699 const char *open_arg;
1702 if (! dump_file[index].enabled)
1705 timevar_push (TV_DUMP);
1706 if (rtl_dump_file != NULL)
1707 fclose (rtl_dump_file);
1709 sprintf (seq, ".%02d.", index);
1711 if (! dump_file[index].initialized)
1713 /* If we've not initialized the files, do so now. */
1714 if (graph_dump_format != no_graph
1715 && dump_file[index].graph_dump_p)
1717 dump_name = concat (seq, dump_file[index].extension, NULL);
1718 clean_graph_dump_file (dump_base_name, dump_name);
1721 dump_file[index].initialized = 1;
1727 dump_name = concat (dump_base_name, seq,
1728 dump_file[index].extension, NULL);
1730 rtl_dump_file = fopen (dump_name, open_arg);
1731 if (rtl_dump_file == NULL)
1732 pfatal_with_name (dump_name);
1737 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1738 decl_printable_name (decl, 2));
1740 timevar_pop (TV_DUMP);
1744 /* Routine to close a dump file. */
1747 close_dump_file (index, func, insns)
1748 enum dump_file_index index;
1749 void (*func) PARAMS ((FILE *, rtx));
1752 if (! rtl_dump_file)
1755 timevar_push (TV_DUMP);
1757 && graph_dump_format != no_graph
1758 && dump_file[index].graph_dump_p)
1763 sprintf (seq, ".%02d.", index);
1764 suffix = concat (seq, dump_file[index].extension, NULL);
1765 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1770 func (rtl_dump_file, insns);
1772 fflush (rtl_dump_file);
1773 fclose (rtl_dump_file);
1775 rtl_dump_file = NULL;
1776 timevar_pop (TV_DUMP);
1779 /* Do any final processing required for the declarations in VEC, of
1780 which there are LEN. We write out inline functions and variables
1781 that have been deferred until this point, but which are required.
1782 Returns non-zero if anything was put out. */
1784 wrapup_global_declarations (vec, len)
1791 int output_something = 0;
1793 for (i = 0; i < len; i++)
1797 /* We're not deferring this any longer. */
1798 DECL_DEFER_OUTPUT (decl) = 0;
1800 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1801 && incomplete_decl_finalize_hook != 0)
1802 (*incomplete_decl_finalize_hook) (decl);
1805 /* Now emit any global variables or functions that we have been
1806 putting off. We need to loop in case one of the things emitted
1807 here references another one which comes earlier in the list. */
1811 for (i = 0; i < len; i++)
1815 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1818 /* Don't write out static consts, unless we still need them.
1820 We also keep static consts if not optimizing (for debugging),
1821 unless the user specified -fno-keep-static-consts.
1822 ??? They might be better written into the debug information.
1823 This is possible when using DWARF.
1825 A language processor that wants static constants to be always
1826 written out (even if it is not used) is responsible for
1827 calling rest_of_decl_compilation itself. E.g. the C front-end
1828 calls rest_of_decl_compilation from finish_decl.
1829 One motivation for this is that is conventional in some
1830 environments to write things like:
1831 static const char rcsid[] = "... version string ...";
1832 intending to force the string to be in the executable.
1834 A language processor that would prefer to have unneeded
1835 static constants "optimized away" would just defer writing
1836 them out until here. E.g. C++ does this, because static
1837 constants are often defined in header files.
1839 ??? A tempting alternative (for both C and C++) would be
1840 to force a constant to be written if and only if it is
1841 defined in a main file, as opposed to an include file. */
1843 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1844 && (! TREE_READONLY (decl)
1845 || TREE_PUBLIC (decl)
1846 || (!optimize && flag_keep_static_consts)
1847 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1850 rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
1853 if (TREE_CODE (decl) == FUNCTION_DECL
1854 && DECL_INITIAL (decl) != 0
1855 && DECL_SAVED_INSNS (decl) != 0
1856 && (flag_keep_inline_functions
1857 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1858 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1861 temporary_allocation ();
1862 output_inline_function (decl);
1863 permanent_allocation (1);
1868 output_something = 1;
1872 return output_something;
1875 /* Issue appropriate warnings for the global declarations in VEC (of
1876 which there are LEN). Output debugging information for them. */
1878 check_global_declarations (vec, len)
1885 for (i = 0; i < len; i++)
1889 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1890 && ! TREE_ASM_WRITTEN (decl))
1891 /* Cancel the RTL for this decl so that, if debugging info
1892 output for global variables is still to come,
1893 this one will be omitted. */
1894 DECL_RTL (decl) = NULL;
1896 /* Warn about any function
1897 declared static but not defined.
1898 We don't warn about variables,
1899 because many programs have static variables
1900 that exist only to get some text into the object file. */
1901 if (TREE_CODE (decl) == FUNCTION_DECL
1903 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1904 && DECL_INITIAL (decl) == 0
1905 && DECL_EXTERNAL (decl)
1906 && ! DECL_ARTIFICIAL (decl)
1907 && ! TREE_PUBLIC (decl))
1909 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1910 pedwarn_with_decl (decl,
1911 "`%s' used but never defined");
1913 warning_with_decl (decl,
1914 "`%s' declared `static' but never defined");
1915 /* This symbol is effectively an "extern" declaration now. */
1916 TREE_PUBLIC (decl) = 1;
1917 assemble_external (decl);
1920 /* Warn about static fns or vars defined but not used,
1921 but not about inline functions or static consts
1922 since defining those in header files is normal practice. */
1924 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
1925 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1926 && ! DECL_IN_SYSTEM_HEADER (decl)
1927 && ! DECL_EXTERNAL (decl)
1928 && ! TREE_PUBLIC (decl)
1929 && ! TREE_USED (decl)
1930 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
1931 /* The TREE_USED bit for file-scope decls
1932 is kept in the identifier, to handle multiple
1933 external decls in different scopes. */
1934 && ! TREE_USED (DECL_NAME (decl)))
1935 warning_with_decl (decl, "`%s' defined but not used");
1937 timevar_push (TV_SYMOUT);
1938 #ifdef SDB_DEBUGGING_INFO
1939 /* The COFF linker can move initialized global vars to the end.
1940 And that can screw up the symbol ordering.
1941 By putting the symbols in that order to begin with,
1942 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1943 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL
1944 && TREE_PUBLIC (decl) && DECL_INITIAL (decl)
1945 && ! DECL_EXTERNAL (decl)
1946 && DECL_RTL (decl) != 0)
1947 sdbout_symbol (decl, 0);
1949 /* Output COFF information for non-global
1950 file-scope initialized variables. */
1951 if (write_symbols == SDB_DEBUG
1952 && TREE_CODE (decl) == VAR_DECL
1953 && DECL_INITIAL (decl)
1954 && ! DECL_EXTERNAL (decl)
1955 && DECL_RTL (decl) != 0
1956 && GET_CODE (DECL_RTL (decl)) == MEM)
1957 sdbout_toplevel_data (decl);
1958 #endif /* SDB_DEBUGGING_INFO */
1959 #ifdef DWARF_DEBUGGING_INFO
1960 /* Output DWARF information for file-scope tentative data object
1961 declarations, file-scope (extern) function declarations (which
1962 had no corresponding body) and file-scope tagged type declarations
1963 and definitions which have not yet been forced out. */
1965 if (write_symbols == DWARF_DEBUG
1966 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1967 dwarfout_file_scope_decl (decl, 1);
1969 #ifdef DWARF2_DEBUGGING_INFO
1970 /* Output DWARF2 information for file-scope tentative data object
1971 declarations, file-scope (extern) function declarations (which
1972 had no corresponding body) and file-scope tagged type declarations
1973 and definitions which have not yet been forced out. */
1975 if (write_symbols == DWARF2_DEBUG
1976 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
1977 dwarf2out_decl (decl);
1979 timevar_pop (TV_SYMOUT);
1983 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
1984 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1985 INPUT_FILENAME and LINENO accordingly. */
1988 push_srcloc (file, line)
1992 struct file_stack *fs;
1994 if (input_file_stack)
1996 input_file_stack->name = input_filename;
1997 input_file_stack->line = lineno;
2000 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2001 fs->name = input_filename = file;
2002 fs->line = lineno = line;
2003 fs->indent_level = 0;
2004 fs->next = input_file_stack;
2005 input_file_stack = fs;
2006 input_file_stack_tick++;
2009 /* Pop the top entry off the stack of presently open source files.
2010 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2016 struct file_stack *fs;
2018 fs = input_file_stack;
2019 input_file_stack = fs->next;
2021 input_file_stack_tick++;
2022 /* The initial souce file is never popped. */
2023 if (!input_file_stack)
2025 input_filename = input_file_stack->name;
2026 lineno = input_file_stack->line;
2029 /* Compile an entire file of output from cpp, named NAME.
2030 Write a file of assembly output and various debugging dumps. */
2038 int name_specified = name != 0;
2040 if (dump_base_name == 0)
2041 dump_base_name = name ? name : "gccdump";
2043 /* Start timing total execution time. */
2046 timevar_start (TV_TOTAL);
2048 /* Initialize data in various passes. */
2052 name = init_parse (name);
2053 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2054 || debug_info_level == DINFO_LEVEL_VERBOSE
2055 || flag_test_coverage
2056 || warn_notreached);
2058 init_decl_processing ();
2065 init_function_once ();
2066 init_stor_layout_once ();
2067 init_varasm_once ();
2069 /* The following initialization functions need to generate rtl, so
2070 provide a dummy function context for them. */
2071 init_dummy_function_start ();
2074 if (flag_caller_saves)
2075 init_caller_save ();
2076 expand_dummy_function_end ();
2078 /* If auxiliary info generation is desired, open the output file.
2079 This goes in the same directory as the source file--unlike
2080 all the other output files. */
2081 if (flag_gen_aux_info)
2083 aux_info_file = fopen (aux_info_file_name, "w");
2084 if (aux_info_file == 0)
2085 pfatal_with_name (aux_info_file_name);
2088 /* Open assembler code output file. */
2090 if (flag_syntax_only)
2091 asm_out_file = NULL;
2094 if (! name_specified && asm_file_name == 0)
2095 asm_out_file = stdout;
2098 if (asm_file_name == 0)
2100 int len = strlen (dump_base_name);
2101 char *dumpname = (char *) xmalloc (len + 6);
2102 memcpy (dumpname, dump_base_name, len + 1);
2103 strip_off_ending (dumpname, len);
2104 strcat (dumpname, ".s");
2105 asm_file_name = dumpname;
2107 if (!strcmp (asm_file_name, "-"))
2108 asm_out_file = stdout;
2110 asm_out_file = fopen (asm_file_name, "w");
2111 if (asm_out_file == 0)
2112 pfatal_with_name (asm_file_name);
2115 #ifdef IO_BUFFER_SIZE
2116 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2117 _IOFBF, IO_BUFFER_SIZE);
2122 name = ggc_alloc_string (name, strlen (name));
2123 input_filename = name;
2125 /* Put an entry on the input file stack for the main input file. */
2126 push_srcloc (input_filename, 0);
2128 /* Perform language-specific initialization.
2129 This may set main_input_filename. */
2132 /* If the input doesn't start with a #line, use the input name
2133 as the official input file name. */
2134 if (main_input_filename == 0)
2135 main_input_filename = name;
2137 if (flag_syntax_only)
2139 write_symbols = NO_DEBUG;
2141 profile_block_flag = 0;
2145 ASM_FILE_START (asm_out_file);
2147 #ifdef ASM_COMMENT_START
2148 if (flag_verbose_asm)
2150 /* Print the list of options in effect. */
2151 print_version (asm_out_file, ASM_COMMENT_START);
2152 print_switch_values (asm_out_file, 0, MAX_LINE,
2153 ASM_COMMENT_START, " ", "\n");
2154 /* Add a blank line here so it appears in assembler output but not
2156 fprintf (asm_out_file, "\n");
2160 /* Output something to inform GDB that this compilation was by GCC. */
2161 #ifndef ASM_IDENTIFY_GCC
2162 fprintf (asm_out_file, "gcc2_compiled.:\n");
2164 ASM_IDENTIFY_GCC (asm_out_file);
2167 /* Output something to identify which front-end produced this file. */
2168 #ifdef ASM_IDENTIFY_LANGUAGE
2169 ASM_IDENTIFY_LANGUAGE (asm_out_file);
2171 } /* ! flag_syntax_only */
2173 #ifndef ASM_OUTPUT_SECTION_NAME
2174 if (flag_function_sections)
2176 warning ("-ffunction-sections not supported for this target.");
2177 flag_function_sections = 0;
2179 if (flag_data_sections)
2181 warning ("-fdata-sections not supported for this target.");
2182 flag_data_sections = 0;
2186 if (flag_function_sections
2187 && (profile_flag || profile_block_flag))
2189 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2190 flag_function_sections = 0;
2193 #ifndef OBJECT_FORMAT_ELF
2194 if (flag_function_sections && write_symbols != NO_DEBUG)
2195 warning ("-ffunction-sections may affect debugging on some targets.");
2198 /* ??? Note: There used to be a conditional here
2199 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2200 This was to guarantee separation between gcc_compiled. and
2201 the first function, for the sake of dbx on Suns.
2202 However, having the extra zero here confused the Emacs
2203 code for unexec, and might confuse other programs too.
2204 Therefore, I took out that change.
2205 In future versions we should find another way to solve
2206 that dbx problem. -- rms, 23 May 93. */
2208 /* Don't let the first function fall at the same address
2209 as gcc_compiled., if profiling. */
2210 if (profile_flag || profile_block_flag)
2212 /* It's best if we can write a nop here since some
2213 assemblers don't tolerate zeros in the text section. */
2214 output_asm_insn (get_insn_template (CODE_FOR_nop, NULL), NULL_PTR);
2217 /* If dbx symbol table desired, initialize writing it
2218 and output the predefined types. */
2219 timevar_push (TV_SYMOUT);
2220 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2221 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2222 dbxout_init (asm_out_file, main_input_filename, getdecls ());
2224 #ifdef SDB_DEBUGGING_INFO
2225 if (write_symbols == SDB_DEBUG)
2226 sdbout_init (asm_out_file, main_input_filename, getdecls ());
2228 #ifdef DWARF_DEBUGGING_INFO
2229 if (write_symbols == DWARF_DEBUG)
2230 dwarfout_init (asm_out_file, main_input_filename);
2232 #ifdef DWARF2_UNWIND_INFO
2233 if (dwarf2out_do_frame ())
2234 dwarf2out_frame_init ();
2236 #ifdef DWARF2_DEBUGGING_INFO
2237 if (write_symbols == DWARF2_DEBUG)
2238 dwarf2out_init (asm_out_file, main_input_filename);
2240 timevar_pop (TV_SYMOUT);
2242 /* Initialize yet another pass. */
2244 init_final (main_input_filename);
2245 init_branch_prob (dump_base_name);
2247 timevar_push (TV_PARSE);
2249 /* Call the parser, which parses the entire file
2250 (calling rest_of_compilation for each function). */
2252 if (yyparse () != 0)
2254 if (errorcount == 0)
2255 fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
2257 /* In case there were missing closebraces,
2258 get us back to the global binding level. */
2259 while (! global_bindings_p ())
2263 /* Compilation is now finished except for writing
2264 what's left of the symbol table output. */
2266 timevar_pop (TV_PARSE);
2268 if (flag_syntax_only)
2271 globals = getdecls ();
2273 /* Really define vars that have had only a tentative definition.
2274 Really output inline functions that must actually be callable
2275 and have not been output so far. */
2278 int len = list_length (globals);
2279 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2283 /* Process the decls in reverse order--earliest first.
2284 Put them into VEC from back to front, then take out from front. */
2286 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2287 vec[len - i - 1] = decl;
2289 wrapup_global_declarations (vec, len);
2291 /* This must occur after the loop to output deferred functions. Else
2292 the profiler initializer would not be emitted if all the functions
2293 in this compilation unit were deferred.
2295 output_func_start_profiler can not cause any additional functions or
2296 data to need to be output, so it need not be in the deferred function
2298 output_func_start_profiler ();
2300 /* Now that all possible functions have been output, we can dump
2301 the exception table. */
2303 output_exception_table ();
2305 check_global_declarations (vec, len);
2311 /* Write out any pending weak symbol declarations. */
2315 /* Do dbx symbols */
2316 timevar_push (TV_SYMOUT);
2317 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2318 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2319 dbxout_finish (asm_out_file, main_input_filename);
2322 #ifdef DWARF_DEBUGGING_INFO
2323 if (write_symbols == DWARF_DEBUG)
2327 #ifdef DWARF2_UNWIND_INFO
2328 if (dwarf2out_do_frame ())
2329 dwarf2out_frame_finish ();
2332 #ifdef DWARF2_DEBUGGING_INFO
2333 if (write_symbols == DWARF2_DEBUG)
2334 dwarf2out_finish ();
2336 timevar_pop (TV_SYMOUT);
2338 /* Output some stuff at end of file if nec. */
2340 end_final (dump_base_name);
2342 if (flag_test_coverage || flag_branch_probabilities)
2344 timevar_push (TV_DUMP);
2345 open_dump_file (DFI_bp, NULL);
2346 end_branch_prob (rtl_dump_file);
2347 close_dump_file (DFI_bp, NULL, NULL_RTX);
2348 timevar_pop (TV_DUMP);
2352 ASM_FILE_END (asm_out_file);
2355 /* Language-specific end of compilation actions. */
2359 /* Close the dump files. */
2361 if (flag_gen_aux_info)
2363 fclose (aux_info_file);
2365 unlink (aux_info_file_name);
2368 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2370 timevar_push (TV_DUMP);
2371 dump_combine_total_stats (rtl_dump_file);
2372 close_dump_file (DFI_combine, NULL, NULL_RTX);
2373 timevar_pop (TV_DUMP);
2376 /* Close non-debugging input and output files. Take special care to note
2377 whether fclose returns an error, since the pages might still be on the
2378 buffer chain while the file is open. */
2382 if (! flag_syntax_only
2383 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0))
2384 fatal_io_error (asm_file_name);
2386 /* Do whatever is necessary to finish printing the graphs. */
2387 if (graph_dump_format != no_graph)
2391 for (i = 0; i < DFI_MAX; ++i)
2392 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2397 sprintf (seq, ".%02d.", i);
2398 suffix = concat (seq, dump_file[i].extension, NULL);
2399 finish_graph_dump_file (dump_base_name, suffix);
2404 /* Free up memory for the benefit of leak detectors. */
2407 /* Stop timing total execution time. */
2408 timevar_stop (TV_TOTAL);
2410 /* Print the times. */
2413 timevar_print (stderr);
2416 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2417 and TYPE_DECL nodes.
2419 This does nothing for local (non-static) variables, unless the
2420 variable is a register variable with an ASMSPEC. In that case, or
2421 if the variable is not an automatice, it sets up the RTL and
2422 outputs any assembler code (label definition, storage allocation
2423 and initialization).
2425 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2426 the assembler symbol name to be used. TOP_LEVEL is nonzero
2427 if this declaration is not within a function. */
2430 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2432 const char *asmspec;
2436 /* Declarations of variables, and of functions defined elsewhere. */
2438 /* The most obvious approach, to put an #ifndef around where
2439 this macro is used, doesn't work since it's inside a macro call. */
2440 #ifndef ASM_FINISH_DECLARE_OBJECT
2441 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2444 /* Forward declarations for nested functions are not "external",
2445 but we need to treat them as if they were. */
2446 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2447 || TREE_CODE (decl) == FUNCTION_DECL)
2449 timevar_push (TV_VARCONST);
2450 make_decl_rtl (decl, asmspec, top_level);
2451 /* Initialized extern variable exists to be replaced
2452 with its value, or represents something that will be
2453 output in another file. */
2454 if (! (TREE_CODE (decl) == VAR_DECL
2455 && DECL_EXTERNAL (decl) && TREE_READONLY (decl)
2456 && DECL_INITIAL (decl) != 0
2457 && DECL_INITIAL (decl) != error_mark_node))
2458 /* Don't output anything
2459 when a tentative file-scope definition is seen.
2460 But at end of compilation, do output code for them. */
2461 if (! (! at_end && top_level
2462 && (DECL_INITIAL (decl) == 0
2463 || DECL_INITIAL (decl) == error_mark_node)))
2464 assemble_variable (decl, top_level, at_end, 0);
2465 if (decl == last_assemble_variable_decl)
2467 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2470 timevar_pop (TV_VARCONST);
2472 else if (DECL_REGISTER (decl) && asmspec != 0)
2474 if (decode_reg_name (asmspec) >= 0)
2476 DECL_RTL (decl) = 0;
2477 make_decl_rtl (decl, asmspec, top_level);
2480 error ("invalid register name `%s' for register variable", asmspec);
2482 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2483 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2484 && TREE_CODE (decl) == TYPE_DECL)
2486 timevar_push (TV_SYMOUT);
2487 dbxout_symbol (decl, 0);
2488 timevar_pop (TV_SYMOUT);
2491 #ifdef SDB_DEBUGGING_INFO
2492 else if (write_symbols == SDB_DEBUG && top_level
2493 && TREE_CODE (decl) == TYPE_DECL)
2495 timevar_push (TV_SYMOUT);
2496 sdbout_symbol (decl, 0);
2497 timevar_pop (TV_SYMOUT);
2502 /* Called after finishing a record, union or enumeral type. */
2505 rest_of_type_compilation (type, toplev)
2506 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2510 tree type ATTRIBUTE_UNUSED;
2511 int toplev ATTRIBUTE_UNUSED;
2514 timevar_push (TV_SYMOUT);
2515 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2516 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2517 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2519 #ifdef SDB_DEBUGGING_INFO
2520 if (write_symbols == SDB_DEBUG)
2521 symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2523 timevar_pop (TV_SYMOUT);
2526 /* DECL is an inline function, whose body is present, but which is not
2527 being output at this point. (We're putting that off until we need
2528 to do it.) If there are any actions that need to take place,
2529 including the emission of debugging information for the function,
2530 this is where they should go. This function may be called by
2531 language-dependent code for front-ends that do not even generate
2532 RTL for functions that don't need to be put out. */
2535 note_deferral_of_defined_inline_function (decl)
2536 tree decl ATTRIBUTE_UNUSED;
2538 #ifdef DWARF_DEBUGGING_INFO
2539 /* Generate the DWARF info for the "abstract" instance of a function
2540 which we may later generate inlined and/or out-of-line instances
2542 if (write_symbols == DWARF_DEBUG && DECL_INLINE (decl))
2544 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2545 DWARF code expects it to be set in this case. Intuitively,
2546 DECL is the function we just finished defining, so setting
2547 CURRENT_FUNCTION_DECL is sensible. */
2548 tree saved_cfd = current_function_decl;
2549 current_function_decl = decl;
2551 /* Let the DWARF code do its work. */
2552 set_decl_abstract_flags (decl, 1);
2553 dwarfout_file_scope_decl (decl, 0);
2554 set_decl_abstract_flags (decl, 0);
2556 /* Reset CURRENT_FUNCTION_DECL. */
2557 current_function_decl = saved_cfd;
2562 /* This is called from finish_function (within yyparse)
2563 after each top-level definition is parsed.
2564 It is supposed to compile that function or variable
2565 and output the assembler code for it.
2566 After we return, the tree storage is freed. */
2569 rest_of_compilation (decl)
2575 int rebuild_label_notes_after_reload;
2577 timevar_push (TV_REST_OF_COMPILATION);
2579 /* When processing delayed functions, prepare_function_start() won't
2580 have been run to re-initialize it. */
2581 cse_not_expected = ! optimize;
2583 /* First, make sure that NOTE_BLOCK is set correctly for each
2584 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2585 if (!cfun->x_whole_function_mode_p)
2588 /* Then remove any notes we don't need. That will make iterating
2589 over the instruction sequence faster, and allow the garbage
2590 collector to reclaim the memory used by the notes. */
2591 remove_unncessary_notes ();
2593 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2594 tree in sensible shape. So, we just recalculate it here. */
2595 if (cfun->x_whole_function_mode_p)
2598 /* If we are reconsidering an inline function
2599 at the end of compilation, skip the stuff for making it inline. */
2601 if (DECL_SAVED_INSNS (decl) == 0)
2607 /* If this is nested inside an inlined external function, pretend
2608 it was only declared. Since we cannot inline such functions,
2609 generating code for this one is not only not necessary but will
2610 confuse some debugging output writers. */
2611 for (parent = DECL_CONTEXT (current_function_decl);
2612 parent != NULL_TREE;
2613 parent = get_containing_scope (parent))
2614 if (TREE_CODE (parent) == FUNCTION_DECL
2615 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2617 DECL_INITIAL (decl) = 0;
2618 goto exit_rest_of_compilation;
2621 /* If requested, consider whether to make this function inline. */
2622 if (DECL_INLINE (decl) || flag_inline_functions)
2624 timevar_push (TV_INTEGRATION);
2625 lose = function_cannot_inline_p (decl);
2626 timevar_pop (TV_INTEGRATION);
2627 if (lose || ! optimize)
2629 if (warn_inline && DECL_INLINE (decl))
2630 warning_with_decl (decl, lose);
2631 DECL_ABSTRACT_ORIGIN (decl) = 0;
2632 /* Don't really compile an extern inline function.
2633 If we can't make it inline, pretend
2634 it was only declared. */
2635 if (DECL_EXTERNAL (decl))
2637 DECL_INITIAL (decl) = 0;
2638 goto exit_rest_of_compilation;
2642 /* ??? Note that this has the effect of making it look
2643 like "inline" was specified for a function if we choose
2644 to inline it. This isn't quite right, but it's
2645 probably not worth the trouble to fix. */
2646 inlinable = DECL_INLINE (decl) = 1;
2649 insns = get_insns ();
2651 /* Dump the rtl code if we are dumping rtl. */
2653 if (open_dump_file (DFI_rtl, decl))
2655 if (DECL_SAVED_INSNS (decl))
2656 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2657 close_dump_file (DFI_rtl, print_rtl, insns);
2660 /* If function is inline, and we don't yet know whether to
2661 compile it by itself, defer decision till end of compilation.
2662 finish_compilation will call rest_of_compilation again
2663 for those functions that need to be output. Also defer those
2664 functions that we are supposed to defer. */
2667 || (DECL_INLINE (decl)
2668 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2669 && ! flag_keep_inline_functions)
2670 || DECL_EXTERNAL (decl))))
2671 DECL_DEFER_OUTPUT (decl) = 1;
2673 if (DECL_DEFER_OUTPUT (decl))
2675 /* If -Wreturn-type, we have to do a bit of compilation.
2676 However, if we just fall through we will call
2677 save_for_inline_copying() which results in excessive
2678 memory use. Instead, we just want to call
2679 jump_optimize() to figure out whether or not we can fall
2680 off the end of the function; we do the minimum amount of
2681 work necessary to make that safe. And, we set optimize
2682 to zero to keep jump_optimize from working too hard. */
2683 if (warn_return_type)
2685 int saved_optimize = optimize;
2687 find_exception_handler_labels ();
2688 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2689 !JUMP_AFTER_REGSCAN);
2690 optimize = saved_optimize;
2693 current_function_nothrow = nothrow_function_p ();
2694 if (current_function_nothrow)
2695 /* Now we know that this can't throw; set the flag for the benefit
2696 of other functions later in this translation unit. */
2697 TREE_NOTHROW (current_function_decl) = 1;
2699 note_deferral_of_defined_inline_function (decl);
2700 timevar_push (TV_INTEGRATION);
2701 save_for_inline_nocopy (decl);
2702 timevar_pop (TV_INTEGRATION);
2703 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2704 goto exit_rest_of_compilation;
2707 /* If specified extern inline but we aren't inlining it, we are
2708 done. This goes for anything that gets here with DECL_EXTERNAL
2709 set, not just things with DECL_INLINE. */
2710 if (DECL_EXTERNAL (decl))
2711 goto exit_rest_of_compilation;
2714 init_EXPR_INSN_LIST_cache ();
2719 /* Initialize some variables used by the optimizers. */
2720 init_function_for_compilation ();
2722 if (! DECL_DEFER_OUTPUT (decl))
2723 TREE_ASM_WRITTEN (decl) = 1;
2725 /* Now that integrate will no longer see our rtl, we need not distinguish
2726 between the return value of this function and the return value of called
2728 rtx_equal_function_value_matters = 0;
2730 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2731 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2732 goto exit_rest_of_compilation;
2734 /* Emit code to get eh context, if needed. */
2737 /* We may have potential sibling or tail recursion sites. Select one
2738 (of possibly multiple) methods of performing the call. */
2739 if (flag_optimize_sibling_calls)
2741 timevar_push (TV_JUMP);
2742 open_dump_file (DFI_sibling, decl);
2744 optimize_sibling_and_tail_recursive_calls ();
2746 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2747 timevar_pop (TV_JUMP);
2751 /* If we are doing position-independent code generation, now
2752 is the time to output special prologues and epilogues.
2753 We do not want to do this earlier, because it just clutters
2754 up inline functions with meaningless insns. */
2759 /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
2760 Note that that may have been done above, in save_for_inline_copying.
2761 The call to resume_temporary_allocation near the end of this function
2762 goes back to the usual state of affairs. This must be done after
2763 we've built up any unwinders for exception handling, and done
2764 the FINALIZE_PIC work, if necessary. */
2766 rtl_in_current_obstack ();
2768 insns = get_insns ();
2770 /* Copy any shared structure that should not be shared. */
2771 unshare_all_rtl (current_function_decl, insns);
2773 #ifdef SETJMP_VIA_SAVE_AREA
2774 /* This must be performed before virutal register instantiation. */
2775 if (current_function_calls_alloca)
2776 optimize_save_area_alloca (insns);
2779 /* Instantiate all virtual registers. */
2780 instantiate_virtual_regs (current_function_decl, insns);
2782 /* Find all the EH handlers. */
2783 find_exception_handler_labels ();
2785 open_dump_file (DFI_jump, decl);
2787 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2788 are initialized and to compute whether control can drop off the end
2791 timevar_push (TV_JUMP);
2792 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2793 before jump optimization switches branch directions. */
2794 expected_value_to_br_prob ();
2796 reg_scan (insns, max_reg_num (), 0);
2797 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2798 JUMP_AFTER_REGSCAN);
2800 timevar_pop (TV_JUMP);
2802 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2803 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2805 close_dump_file (DFI_jump, print_rtl, insns);
2806 goto exit_rest_of_compilation;
2809 timevar_push (TV_JUMP);
2810 /* Try to identify useless null pointer tests and delete them. */
2811 if (flag_delete_null_pointer_checks)
2813 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2814 cleanup_cfg (insns);
2815 delete_null_pointer_checks (insns);
2818 /* Jump optimization, and the removal of NULL pointer checks, may
2819 have reduced the number of instructions substantially. CSE, and
2820 future passes, allocate arrays whose dimensions involve the
2821 maximum instruction UID, so if we can reduce the maximum UID
2822 we'll save big on memory. */
2823 renumber_insns (rtl_dump_file);
2824 timevar_pop (TV_JUMP);
2826 close_dump_file (DFI_jump, print_rtl, insns);
2831 /* Perform common subexpression elimination.
2832 Nonzero value from `cse_main' means that jumps were simplified
2833 and some code may now be unreachable, so do
2834 jump optimization again. */
2838 open_dump_file (DFI_cse, decl);
2839 timevar_push (TV_CSE);
2841 reg_scan (insns, max_reg_num (), 1);
2843 if (flag_thread_jumps)
2845 timevar_push (TV_JUMP);
2846 thread_jumps (insns, max_reg_num (), 1);
2847 timevar_pop (TV_JUMP);
2850 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2852 /* If we are not running the second CSE pass, then we are no longer
2853 expecting CSE to be run. */
2854 cse_not_expected = !flag_rerun_cse_after_loop;
2856 if (tem || optimize > 1)
2858 timevar_push (TV_JUMP);
2859 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2860 !JUMP_AFTER_REGSCAN);
2861 timevar_pop (TV_JUMP);
2864 /* Run this after jump optmizations remove all the unreachable code
2865 so that unreachable code will not keep values live. */
2866 delete_trivially_dead_insns (insns, max_reg_num ());
2868 /* Try to identify useless null pointer tests and delete them. */
2869 if (flag_delete_null_pointer_checks)
2871 timevar_push (TV_JUMP);
2872 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2874 cleanup_cfg (insns);
2876 delete_null_pointer_checks (insns);
2877 timevar_pop (TV_JUMP);
2880 /* The second pass of jump optimization is likely to have
2881 removed a bunch more instructions. */
2882 renumber_insns (rtl_dump_file);
2884 timevar_pop (TV_CSE);
2885 close_dump_file (DFI_cse, print_rtl, insns);
2888 open_dump_file (DFI_addressof, decl);
2890 purge_addressof (insns);
2891 reg_scan (insns, max_reg_num (), 1);
2893 close_dump_file (DFI_addressof, print_rtl, insns);
2898 if (optimize > 0 && flag_ssa)
2900 /* Convert to SSA form. */
2902 timevar_push (TV_TO_SSA);
2903 open_dump_file (DFI_ssa, decl);
2905 find_basic_blocks (insns, max_reg_num(), rtl_dump_file);
2906 cleanup_cfg (insns);
2909 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2910 timevar_pop (TV_TO_SSA);
2912 /* Currently, there's nothing to do in SSA form. */
2914 /* Convert from SSA form. */
2916 timevar_push (TV_FROM_SSA);
2917 open_dump_file (DFI_ussa, decl);
2919 convert_from_ssa ();
2920 /* New registers have been created. Rescan their usage. */
2921 reg_scan (insns, max_reg_num (), 1);
2922 /* Life analysis used in SSA adds log_links but these
2923 shouldn't be there until the flow stage, so clear
2925 clear_log_links (insns);
2927 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2928 timevar_pop (TV_FROM_SSA);
2934 /* Perform global cse. */
2936 if (optimize > 0 && flag_gcse)
2938 timevar_push (TV_GCSE);
2939 open_dump_file (DFI_gcse, decl);
2941 find_basic_blocks (insns, max_reg_num(), rtl_dump_file);
2942 cleanup_cfg (insns);
2943 tem = gcse_main (insns, rtl_dump_file);
2945 /* If gcse altered any jumps, rerun jump optimizations to clean
2949 timevar_push (TV_JUMP);
2950 jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES,
2951 !JUMP_AFTER_REGSCAN);
2952 timevar_pop (TV_JUMP);
2955 close_dump_file (DFI_gcse, print_rtl, insns);
2956 timevar_pop (TV_GCSE);
2962 /* Move constant computations out of loops. */
2966 timevar_push (TV_LOOP);
2967 open_dump_file (DFI_loop, decl);
2969 if (flag_rerun_loop_opt)
2971 /* We only want to perform unrolling once. */
2973 loop_optimize (insns, rtl_dump_file, 0, 0);
2975 /* The first call to loop_optimize makes some instructions
2976 trivially dead. We delete those instructions now in the
2977 hope that doing so will make the heuristics in loop work
2978 better and possibly speed up compilation. */
2979 delete_trivially_dead_insns (insns, max_reg_num ());
2981 /* The regscan pass is currently necessary as the alias
2982 analysis code depends on this information. */
2983 reg_scan (insns, max_reg_num (), 1);
2985 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1);
2987 close_dump_file (DFI_loop, print_rtl, insns);
2988 timevar_pop (TV_LOOP);
2994 /* ??? Well, nearly. If HAVE_conditional_arithmetic, jump_optimize
2995 has put off all if-conversion until "after CSE". If we put this
2996 off any longer we may miss out doing if-conversion entirely. */
2997 cse_not_expected = 1;
3001 timevar_push (TV_CSE2);
3002 open_dump_file (DFI_cse2, decl);
3004 if (flag_rerun_cse_after_loop)
3006 /* Running another jump optimization pass before the second
3007 cse pass sometimes simplifies the RTL enough to allow
3008 the second CSE pass to do a better job. Jump_optimize can change
3009 max_reg_num so we must rerun reg_scan afterwards.
3010 ??? Rework to not call reg_scan so often. */
3011 timevar_push (TV_JUMP);
3012 reg_scan (insns, max_reg_num (), 0);
3013 jump_optimize (insns, !JUMP_CROSS_JUMP,
3014 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
3015 timevar_pop (TV_JUMP);
3017 reg_scan (insns, max_reg_num (), 0);
3018 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3022 timevar_push (TV_JUMP);
3023 jump_optimize (insns, !JUMP_CROSS_JUMP,
3024 !JUMP_NOOP_MOVES, !JUMP_AFTER_REGSCAN);
3025 timevar_pop (TV_JUMP);
3029 if (flag_thread_jumps)
3031 /* This pass of jump threading straightens out code
3032 that was kinked by loop optimization. */
3033 timevar_push (TV_JUMP);
3034 reg_scan (insns, max_reg_num (), 0);
3035 thread_jumps (insns, max_reg_num (), 0);
3036 timevar_pop (TV_JUMP);
3039 close_dump_file (DFI_cse2, print_rtl, insns);
3040 timevar_pop (TV_CSE2);
3046 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3048 timevar_push (TV_BRANCH_PROB);
3049 open_dump_file (DFI_bp, decl);
3051 branch_prob (insns, rtl_dump_file);
3053 close_dump_file (DFI_bp, print_rtl, insns);
3054 timevar_pop (TV_BRANCH_PROB);
3062 /* Print function header into flow dump now
3063 because doing the flow analysis makes some of the dump. */
3065 open_dump_file (DFI_flow, decl);
3067 /* Do control and data flow analysis; wrote some of the results to
3070 timevar_push (TV_FLOW);
3071 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3072 cleanup_cfg (insns);
3077 /* Discover and record the loop depth at the head of each basic
3078 block. The loop infrastructure does the real job for us. */
3079 flow_loops_find (&loops);
3081 /* Estimate using heuristics if no profiling info is available. */
3082 if (! flag_branch_probabilities)
3083 estimate_probability (&loops);
3086 flow_loops_dump (&loops, rtl_dump_file, 0);
3088 flow_loops_free (&loops);
3090 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3091 mark_constant_function ();
3092 timevar_pop (TV_FLOW);
3094 if (warn_uninitialized || extra_warnings)
3096 uninitialized_vars_warning (DECL_INITIAL (decl));
3098 setjmp_args_warning ();
3101 close_dump_file (DFI_flow, print_rtl_with_bb, insns);
3106 /* The first life analysis pass has finished. From now on we can not
3107 generate any new pseudos. */
3110 /* If -opt, try combining insns through substitution. */
3114 int rebuild_jump_labels_after_combine = 0;
3116 timevar_push (TV_COMBINE);
3117 open_dump_file (DFI_combine, decl);
3119 rebuild_jump_labels_after_combine
3120 = combine_instructions (insns, max_reg_num ());
3122 /* Combining insns may have turned an indirect jump into a
3123 direct jump. Rebuid the JUMP_LABEL fields of jumping
3125 if (rebuild_jump_labels_after_combine)
3127 timevar_push (TV_JUMP);
3128 rebuild_jump_labels (insns);
3129 timevar_pop (TV_JUMP);
3132 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3133 timevar_pop (TV_COMBINE);
3139 /* Register allocation pre-pass, to reduce number of moves
3140 necessary for two-address machines. */
3141 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3143 timevar_push (TV_REGMOVE);
3144 open_dump_file (DFI_regmove, decl);
3146 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3148 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3149 timevar_pop (TV_REGMOVE);
3155 if (optimize && n_basic_blocks)
3157 timevar_push (TV_GCSE);
3158 optimize_mode_switching (NULL_PTR);
3159 timevar_pop (TV_GCSE);
3162 #ifdef INSN_SCHEDULING
3164 /* Print function header into sched dump now
3165 because doing the sched analysis makes some of the dump. */
3166 if (optimize > 0 && flag_schedule_insns)
3168 timevar_push (TV_SCHED);
3169 open_dump_file (DFI_sched, decl);
3171 /* Do control and data sched analysis,
3172 and write some of the results to dump file. */
3174 schedule_insns (rtl_dump_file);
3176 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3177 timevar_pop (TV_SCHED);
3184 /* Determine if the current function is a leaf before running reload
3185 since this can impact optimizations done by the prologue and
3186 epilogue thus changing register elimination offsets. */
3187 current_function_is_leaf = leaf_function_p ();
3189 timevar_push (TV_LOCAL_ALLOC);
3190 open_dump_file (DFI_lreg, decl);
3192 /* Allocate pseudo-regs that are used only within 1 basic block.
3194 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3195 jump optimizer after register allocation and reloading are finished. */
3197 /* We recomputed reg usage as part of updating the rest
3198 of life info during sched. */
3199 if (! flag_schedule_insns)
3200 recompute_reg_usage (insns, ! optimize_size);
3201 regclass (insns, max_reg_num (), rtl_dump_file);
3202 rebuild_label_notes_after_reload = local_alloc ();
3204 timevar_pop (TV_LOCAL_ALLOC);
3206 if (dump_file[DFI_lreg].enabled)
3208 timevar_push (TV_DUMP);
3210 dump_flow_info (rtl_dump_file);
3211 dump_local_alloc (rtl_dump_file);
3213 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3214 timevar_pop (TV_DUMP);
3220 timevar_push (TV_GLOBAL_ALLOC);
3221 open_dump_file (DFI_greg, decl);
3223 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3224 pass fixing up any insns that are invalid. */
3227 failure = global_alloc (rtl_dump_file);
3230 build_insn_chain (insns);
3231 failure = reload (insns, 0, rtl_dump_file);
3234 timevar_pop (TV_GLOBAL_ALLOC);
3237 goto exit_rest_of_compilation;
3242 /* Do a very simple CSE pass over just the hard registers. */
3245 timevar_push (TV_RELOAD_CSE_REGS);
3246 reload_cse_regs (insns);
3247 timevar_pop (TV_RELOAD_CSE_REGS);
3250 /* If optimizing, then go ahead and split insns now since we are about
3251 to recompute flow information anyway. */
3253 split_all_insns (0);
3255 /* Register allocation and reloading may have turned an indirect jump into
3256 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3257 jumping instructions. */
3258 if (rebuild_label_notes_after_reload)
3260 timevar_push (TV_JUMP);
3262 rebuild_jump_labels (insns);
3264 timevar_pop (TV_JUMP);
3267 if (dump_file[DFI_greg].enabled)
3269 timevar_push (TV_DUMP);
3271 dump_global_regs (rtl_dump_file);
3273 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3274 timevar_pop (TV_DUMP);
3277 /* Re-create the death notes which were deleted during reload. */
3278 timevar_push (TV_FLOW2);
3279 open_dump_file (DFI_flow2, decl);
3281 jump_optimize_minimal (insns);
3282 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3284 /* On some machines, the prologue and epilogue code, or parts thereof,
3285 can be represented as RTL. Doing so lets us schedule insns between
3286 it and the rest of the code and also allows delayed branch
3287 scheduling to operate in the epilogue. */
3288 thread_prologue_and_epilogue_insns (insns);
3292 cleanup_cfg (insns);
3293 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3295 /* This is kind of heruistics. We need to run combine_stack_adjustments
3296 even for machines with possibly nonzero RETURN_POPS_ARGS
3297 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3298 push instructions will have popping returns. */
3299 #ifndef PUSH_ROUNDING
3300 if (!ACCUMULATE_OUTGOING_ARGS)
3302 combine_stack_adjustments ();
3308 flow2_completed = 1;
3310 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3311 timevar_pop (TV_FLOW2);
3313 #ifdef HAVE_peephole2
3314 if (optimize > 0 && flag_peephole2)
3316 timevar_push (TV_PEEPHOLE2);
3318 open_dump_file (DFI_peephole2, decl);
3319 peephole2_optimize (rtl_dump_file);
3321 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3322 timevar_pop (TV_PEEPHOLE2);
3326 #ifdef INSN_SCHEDULING
3327 if (optimize > 0 && flag_schedule_insns_after_reload)
3329 timevar_push (TV_SCHED2);
3330 open_dump_file (DFI_sched2, decl);
3332 /* Do control and data sched analysis again,
3333 and write some more of the results to dump file. */
3335 schedule_insns (rtl_dump_file);
3337 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3338 timevar_pop (TV_SCHED2);
3345 #ifdef LEAF_REGISTERS
3346 current_function_uses_only_leaf_regs
3347 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3350 if (optimize > 0 && flag_reorder_blocks)
3352 timevar_push (TV_REORDER_BLOCKS);
3353 open_dump_file (DFI_bbro, decl);
3355 reorder_basic_blocks ();
3357 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3358 timevar_pop (TV_REORDER_BLOCKS);
3361 if (optimize > 0 && flag_rename_registers)
3363 timevar_push (TV_RENAME_REGISTERS);
3364 open_dump_file (DFI_rnreg, decl);
3366 regrename_optimize ();
3368 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3369 timevar_pop (TV_RENAME_REGISTERS);
3372 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3373 Also do cross-jumping this time and delete no-op move insns. */
3377 timevar_push (TV_JUMP);
3378 open_dump_file (DFI_jump2, decl);
3380 jump_optimize (insns, JUMP_CROSS_JUMP, JUMP_NOOP_MOVES,
3381 !JUMP_AFTER_REGSCAN);
3383 close_dump_file (DFI_jump2, print_rtl_with_bb, insns);
3384 timevar_pop (TV_JUMP);
3387 /* If a machine dependent reorganization is needed, call it. */
3388 #ifdef MACHINE_DEPENDENT_REORG
3389 open_dump_file (DFI_mach, decl);
3391 MACHINE_DEPENDENT_REORG (insns);
3393 close_dump_file (DFI_mach, print_rtl_with_bb, insns);
3399 /* If a scheduling pass for delayed branches is to be done,
3400 call the scheduling code. */
3403 if (optimize > 0 && flag_delayed_branch)
3405 timevar_push (TV_DBR_SCHED);
3406 open_dump_file (DFI_dbr, decl);
3408 dbr_schedule (insns, rtl_dump_file);
3410 close_dump_file (DFI_dbr, print_rtl_with_bb, insns);
3411 timevar_pop (TV_DBR_SCHED);
3418 /* Shorten branches.
3420 Note this must run before reg-stack because of death note (ab)use
3421 in the ia32 backend. */
3422 timevar_push (TV_SHORTEN_BRANCH);
3423 shorten_branches (get_insns ());
3424 timevar_pop (TV_SHORTEN_BRANCH);
3427 timevar_push (TV_REG_STACK);
3428 open_dump_file (DFI_stack, decl);
3430 reg_to_stack (insns, rtl_dump_file);
3432 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3433 timevar_pop (TV_REG_STACK);
3439 current_function_nothrow = nothrow_function_p ();
3440 if (current_function_nothrow)
3441 /* Now we know that this can't throw; set the flag for the benefit
3442 of other functions later in this translation unit. */
3443 TREE_NOTHROW (current_function_decl) = 1;
3445 /* Now turn the rtl into assembler code. */
3447 timevar_push (TV_FINAL);
3452 /* Get the function's name, as described by its RTL.
3453 This may be different from the DECL_NAME name used
3454 in the source file. */
3456 x = DECL_RTL (decl);
3457 if (GET_CODE (x) != MEM)
3460 if (GET_CODE (x) != SYMBOL_REF)
3462 fnname = XSTR (x, 0);
3464 assemble_start_function (decl, fnname);
3465 final_start_function (insns, asm_out_file, optimize);
3466 final (insns, asm_out_file, optimize, 0);
3467 final_end_function (insns, asm_out_file, optimize);
3468 assemble_end_function (decl, fnname);
3470 fflush (asm_out_file);
3472 /* Release all memory allocated by flow. */
3473 free_basic_block_vars (0);
3475 /* Release all memory held by regsets now */
3476 regset_release_memory ();
3478 timevar_pop (TV_FINAL);
3483 /* Write DBX symbols if requested */
3485 /* Note that for those inline functions where we don't initially
3486 know for certain that we will be generating an out-of-line copy,
3487 the first invocation of this routine (rest_of_compilation) will
3488 skip over this code by doing a `goto exit_rest_of_compilation;'.
3489 Later on, finish_compilation will call rest_of_compilation again
3490 for those inline functions that need to have out-of-line copies
3491 generated. During that call, we *will* be routed past here. */
3493 timevar_push (TV_SYMOUT);
3494 #ifdef DBX_DEBUGGING_INFO
3495 if (write_symbols == DBX_DEBUG)
3496 dbxout_function (decl);
3499 #ifdef DWARF_DEBUGGING_INFO
3500 if (write_symbols == DWARF_DEBUG)
3501 dwarfout_file_scope_decl (decl, 0);
3504 #ifdef DWARF2_DEBUGGING_INFO
3505 if (write_symbols == DWARF2_DEBUG)
3506 dwarf2out_decl (decl);
3508 timevar_pop (TV_SYMOUT);
3510 exit_rest_of_compilation:
3512 /* In case the function was not output,
3513 don't leave any temporary anonymous types
3514 queued up for sdb output. */
3515 #ifdef SDB_DEBUGGING_INFO
3516 if (write_symbols == SDB_DEBUG)
3517 sdbout_types (NULL_TREE);
3520 reload_completed = 0;
3521 flow2_completed = 0;
3524 timevar_push (TV_FINAL);
3526 /* Clear out the insn_length contents now that they are no
3528 init_insn_lengths ();
3530 /* Clear out the real_constant_chain before some of the rtx's
3531 it runs through become garbage. */
3532 clear_const_double_mem ();
3534 /* Cancel the effect of rtl_in_current_obstack. */
3535 resume_temporary_allocation ();
3537 /* Show no temporary slots allocated. */
3540 free_basic_block_vars (0);
3542 timevar_pop (TV_FINAL);
3544 /* Make sure volatile mem refs aren't considered valid operands for
3545 arithmetic insns. We must call this here if this is a nested inline
3546 function, since the above code leaves us in the init_recog state
3547 (from final.c), and the function context push/pop code does not
3548 save/restore volatile_ok.
3550 ??? Maybe it isn't necessary for expand_start_function to call this
3551 anymore if we do it here? */
3553 init_recog_no_volatile ();
3555 /* We're done with this function. Free up memory if we can. */
3556 free_after_parsing (cfun);
3557 if (! DECL_DEFER_OUTPUT (decl))
3558 free_after_compilation (cfun);
3564 timevar_pop (TV_REST_OF_COMPILATION);
3575 printf ("Usage: %s input [switches]\n", progname);
3576 printf ("Switches:\n");
3578 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n");
3579 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
3580 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
3581 printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
3583 for (i = NUM_ELEM (f_options); i--;)
3585 const char * description = f_options[i].description;
3587 if (description != NULL && * description != 0)
3588 printf (" -f%-21s %s\n",
3589 f_options[i].string, description);
3592 printf (" -O[number] Set optimisation level to [number]\n");
3593 printf (" -Os Optimise for space rather than speed\n");
3594 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n");
3595 printf (" -pedantic-errors Like -pedantic except that errors are produced\n");
3596 printf (" -w Suppress warnings\n");
3597 printf (" -W Enable extra warnings\n");
3599 for (i = NUM_ELEM (W_options); i--;)
3601 const char * description = W_options[i].description;
3603 if (description != NULL && * description != 0)
3604 printf (" -W%-21s %s\n",
3605 W_options[i].string, description);
3608 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n");
3609 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n");
3610 printf (" -p Enable function profiling\n");
3611 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3612 printf (" -a Enable block profiling \n");
3614 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3615 printf (" -ax Enable jump profiling \n");
3617 printf (" -o <file> Place output into <file> \n");
3618 printf (" -G <number> Put global and static data smaller than <number>\n");
3619 printf (" bytes into a special section (on some targets)\n");
3621 for (i = NUM_ELEM (debug_args); i--;)
3623 if (debug_args[i].description != NULL)
3624 printf (" -g%-21s %s\n", debug_args[i].arg, debug_args[i].description);
3627 printf (" -aux-info <file> Emit declaration info into <file>.X\n");
3628 printf (" -quiet Do not display functions compiled or elapsed time\n");
3629 printf (" -version Display the compiler's version\n");
3630 printf (" -d[letters] Enable dumps from specific passes of the compiler\n");
3631 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n");
3632 #if defined INSN_SCHEDULING
3633 printf (" -fsched-verbose=<number> Set the verbosity level of the scheduler\n");
3635 printf (" --help Display this information\n");
3640 /* Display descriptions of language specific options.
3641 If there is no description, note that there is an undocumented option.
3642 If the description is empty, do not display anything. (This allows
3643 options to be deliberately undocumented, for whatever reason).
3644 If the option string is missing, then this is a marker, indicating
3645 that the description string is in fact the name of a language, whose
3646 language specific options are to follow. */
3648 if (NUM_ELEM (documented_lang_options) > 1)
3650 printf ("\nLanguage specific options:\n");
3652 for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
3654 const char * description = documented_lang_options[i].description;
3655 const char * option = documented_lang_options[i].option;
3657 if (description == NULL)
3662 printf (" %-23.23s [undocumented]\n", option);
3664 else if (* description == 0)
3666 else if (option == NULL)
3670 ("\nThere are undocumented %s specific options as well.\n",
3674 printf ("\n Options for %s:\n", description);
3679 printf (" %-23.23s %s\n", option, description);
3684 printf ("\nThere are undocumented %s specific options as well.\n", lang);
3686 if (NUM_ELEM (target_switches) > 1
3687 #ifdef TARGET_OPTIONS
3688 || NUM_ELEM (target_options) > 1
3696 printf ("\nTarget specific options:\n");
3698 for (i = NUM_ELEM (target_switches); i--;)
3700 const char * option = target_switches[i].name;
3701 const char * description = target_switches[i].description;
3703 if (option == NULL || * option == 0)
3705 else if (description == NULL)
3710 printf (" -m%-21.21s [undocumented]\n", option);
3712 else if (* description != 0)
3713 doc += printf (" -m%-21.21s %s\n", option, description);
3716 #ifdef TARGET_OPTIONS
3717 for (i = NUM_ELEM (target_options); i--;)
3719 const char * option = target_options[i].prefix;
3720 const char * description = target_options[i].description;
3722 if (option == NULL || * option == 0)
3724 else if (description == NULL)
3729 printf (" -m%-21.21s [undocumented]\n", option);
3731 else if (* description != 0)
3732 doc += printf (" -m%-21.21s %s\n", option, description);
3738 printf ("\nThere are undocumented target specific options as well.\n");
3740 printf (" They exist, but they are not documented.\n");
3745 /* Parse a -d... comand line switch. */
3748 decode_d_option (arg)
3757 for (i = 0; i < DFI_MAX; ++i)
3758 dump_file[i].enabled = 1;
3767 flag_print_asm_name = 1;
3770 graph_dump_format = vcg;
3773 rtl_dump_and_exit = 1;
3778 case 'D': /* These are handled by the preprocessor. */
3784 for (i = 0; i < DFI_MAX; ++i)
3785 if (c == dump_file[i].debug_switch)
3787 dump_file[i].enabled = 1;
3792 warning ("unrecognized gcc debugging option: %c", c);
3797 /* Parse a -f... comand line switch. ARG is the value after the -f.
3798 It is safe to access 'ARG - 2' to generate the full switch name.
3799 Return the number of strings consumed. */
3802 decode_f_option (arg)
3807 /* Search for the option in the table of binary f options. */
3808 for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
3810 if (!strcmp (arg, f_options[j].string))
3812 *f_options[j].variable = f_options[j].on_value;
3816 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3817 && ! strcmp (arg + 3, f_options[j].string))
3819 *f_options[j].variable = ! f_options[j].on_value;
3824 if (!strncmp (arg, "inline-limit-", 13)
3825 || !strncmp (arg, "inline-limit=", 13))
3827 read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
3828 #ifdef INSN_SCHEDULING
3829 else if (!strncmp (arg, "sched-verbose=", 14))
3830 fix_sched_param ("verbose", (const char *)(arg + 14));
3832 else if (!strncmp (arg, "fixed-", 6))
3833 fix_register ((const char *)(arg + 6), 1, 1);
3834 else if (!strncmp (arg, "call-used-", 10))
3835 fix_register ((const char *)(arg + 10), 0, 1);
3836 else if (!strncmp (arg, "call-saved-", 11))
3837 fix_register ((const char *)(arg + 11), 0, 0);
3838 else if (!strncmp (arg, "align-loops=", 12))
3839 align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
3840 else if (!strncmp (arg, "align-functions=", 16))
3842 = read_integral_parameter (arg + 16, arg - 2, align_functions);
3843 else if (!strncmp (arg, "align-jumps=", 12))
3844 align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
3845 else if (!strncmp (arg, "align-labels=", 13))
3846 align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
3847 else if (!strncmp (arg, "stack-limit-register=", 21))
3849 int reg = decode_reg_name (arg + 21);
3851 error ("unrecognized register name `%s'", arg + 21);
3853 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3855 else if (!strncmp (arg, "stack-limit-symbol=", 19))
3859 nm = ggc_alloc_string (arg + 19, strlen (arg + 19));
3861 nm = xstrdup (arg + 19);
3862 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3864 else if (!strcmp (arg, "no-stack-limit"))
3865 stack_limit_rtx = NULL_RTX;
3866 else if (!strcmp (arg, "preprocessed"))
3867 /* Recognise this switch but do nothing. This prevents warnings
3868 about an unrecognized switch if cpplib has not been linked in. */
3876 /* Parse a -W... comand line switch. ARG is the value after the -W.
3877 It is safe to access 'ARG - 2' to generate the full switch name.
3878 Return the number of strings consumed. */
3881 decode_W_option (arg)
3886 /* Search for the option in the table of binary W options. */
3888 for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
3890 if (!strcmp (arg, W_options[j].string))
3892 *W_options[j].variable = W_options[j].on_value;
3896 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3897 && ! strcmp (arg + 3, W_options[j].string))
3899 *W_options[j].variable = ! W_options[j].on_value;
3904 if (!strncmp (arg, "id-clash-", 9))
3906 id_clash_len = read_integral_parameter (arg + 9, arg - 2, -1);
3908 if (id_clash_len != -1)
3911 else if (!strncmp (arg, "larger-than-", 12))
3913 larger_than_size = read_integral_parameter (arg + 12, arg - 2, -1);
3915 if (larger_than_size != -1)
3916 warn_larger_than = 1;
3924 /* Parse a -g... comand line switch. ARG is the value after the -g.
3925 It is safe to access 'ARG - 2' to generate the full switch name.
3926 Return the number of strings consumed. */
3929 decode_g_option (arg)
3933 /* A lot of code assumes write_symbols == NO_DEBUG if the
3934 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
3935 of what debugging type has been selected). This records the
3936 selected type. It is an error to specify more than one
3938 static enum debug_info_type selected_debug_type = NO_DEBUG;
3939 /* Non-zero if debugging format has been explicitly set.
3940 -g and -ggdb don't explicitly set the debugging format so
3941 -gdwarf -g3 is equivalent to -gdwarf3. */
3942 static int type_explicitly_set_p = 0;
3943 /* Indexed by enum debug_info_type. */
3944 static const char * debug_type_names[] =
3946 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
3949 /* The maximum admissible debug level value. */
3950 static const unsigned max_debug_level = 3;
3952 /* Look up ARG in the table. */
3953 for (da = debug_args; da->arg; da++)
3955 const int da_len = strlen (da->arg);
3957 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
3959 enum debug_info_type type = da->debug_type;
3960 const char * p = arg + da_len;
3962 if (*p && (*p < '0' || *p > '9'))
3965 /* A debug flag without a level defaults to level 2.
3966 Note we do not want to call read_integral_parameter
3967 for that case since it will call atoi which
3970 ??? We may want to generalize the interface to
3971 read_integral_parameter to better handle this case
3972 if this case shows up often. */
3974 level = read_integral_parameter (p, 0, max_debug_level + 1);
3978 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
3980 error ("use -gdwarf -g%d for DWARF v1, level %d",
3983 error ("use -gdwarf-2 for DWARF v2");
3986 if (level > max_debug_level)
3989 ignoring option `%s' due to invalid debug level specification",
3991 level = debug_info_level;
3994 if (type == NO_DEBUG)
3996 type = PREFERRED_DEBUGGING_TYPE;
3998 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4000 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4001 type = DWARF2_DEBUG;
4003 #ifdef DBX_DEBUGGING_INFO
4010 if (type == NO_DEBUG)
4011 warning ("`%s': unknown or unsupported -g option", arg - 2);
4013 /* Does it conflict with an already selected type? */
4014 if (type_explicitly_set_p
4015 /* -g/-ggdb don't conflict with anything */
4016 && da->debug_type != NO_DEBUG
4017 && type != selected_debug_type)
4018 warning ("`%s' ignored, conflicts with `-g%s'",
4019 arg - 2, debug_type_names[(int) selected_debug_type]);
4022 /* If the format has already been set, -g/-ggdb
4023 only change the debug level. */
4024 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4025 ; /* don't change debugging type */
4028 selected_debug_type = type;
4029 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4032 write_symbols = (level == 0
4034 : selected_debug_type);
4035 use_gnu_debug_info_extensions = da->use_extensions_p;
4036 debug_info_level = (enum debug_info_level) level;
4044 warning ("`%s': unknown or unsupported -g option", arg - 2);
4049 /* Decode the first argument in the argv as a language-independent option.
4050 Return the number of strings consumed. 'strings_processed' is the
4051 number of strings that have already been decoded in a language
4052 specific fashion before this function was invoked. */
4055 independent_decode_option (argc, argv, strings_processed)
4058 unsigned int strings_processed;
4060 char *arg = argv[0];
4062 if (arg[0] != '-' || arg[1] == 0)
4074 if (!strcmp (arg, "-help"))
4089 /* Already been treated in main (). Do nothing. */
4093 set_target_switch (arg + 1);
4097 return decode_f_option (arg + 1);
4100 if (strings_processed == 0)
4101 return decode_g_option (arg + 1);
4103 return strings_processed;
4106 if (!strcmp (arg, "dumpbase"))
4111 dump_base_name = argv[1];
4115 decode_d_option (arg + 1);
4119 if (!strcmp (arg, "pedantic"))
4121 else if (!strcmp (arg, "pedantic-errors"))
4122 flag_pedantic_errors = pedantic = 1;
4123 else if (arg[1] == 0)
4130 if (!strcmp (arg, "quiet"))
4137 if (!strcmp (arg, "version"))
4145 inhibit_warnings = 1;
4154 /* We save the value of warn_uninitialized, since if they put
4155 -Wuninitialized on the command line, we need to generate a
4156 warning about not using it without also specifying -O. */
4157 if (warn_uninitialized != 1)
4158 warn_uninitialized = 2;
4161 return decode_W_option (arg + 1);
4167 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4168 warning ("`-a' option (basic block profile) not supported");
4170 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4173 else if (!strcmp (arg, "ax"))
4175 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4176 warning ("`-ax' option (jump profiling) not supported");
4178 profile_block_flag = (!profile_block_flag
4179 || profile_block_flag == 2) ? 2 : 3;
4182 else if (!strncmp (arg, "aux-info", 8))
4184 flag_gen_aux_info = 1;
4190 aux_info_file_name = argv[1];
4194 aux_info_file_name = arg + 8;
4206 asm_file_name = argv[1];
4221 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4226 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4230 if (g_switch_val == -1)
4234 g_switch_set = TRUE;
4235 g_switch_value = g_switch_val;
4245 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4246 Exit code is 35 if can't open files, 34 if fatal error,
4247 33 if had nonfatal errors, else success. */
4249 extern int main PARAMS ((int, char **));
4259 /* save in case md file wants to emit args as a comment. */
4263 p = argv[0] + strlen (argv[0]);
4264 while (p != argv[0] && p[-1] != '/'
4265 #ifdef DIR_SEPARATOR
4266 && p[-1] != DIR_SEPARATOR
4272 #ifdef HAVE_LC_MESSAGES
4273 setlocale (LC_MESSAGES, "");
4275 (void) bindtextdomain (PACKAGE, localedir);
4276 (void) textdomain (PACKAGE);
4278 signal (SIGFPE, float_signal);
4281 signal (SIGPIPE, pipe_closed);
4284 decl_printable_name = decl_name;
4285 lang_expand_expr = (lang_expand_expr_t) do_abort;
4287 /* Initialize whether `char' is signed. */
4288 flag_signed_char = DEFAULT_SIGNED_CHAR;
4289 #ifdef DEFAULT_SHORT_ENUMS
4290 /* Initialize how much space enums occupy, by default. */
4291 flag_short_enums = DEFAULT_SHORT_ENUMS;
4294 /* Initialize the garbage-collector. */
4296 ggc_add_root (&input_file_stack, 1, sizeof input_file_stack,
4298 ggc_add_rtx_root (&stack_limit_rtx, 1);
4299 ggc_add_tree_root (¤t_function_decl, 1);
4300 ggc_add_tree_root (¤t_function_func_begin_label, 1);
4302 /* Perform language-specific options intialization. */
4303 lang_init_options ();
4305 /* Scan to see what optimization level has been specified. That will
4306 determine the default value of many flags. */
4307 for (i = 1; i < argc; i++)
4309 if (!strcmp (argv[i], "-O"))
4314 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4316 /* Handle -Os, -O2, -O3, -O69, ... */
4317 char *p = &argv[i][2];
4319 if ((p[0] == 's') && (p[1] == 0))
4323 /* Optimizing for size forces optimize to be 2. */
4328 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4329 if (optimize_val != -1)
4331 optimize = optimize_val;
4341 flag_thread_jumps = 1;
4343 flag_delayed_branch = 1;
4345 #ifdef CAN_DEBUG_WITHOUT_FP
4346 flag_omit_frame_pointer = 1;
4352 flag_optimize_sibling_calls = 1;
4353 flag_cse_follow_jumps = 1;
4354 flag_cse_skip_blocks = 1;
4356 flag_expensive_optimizations = 1;
4357 flag_strength_reduce = 1;
4358 flag_rerun_cse_after_loop = 1;
4359 flag_rerun_loop_opt = 1;
4360 flag_caller_saves = 1;
4363 #ifdef INSN_SCHEDULING
4364 flag_schedule_insns = 1;
4365 flag_schedule_insns_after_reload = 1;
4368 flag_strict_aliasing = 1;
4369 flag_delete_null_pointer_checks = 1;
4374 flag_inline_functions = 1;
4377 if (optimize < 2 || optimize_size)
4382 align_functions = 1;
4385 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4388 set_target_switch ("");
4390 #ifdef OPTIMIZATION_OPTIONS
4391 /* Allow default optimizations to be specified on a per-machine basis. */
4392 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4395 /* Initialize register usage now so switches may override. */
4398 /* Perform normal command line switch decoding. */
4399 for (i = 1; i < argc;)
4401 unsigned int lang_processed;
4402 unsigned int indep_processed;
4404 /* Give the language a chance to decode the option for itself. */
4405 lang_processed = lang_decode_option (argc - i, argv + i);
4407 /* Now see if the option also has a language independent meaning.
4408 Some options are both language specific and language independent,
4409 eg --help. It is possible that there might be options that should
4410 only be decoded in a language independent way if they were not
4411 decoded in a langauge specific way, which is why 'lang_processed'
4413 indep_processed = independent_decode_option (argc - i, argv + i,
4416 if (lang_processed || indep_processed)
4417 i += (lang_processed > indep_processed
4418 ? lang_processed : indep_processed);
4421 const char * option = NULL;
4422 const char * lang = NULL;
4425 /* It is possible that the command line switch is not valid for the
4426 current language, but it is valid for another language. In order
4427 to be compatible with previous versions of the compiler (which
4428 did not issue an error message in this case) we check for this
4429 possibilty here. If we do find a match, then if extra_warnings
4430 is set we generate a warning message, otherwise we will just
4431 ignore the option. */
4432 for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
4434 option = documented_lang_options[j].option;
4437 lang = documented_lang_options[j].description;
4438 else if (! strncmp (argv[i], option, strlen (option)))
4442 if (j != NUM_ELEM (documented_lang_options))
4446 warning ("Ignoring command line option '%s'", argv[i]);
4449 (It is valid for %s but not the selected langauge)", lang);
4453 error ("Unrecognized option `%s'", argv[i]);
4459 /* Checker uses the frame pointer. */
4460 if (flag_check_memory_usage)
4461 flag_omit_frame_pointer = 0;
4465 /* Inlining does not work if not optimizing,
4466 so force it not to be done. */
4470 /* The c_decode_option and lang_decode_option functions set
4471 this to `2' if -Wall is used, so we can avoid giving out
4472 lots of errors for people who don't realize what -Wall does. */
4473 if (warn_uninitialized == 1)
4474 warning ("-Wuninitialized is not supported without -O");
4477 #ifdef OVERRIDE_OPTIONS
4478 /* Some machines may reject certain combinations of options. */
4482 if (exceptions_via_longjmp == 2)
4484 #ifdef DWARF2_UNWIND_INFO
4485 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO;
4487 exceptions_via_longjmp = 1;
4491 /* Set up the align_*_log variables, defaulting them to 1 if they
4492 were still unset. */
4493 if (align_loops <= 0) align_loops = 1;
4494 align_loops_log = floor_log2 (align_loops*2-1);
4495 if (align_jumps <= 0) align_jumps = 1;
4496 align_jumps_log = floor_log2 (align_jumps*2-1);
4497 if (align_labels <= 0) align_labels = 1;
4498 align_labels_log = floor_log2 (align_labels*2-1);
4499 if (align_functions <= 0) align_functions = 1;
4500 align_functions_log = floor_log2 (align_functions*2-1);
4502 if (profile_block_flag == 3)
4504 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4505 profile_block_flag = 2;
4508 /* Unrolling all loops implies that standard loop unrolling must also
4510 if (flag_unroll_all_loops)
4511 flag_unroll_loops = 1;
4512 /* Loop unrolling requires that strength_reduction be on also. Silently
4513 turn on strength reduction here if it isn't already on. Also, the loop
4514 unrolling code assumes that cse will be run after loop, so that must
4515 be turned on also. */
4516 if (flag_unroll_loops)
4518 flag_strength_reduce = 1;
4519 flag_rerun_cse_after_loop = 1;
4522 /* Warn about options that are not supported on this machine. */
4523 #ifndef INSN_SCHEDULING
4524 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4525 warning ("instruction scheduling not supported on this target machine");
4528 if (flag_delayed_branch)
4529 warning ("this target machine does not have delayed branches");
4532 user_label_prefix = USER_LABEL_PREFIX;
4533 if (flag_leading_underscore != -1)
4535 /* If the default prefix is more complicated than "" or "_",
4536 issue a warning and ignore this option. */
4537 if (user_label_prefix[0] == 0 ||
4538 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4540 user_label_prefix = flag_leading_underscore ? "_" : "";
4543 warning ("-f%sleading-underscore not supported on this target machine",
4544 flag_leading_underscore ? "" : "no-");
4547 /* If we are in verbose mode, write out the version and maybe all the
4548 option flags in use. */
4551 print_version (stderr, "");
4553 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4556 compile_file (filename);
4558 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4561 char *lim = (char *) sbrk (0);
4563 fnotice (stderr, "Data size %ld.\n", (long) (lim - (char *) &environ));
4568 system ("ps -l 1>&2");
4571 #endif /* not USG */
4574 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4577 return (FATAL_EXIT_CODE);
4579 return (FATAL_EXIT_CODE);
4580 return (SUCCESS_EXIT_CODE);
4583 /* Decode -m switches. */
4584 /* Decode the switch -mNAME. */
4587 set_target_switch (name)
4591 int valid_target_option = 0;
4593 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4594 if (!strcmp (target_switches[j].name, name))
4596 if (target_switches[j].value < 0)
4597 target_flags &= ~-target_switches[j].value;
4599 target_flags |= target_switches[j].value;
4600 valid_target_option = 1;
4603 #ifdef TARGET_OPTIONS
4604 if (!valid_target_option)
4605 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4607 int len = strlen (target_options[j].prefix);
4608 if (!strncmp (target_options[j].prefix, name, len))
4610 *target_options[j].variable = name + len;
4611 valid_target_option = 1;
4616 if (!valid_target_option)
4617 error ("Invalid option `%s'", name);
4620 /* Print version information to FILE.
4621 Each line begins with INDENT (for the case where FILE is the
4622 assembler output file). */
4625 print_version (file, indent)
4630 #define __VERSION__ "[?]"
4634 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4636 "%s%s%s version %s (%s) compiled by CC.\n"
4638 , indent, *indent != 0 ? " " : "",
4639 language_string, version_string, TARGET_NAME, __VERSION__);
4642 /* Print an option value and return the adjusted position in the line.
4643 ??? We don't handle error returns from fprintf (disk full); presumably
4644 other code will catch a disk full though. */
4647 print_single_switch (file, pos, max, indent, sep, term, type, name)
4650 const char *indent, *sep, *term, *type, *name;
4652 /* The ultrix fprintf returns 0 on success, so compute the result we want
4653 here since we need it for the following test. */
4654 int len = strlen (sep) + strlen (type) + strlen (name);
4659 fprintf (file, "%s", term);
4664 fprintf (file, "%s", indent);
4665 pos = strlen (indent);
4667 fprintf (file, "%s%s%s", sep, type, name);
4672 /* Print active target switches to FILE.
4673 POS is the current cursor position and MAX is the size of a "line".
4674 Each line begins with INDENT and ends with TERM.
4675 Each switch is separated from the next by SEP. */
4678 print_switch_values (file, pos, max, indent, sep, term)
4681 const char *indent, *sep, *term;
4686 /* Print the options as passed. */
4688 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4689 _("options passed: "), "");
4691 for (p = &save_argv[1]; *p != NULL; p++)
4695 if (strcmp (*p, "-o") == 0)
4701 if (strcmp (*p, "-quiet") == 0)
4703 if (strcmp (*p, "-version") == 0)
4708 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4711 fprintf (file, "%s", term);
4713 /* Print the -f and -m options that have been enabled.
4714 We don't handle language specific options but printing argv
4717 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4718 _("options enabled: "), "");
4720 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
4721 if (*f_options[j].variable == f_options[j].on_value)
4722 pos = print_single_switch (file, pos, max, indent, sep, term,
4723 "-f", f_options[j].string);
4725 /* Print target specific options. */
4727 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
4728 if (target_switches[j].name[0] != '\0'
4729 && target_switches[j].value > 0
4730 && ((target_switches[j].value & target_flags)
4731 == target_switches[j].value))
4733 pos = print_single_switch (file, pos, max, indent, sep, term,
4734 "-m", target_switches[j].name);
4737 #ifdef TARGET_OPTIONS
4738 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
4739 if (*target_options[j].variable != NULL)
4742 sprintf (prefix, "-m%s", target_options[j].prefix);
4743 pos = print_single_switch (file, pos, max, indent, sep, term,
4744 prefix, *target_options[j].variable);
4748 fprintf (file, "%s", term);
4751 /* Record the beginning of a new source file, named FILENAME. */
4754 debug_start_source_file (filename)
4755 register char *filename ATTRIBUTE_UNUSED;
4757 #ifdef DBX_DEBUGGING_INFO
4758 if (write_symbols == DBX_DEBUG)
4759 dbxout_start_new_source_file (filename);
4761 #ifdef DWARF_DEBUGGING_INFO
4762 if (debug_info_level == DINFO_LEVEL_VERBOSE
4763 && write_symbols == DWARF_DEBUG)
4764 dwarfout_start_new_source_file (filename);
4765 #endif /* DWARF_DEBUGGING_INFO */
4766 #ifdef DWARF2_DEBUGGING_INFO
4767 if (debug_info_level == DINFO_LEVEL_VERBOSE
4768 && write_symbols == DWARF2_DEBUG)
4769 dwarf2out_start_source_file (filename);
4770 #endif /* DWARF2_DEBUGGING_INFO */
4771 #ifdef SDB_DEBUGGING_INFO
4772 if (write_symbols == SDB_DEBUG)
4773 sdbout_start_new_source_file (filename);
4777 /* Record the resumption of a source file. LINENO is the line number in
4778 the source file we are returning to. */
4781 debug_end_source_file (lineno)
4782 register unsigned lineno ATTRIBUTE_UNUSED;
4784 #ifdef DBX_DEBUGGING_INFO
4785 if (write_symbols == DBX_DEBUG)
4786 dbxout_resume_previous_source_file ();
4788 #ifdef DWARF_DEBUGGING_INFO
4789 if (debug_info_level == DINFO_LEVEL_VERBOSE
4790 && write_symbols == DWARF_DEBUG)
4791 dwarfout_resume_previous_source_file (lineno);
4792 #endif /* DWARF_DEBUGGING_INFO */
4793 #ifdef DWARF2_DEBUGGING_INFO
4794 if (debug_info_level == DINFO_LEVEL_VERBOSE
4795 && write_symbols == DWARF2_DEBUG)
4796 dwarf2out_end_source_file ();
4797 #endif /* DWARF2_DEBUGGING_INFO */
4798 #ifdef SDB_DEBUGGING_INFO
4799 if (write_symbols == SDB_DEBUG)
4800 sdbout_resume_previous_source_file ();
4804 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4805 the tail part of the directive line, i.e. the part which is past the
4806 initial whitespace, #, whitespace, directive-name, whitespace part. */
4809 debug_define (lineno, buffer)
4810 register unsigned lineno ATTRIBUTE_UNUSED;
4811 register char *buffer ATTRIBUTE_UNUSED;
4813 #ifdef DWARF_DEBUGGING_INFO
4814 if (debug_info_level == DINFO_LEVEL_VERBOSE
4815 && write_symbols == DWARF_DEBUG)
4816 dwarfout_define (lineno, buffer);
4817 #endif /* DWARF_DEBUGGING_INFO */
4818 #ifdef DWARF2_DEBUGGING_INFO
4819 if (debug_info_level == DINFO_LEVEL_VERBOSE
4820 && write_symbols == DWARF2_DEBUG)
4821 dwarf2out_define (lineno, buffer);
4822 #endif /* DWARF2_DEBUGGING_INFO */
4825 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
4826 the tail part of the directive line, i.e. the part which is past the
4827 initial whitespace, #, whitespace, directive-name, whitespace part. */
4830 debug_undef (lineno, buffer)
4831 register unsigned lineno ATTRIBUTE_UNUSED;
4832 register char *buffer ATTRIBUTE_UNUSED;
4834 #ifdef DWARF_DEBUGGING_INFO
4835 if (debug_info_level == DINFO_LEVEL_VERBOSE
4836 && write_symbols == DWARF_DEBUG)
4837 dwarfout_undef (lineno, buffer);
4838 #endif /* DWARF_DEBUGGING_INFO */
4839 #ifdef DWARF2_DEBUGGING_INFO
4840 if (debug_info_level == DINFO_LEVEL_VERBOSE
4841 && write_symbols == DWARF2_DEBUG)
4842 dwarf2out_undef (lineno, buffer);
4843 #endif /* DWARF2_DEBUGGING_INFO */
4846 /* Tell the debugging backend that we've decided not to emit any
4847 debugging information for BLOCK, so it can clean up after any local
4848 classes or nested functions. */
4851 debug_ignore_block (block)
4852 tree block ATTRIBUTE_UNUSED;
4854 #ifdef DWARF2_DEBUGGING_INFO
4855 if (write_symbols == DWARF2_DEBUG)
4856 dwarf2out_ignore_block (block);