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"
50 #include "hard-reg-set.h"
58 #include "basic-block.h"
65 #include "diagnostic.h"
68 #ifndef ACCUMULATE_OUTGOING_ARGS
69 #define ACCUMULATE_OUTGOING_ARGS 0
72 #ifdef DWARF_DEBUGGING_INFO
76 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
77 #include "dwarf2out.h"
80 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
84 #ifdef SDB_DEBUGGING_INFO
88 #ifdef XCOFF_DEBUGGING_INFO
93 /* The extra parameters substantially improve the I/O performance. */
96 vms_fopen (fname
, type
)
100 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
101 fixed arguments, which matches ANSI's specification but not VAXCRTL's
102 pre-ANSI implementation. This hack circumvents the mismatch problem. */
103 FILE *(*vmslib_fopen
)() = (FILE *(*)()) fopen
;
106 return (*vmslib_fopen
) (fname
, type
, "mbc=32",
107 "deq=64", "fop=tef", "shr=nil");
109 return (*vmslib_fopen
) (fname
, type
, "mbc=32");
112 #define fopen vms_fopen
115 #ifndef DEFAULT_GDB_EXTENSIONS
116 #define DEFAULT_GDB_EXTENSIONS 1
119 /* If more than one debugging type is supported, you must define
120 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
122 This is one long line cause VAXC can't handle a \-newline. */
123 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
124 #ifndef PREFERRED_DEBUGGING_TYPE
125 You Lose
! You must define PREFERRED_DEBUGGING_TYPE
!
126 #endif /* no PREFERRED_DEBUGGING_TYPE */
127 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
128 so the following code needn't care. */
129 #ifdef DBX_DEBUGGING_INFO
130 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
132 #ifdef SDB_DEBUGGING_INFO
133 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
135 #ifdef DWARF_DEBUGGING_INFO
136 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
138 #ifdef DWARF2_DEBUGGING_INFO
139 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
141 #ifdef XCOFF_DEBUGGING_INFO
142 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
144 #endif /* More than one debugger format enabled. */
146 /* If still not defined, must have been because no debugging formats
148 #ifndef PREFERRED_DEBUGGING_TYPE
149 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
152 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
153 extern char **environ
;
156 /* Carry information from ASM_DECLARE_OBJECT_NAME
157 to ASM_FINISH_DECLARE_OBJECT. */
159 extern int size_directive_output
;
160 extern tree last_assemble_variable_decl
;
162 static void set_target_switch
PARAMS ((const char *));
163 static const char *decl_name
PARAMS ((tree
, int));
165 static void float_signal
PARAMS ((int)) ATTRIBUTE_NORETURN
;
166 static void crash_signal
PARAMS ((int)) ATTRIBUTE_NORETURN
;
167 #ifdef ASM_IDENTIFY_LANGUAGE
168 /* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */
169 static void output_lang_identify
PARAMS ((FILE *)) ATTRIBUTE_UNUSED
;
171 static void compile_file
PARAMS ((const char *));
172 static void display_help
PARAMS ((void));
173 static void display_target_options
PARAMS ((void));
174 static void mark_file_stack
PARAMS ((void *));
176 static void decode_d_option
PARAMS ((const char *));
177 static int decode_f_option
PARAMS ((const char *));
178 static int decode_W_option
PARAMS ((const char *));
179 static int decode_g_option
PARAMS ((const char *));
180 static unsigned int independent_decode_option
PARAMS ((int, char **));
182 static void print_version
PARAMS ((FILE *, const char *));
183 static int print_single_switch
PARAMS ((FILE *, int, int, const char *,
184 const char *, const char *,
185 const char *, const char *));
186 static void print_switch_values
PARAMS ((FILE *, int, int, const char *,
187 const char *, const char *));
189 /* Length of line when printing switch values. */
192 /* Name of program invoked, sans directories. */
194 const char *progname
;
196 /* Copy of arguments to main. */
200 /* Name of current original source file (what was input to cpp).
201 This comes from each #-command in the actual input. */
203 const char *input_filename
;
205 /* Name of top-level original source file (what was input to cpp).
206 This comes from the #-command at the beginning of the actual input.
207 If there isn't any there, then this is the cc1 input file name. */
209 const char *main_input_filename
;
211 /* Current line number in real source file. */
215 /* Nonzero if it is unsafe to create any new pseudo registers. */
218 /* Stack of currently pending input files. */
220 struct file_stack
*input_file_stack
;
222 /* Incremented on each change to input_file_stack. */
223 int input_file_stack_tick
;
225 /* Name to use as base of names for dump output files. */
227 const char *dump_base_name
;
229 /* Bit flags that specify the machine subtype we are compiling for.
230 Bits are tested using macros TARGET_... defined in the tm.h file
231 and set by `-m...' switches. Must be defined in rtlanal.c. */
233 extern int target_flags
;
235 /* Describes a dump file. */
237 struct dump_file_info
239 /* The unique extension to apply, e.g. ".jump". */
240 const char *const extension
;
242 /* The -d<c> character that enables this dump file. */
243 char const debug_switch
;
245 /* True if there is a corresponding graph dump file. */
246 char const graph_dump_p
;
248 /* True if the user selected this dump. */
251 /* True if the files have been initialized (ie truncated). */
255 /* Enumerate the extant dump files. */
293 /* Describes all the dump files. Should be kept in order of the
294 pass and in sync with dump_file_index above.
296 Remaining -d letters:
302 struct dump_file_info dump_file
[DFI_MAX
] =
304 { "rtl", 'r', 0, 0, 0 },
305 { "sibling", 'i', 0, 0, 0 },
306 { "jump", 'j', 0, 0, 0 },
307 { "cse", 's', 0, 0, 0 },
308 { "addressof", 'F', 0, 0, 0 },
309 { "ssa", 'e', 1, 0, 0 },
310 { "dce", 'X', 1, 0, 0 },
311 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
312 { "gcse", 'G', 1, 0, 0 },
313 { "loop", 'L', 1, 0, 0 },
314 { "cse2", 't', 1, 0, 0 },
315 { "cfg", 'f', 1, 0, 0 },
316 { "bp", 'b', 1, 0, 0 },
317 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
318 { "combine", 'c', 1, 0, 0 },
319 { "ce", 'C', 1, 0, 0 },
320 { "regmove", 'N', 1, 0, 0 },
321 { "sched", 'S', 1, 0, 0 },
322 { "lreg", 'l', 1, 0, 0 },
323 { "greg", 'g', 1, 0, 0 },
324 { "postreload", 'o', 1, 0, 0 },
325 { "flow2", 'w', 1, 0, 0 },
326 { "peephole2", 'z', 1, 0, 0 },
327 { "rnreg", 'n', 1, 0, 0 },
328 { "ce2", 'E', 1, 0, 0 },
329 { "sched2", 'R', 1, 0, 0 },
330 { "bbro", 'B', 1, 0, 0 },
331 { "jump2", 'J', 1, 0, 0 },
332 { "mach", 'M', 1, 0, 0 },
333 { "dbr", 'd', 0, 0, 0 },
334 { "stack", 'k', 1, 0, 0 },
337 static int open_dump_file
PARAMS ((enum dump_file_index
, tree
));
338 static void close_dump_file
PARAMS ((enum dump_file_index
,
339 void (*) (FILE *, rtx
), rtx
));
341 /* Other flags saying which kinds of debugging dump have been requested. */
343 int rtl_dump_and_exit
;
344 int flag_print_asm_name
;
345 static int flag_print_mem
;
346 static int version_flag
;
347 static char *filename
;
348 enum graph_dump_types graph_dump_format
;
350 /* Name for output file of assembly code, specified with -o. */
354 /* Value of the -G xx switch, and whether it was passed or not. */
358 /* Type(s) of debugging information we are producing (if any).
359 See flags.h for the definitions of the different possible
360 types of debugging information. */
361 enum debug_info_type write_symbols
= NO_DEBUG
;
363 /* Level of debugging information we are producing. See flags.h
364 for the definitions of the different possible levels. */
365 enum debug_info_level debug_info_level
= DINFO_LEVEL_NONE
;
367 /* Nonzero means use GNU-only extensions in the generated symbolic
368 debugging information. */
369 /* Currently, this only has an effect when write_symbols is set to
370 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
371 int use_gnu_debug_info_extensions
= 0;
373 /* Nonzero means do optimizations. -O.
374 Particular numeric values stand for particular amounts of optimization;
375 thus, -O2 stores 2 here. However, the optimizations beyond the basic
376 ones are not controlled directly by this variable. Instead, they are
377 controlled by individual `flag_...' variables that are defaulted
378 based on this variable. */
382 /* Nonzero means optimize for size. -Os.
383 The only valid values are zero and non-zero. When optimize_size is
384 non-zero, optimize defaults to 2, but certain individual code
385 bloating optimizations are disabled. */
387 int optimize_size
= 0;
389 /* Number of error messages and warning messages so far. */
392 int warningcount
= 0;
395 /* The FUNCTION_DECL for the function currently being compiled,
396 or 0 if between functions. */
397 tree current_function_decl
;
399 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
401 tree current_function_func_begin_label
;
403 /* Pointer to function to compute the name to use to print a declaration.
404 DECL is the declaration in question.
405 VERBOSITY determines what information will be printed:
406 0: DECL_NAME, demangled as necessary.
407 1: and scope information.
408 2: and any other information that might be interesting, such as function
409 parameter types in C++. */
411 const char *(*decl_printable_name
) PARAMS ((tree
, int));
413 /* Pointer to function to compute rtl for a language-specific tree code. */
415 typedef rtx (*lang_expand_expr_t
)
416 PARAMS ((union tree_node
*, rtx
, enum machine_mode
,
417 enum expand_modifier modifier
));
419 lang_expand_expr_t lang_expand_expr
= 0;
421 tree (*lang_expand_constant
) PARAMS ((tree
)) = 0;
423 /* Pointer to function to finish handling an incomplete decl at the
424 end of compilation. */
426 void (*incomplete_decl_finalize_hook
) PARAMS ((tree
)) = 0;
428 /* Nonzero if doing dwarf2 duplicate elimination. */
430 int flag_eliminate_dwarf2_dups
= 0;
432 /* Nonzero if generating code to do profiling. */
434 int profile_flag
= 0;
436 /* Nonzero if generating code to do profiling on a line-by-line basis. */
438 int profile_block_flag
;
440 /* Nonzero if generating code to profile program flow graph arcs. */
442 int profile_arc_flag
= 0;
444 /* Nonzero if generating info for gcov to calculate line test coverage. */
446 int flag_test_coverage
= 0;
448 /* Nonzero indicates that branch taken probabilities should be calculated. */
450 int flag_branch_probabilities
= 0;
452 /* Nonzero if basic blocks should be reordered. */
454 int flag_reorder_blocks
= 0;
456 /* Nonzero if registers should be renamed. */
458 int flag_rename_registers
= 0;
460 /* Nonzero for -pedantic switch: warn about anything
461 that standard spec forbids. */
465 /* Temporarily suppress certain warnings.
466 This is set while reading code from a system header file. */
468 int in_system_header
= 0;
470 /* Don't print functions as they are compiled. -quiet. */
474 /* Print times taken by the various passes. -ftime-report. */
478 /* Print memory still in use at end of compilation (which may have little
479 to do with peak memory consumption). -fmem-report. */
483 /* Non-zero means to collect statistics which might be expensive
484 and to print them when we are done. */
485 int flag_detailed_statistics
= 0;
490 /* Nonzero means `char' should be signed. */
492 int flag_signed_char
;
494 /* Nonzero means give an enum type only as many bytes as it needs. */
496 int flag_short_enums
;
498 /* Nonzero for -fcaller-saves: allocate values in regs that need to
499 be saved across function calls, if that produces overall better code.
500 Optional now, so people can test it. */
502 #ifdef DEFAULT_CALLER_SAVES
503 int flag_caller_saves
= 1;
505 int flag_caller_saves
= 0;
508 /* Nonzero if structures and unions should be returned in memory.
510 This should only be defined if compatibility with another compiler or
511 with an ABI is needed, because it results in slower code. */
513 #ifndef DEFAULT_PCC_STRUCT_RETURN
514 #define DEFAULT_PCC_STRUCT_RETURN 1
517 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
519 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
521 /* Nonzero for -fforce-mem: load memory value into a register
522 before arithmetic on it. This makes better cse but slower compilation. */
524 int flag_force_mem
= 0;
526 /* Nonzero for -fforce-addr: load memory address into a register before
527 reference to memory. This makes better cse but slower compilation. */
529 int flag_force_addr
= 0;
531 /* Nonzero for -fdefer-pop: don't pop args after each function call;
532 instead save them up to pop many calls' args with one insns. */
534 int flag_defer_pop
= 0;
536 /* Nonzero for -ffloat-store: don't allocate floats and doubles
537 in extended-precision registers. */
539 int flag_float_store
= 0;
541 /* Nonzero for -fcse-follow-jumps:
542 have cse follow jumps to do a more extensive job. */
544 int flag_cse_follow_jumps
;
546 /* Nonzero for -fcse-skip-blocks:
547 have cse follow a branch around a block. */
548 int flag_cse_skip_blocks
;
550 /* Nonzero for -fexpensive-optimizations:
551 perform miscellaneous relatively-expensive optimizations. */
552 int flag_expensive_optimizations
;
554 /* Nonzero for -fthread-jumps:
555 have jump optimize output of loop. */
557 int flag_thread_jumps
;
559 /* Nonzero enables strength-reduction in loop.c. */
561 int flag_strength_reduce
= 0;
563 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
564 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
565 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
568 int flag_unroll_loops
;
570 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
571 This is generally not a win. */
573 int flag_unroll_all_loops
;
575 /* Nonzero forces all invariant computations in loops to be moved
578 int flag_move_all_movables
= 0;
580 /* Nonzero forces all general induction variables in loops to be
583 int flag_reduce_all_givs
= 0;
585 /* Nonzero to perform full register move optimization passes. This is the
588 int flag_regmove
= 0;
590 /* Nonzero for -fwritable-strings:
591 store string constants in data segment and don't uniquize them. */
593 int flag_writable_strings
= 0;
595 /* Nonzero means don't put addresses of constant functions in registers.
596 Used for compiling the Unix kernel, where strange substitutions are
597 done on the assembly output. */
599 int flag_no_function_cse
= 0;
601 /* Nonzero for -fomit-frame-pointer:
602 don't make a frame pointer in simple functions that don't require one. */
604 int flag_omit_frame_pointer
= 0;
606 /* Nonzero means place each function into its own section on those platforms
607 which support arbitrary section names and unlimited numbers of sections. */
609 int flag_function_sections
= 0;
611 /* ... and similar for data. */
613 int flag_data_sections
= 0;
615 /* Nonzero to inhibit use of define_optimization peephole opts. */
617 int flag_no_peephole
= 0;
619 /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
620 operations in the interest of optimization. For example it allows
621 GCC to assume arguments to sqrt are nonnegative numbers, allowing
622 faster code for sqrt to be generated. */
624 int flag_fast_math
= 0;
626 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
628 int flag_optimize_sibling_calls
= 0;
630 /* Nonzero means the front end generally wants `errno' maintained by math
631 operations, like built-in SQRT, unless overridden by flag_fast_math. */
633 int flag_errno_math
= 1;
635 /* 0 means straightforward implementation of complex divide acceptable.
636 1 means wide ranges of inputs must work for complex divide.
637 2 means C99-like requirements for complex divide (not yet implemented). */
639 int flag_complex_divide_method
= 0;
641 /* Nonzero means all references through pointers are volatile. */
645 /* Nonzero means treat all global and extern variables as volatile. */
647 int flag_volatile_global
;
649 /* Nonzero means treat all static variables as volatile. */
651 int flag_volatile_static
;
653 /* Nonzero means just do syntax checking; don't output anything. */
655 int flag_syntax_only
= 0;
657 /* Nonzero means perform global cse. */
659 static int flag_gcse
;
661 /* Nonzero means to use global dataflow analysis to eliminate
662 useless null pointer tests. */
664 static int flag_delete_null_pointer_checks
;
666 /* Nonzero means to rerun cse after loop optimization. This increases
667 compilation time about 20% and picks up a few more common expressions. */
669 static int flag_rerun_cse_after_loop
;
671 /* Nonzero means to run loop optimizations twice. */
673 int flag_rerun_loop_opt
;
675 /* Nonzero for -finline-functions: ok to inline functions that look like
676 good inline candidates. */
678 int flag_inline_functions
;
680 /* Nonzero for -fkeep-inline-functions: even if we make a function
681 go inline everywhere, keep its definition around for debugging
684 int flag_keep_inline_functions
;
686 /* Nonzero means that functions will not be inlined. */
690 /* Nonzero means that we should emit static const variables
691 regardless of whether or not optimization is turned on. */
693 int flag_keep_static_consts
= 1;
695 /* Nonzero means we should be saving declaration info into a .X file. */
697 int flag_gen_aux_info
= 0;
699 /* Specified name of aux-info file. */
701 static char *aux_info_file_name
;
703 /* Nonzero means make the text shared if supported. */
705 int flag_shared_data
;
707 /* Nonzero means schedule into delayed branch slots if supported. */
709 int flag_delayed_branch
;
711 /* Nonzero if we are compiling pure (sharable) code.
712 Value is 1 if we are doing reasonable (i.e. simple
713 offset into offset table) pic. Value is 2 if we can
714 only perform register offsets. */
718 /* Nonzero means generate extra code for exception handling and enable
719 exception handling. */
723 /* Nonzero means use the new model for exception handling. Replaces
724 -DNEW_EH_MODEL as a compile option. */
726 int flag_new_exceptions
= 1;
728 /* Nonzero means generate frame unwind info table when supported. */
730 int flag_unwind_tables
= 0;
732 /* Nonzero means don't place uninitialized global data in common storage
737 /* Nonzero means pretend it is OK to examine bits of target floats,
738 even if that isn't true. The resulting code will have incorrect constants,
739 but the same series of instructions that the native compiler would make. */
741 int flag_pretend_float
;
743 /* Nonzero means change certain warnings into errors.
744 Usually these are warnings about failure to conform to some standard. */
746 int flag_pedantic_errors
= 0;
748 /* flag_schedule_insns means schedule insns within basic blocks (before
750 flag_schedule_insns_after_reload means schedule insns after
753 int flag_schedule_insns
= 0;
754 int flag_schedule_insns_after_reload
= 0;
756 /* The following flags have effect only for scheduling before register
759 flag_schedule_interblock means schedule insns accross basic blocks.
760 flag_schedule_speculative means allow speculative motion of non-load insns.
761 flag_schedule_speculative_load means allow speculative motion of some
763 flag_schedule_speculative_load_dangerous allows speculative motion of more
766 int flag_schedule_interblock
= 1;
767 int flag_schedule_speculative
= 1;
768 int flag_schedule_speculative_load
= 0;
769 int flag_schedule_speculative_load_dangerous
= 0;
771 int flag_single_precision_constant
;
773 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
774 by a cheaper branch on a count register. */
775 int flag_branch_on_count_reg
= 1;
777 /* -finhibit-size-directive inhibits output of .size for ELF.
778 This is used only for compiling crtstuff.c,
779 and it may be extended to other effects
780 needed for crtstuff.c on other systems. */
781 int flag_inhibit_size_directive
= 0;
783 /* -fverbose-asm causes extra commentary information to be produced in
784 the generated assembly code (to make it more readable). This option
785 is generally only of use to those who actually need to read the
786 generated assembly code (perhaps while debugging the compiler itself).
787 -fno-verbose-asm, the default, causes the extra information
788 to be omitted and is useful when comparing two assembler files. */
790 int flag_verbose_asm
= 0;
792 /* -dA causes debug commentary information to be produced in
793 the generated assembly code (to make it more readable). This option
794 is generally only of use to those who actually need to read the
795 generated assembly code (perhaps while debugging the compiler itself).
796 Currently, this switch is only used by dwarfout.c; however, it is intended
797 to be a catchall for printing debug information in the assembler file. */
799 int flag_debug_asm
= 0;
801 /* -dP causes the rtl to be emitted as a comment in assembly. */
803 int flag_dump_rtl_in_asm
= 0;
805 /* -fgnu-linker specifies use of the GNU linker for initializations.
806 (Or, more generally, a linker that handles initializations.)
807 -fno-gnu-linker says that collect2 will be used. */
809 int flag_gnu_linker
= 0;
811 int flag_gnu_linker
= 1;
817 /* Enable dead code elimination. */
820 /* Tag all structures with __attribute__(packed). */
821 int flag_pack_struct
= 0;
823 /* Emit code to check for stack overflow; also may cause large objects
824 to be allocated dynamically. */
825 int flag_stack_check
;
827 /* When non-NULL, indicates that whenever space is allocated on the
828 stack, the resulting stack pointer must not pass this
829 address---that is, for stacks that grow downward, the stack pointer
830 must always be greater than or equal to this address; for stacks
831 that grow upward, the stack pointer must be less than this address.
832 At present, the rtx may be either a REG or a SYMBOL_REF, although
833 the support provided depends on the backend. */
836 /* -fcheck-memory-usage causes extra code to be generated in order to check
837 memory accesses. This is used by a detector of bad memory accesses such
839 int flag_check_memory_usage
= 0;
841 /* -fprefix-function-name causes function name to be prefixed. This
842 can be used with -fcheck-memory-usage to isolate code compiled with
843 -fcheck-memory-usage. */
844 int flag_prefix_function_name
= 0;
846 /* 0 if pointer arguments may alias each other. True in C.
847 1 if pointer arguments may not alias each other but may alias
849 2 if pointer arguments may not alias each other and may not
850 alias global variables. True in Fortran.
851 This defaults to 0 for C. */
852 int flag_argument_noalias
= 0;
854 /* Nonzero if we should do (language-dependent) alias analysis.
855 Typically, this analysis will assume that expressions of certain
856 types do not alias expressions of certain other types. Only used
857 if alias analysis (in general) is enabled. */
858 int flag_strict_aliasing
= 0;
860 /* Instrument functions with calls at entry and exit, for profiling. */
861 int flag_instrument_function_entry_exit
= 0;
863 /* Nonzero means ignore `#ident' directives. 0 means handle them.
864 On SVR4 targets, it also controls whether or not to emit a
865 string identifying the compiler. */
867 int flag_no_ident
= 0;
869 /* This will perform a peephole pass before sched2. */
870 int flag_peephole2
= 0;
872 /* -fbounded-pointers causes gcc to compile pointers as composite
873 objects occupying three words: the pointer value, the base address
874 of the referent object, and the address immediately beyond the end
875 of the referent object. The base and extent allow us to perform
876 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
877 int flag_bounded_pointers
= 0;
879 /* -fcheck-bounds causes gcc to generate array bounds checks.
880 For C, C++: defaults to value of flag_bounded_pointers.
881 For ObjC: defaults to off.
882 For Java: defaults to on.
883 For Fortran: defaults to off.
884 For CHILL: defaults to off. */
885 int flag_bounds_check
= 0;
887 /* If one, renumber instruction UIDs to reduce the number of
888 unused UIDs if there are a lot of instructions. If greater than
889 one, unconditionally renumber instruction UIDs. */
890 int flag_renumber_insns
= 1;
892 /* Values of the -falign-* flags: how much to align labels in code.
893 0 means `use default', 1 means `don't align'.
894 For each variable, there is an _log variant which is the power
895 of two not less than the variable, for .align output. */
902 int align_labels_log
;
904 int align_functions_log
;
906 /* Table of supported debugging formats. */
910 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
911 constant expression, we use NO_DEBUG in its place. */
912 enum debug_info_type debug_type
;
913 int use_extensions_p
;
914 const char *description
;
918 { "", NO_DEBUG
, DEFAULT_GDB_EXTENSIONS
,
919 "Generate default debug format output" },
920 { "gdb", NO_DEBUG
, 1, "Generate default extended debug format output" },
921 #ifdef DBX_DEBUGGING_INFO
922 { "stabs", DBX_DEBUG
, 0, "Generate STABS format debug output" },
923 { "stabs+", DBX_DEBUG
, 1, "Generate extended STABS format debug output" },
925 #ifdef DWARF_DEBUGGING_INFO
926 { "dwarf", DWARF_DEBUG
, 0, "Generate DWARF-1 format debug output"},
927 { "dwarf+", DWARF_DEBUG
, 1,
928 "Generated extended DWARF-1 format debug output" },
930 #ifdef DWARF2_DEBUGGING_INFO
931 { "dwarf-2", DWARF2_DEBUG
, 0, "Enable DWARF-2 debug output" },
933 #ifdef XCOFF_DEBUGGING_INFO
934 { "xcoff", XCOFF_DEBUG
, 0, "Generate XCOFF format debug output" },
935 { "xcoff+", XCOFF_DEBUG
, 1, "Generate extended XCOFF format debug output" },
937 #ifdef SDB_DEBUGGING_INFO
938 { "coff", SDB_DEBUG
, 0, "Generate COFF format debug output" },
948 const char *description
;
950 lang_independent_options
;
954 /* Add or remove a leading underscore from user symbols. */
955 int flag_leading_underscore
= -1;
957 /* The user symbol prefix after having resolved same. */
958 const char *user_label_prefix
;
960 /* A default for same. */
961 #ifndef USER_LABEL_PREFIX
962 #define USER_LABEL_PREFIX ""
965 /* Table of language-independent -f options.
966 STRING is the option name. VARIABLE is the address of the variable.
967 ON_VALUE is the value to store in VARIABLE
968 if `-fSTRING' is seen as an option.
969 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
971 lang_independent_options f_options
[] =
973 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups
, 1,
974 "Perform DWARF2 duplicate elimination"},
975 {"float-store", &flag_float_store
, 1,
976 "Do not store floats in registers" },
977 {"volatile", &flag_volatile
, 1,
978 "Consider all mem refs through pointers as volatile"},
979 {"volatile-global", &flag_volatile_global
, 1,
980 "Consider all mem refs to global data to be volatile" },
981 {"volatile-static", &flag_volatile_static
, 1,
982 "Consider all mem refs to static data to be volatile" },
983 {"defer-pop", &flag_defer_pop
, 1,
984 "Defer popping functions args from stack until later" },
985 {"omit-frame-pointer", &flag_omit_frame_pointer
, 1,
986 "When possible do not generate stack frames"},
987 {"optimize-sibling-calls", &flag_optimize_sibling_calls
, 1,
988 "Optimize sibling and tail recursive calls" },
989 {"cse-follow-jumps", &flag_cse_follow_jumps
, 1,
990 "When running CSE, follow jumps to their targets" },
991 {"cse-skip-blocks", &flag_cse_skip_blocks
, 1,
992 "When running CSE, follow conditional jumps" },
993 {"expensive-optimizations", &flag_expensive_optimizations
, 1,
994 "Perform a number of minor, expensive optimisations" },
995 {"thread-jumps", &flag_thread_jumps
, 1,
996 "Perform jump threading optimisations"},
997 {"strength-reduce", &flag_strength_reduce
, 1,
998 "Perform strength reduction optimisations" },
999 {"unroll-loops", &flag_unroll_loops
, 1,
1000 "Perform loop unrolling when iteration count is known" },
1001 {"unroll-all-loops", &flag_unroll_all_loops
, 1,
1002 "Perform loop unrolling for all loops" },
1003 {"move-all-movables", &flag_move_all_movables
, 1,
1004 "Force all loop invariant computations out of loops" },
1005 {"reduce-all-givs", &flag_reduce_all_givs
, 1,
1006 "Strength reduce all loop general induction variables" },
1007 {"writable-strings", &flag_writable_strings
, 1,
1008 "Store strings in writable data section" },
1009 {"peephole", &flag_no_peephole
, 0,
1010 "Enable machine specific peephole optimisations" },
1011 {"force-mem", &flag_force_mem
, 1,
1012 "Copy memory operands into registers before using" },
1013 {"force-addr", &flag_force_addr
, 1,
1014 "Copy memory address constants into regs before using" },
1015 {"function-cse", &flag_no_function_cse
, 0,
1016 "Allow function addresses to be held in registers" },
1017 {"inline-functions", &flag_inline_functions
, 1,
1018 "Integrate simple functions into their callers" },
1019 {"keep-inline-functions", &flag_keep_inline_functions
, 1,
1020 "Generate code for funcs even if they are fully inlined" },
1021 {"inline", &flag_no_inline
, 0,
1022 "Pay attention to the 'inline' keyword"},
1023 {"keep-static-consts", &flag_keep_static_consts
, 1,
1024 "Emit static const variables even if they are not used" },
1025 {"syntax-only", &flag_syntax_only
, 1,
1026 "Check for syntax errors, then stop" },
1027 {"shared-data", &flag_shared_data
, 1,
1028 "Mark data as shared rather than private" },
1029 {"caller-saves", &flag_caller_saves
, 1,
1030 "Enable saving registers around function calls" },
1031 {"pcc-struct-return", &flag_pcc_struct_return
, 1,
1032 "Return 'short' aggregates in memory, not registers" },
1033 {"reg-struct-return", &flag_pcc_struct_return
, 0,
1034 "Return 'short' aggregates in registers" },
1035 {"delayed-branch", &flag_delayed_branch
, 1,
1036 "Attempt to fill delay slots of branch instructions" },
1037 {"gcse", &flag_gcse
, 1,
1038 "Perform the global common subexpression elimination" },
1039 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop
, 1,
1040 "Run CSE pass after loop optimisations"},
1041 {"rerun-loop-opt", &flag_rerun_loop_opt
, 1,
1042 "Run the loop optimiser twice"},
1043 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks
, 1,
1044 "Delete useless null pointer checks" },
1045 {"pretend-float", &flag_pretend_float
, 1,
1046 "Pretend that host and target use the same FP format"},
1047 {"schedule-insns", &flag_schedule_insns
, 1,
1048 "Reschedule instructions to avoid pipeline stalls"},
1049 {"schedule-insns2", &flag_schedule_insns_after_reload
, 1,
1050 "Run two passes of the instruction scheduler"},
1051 {"sched-interblock",&flag_schedule_interblock
, 1,
1052 "Enable scheduling across basic blocks" },
1053 {"sched-spec",&flag_schedule_speculative
, 1,
1054 "Allow speculative motion of non-loads" },
1055 {"sched-spec-load",&flag_schedule_speculative_load
, 1,
1056 "Allow speculative motion of some loads" },
1057 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous
, 1,
1058 "Allow speculative motion of more loads" },
1059 {"branch-count-reg",&flag_branch_on_count_reg
, 1,
1060 "Replace add,compare,branch with branch on count reg"},
1061 {"pic", &flag_pic
, 1,
1062 "Generate position independent code, if possible"},
1063 {"PIC", &flag_pic
, 2, ""},
1064 {"exceptions", &flag_exceptions
, 1,
1065 "Enable exception handling" },
1066 {"new-exceptions", &flag_new_exceptions
, 1,
1067 "Use the new model for exception handling" },
1068 {"unwind-tables", &flag_unwind_tables
, 1,
1069 "Just generate unwind tables for exception handling" },
1070 {"sjlj-exceptions", &exceptions_via_longjmp
, 1,
1071 "Use setjmp/longjmp to handle exceptions" },
1072 {"asynchronous-exceptions", &asynchronous_exceptions
, 1,
1073 "Support asynchronous exceptions" },
1074 {"profile-arcs", &profile_arc_flag
, 1,
1075 "Insert arc based program profiling code" },
1076 {"test-coverage", &flag_test_coverage
, 1,
1077 "Create data files needed by gcov" },
1078 {"branch-probabilities", &flag_branch_probabilities
, 1,
1079 "Use profiling information for branch probabilities" },
1080 {"reorder-blocks", &flag_reorder_blocks
, 1,
1081 "Reorder basic blocks to improve code placement" },
1082 {"rename-registers", &flag_rename_registers
, 1,
1083 "Do the register renaming optimization pass"},
1084 {"fast-math", &flag_fast_math
, 1,
1085 "Improve FP speed by violating ANSI & IEEE rules" },
1086 {"common", &flag_no_common
, 0,
1087 "Do not put unitialised globals in the common section" },
1088 {"inhibit-size-directive", &flag_inhibit_size_directive
, 1,
1089 "Do not generate .size directives" },
1090 {"function-sections", &flag_function_sections
, 1,
1091 "place each function into its own section" },
1092 {"data-sections", &flag_data_sections
, 1,
1093 "place data items into their own section" },
1094 {"verbose-asm", &flag_verbose_asm
, 1,
1095 "Add extra commentry to assembler output"},
1096 {"gnu-linker", &flag_gnu_linker
, 1,
1097 "Output GNU ld formatted global initialisers"},
1098 {"regmove", &flag_regmove
, 1,
1099 "Enables a register move optimisation"},
1100 {"optimize-register-move", &flag_regmove
, 1,
1101 "Do the full regmove optimization pass"},
1102 {"pack-struct", &flag_pack_struct
, 1,
1103 "Pack structure members together without holes" },
1104 {"stack-check", &flag_stack_check
, 1,
1105 "Insert stack checking code into the program" },
1106 {"argument-alias", &flag_argument_noalias
, 0,
1107 "Specify that arguments may alias each other & globals"},
1108 {"argument-noalias", &flag_argument_noalias
, 1,
1109 "Assume arguments may alias globals but not each other"},
1110 {"argument-noalias-global", &flag_argument_noalias
, 2,
1111 "Assume arguments do not alias each other or globals" },
1112 {"strict-aliasing", &flag_strict_aliasing
, 1,
1113 "Assume strict aliasing rules apply" },
1114 {"align-loops", &align_loops
, 0,
1115 "Align the start of loops" },
1116 {"align-jumps", &align_jumps
, 0,
1117 "Align labels which are only reached by jumping" },
1118 {"align-labels", &align_labels
, 0,
1119 "Align all labels" },
1120 {"align-functions", &align_functions
, 0,
1121 "Align the start of functions" },
1122 {"check-memory-usage", &flag_check_memory_usage
, 1,
1123 "Generate code to check every memory access" },
1124 {"prefix-function-name", &flag_prefix_function_name
, 1,
1125 "Add a prefix to all function names" },
1126 {"dump-unnumbered", &flag_dump_unnumbered
, 1,
1127 "Suppress output of instruction numbers and line number notes in debugging dumps"},
1128 {"instrument-functions", &flag_instrument_function_entry_exit
, 1,
1129 "Instrument function entry/exit with profiling calls"},
1130 {"ssa", &flag_ssa
, 1,
1131 "Enable SSA optimizations" },
1132 {"dce", &flag_dce
, 1,
1133 "Enable dead code elimination" },
1134 {"leading-underscore", &flag_leading_underscore
, 1,
1135 "External symbols have a leading underscore" },
1136 {"ident", &flag_no_ident
, 0,
1137 "Process #ident directives"},
1138 { "peephole2", &flag_peephole2
, 1,
1139 "Enables an rtl peephole pass run before sched2" },
1140 {"math-errno", &flag_errno_math
, 1,
1141 "Set errno after built-in math functions"},
1142 {"bounded-pointers", &flag_bounded_pointers
, 1,
1143 "Compile pointers as triples: value, base & end" },
1144 {"bounds-check", &flag_bounds_check
, 1,
1145 "Generate code to check bounds before dereferencing pointers and arrays" },
1146 {"single-precision-constant", &flag_single_precision_constant
, 1,
1147 "Convert floating point constant to single precision constant"},
1148 {"time-report", &time_report
, 1,
1149 "Report time taken by each compiler pass at end of run"},
1150 {"mem-report", &mem_report
, 1,
1151 "Report on permanent memory allocation at end of run"},
1152 { "trapv", &flag_trapv
, 1,
1153 "Trap for signed overflow in addition / subtraction / multiplication." },
1156 /* Table of language-specific options. */
1158 static struct lang_opt
1161 const char *description
;
1163 documented_lang_options
[] =
1165 /* In order not to overload the --help output, the convention
1166 used here is to only describe those options which are not
1167 enabled by default. */
1169 { "-ansi", "Compile just for ISO C89" },
1170 { "-fallow-single-precision",
1171 "Do not promote floats to double if using -traditional" },
1172 { "-std= ", "Determine language standard"},
1174 { "-fsigned-bitfields", "" },
1175 { "-funsigned-bitfields","Make bitfields by unsigned by default" },
1176 { "-fno-signed-bitfields", "" },
1177 { "-fno-unsigned-bitfields","" },
1178 { "-fsigned-char", "Make 'char' be signed by default"},
1179 { "-funsigned-char", "Make 'char' be unsigned by default"},
1180 { "-fno-signed-char", "" },
1181 { "-fno-unsigned-char", "" },
1183 { "-ftraditional", "" },
1184 { "-traditional", "Attempt to support traditional K&R style C"},
1185 { "-fnotraditional", "" },
1186 { "-fno-traditional", "" },
1189 { "-fno-asm", "Do not recognise the 'asm' keyword" },
1190 { "-fbuiltin", "" },
1191 { "-fno-builtin", "Do not recognise any built in functions" },
1192 { "-fhosted", "Assume normal C execution environment" },
1193 { "-fno-hosted", "" },
1195 "Assume that standard libraries & main might not exist" },
1196 { "-fno-freestanding", "" },
1197 { "-fcond-mismatch", "Allow different types as args of ? operator"},
1198 { "-fno-cond-mismatch", "" },
1199 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
1200 { "-fno-dollars-in-identifiers", "" },
1201 { "-fpreprocessed", "" },
1202 { "-fno-preprocessed", "" },
1203 { "-fshort-double", "Use the same size for double as for float" },
1204 { "-fno-short-double", "" },
1205 { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
1206 { "-fno-short-enums", "" },
1207 { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
1208 { "-fno-short-wchar", "" },
1210 { "-Wall", "Enable most warning messages" },
1211 { "-Wbad-function-cast",
1212 "Warn about casting functions to incompatible types" },
1213 { "-Wno-bad-function-cast", "" },
1214 { "-Wmissing-noreturn",
1215 "Warn about functions which might be candidates for attribute noreturn" },
1216 { "-Wno-missing-noreturn", "" },
1217 { "-Wmissing-format-attribute",
1218 "Warn about functions which might be candidates for format attributes" },
1219 { "-Wno-missing-format-attribute", "" },
1220 { "-Wcast-qual", "Warn about casts which discard qualifiers"},
1221 { "-Wno-cast-qual", "" },
1222 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
1223 { "-Wno-char-subscripts", "" },
1224 { "-Wcomment", "Warn if nested comments are detected" },
1225 { "-Wno-comment", "" },
1226 { "-Wcomments", "Warn if nested comments are detected" },
1227 { "-Wno-comments", "" },
1228 { "-Wconversion", "Warn about possibly confusing type conversions" },
1229 { "-Wno-conversion", "" },
1230 { "-Wformat", "Warn about printf format anomalies" },
1231 { "-Wno-format", "" },
1232 { "-Wimplicit-function-declaration",
1233 "Warn about implicit function declarations" },
1234 { "-Wno-implicit-function-declaration", "" },
1235 { "-Werror-implicit-function-declaration", "" },
1236 { "-Wimplicit-int", "Warn when a declaration does not specify a type" },
1237 { "-Wno-implicit-int", "" },
1238 { "-Wimplicit", "" },
1239 { "-Wno-implicit", "" },
1240 { "-Wimport", "Warn about the use of the #import directive" },
1241 { "-Wno-import", "" },
1242 { "-Wlong-long","" },
1243 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" },
1244 { "-Wmain", "Warn about suspicious declarations of main" },
1245 { "-Wno-main", "" },
1246 { "-Wmissing-braces",
1247 "Warn about possibly missing braces around initialisers" },
1248 { "-Wno-missing-braces", "" },
1249 { "-Wmissing-declarations",
1250 "Warn about global funcs without previous declarations"},
1251 { "-Wno-missing-declarations", "" },
1252 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" },
1253 { "-Wno-missing-prototypes", "" },
1254 { "-Wmultichar", "Warn about use of multicharacter literals"},
1255 { "-Wno-multichar", "" },
1256 { "-Wnested-externs", "Warn about externs not at file scope level" },
1257 { "-Wno-nested-externs", "" },
1258 { "-Wparentheses", "Warn about possible missing parentheses" },
1259 { "-Wno-parentheses", "" },
1260 { "-Wsequence-point",
1261 "Warn about possible violations of sequence point rules" },
1262 { "-Wno-sequence-point", "" },
1263 { "-Wpointer-arith", "Warn about function pointer arithmetic" },
1264 { "-Wno-pointer-arith", "" },
1265 { "-Wredundant-decls",
1266 "Warn about multiple declarations of the same object" },
1267 { "-Wno-redundant-decls", "" },
1268 { "-Wsign-compare", "Warn about signed/unsigned comparisons" },
1269 { "-Wno-sign-compare", "" },
1270 { "-Wfloat-equal", "Warn about testing equality of floating point numbers" },
1271 { "-Wno-float-equal", "" },
1272 { "-Wunknown-pragmas", "Warn about unrecognized pragmas" },
1273 { "-Wno-unknown-pragmas", "" },
1274 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" },
1275 { "-Wno-strict-prototypes", "" },
1276 { "-Wtraditional", "Warn about constructs whose meaning change in ISO C"},
1277 { "-Wno-traditional", "" },
1278 { "-Wtrigraphs", "Warn when trigraphs are encountered" },
1279 { "-Wno-trigraphs", "" },
1281 { "-Wno-undef", "" },
1282 { "-Wwrite-strings", "Mark strings as 'const char *'"},
1283 { "-Wno-write-strings", "" },
1285 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1287 #include "options.h"
1291 /* Here is a table, controlled by the tm.h file, listing each -m switch
1292 and which bits in `target_switches' it should set or clear.
1293 If VALUE is positive, it is bits to set.
1294 If VALUE is negative, -VALUE is bits to clear.
1295 (The sign bit is not used so there is no confusion.) */
1301 const char *description
;
1303 target_switches
[] = TARGET_SWITCHES
;
1305 /* This table is similar, but allows the switch to have a value. */
1307 #ifdef TARGET_OPTIONS
1311 const char **variable
;
1312 const char *description
;
1314 target_options
[] = TARGET_OPTIONS
;
1317 /* Options controlling warnings. */
1319 /* Don't print warning messages. -w. */
1321 int inhibit_warnings
= 0;
1323 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1325 int warn_system_headers
= 0;
1327 /* Print various extra warnings. -W. */
1329 int extra_warnings
= 0;
1331 /* Treat warnings as errors. -Werror. */
1333 int warnings_are_errors
= 0;
1335 /* Nonzero to warn about unused variables, functions et.al. */
1337 int warn_unused_function
;
1338 int warn_unused_label
;
1339 int warn_unused_parameter
;
1340 int warn_unused_variable
;
1341 int warn_unused_value
;
1344 set_Wunused (setting
)
1347 warn_unused_function
= setting
;
1348 warn_unused_label
= setting
;
1349 /* Unused function parameter warnings are reported when either ``-W
1350 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1351 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1353 warn_unused_parameter
= 0;
1354 else if (!warn_unused_parameter
)
1355 warn_unused_parameter
= -1;
1356 warn_unused_variable
= setting
;
1357 warn_unused_value
= setting
;
1360 /* Nonzero to warn about code which is never reached. */
1362 int warn_notreached
;
1364 /* Nonzero to warn about variables used before they are initialized. */
1366 int warn_uninitialized
;
1368 /* Nonzero means warn about all declarations which shadow others. */
1372 /* Warn if a switch on an enum fails to have a case for every enum value. */
1376 /* Nonzero means warn about function definitions that default the return type
1377 or that use a null return and have a return-type other than void. */
1379 int warn_return_type
;
1381 /* Nonzero means warn about pointer casts that increase the required
1382 alignment of the target type (and might therefore lead to a crash
1383 due to a misaligned access). */
1385 int warn_cast_align
;
1387 /* Nonzero means warn about any identifiers that match in the first N
1388 characters. The value N is in `id_clash_len'. */
1393 /* Nonzero means warn about any objects definitions whose size is larger
1394 than N bytes. Also want about function definitions whose returned
1395 values are larger than N bytes. The value N is in `larger_than_size'. */
1397 int warn_larger_than
;
1398 HOST_WIDE_INT larger_than_size
;
1400 /* Nonzero means warn if inline function is too large. */
1404 /* Warn if a function returns an aggregate,
1405 since there are often incompatible calling conventions for doing this. */
1407 int warn_aggregate_return
;
1409 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1413 /* Warn when gcc pads a structure to an alignment boundary. */
1417 /* Warn when an optimization pass is disabled. */
1419 int warn_disabled_optimization
;
1421 /* Warn about functions which might be candidates for attribute noreturn. */
1423 int warn_missing_noreturn
;
1425 /* Likewise for -W. */
1427 lang_independent_options W_options
[] =
1429 {"unused-function", &warn_unused_function
, 1, "Warn when a function is unused" },
1430 {"unused-label", &warn_unused_label
, 1, "Warn when a label is unused" },
1431 {"unused-parameter", &warn_unused_parameter
, 1, "Warn when a function parameter is unused" },
1432 {"unused-variable", &warn_unused_variable
, 1, "Warn when a variable is unused" },
1433 {"unused-value", &warn_unused_value
, 1, "Warn when an expression value is unused" },
1434 {"system-headers", &warn_system_headers
, 1, "Do not suppress warnings from system headers"},
1435 {"error", &warnings_are_errors
, 1, ""},
1436 {"shadow", &warn_shadow
, 1, "Warn when one local variable shadows another" },
1437 {"switch", &warn_switch
, 1,
1438 "Warn about enumerated switches missing a specific case" },
1439 {"aggregate-return", &warn_aggregate_return
, 1,
1440 "Warn about returning structures, unions or arrays" },
1441 {"cast-align", &warn_cast_align
, 1,
1442 "Warn about pointer casts which increase alignment" },
1443 {"unreachable-code", &warn_notreached
, 1,
1444 "Warn about code that will never be executed" },
1445 {"uninitialized", &warn_uninitialized
, 1,
1446 "Warn about unitialized automatic variables"},
1447 {"inline", &warn_inline
, 1,
1448 "Warn when an inlined function cannot be inlined"},
1449 {"packed", &warn_packed
, 1,
1450 "Warn when the packed attribute has no effect on struct layout"},
1451 {"padded", &warn_padded
, 1,
1452 "Warn when padding is required to align struct members"},
1453 {"disabled-optimization", &warn_disabled_optimization
, 1,
1454 "Warn when an optimization pass is disabled"}
1457 /* Output files for assembler code (real compiler output)
1458 and debugging dumps. */
1461 FILE *aux_info_file
;
1462 FILE *rtl_dump_file
= NULL
;
1464 /* Decode the string P as an integral parameter.
1465 If the string is indeed an integer return its numeric value else
1466 issue an Invalid Option error for the option PNAME and return DEFVAL.
1467 If PNAME is zero just return DEFVAL, do not call error. */
1470 read_integral_parameter (p
, pname
, defval
)
1475 const char *endp
= p
;
1479 if (*endp
>= '0' && *endp
<= '9')
1488 error ("Invalid option `%s'", pname
);
1496 /* This is the default decl_printable_name function. */
1499 decl_name (decl
, verbosity
)
1501 int verbosity ATTRIBUTE_UNUSED
;
1503 return IDENTIFIER_POINTER (DECL_NAME (decl
));
1506 /* Mark P for GC. Also mark main_input_filename and input_filename. */
1512 struct file_stack
*stack
= *(struct file_stack
**)p
;
1514 /* We're only called for input_file_stack, so we can mark the current
1515 input_filename here as well. */
1516 ggc_mark_string (main_input_filename
);
1517 ggc_mark_string (input_filename
);
1521 ggc_mark_string (stack
->name
);
1522 stack
= stack
->next
;
1527 /* This calls abort and is used to avoid problems when abort if a macro.
1528 It is used when we need to pass the address of abort. */
1536 /* When `malloc.c' is compiled with `rcheck' defined,
1537 it calls this function to report clobberage. */
1541 const char *s ATTRIBUTE_UNUSED
;
1546 /* Return the logarithm of X, base 2, considering X unsigned,
1547 if X is a power of 2. Otherwise, returns -1.
1549 This should be used via the `exact_log2' macro. */
1553 register unsigned HOST_WIDE_INT x
;
1555 register int log
= 0;
1556 /* Test for 0 or a power of 2. */
1557 if (x
== 0 || x
!= (x
& -x
))
1559 while ((x
>>= 1) != 0)
1564 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1565 If X is 0, return -1.
1567 This should be used via the floor_log2 macro. */
1571 register unsigned HOST_WIDE_INT x
;
1573 register int log
= -1;
1580 static int float_handler_set
;
1582 jmp_buf float_handler
;
1584 /* Signals actually come here. */
1587 float_signal (signo
)
1588 /* If this is missing, some compilers complain. */
1589 int signo ATTRIBUTE_UNUSED
;
1591 if (float_handled
== 0)
1592 crash_signal (signo
);
1593 #if defined (USG) || defined (hpux)
1594 /* Re-enable the signal catcher. */
1595 signal (SIGFPE
, float_signal
);
1598 signal (SIGFPE
, float_signal
);
1599 longjmp (float_handler
, 1);
1602 /* Specify where to longjmp to when a floating arithmetic error happens.
1603 If HANDLER is 0, it means don't handle the errors any more. */
1606 set_float_handler (handler
)
1609 float_handled
= (handler
!= 0);
1611 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
1613 if (float_handled
&& ! float_handler_set
)
1615 signal (SIGFPE
, float_signal
);
1616 float_handler_set
= 1;
1620 /* This is a wrapper function for code which might elicit an
1621 arithmetic exception. That code should be passed in as a function
1622 pointer FN, and one argument DATA. DATA is usually a struct which
1623 contains the real input and output for function FN. This function
1624 returns 0 (failure) if longjmp was called (i.e. an exception
1625 occured.) It returns 1 (success) otherwise. */
1628 do_float_handler (fn
, data
)
1629 void (*fn
) PARAMS ((PTR
));
1636 /* We got here via longjmp () caused by an exception in function
1638 set_float_handler (NULL
);
1642 set_float_handler (buf
);
1644 set_float_handler (NULL
);
1648 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
1649 error happens, pushing the previous specification into OLD_HANDLER.
1650 Return an indication of whether there was a previous handler in effect. */
1653 push_float_handler (handler
, old_handler
)
1654 jmp_buf handler
, old_handler
;
1656 int was_handled
= float_handled
;
1660 memcpy ((char *) old_handler
, (char *) float_handler
,
1661 sizeof (float_handler
));
1663 memcpy ((char *) float_handler
, (char *) handler
, sizeof (float_handler
));
1667 /* Restore the previous specification of whether and where to longjmp to
1668 when a floating arithmetic error happens. */
1671 pop_float_handler (handled
, handler
)
1675 float_handled
= handled
;
1677 bcopy ((char *) handler
, (char *) float_handler
, sizeof (float_handler
));
1680 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1681 into ICE messages, which is much more user friendly. */
1684 crash_signal (signo
)
1685 /* If this is missing, some compilers complain. */
1688 fatal ("Internal error: %s.\n\
1689 Please submit a full bug report.\n\
1690 See %s for instructions.", strsignal (signo
), GCCBUGURL
);
1693 /* Strip off a legitimate source ending from the input string NAME of
1694 length LEN. Rather than having to know the names used by all of
1695 our front ends, we strip off an ending of a period followed by
1696 up to five characters. (Java uses ".class".) */
1699 strip_off_ending (name
, len
)
1704 for (i
= 2; i
< 6 && len
> i
; i
++)
1706 if (name
[len
- i
] == '.')
1708 name
[len
- i
] = '\0';
1714 /* Given a file name X, return the nondirectory portion. */
1717 file_name_nondirectory (x
)
1720 char *tmp
= (char *) strrchr (x
, '/');
1721 if (DIR_SEPARATOR
!= '/' && ! tmp
)
1722 tmp
= (char *) strrchr (x
, DIR_SEPARATOR
);
1724 return (char *) (tmp
+ 1);
1729 /* Output a quoted string. */
1732 output_quoted_string (asm_file
, string
)
1736 #ifdef OUTPUT_QUOTED_STRING
1737 OUTPUT_QUOTED_STRING (asm_file
, string
);
1741 putc ('\"', asm_file
);
1742 while ((c
= *string
++) != 0)
1744 if (c
== '\"' || c
== '\\')
1745 putc ('\\', asm_file
);
1748 putc ('\"', asm_file
);
1752 /* Output a file name in the form wanted by System V. */
1755 output_file_directive (asm_file
, input_name
)
1757 const char *input_name
;
1759 int len
= strlen (input_name
);
1760 const char *na
= input_name
+ len
;
1762 /* NA gets INPUT_NAME sans directory names. */
1763 while (na
> input_name
)
1765 if (IS_DIR_SEPARATOR (na
[-1]))
1770 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1771 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file
, na
);
1773 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1774 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
1776 fprintf (asm_file
, "\t.file\t");
1777 output_quoted_string (asm_file
, na
);
1778 fputc ('\n', asm_file
);
1783 #ifdef ASM_IDENTIFY_LANGUAGE
1784 /* Routine to build language identifier for object file. */
1787 output_lang_identify (asm_out_file
)
1790 int len
= strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1;
1791 char *s
= (char *) alloca (len
);
1793 sprintf (s
, "__gnu_compiled_%s", lang_identify ());
1794 ASM_OUTPUT_LABEL (asm_out_file
, s
);
1798 /* Routine to open a dump file. Return true if the dump file is enabled. */
1801 open_dump_file (index
, decl
)
1802 enum dump_file_index index
;
1806 const char *open_arg
;
1809 if (! dump_file
[index
].enabled
)
1812 timevar_push (TV_DUMP
);
1813 if (rtl_dump_file
!= NULL
)
1814 fclose (rtl_dump_file
);
1816 sprintf (seq
, ".%02d.", index
);
1818 if (! dump_file
[index
].initialized
)
1820 /* If we've not initialized the files, do so now. */
1821 if (graph_dump_format
!= no_graph
1822 && dump_file
[index
].graph_dump_p
)
1824 dump_name
= concat (seq
, dump_file
[index
].extension
, NULL
);
1825 clean_graph_dump_file (dump_base_name
, dump_name
);
1828 dump_file
[index
].initialized
= 1;
1834 dump_name
= concat (dump_base_name
, seq
,
1835 dump_file
[index
].extension
, NULL
);
1837 rtl_dump_file
= fopen (dump_name
, open_arg
);
1838 if (rtl_dump_file
== NULL
)
1839 pfatal_with_name (dump_name
);
1844 fprintf (rtl_dump_file
, "\n;; Function %s\n\n",
1845 decl_printable_name (decl
, 2));
1847 timevar_pop (TV_DUMP
);
1851 /* Routine to close a dump file. */
1854 close_dump_file (index
, func
, insns
)
1855 enum dump_file_index index
;
1856 void (*func
) PARAMS ((FILE *, rtx
));
1859 if (! rtl_dump_file
)
1862 timevar_push (TV_DUMP
);
1864 && graph_dump_format
!= no_graph
1865 && dump_file
[index
].graph_dump_p
)
1870 sprintf (seq
, ".%02d.", index
);
1871 suffix
= concat (seq
, dump_file
[index
].extension
, NULL
);
1872 print_rtl_graph_with_bb (dump_base_name
, suffix
, insns
);
1877 func (rtl_dump_file
, insns
);
1879 fflush (rtl_dump_file
);
1880 fclose (rtl_dump_file
);
1882 rtl_dump_file
= NULL
;
1883 timevar_pop (TV_DUMP
);
1886 /* Do any final processing required for the declarations in VEC, of
1887 which there are LEN. We write out inline functions and variables
1888 that have been deferred until this point, but which are required.
1889 Returns non-zero if anything was put out. */
1892 wrapup_global_declarations (vec
, len
)
1899 int output_something
= 0;
1901 for (i
= 0; i
< len
; i
++)
1905 /* We're not deferring this any longer. */
1906 DECL_DEFER_OUTPUT (decl
) = 0;
1908 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0
1909 && incomplete_decl_finalize_hook
!= 0)
1910 (*incomplete_decl_finalize_hook
) (decl
);
1913 /* Now emit any global variables or functions that we have been
1914 putting off. We need to loop in case one of the things emitted
1915 here references another one which comes earlier in the list. */
1919 for (i
= 0; i
< len
; i
++)
1923 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
1926 /* Don't write out static consts, unless we still need them.
1928 We also keep static consts if not optimizing (for debugging),
1929 unless the user specified -fno-keep-static-consts.
1930 ??? They might be better written into the debug information.
1931 This is possible when using DWARF.
1933 A language processor that wants static constants to be always
1934 written out (even if it is not used) is responsible for
1935 calling rest_of_decl_compilation itself. E.g. the C front-end
1936 calls rest_of_decl_compilation from finish_decl.
1937 One motivation for this is that is conventional in some
1938 environments to write things like:
1939 static const char rcsid[] = "... version string ...";
1940 intending to force the string to be in the executable.
1942 A language processor that would prefer to have unneeded
1943 static constants "optimized away" would just defer writing
1944 them out until here. E.g. C++ does this, because static
1945 constants are often defined in header files.
1947 ??? A tempting alternative (for both C and C++) would be
1948 to force a constant to be written if and only if it is
1949 defined in a main file, as opposed to an include file. */
1951 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
1952 && (! TREE_READONLY (decl
)
1953 || TREE_PUBLIC (decl
)
1954 || (!optimize
&& flag_keep_static_consts
)
1955 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
1958 rest_of_decl_compilation (decl
, NULL_PTR
, 1, 1);
1961 if (TREE_CODE (decl
) == FUNCTION_DECL
1962 && DECL_INITIAL (decl
) != 0
1963 && DECL_SAVED_INSNS (decl
) != 0
1964 && (flag_keep_inline_functions
1965 || (TREE_PUBLIC (decl
) && !DECL_COMDAT (decl
))
1966 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
1969 output_inline_function (decl
);
1974 output_something
= 1;
1978 return output_something
;
1981 /* Issue appropriate warnings for the global declarations in VEC (of
1982 which there are LEN). Output debugging information for them. */
1985 check_global_declarations (vec
, len
)
1992 for (i
= 0; i
< len
; i
++)
1996 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
)
1997 && ! TREE_ASM_WRITTEN (decl
))
1998 /* Cancel the RTL for this decl so that, if debugging info
1999 output for global variables is still to come,
2000 this one will be omitted. */
2001 DECL_RTL (decl
) = NULL
;
2003 /* Warn about any function
2004 declared static but not defined.
2005 We don't warn about variables,
2006 because many programs have static variables
2007 that exist only to get some text into the object file. */
2008 if (TREE_CODE (decl
) == FUNCTION_DECL
2009 && (warn_unused_function
2010 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2011 && DECL_INITIAL (decl
) == 0
2012 && DECL_EXTERNAL (decl
)
2013 && ! DECL_ARTIFICIAL (decl
)
2014 && ! TREE_PUBLIC (decl
))
2016 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
2017 pedwarn_with_decl (decl
,
2018 "`%s' used but never defined");
2020 warning_with_decl (decl
,
2021 "`%s' declared `static' but never defined");
2022 /* This symbol is effectively an "extern" declaration now. */
2023 TREE_PUBLIC (decl
) = 1;
2024 assemble_external (decl
);
2027 /* Warn about static fns or vars defined but not used,
2028 but not about inline functions or static consts
2029 since defining those in header files is normal practice. */
2030 if (((warn_unused_function
2031 && TREE_CODE (decl
) == FUNCTION_DECL
&& ! DECL_INLINE (decl
))
2032 || (warn_unused_variable
2033 && TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
2034 && ! DECL_IN_SYSTEM_HEADER (decl
)
2035 && ! DECL_EXTERNAL (decl
)
2036 && ! TREE_PUBLIC (decl
)
2037 && ! TREE_USED (decl
)
2038 && (TREE_CODE (decl
) == FUNCTION_DECL
|| ! DECL_REGISTER (decl
))
2039 /* The TREE_USED bit for file-scope decls
2040 is kept in the identifier, to handle multiple
2041 external decls in different scopes. */
2042 && ! TREE_USED (DECL_NAME (decl
)))
2043 warning_with_decl (decl
, "`%s' defined but not used");
2045 timevar_push (TV_SYMOUT
);
2046 #ifdef SDB_DEBUGGING_INFO
2047 /* The COFF linker can move initialized global vars to the end.
2048 And that can screw up the symbol ordering.
2049 By putting the symbols in that order to begin with,
2050 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
2051 if (write_symbols
== SDB_DEBUG
&& TREE_CODE (decl
) == VAR_DECL
2052 && TREE_PUBLIC (decl
) && DECL_INITIAL (decl
)
2053 && ! DECL_EXTERNAL (decl
)
2054 && DECL_RTL (decl
) != 0)
2055 sdbout_symbol (decl
, 0);
2057 /* Output COFF information for non-global
2058 file-scope initialized variables. */
2059 if (write_symbols
== SDB_DEBUG
2060 && TREE_CODE (decl
) == VAR_DECL
2061 && DECL_INITIAL (decl
)
2062 && ! DECL_EXTERNAL (decl
)
2063 && DECL_RTL (decl
) != 0
2064 && GET_CODE (DECL_RTL (decl
)) == MEM
)
2065 sdbout_toplevel_data (decl
);
2066 #endif /* SDB_DEBUGGING_INFO */
2067 #ifdef DWARF_DEBUGGING_INFO
2068 /* Output DWARF information for file-scope tentative data object
2069 declarations, file-scope (extern) function declarations (which
2070 had no corresponding body) and file-scope tagged type declarations
2071 and definitions which have not yet been forced out. */
2073 if (write_symbols
== DWARF_DEBUG
2074 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2075 dwarfout_file_scope_decl (decl
, 1);
2077 #ifdef DWARF2_DEBUGGING_INFO
2078 /* Output DWARF2 information for file-scope tentative data object
2079 declarations, file-scope (extern) function declarations (which
2080 had no corresponding body) and file-scope tagged type declarations
2081 and definitions which have not yet been forced out. */
2083 if (write_symbols
== DWARF2_DEBUG
2084 && (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
)))
2085 dwarf2out_decl (decl
);
2087 timevar_pop (TV_SYMOUT
);
2091 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2092 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2093 INPUT_FILENAME and LINENO accordingly. */
2096 push_srcloc (file
, line
)
2100 struct file_stack
*fs
;
2102 if (input_file_stack
)
2104 input_file_stack
->name
= input_filename
;
2105 input_file_stack
->line
= lineno
;
2108 fs
= (struct file_stack
*) xmalloc (sizeof (struct file_stack
));
2109 fs
->name
= input_filename
= file
;
2110 fs
->line
= lineno
= line
;
2111 fs
->indent_level
= 0;
2112 fs
->next
= input_file_stack
;
2113 input_file_stack
= fs
;
2114 input_file_stack_tick
++;
2117 /* Pop the top entry off the stack of presently open source files.
2118 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2124 struct file_stack
*fs
;
2126 fs
= input_file_stack
;
2127 input_file_stack
= fs
->next
;
2129 input_file_stack_tick
++;
2130 /* The initial souce file is never popped. */
2131 if (!input_file_stack
)
2133 input_filename
= input_file_stack
->name
;
2134 lineno
= input_file_stack
->line
;
2137 /* Compile an entire file of output from cpp, named NAME.
2138 Write a file of assembly output and various debugging dumps. */
2146 int name_specified
= name
!= 0;
2148 if (dump_base_name
== 0)
2149 dump_base_name
= name
? name
: "gccdump";
2154 /* Start timing total execution time. */
2157 timevar_start (TV_TOTAL
);
2159 /* Initialize data in various passes. */
2163 name
= init_parse (name
);
2164 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2165 || debug_info_level
== DINFO_LEVEL_VERBOSE
2166 || flag_test_coverage
2167 || warn_notreached
);
2170 init_decl_processing ();
2176 init_function_once ();
2177 init_stor_layout_once ();
2178 init_varasm_once ();
2180 /* The following initialization functions need to generate rtl, so
2181 provide a dummy function context for them. */
2182 init_dummy_function_start ();
2185 if (flag_caller_saves
)
2186 init_caller_save ();
2187 expand_dummy_function_end ();
2189 /* If auxiliary info generation is desired, open the output file.
2190 This goes in the same directory as the source file--unlike
2191 all the other output files. */
2192 if (flag_gen_aux_info
)
2194 aux_info_file
= fopen (aux_info_file_name
, "w");
2195 if (aux_info_file
== 0)
2196 pfatal_with_name (aux_info_file_name
);
2199 /* Open assembler code output file. Do this even if -fsyntax-only is on,
2200 because then the driver will have provided the name of a temporary
2201 file or bit bucket for us. */
2203 if (! name_specified
&& asm_file_name
== 0)
2204 asm_out_file
= stdout
;
2207 if (asm_file_name
== 0)
2209 int len
= strlen (dump_base_name
);
2210 char *dumpname
= (char *) xmalloc (len
+ 6);
2211 memcpy (dumpname
, dump_base_name
, len
+ 1);
2212 strip_off_ending (dumpname
, len
);
2213 strcat (dumpname
, ".s");
2214 asm_file_name
= dumpname
;
2216 if (!strcmp (asm_file_name
, "-"))
2217 asm_out_file
= stdout
;
2219 asm_out_file
= fopen (asm_file_name
, "w");
2220 if (asm_out_file
== 0)
2221 pfatal_with_name (asm_file_name
);
2224 #ifdef IO_BUFFER_SIZE
2225 setvbuf (asm_out_file
, (char *) xmalloc (IO_BUFFER_SIZE
),
2226 _IOFBF
, IO_BUFFER_SIZE
);
2230 name
= ggc_alloc_string (name
, strlen (name
));
2232 input_filename
= name
;
2234 /* Put an entry on the input file stack for the main input file. */
2235 push_srcloc (input_filename
, 0);
2237 /* Perform language-specific initialization.
2238 This may set main_input_filename. */
2241 /* If the input doesn't start with a #line, use the input name
2242 as the official input file name. */
2243 if (main_input_filename
== 0)
2244 main_input_filename
= name
;
2246 if (flag_syntax_only
)
2248 write_symbols
= NO_DEBUG
;
2250 profile_block_flag
= 0;
2254 ASM_FILE_START (asm_out_file
);
2256 #ifdef ASM_COMMENT_START
2257 if (flag_verbose_asm
)
2259 /* Print the list of options in effect. */
2260 print_version (asm_out_file
, ASM_COMMENT_START
);
2261 print_switch_values (asm_out_file
, 0, MAX_LINE
,
2262 ASM_COMMENT_START
, " ", "\n");
2263 /* Add a blank line here so it appears in assembler output but not
2265 fprintf (asm_out_file
, "\n");
2269 /* Output something to inform GDB that this compilation was by GCC. */
2270 #ifndef ASM_IDENTIFY_GCC
2271 fprintf (asm_out_file
, "gcc2_compiled.:\n");
2273 ASM_IDENTIFY_GCC (asm_out_file
);
2276 /* Output something to identify which front-end produced this file. */
2277 #ifdef ASM_IDENTIFY_LANGUAGE
2278 ASM_IDENTIFY_LANGUAGE (asm_out_file
);
2280 } /* ! flag_syntax_only */
2282 #ifndef ASM_OUTPUT_SECTION_NAME
2283 if (flag_function_sections
)
2285 warning ("-ffunction-sections not supported for this target.");
2286 flag_function_sections
= 0;
2288 if (flag_data_sections
)
2290 warning ("-fdata-sections not supported for this target.");
2291 flag_data_sections
= 0;
2295 if (flag_function_sections
2296 && (profile_flag
|| profile_block_flag
))
2298 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2299 flag_function_sections
= 0;
2302 #ifndef OBJECT_FORMAT_ELF
2303 if (flag_function_sections
&& write_symbols
!= NO_DEBUG
)
2304 warning ("-ffunction-sections may affect debugging on some targets.");
2307 /* ??? Note: There used to be a conditional here
2308 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined.
2309 This was to guarantee separation between gcc_compiled. and
2310 the first function, for the sake of dbx on Suns.
2311 However, having the extra zero here confused the Emacs
2312 code for unexec, and might confuse other programs too.
2313 Therefore, I took out that change.
2314 In future versions we should find another way to solve
2315 that dbx problem. -- rms, 23 May 93. */
2317 /* Don't let the first function fall at the same address
2318 as gcc_compiled., if profiling. */
2319 if (profile_flag
|| profile_block_flag
)
2321 /* It's best if we can write a nop here since some
2322 assemblers don't tolerate zeros in the text section. */
2323 output_asm_insn (get_insn_template (CODE_FOR_nop
, NULL
), NULL_PTR
);
2326 /* If dbx symbol table desired, initialize writing it
2327 and output the predefined types. */
2328 timevar_push (TV_SYMOUT
);
2329 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2330 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2331 dbxout_init (asm_out_file
, main_input_filename
, getdecls ());
2333 #ifdef SDB_DEBUGGING_INFO
2334 if (write_symbols
== SDB_DEBUG
)
2335 sdbout_init (asm_out_file
, main_input_filename
, getdecls ());
2337 #ifdef DWARF_DEBUGGING_INFO
2338 if (write_symbols
== DWARF_DEBUG
)
2339 dwarfout_init (asm_out_file
, main_input_filename
);
2341 #ifdef DWARF2_UNWIND_INFO
2342 if (dwarf2out_do_frame ())
2343 dwarf2out_frame_init ();
2345 #ifdef DWARF2_DEBUGGING_INFO
2346 if (write_symbols
== DWARF2_DEBUG
)
2347 dwarf2out_init (asm_out_file
, main_input_filename
);
2349 timevar_pop (TV_SYMOUT
);
2351 /* Initialize yet another pass. */
2353 init_final (main_input_filename
);
2354 init_branch_prob (dump_base_name
);
2356 timevar_push (TV_PARSE
);
2358 /* Call the parser, which parses the entire file
2359 (calling rest_of_compilation for each function). */
2361 if (yyparse () != 0)
2363 if (errorcount
== 0)
2364 fnotice (stderr
, "Errors detected in input file (your bison.simple is out of date)\n");
2366 /* In case there were missing closebraces,
2367 get us back to the global binding level. */
2368 while (! global_bindings_p ())
2372 /* Compilation is now finished except for writing
2373 what's left of the symbol table output. */
2375 timevar_pop (TV_PARSE
);
2377 if (flag_syntax_only
)
2380 globals
= getdecls ();
2382 /* Really define vars that have had only a tentative definition.
2383 Really output inline functions that must actually be callable
2384 and have not been output so far. */
2387 int len
= list_length (globals
);
2388 tree
*vec
= (tree
*) xmalloc (sizeof (tree
) * len
);
2392 /* Process the decls in reverse order--earliest first.
2393 Put them into VEC from back to front, then take out from front. */
2395 for (i
= 0, decl
= globals
; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
2396 vec
[len
- i
- 1] = decl
;
2398 wrapup_global_declarations (vec
, len
);
2400 /* This must occur after the loop to output deferred functions. Else
2401 the profiler initializer would not be emitted if all the functions
2402 in this compilation unit were deferred.
2404 output_func_start_profiler can not cause any additional functions or
2405 data to need to be output, so it need not be in the deferred function
2407 output_func_start_profiler ();
2409 /* Now that all possible functions have been output, we can dump
2410 the exception table. */
2412 #ifndef IA64_UNWIND_INFO
2413 output_exception_table ();
2415 free_exception_table ();
2417 check_global_declarations (vec
, len
);
2423 /* Write out any pending weak symbol declarations. */
2427 /* Do dbx symbols. */
2428 timevar_push (TV_SYMOUT
);
2429 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2430 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2431 dbxout_finish (asm_out_file
, main_input_filename
);
2434 #ifdef DWARF_DEBUGGING_INFO
2435 if (write_symbols
== DWARF_DEBUG
)
2439 #ifdef DWARF2_UNWIND_INFO
2440 if (dwarf2out_do_frame ())
2441 dwarf2out_frame_finish ();
2444 #ifdef DWARF2_DEBUGGING_INFO
2445 if (write_symbols
== DWARF2_DEBUG
)
2446 dwarf2out_finish ();
2448 timevar_pop (TV_SYMOUT
);
2450 /* Output some stuff at end of file if nec. */
2452 end_final (dump_base_name
);
2454 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
2456 timevar_push (TV_DUMP
);
2457 open_dump_file (DFI_bp
, NULL
);
2461 close_dump_file (DFI_bp
, NULL
, NULL_RTX
);
2462 timevar_pop (TV_DUMP
);
2466 ASM_FILE_END (asm_out_file
);
2469 /* Language-specific end of compilation actions. */
2473 /* Close the dump files. */
2475 if (flag_gen_aux_info
)
2477 fclose (aux_info_file
);
2479 unlink (aux_info_file_name
);
2482 if (optimize
> 0 && open_dump_file (DFI_combine
, NULL
))
2484 timevar_push (TV_DUMP
);
2485 dump_combine_total_stats (rtl_dump_file
);
2486 close_dump_file (DFI_combine
, NULL
, NULL_RTX
);
2487 timevar_pop (TV_DUMP
);
2490 /* Close non-debugging input and output files. Take special care to note
2491 whether fclose returns an error, since the pages might still be on the
2492 buffer chain while the file is open. */
2496 if (ferror (asm_out_file
) != 0 || fclose (asm_out_file
) != 0)
2497 fatal_io_error (asm_file_name
);
2499 /* Do whatever is necessary to finish printing the graphs. */
2500 if (graph_dump_format
!= no_graph
)
2504 for (i
= 0; i
< DFI_MAX
; ++i
)
2505 if (dump_file
[i
].initialized
&& dump_file
[i
].graph_dump_p
)
2510 sprintf (seq
, ".%02d.", i
);
2511 suffix
= concat (seq
, dump_file
[i
].extension
, NULL
);
2512 finish_graph_dump_file (dump_base_name
, suffix
);
2518 ggc_print_statistics ();
2520 /* Free up memory for the benefit of leak detectors. */
2523 /* Stop timing total execution time. */
2524 timevar_stop (TV_TOTAL
);
2526 /* Print the times. */
2528 timevar_print (stderr
);
2531 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2532 and TYPE_DECL nodes.
2534 This does nothing for local (non-static) variables, unless the
2535 variable is a register variable with an ASMSPEC. In that case, or
2536 if the variable is not an automatice, it sets up the RTL and
2537 outputs any assembler code (label definition, storage allocation
2538 and initialization).
2540 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2541 the assembler symbol name to be used. TOP_LEVEL is nonzero
2542 if this declaration is not within a function. */
2545 rest_of_decl_compilation (decl
, asmspec
, top_level
, at_end
)
2547 const char *asmspec
;
2551 /* Declarations of variables, and of functions defined elsewhere. */
2553 /* The most obvious approach, to put an #ifndef around where
2554 this macro is used, doesn't work since it's inside a macro call. */
2555 #ifndef ASM_FINISH_DECLARE_OBJECT
2556 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2559 /* Forward declarations for nested functions are not "external",
2560 but we need to treat them as if they were. */
2561 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
2562 || TREE_CODE (decl
) == FUNCTION_DECL
)
2564 timevar_push (TV_VARCONST
);
2565 make_decl_rtl (decl
, asmspec
, top_level
);
2566 /* Initialized extern variable exists to be replaced
2567 with its value, or represents something that will be
2568 output in another file. */
2569 if (! (TREE_CODE (decl
) == VAR_DECL
2570 && DECL_EXTERNAL (decl
) && TREE_READONLY (decl
)
2571 && DECL_INITIAL (decl
) != 0
2572 && DECL_INITIAL (decl
) != error_mark_node
))
2573 /* Don't output anything
2574 when a tentative file-scope definition is seen.
2575 But at end of compilation, do output code for them. */
2576 if (! (! at_end
&& top_level
2577 && (DECL_INITIAL (decl
) == 0
2578 || DECL_INITIAL (decl
) == error_mark_node
)))
2579 assemble_variable (decl
, top_level
, at_end
, 0);
2580 if (decl
== last_assemble_variable_decl
)
2582 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
2585 timevar_pop (TV_VARCONST
);
2587 else if (DECL_REGISTER (decl
) && asmspec
!= 0)
2589 if (decode_reg_name (asmspec
) >= 0)
2591 DECL_RTL (decl
) = 0;
2592 make_decl_rtl (decl
, asmspec
, top_level
);
2596 error ("invalid register name `%s' for register variable", asmspec
);
2597 DECL_REGISTER (decl
) = 0;
2598 make_decl_rtl (decl
, NULL
, top_level
);
2601 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2602 else if ((write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2603 && TREE_CODE (decl
) == TYPE_DECL
)
2605 timevar_push (TV_SYMOUT
);
2606 dbxout_symbol (decl
, 0);
2607 timevar_pop (TV_SYMOUT
);
2610 #ifdef SDB_DEBUGGING_INFO
2611 else if (write_symbols
== SDB_DEBUG
&& top_level
2612 && TREE_CODE (decl
) == TYPE_DECL
)
2614 timevar_push (TV_SYMOUT
);
2615 sdbout_symbol (decl
, 0);
2616 timevar_pop (TV_SYMOUT
);
2621 /* Called after finishing a record, union or enumeral type. */
2624 rest_of_type_compilation (type
, toplev
)
2625 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2629 tree type ATTRIBUTE_UNUSED
;
2630 int toplev ATTRIBUTE_UNUSED
;
2633 timevar_push (TV_SYMOUT
);
2634 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2635 if (write_symbols
== DBX_DEBUG
|| write_symbols
== XCOFF_DEBUG
)
2636 dbxout_symbol (TYPE_STUB_DECL (type
), !toplev
);
2638 #ifdef SDB_DEBUGGING_INFO
2639 if (write_symbols
== SDB_DEBUG
)
2640 sdbout_symbol (TYPE_STUB_DECL (type
), !toplev
);
2642 #ifdef DWARF2_DEBUGGING_INFO
2643 if (write_symbols
== DWARF2_DEBUG
&& toplev
)
2644 dwarf2out_decl (TYPE_STUB_DECL (type
));
2646 timevar_pop (TV_SYMOUT
);
2649 /* DECL is an inline function, whose body is present, but which is not
2650 being output at this point. (We're putting that off until we need
2651 to do it.) If there are any actions that need to take place,
2652 including the emission of debugging information for the function,
2653 this is where they should go. This function may be called by
2654 language-dependent code for front-ends that do not even generate
2655 RTL for functions that don't need to be put out. */
2658 note_deferral_of_defined_inline_function (decl
)
2659 tree decl ATTRIBUTE_UNUSED
;
2661 #ifdef DWARF_DEBUGGING_INFO
2662 /* Generate the DWARF info for the "abstract" instance of a function
2663 which we may later generate inlined and/or out-of-line instances
2665 if (write_symbols
== DWARF_DEBUG
&& DECL_INLINE (decl
))
2667 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
2668 DWARF code expects it to be set in this case. Intuitively,
2669 DECL is the function we just finished defining, so setting
2670 CURRENT_FUNCTION_DECL is sensible. */
2671 tree saved_cfd
= current_function_decl
;
2672 current_function_decl
= decl
;
2674 /* Let the DWARF code do its work. */
2675 set_decl_abstract_flags (decl
, 1);
2676 dwarfout_file_scope_decl (decl
, 0);
2677 set_decl_abstract_flags (decl
, 0);
2679 /* Reset CURRENT_FUNCTION_DECL. */
2680 current_function_decl
= saved_cfd
;
2685 /* This is called from finish_function (within yyparse)
2686 after each top-level definition is parsed.
2687 It is supposed to compile that function or variable
2688 and output the assembler code for it.
2689 After we return, the tree storage is freed. */
2692 rest_of_compilation (decl
)
2698 int rebuild_label_notes_after_reload
;
2699 int register_life_up_to_date
;
2701 timevar_push (TV_REST_OF_COMPILATION
);
2703 /* Now that we're out of the frontend, we shouldn't have any more
2704 CONCATs anywhere. */
2705 generating_concat_p
= 0;
2707 /* When processing delayed functions, prepare_function_start() won't
2708 have been run to re-initialize it. */
2709 cse_not_expected
= ! optimize
;
2711 /* First, make sure that NOTE_BLOCK is set correctly for each
2712 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2713 if (!cfun
->x_whole_function_mode_p
)
2716 /* Then remove any notes we don't need. That will make iterating
2717 over the instruction sequence faster, and allow the garbage
2718 collector to reclaim the memory used by the notes. */
2719 remove_unnecessary_notes ();
2721 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2722 tree in sensible shape. So, we just recalculate it here. */
2723 if (cfun
->x_whole_function_mode_p
)
2728 /* If we are reconsidering an inline function
2729 at the end of compilation, skip the stuff for making it inline. */
2731 if (DECL_SAVED_INSNS (decl
) == 0)
2737 /* If this is nested inside an inlined external function, pretend
2738 it was only declared. Since we cannot inline such functions,
2739 generating code for this one is not only not necessary but will
2740 confuse some debugging output writers. */
2741 for (parent
= DECL_CONTEXT (current_function_decl
);
2742 parent
!= NULL_TREE
;
2743 parent
= get_containing_scope (parent
))
2744 if (TREE_CODE (parent
) == FUNCTION_DECL
2745 && DECL_INLINE (parent
) && DECL_EXTERNAL (parent
))
2747 DECL_INITIAL (decl
) = 0;
2748 goto exit_rest_of_compilation
;
2751 /* If requested, consider whether to make this function inline. */
2752 if (DECL_INLINE (decl
) || flag_inline_functions
)
2754 timevar_push (TV_INTEGRATION
);
2755 lose
= function_cannot_inline_p (decl
);
2756 timevar_pop (TV_INTEGRATION
);
2757 if (lose
|| ! optimize
)
2759 if (warn_inline
&& DECL_INLINE (decl
))
2760 warning_with_decl (decl
, lose
);
2761 DECL_ABSTRACT_ORIGIN (decl
) = 0;
2762 /* Don't really compile an extern inline function.
2763 If we can't make it inline, pretend
2764 it was only declared. */
2765 if (DECL_EXTERNAL (decl
))
2767 DECL_INITIAL (decl
) = 0;
2768 goto exit_rest_of_compilation
;
2772 /* ??? Note that this has the effect of making it look
2773 like "inline" was specified for a function if we choose
2774 to inline it. This isn't quite right, but it's
2775 probably not worth the trouble to fix. */
2776 inlinable
= DECL_INLINE (decl
) = 1;
2779 insns
= get_insns ();
2781 /* Dump the rtl code if we are dumping rtl. */
2783 if (open_dump_file (DFI_rtl
, decl
))
2785 if (DECL_SAVED_INSNS (decl
))
2786 fprintf (rtl_dump_file
, ";; (integrable)\n\n");
2787 close_dump_file (DFI_rtl
, print_rtl
, insns
);
2790 /* If function is inline, and we don't yet know whether to
2791 compile it by itself, defer decision till end of compilation.
2792 finish_compilation will call rest_of_compilation again
2793 for those functions that need to be output. Also defer those
2794 functions that we are supposed to defer. */
2797 || (DECL_INLINE (decl
)
2798 && ((! TREE_PUBLIC (decl
) && ! TREE_ADDRESSABLE (decl
)
2799 && ! flag_keep_inline_functions
)
2800 || DECL_EXTERNAL (decl
))))
2801 DECL_DEFER_OUTPUT (decl
) = 1;
2803 if (DECL_INLINE (decl
))
2804 /* DWARF wants seperate debugging info for abstract and
2805 concrete instances of all inline functions, including those
2806 declared inline but not inlined, and those inlined even
2807 though they weren't declared inline. Conveniently, that's
2808 what DECL_INLINE means at this point. */
2809 note_deferral_of_defined_inline_function (decl
);
2811 if (DECL_DEFER_OUTPUT (decl
))
2813 /* If -Wreturn-type, we have to do a bit of compilation. We just
2814 want to call jump_optimize to figure out whether or not we can
2815 fall off the end of the function; we do the minimum amount of
2816 work necessary to make that safe. And, we set optimize to zero
2817 to keep jump_optimize from working too hard. */
2818 if (warn_return_type
)
2820 int saved_optimize
= optimize
;
2823 find_exception_handler_labels ();
2824 jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
2825 !JUMP_AFTER_REGSCAN
);
2826 optimize
= saved_optimize
;
2829 current_function_nothrow
= nothrow_function_p ();
2830 if (current_function_nothrow
)
2831 /* Now we know that this can't throw; set the flag for the benefit
2832 of other functions later in this translation unit. */
2833 TREE_NOTHROW (current_function_decl
) = 1;
2835 timevar_push (TV_INTEGRATION
);
2836 save_for_inline (decl
);
2837 timevar_pop (TV_INTEGRATION
);
2838 DECL_SAVED_INSNS (decl
)->inlinable
= inlinable
;
2839 goto exit_rest_of_compilation
;
2842 /* If specified extern inline but we aren't inlining it, we are
2843 done. This goes for anything that gets here with DECL_EXTERNAL
2844 set, not just things with DECL_INLINE. */
2845 if (DECL_EXTERNAL (decl
))
2846 goto exit_rest_of_compilation
;
2849 init_EXPR_INSN_LIST_cache ();
2853 /* Initialize some variables used by the optimizers. */
2854 init_function_for_compilation ();
2856 if (! DECL_DEFER_OUTPUT (decl
))
2857 TREE_ASM_WRITTEN (decl
) = 1;
2859 /* Now that integrate will no longer see our rtl, we need not
2860 distinguish between the return value of this function and the
2861 return value of called functions. Also, we can remove all SETs
2862 of subregs of hard registers; they are only here because of
2864 rtx_equal_function_value_matters
= 0;
2865 purge_hard_subreg_sets (get_insns ());
2867 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */
2868 if ((rtl_dump_and_exit
|| flag_syntax_only
) && !warn_return_type
)
2869 goto exit_rest_of_compilation
;
2871 /* Emit code to get eh context, if needed. */
2874 /* We may have potential sibling or tail recursion sites. Select one
2875 (of possibly multiple) methods of performing the call. */
2876 if (flag_optimize_sibling_calls
)
2878 timevar_push (TV_JUMP
);
2879 open_dump_file (DFI_sibling
, decl
);
2881 optimize_sibling_and_tail_recursive_calls ();
2883 close_dump_file (DFI_sibling
, print_rtl
, get_insns ());
2884 timevar_pop (TV_JUMP
);
2888 /* If we are doing position-independent code generation, now
2889 is the time to output special prologues and epilogues.
2890 We do not want to do this earlier, because it just clutters
2891 up inline functions with meaningless insns. */
2896 insns
= get_insns ();
2898 /* Copy any shared structure that should not be shared. */
2899 unshare_all_rtl (current_function_decl
, insns
);
2901 #ifdef SETJMP_VIA_SAVE_AREA
2902 /* This must be performed before virutal register instantiation. */
2903 if (current_function_calls_alloca
)
2904 optimize_save_area_alloca (insns
);
2907 /* Instantiate all virtual registers. */
2908 instantiate_virtual_regs (current_function_decl
, insns
);
2910 /* Find all the EH handlers. */
2911 find_exception_handler_labels ();
2913 open_dump_file (DFI_jump
, decl
);
2915 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2916 are initialized and to compute whether control can drop off the end
2919 timevar_push (TV_JUMP
);
2920 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2921 before jump optimization switches branch directions. */
2922 expected_value_to_br_prob ();
2924 reg_scan (insns
, max_reg_num (), 0);
2925 jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
2926 JUMP_AFTER_REGSCAN
);
2928 timevar_pop (TV_JUMP
);
2930 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2931 if (rtl_dump_and_exit
|| flag_syntax_only
|| DECL_DEFER_OUTPUT (decl
))
2933 close_dump_file (DFI_jump
, print_rtl
, insns
);
2934 goto exit_rest_of_compilation
;
2937 timevar_push (TV_JUMP
);
2941 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
2942 cleanup_cfg (insns
);
2944 /* ??? Run if-conversion before delete_null_pointer_checks,
2945 since the later does not preserve the CFG. This should
2946 be changed -- no since converting if's that are going to
2948 timevar_push (TV_IFCVT
);
2950 timevar_pop (TV_IFCVT
);
2952 /* Try to identify useless null pointer tests and delete them. */
2953 if (flag_delete_null_pointer_checks
)
2954 delete_null_pointer_checks (insns
);
2957 /* Jump optimization, and the removal of NULL pointer checks, may
2958 have reduced the number of instructions substantially. CSE, and
2959 future passes, allocate arrays whose dimensions involve the
2960 maximum instruction UID, so if we can reduce the maximum UID
2961 we'll save big on memory. */
2962 renumber_insns (rtl_dump_file
);
2963 timevar_pop (TV_JUMP
);
2965 close_dump_file (DFI_jump
, print_rtl
, insns
);
2969 /* Perform common subexpression elimination.
2970 Nonzero value from `cse_main' means that jumps were simplified
2971 and some code may now be unreachable, so do
2972 jump optimization again. */
2976 open_dump_file (DFI_cse
, decl
);
2977 timevar_push (TV_CSE
);
2979 reg_scan (insns
, max_reg_num (), 1);
2981 if (flag_thread_jumps
)
2983 timevar_push (TV_JUMP
);
2984 thread_jumps (insns
, max_reg_num (), 1);
2985 timevar_pop (TV_JUMP
);
2988 tem
= cse_main (insns
, max_reg_num (), 0, rtl_dump_file
);
2990 /* If we are not running the second CSE pass, then we are no longer
2991 expecting CSE to be run. */
2992 cse_not_expected
= !flag_rerun_cse_after_loop
;
2994 if (tem
|| optimize
> 1)
2996 timevar_push (TV_JUMP
);
2997 jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
2998 !JUMP_AFTER_REGSCAN
);
2999 timevar_pop (TV_JUMP
);
3002 /* Run this after jump optmizations remove all the unreachable code
3003 so that unreachable code will not keep values live. */
3004 delete_trivially_dead_insns (insns
, max_reg_num ());
3006 /* Try to identify useless null pointer tests and delete them. */
3007 if (flag_delete_null_pointer_checks
)
3009 timevar_push (TV_JUMP
);
3010 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3012 cleanup_cfg (insns
);
3014 delete_null_pointer_checks (insns
);
3015 timevar_pop (TV_JUMP
);
3018 /* The second pass of jump optimization is likely to have
3019 removed a bunch more instructions. */
3020 renumber_insns (rtl_dump_file
);
3022 timevar_pop (TV_CSE
);
3023 close_dump_file (DFI_cse
, print_rtl
, insns
);
3026 open_dump_file (DFI_addressof
, decl
);
3028 purge_addressof (insns
);
3029 reg_scan (insns
, max_reg_num (), 1);
3031 close_dump_file (DFI_addressof
, print_rtl
, insns
);
3035 if (optimize
> 0 && flag_ssa
)
3037 /* Convert to SSA form. */
3039 timevar_push (TV_TO_SSA
);
3040 open_dump_file (DFI_ssa
, decl
);
3042 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3043 cleanup_cfg (insns
);
3046 close_dump_file (DFI_ssa
, print_rtl_with_bb
, insns
);
3047 timevar_pop (TV_TO_SSA
);
3049 /* The SSA implementation uses basic block numbers in its phi
3050 nodes. Thus, changing the control-flow graph or the basic
3051 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3052 may cause problems. */
3056 /* Remove dead code. */
3058 timevar_push (TV_DEAD_CODE_ELIM
);
3059 open_dump_file (DFI_dce
, decl
);
3061 insns
= get_insns ();
3062 eliminate_dead_code();
3064 close_dump_file (DFI_dce
, print_rtl_with_bb
, insns
);
3065 timevar_pop (TV_DEAD_CODE_ELIM
);
3068 /* Convert from SSA form. */
3070 timevar_push (TV_FROM_SSA
);
3071 open_dump_file (DFI_ussa
, decl
);
3073 convert_from_ssa ();
3074 /* New registers have been created. Rescan their usage. */
3075 reg_scan (insns
, max_reg_num (), 1);
3076 /* Life analysis used in SSA adds log_links but these
3077 shouldn't be there until the flow stage, so clear
3079 clear_log_links (insns
);
3081 close_dump_file (DFI_ussa
, print_rtl_with_bb
, insns
);
3082 timevar_pop (TV_FROM_SSA
);
3087 /* Perform global cse. */
3089 if (optimize
> 0 && flag_gcse
)
3091 timevar_push (TV_GCSE
);
3092 open_dump_file (DFI_gcse
, decl
);
3094 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3095 cleanup_cfg (insns
);
3096 tem
= gcse_main (insns
, rtl_dump_file
);
3098 /* If gcse altered any jumps, rerun jump optimizations to clean
3102 timevar_push (TV_JUMP
);
3103 jump_optimize (insns
, !JUMP_CROSS_JUMP
, !JUMP_NOOP_MOVES
,
3104 !JUMP_AFTER_REGSCAN
);
3105 timevar_pop (TV_JUMP
);
3108 close_dump_file (DFI_gcse
, print_rtl
, insns
);
3109 timevar_pop (TV_GCSE
);
3114 /* Move constant computations out of loops. */
3118 timevar_push (TV_LOOP
);
3119 open_dump_file (DFI_loop
, decl
);
3121 if (flag_rerun_loop_opt
)
3123 /* We only want to perform unrolling once. */
3125 loop_optimize (insns
, rtl_dump_file
, 0);
3127 /* The first call to loop_optimize makes some instructions
3128 trivially dead. We delete those instructions now in the
3129 hope that doing so will make the heuristics in loop work
3130 better and possibly speed up compilation. */
3131 delete_trivially_dead_insns (insns
, max_reg_num ());
3133 /* The regscan pass is currently necessary as the alias
3134 analysis code depends on this information. */
3135 reg_scan (insns
, max_reg_num (), 1);
3137 loop_optimize (insns
, rtl_dump_file
,
3138 (flag_unroll_loops
? LOOP_UNROLL
: 0) | LOOP_BCT
);
3140 close_dump_file (DFI_loop
, print_rtl
, insns
);
3141 timevar_pop (TV_LOOP
);
3148 timevar_push (TV_CSE2
);
3149 open_dump_file (DFI_cse2
, decl
);
3151 if (flag_rerun_cse_after_loop
)
3153 /* Running another jump optimization pass before the second
3154 cse pass sometimes simplifies the RTL enough to allow
3155 the second CSE pass to do a better job. Jump_optimize can change
3156 max_reg_num so we must rerun reg_scan afterwards.
3157 ??? Rework to not call reg_scan so often. */
3158 timevar_push (TV_JUMP
);
3160 reg_scan (insns
, max_reg_num (), 0);
3161 jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3162 !JUMP_NOOP_MOVES
, JUMP_AFTER_REGSCAN
);
3164 timevar_push (TV_IFCVT
);
3166 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3167 cleanup_cfg (insns
);
3170 timevar_pop(TV_IFCVT
);
3172 timevar_pop (TV_JUMP
);
3174 reg_scan (insns
, max_reg_num (), 0);
3175 tem
= cse_main (insns
, max_reg_num (), 1, rtl_dump_file
);
3179 timevar_push (TV_JUMP
);
3180 jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3181 !JUMP_NOOP_MOVES
, !JUMP_AFTER_REGSCAN
);
3182 timevar_pop (TV_JUMP
);
3186 if (flag_thread_jumps
)
3188 /* This pass of jump threading straightens out code
3189 that was kinked by loop optimization. */
3190 timevar_push (TV_JUMP
);
3191 reg_scan (insns
, max_reg_num (), 0);
3192 thread_jumps (insns
, max_reg_num (), 0);
3193 timevar_pop (TV_JUMP
);
3196 close_dump_file (DFI_cse2
, print_rtl
, insns
);
3197 timevar_pop (TV_CSE2
);
3202 cse_not_expected
= 1;
3206 /* Do control and data flow analysis; wrote some of the results to
3209 timevar_push (TV_FLOW
);
3210 open_dump_file (DFI_cfg
, decl
);
3212 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3213 cleanup_cfg (insns
);
3214 check_function_return_warnings ();
3216 close_dump_file (DFI_cfg
, print_rtl_with_bb
, insns
);
3218 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
3220 timevar_push (TV_BRANCH_PROB
);
3221 open_dump_file (DFI_bp
, decl
);
3225 close_dump_file (DFI_bp
, print_rtl_with_bb
, insns
);
3226 timevar_pop (TV_BRANCH_PROB
);
3229 open_dump_file (DFI_life
, decl
);
3234 /* Discover and record the loop depth at the head of each basic
3235 block. The loop infrastructure does the real job for us. */
3236 flow_loops_find (&loops
, LOOP_TREE
);
3238 /* Estimate using heuristics if no profiling info is available. */
3239 estimate_probability (&loops
);
3242 flow_loops_dump (&loops
, rtl_dump_file
, NULL
, 0);
3244 flow_loops_free (&loops
);
3246 life_analysis (insns
, rtl_dump_file
, PROP_FINAL
);
3247 mark_constant_function ();
3248 timevar_pop (TV_FLOW
);
3250 register_life_up_to_date
= 1;
3253 if (warn_uninitialized
|| extra_warnings
)
3255 uninitialized_vars_warning (DECL_INITIAL (decl
));
3257 setjmp_args_warning ();
3260 close_dump_file (DFI_life
, print_rtl_with_bb
, insns
);
3264 /* If -opt, try combining insns through substitution. */
3268 int rebuild_jump_labels_after_combine
= 0;
3270 timevar_push (TV_COMBINE
);
3271 open_dump_file (DFI_combine
, decl
);
3273 rebuild_jump_labels_after_combine
3274 = combine_instructions (insns
, max_reg_num ());
3276 /* Combining insns may have turned an indirect jump into a
3277 direct jump. Rebuid the JUMP_LABEL fields of jumping
3279 if (rebuild_jump_labels_after_combine
)
3281 timevar_push (TV_JUMP
);
3282 rebuild_jump_labels (insns
);
3283 timevar_pop (TV_JUMP
);
3285 timevar_push (TV_FLOW
);
3286 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3287 cleanup_cfg (insns
);
3289 /* Blimey. We've got to have the CFG up to date for the call to
3290 if_convert below. However, the random deletion of blocks
3291 without updating life info can wind up with Wierd Stuff in
3292 global_live_at_end. We then run sched1, which updates things
3293 properly, discovers the wierdness and aborts. */
3294 update_life_info (NULL
, UPDATE_LIFE_GLOBAL_RM_NOTES
,
3295 PROP_DEATH_NOTES
| PROP_KILL_DEAD_CODE
3296 | PROP_SCAN_DEAD_CODE
);
3298 timevar_pop (TV_FLOW
);
3301 close_dump_file (DFI_combine
, print_rtl_with_bb
, insns
);
3302 timevar_pop (TV_COMBINE
);
3307 /* Rerun if-conversion, as combine may have simplified things enough to
3308 now meet sequence length restrictions. */
3311 timevar_push (TV_IFCVT
);
3312 open_dump_file (DFI_ce
, decl
);
3318 close_dump_file (DFI_ce
, print_rtl_with_bb
, insns
);
3319 timevar_pop (TV_IFCVT
);
3322 /* Register allocation pre-pass, to reduce number of moves
3323 necessary for two-address machines. */
3324 if (optimize
> 0 && (flag_regmove
|| flag_expensive_optimizations
))
3326 timevar_push (TV_REGMOVE
);
3327 open_dump_file (DFI_regmove
, decl
);
3329 regmove_optimize (insns
, max_reg_num (), rtl_dump_file
);
3331 close_dump_file (DFI_regmove
, print_rtl_with_bb
, insns
);
3332 timevar_pop (TV_REGMOVE
);
3337 /* Any of the several passes since flow1 will have munged register
3338 lifetime data a bit. */
3340 register_life_up_to_date
= 0;
3342 #ifdef OPTIMIZE_MODE_SWITCHING
3345 timevar_push (TV_GCSE
);
3347 if (optimize_mode_switching (NULL_PTR
))
3349 /* We did work, and so had to regenerate global life information.
3350 Take advantage of this and don't re-recompute register life
3351 information below. */
3352 register_life_up_to_date
= 1;
3355 timevar_pop (TV_GCSE
);
3359 #ifdef INSN_SCHEDULING
3361 /* Print function header into sched dump now
3362 because doing the sched analysis makes some of the dump. */
3363 if (optimize
> 0 && flag_schedule_insns
)
3365 timevar_push (TV_SCHED
);
3366 open_dump_file (DFI_sched
, decl
);
3368 /* Do control and data sched analysis,
3369 and write some of the results to dump file. */
3371 schedule_insns (rtl_dump_file
);
3373 close_dump_file (DFI_sched
, print_rtl_with_bb
, insns
);
3374 timevar_pop (TV_SCHED
);
3378 /* Register lifetime information was updated as part of verifying
3380 register_life_up_to_date
= 1;
3384 /* Determine if the current function is a leaf before running reload
3385 since this can impact optimizations done by the prologue and
3386 epilogue thus changing register elimination offsets. */
3387 current_function_is_leaf
= leaf_function_p ();
3389 timevar_push (TV_LOCAL_ALLOC
);
3390 open_dump_file (DFI_lreg
, decl
);
3392 /* Allocate pseudo-regs that are used only within 1 basic block.
3394 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3395 jump optimizer after register allocation and reloading are finished. */
3397 if (! register_life_up_to_date
)
3398 recompute_reg_usage (insns
, ! optimize_size
);
3399 regclass (insns
, max_reg_num (), rtl_dump_file
);
3400 rebuild_label_notes_after_reload
= local_alloc ();
3402 timevar_pop (TV_LOCAL_ALLOC
);
3404 if (dump_file
[DFI_lreg
].enabled
)
3406 timevar_push (TV_DUMP
);
3408 dump_flow_info (rtl_dump_file
);
3409 dump_local_alloc (rtl_dump_file
);
3411 close_dump_file (DFI_lreg
, print_rtl_with_bb
, insns
);
3412 timevar_pop (TV_DUMP
);
3417 timevar_push (TV_GLOBAL_ALLOC
);
3418 open_dump_file (DFI_greg
, decl
);
3420 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3421 pass fixing up any insns that are invalid. */
3424 failure
= global_alloc (rtl_dump_file
);
3427 build_insn_chain (insns
);
3428 failure
= reload (insns
, 0);
3431 timevar_pop (TV_GLOBAL_ALLOC
);
3433 if (dump_file
[DFI_greg
].enabled
)
3435 timevar_push (TV_DUMP
);
3437 dump_global_regs (rtl_dump_file
);
3439 close_dump_file (DFI_greg
, print_rtl_with_bb
, insns
);
3440 timevar_pop (TV_DUMP
);
3444 goto exit_rest_of_compilation
;
3448 open_dump_file (DFI_postreload
, decl
);
3450 /* Do a very simple CSE pass over just the hard registers. */
3453 timevar_push (TV_RELOAD_CSE_REGS
);
3454 reload_cse_regs (insns
);
3455 timevar_pop (TV_RELOAD_CSE_REGS
);
3458 /* If optimizing, then go ahead and split insns now since we are about
3459 to recompute flow information anyway. */
3462 int old_labelnum
= max_label_num ();
3464 split_all_insns (0);
3465 rebuild_label_notes_after_reload
|= old_labelnum
!= max_label_num ();
3468 /* Register allocation and reloading may have turned an indirect jump into
3469 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3470 jumping instructions. */
3471 if (rebuild_label_notes_after_reload
)
3473 timevar_push (TV_JUMP
);
3475 rebuild_jump_labels (insns
);
3477 timevar_pop (TV_JUMP
);
3480 close_dump_file (DFI_postreload
, print_rtl_with_bb
, insns
);
3482 /* Re-create the death notes which were deleted during reload. */
3483 timevar_push (TV_FLOW2
);
3484 open_dump_file (DFI_flow2
, decl
);
3486 jump_optimize (insns
, !JUMP_CROSS_JUMP
,
3487 JUMP_NOOP_MOVES
, !JUMP_AFTER_REGSCAN
);
3488 find_basic_blocks (insns
, max_reg_num (), rtl_dump_file
);
3490 /* On some machines, the prologue and epilogue code, or parts thereof,
3491 can be represented as RTL. Doing so lets us schedule insns between
3492 it and the rest of the code and also allows delayed branch
3493 scheduling to operate in the epilogue. */
3494 thread_prologue_and_epilogue_insns (insns
);
3498 cleanup_cfg (insns
);
3499 life_analysis (insns
, rtl_dump_file
, PROP_FINAL
);
3501 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3502 even for machines with possibly nonzero RETURN_POPS_ARGS
3503 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3504 push instructions will have popping returns. */
3505 #ifndef PUSH_ROUNDING
3506 if (!ACCUMULATE_OUTGOING_ARGS
)
3508 combine_stack_adjustments ();
3513 flow2_completed
= 1;
3515 close_dump_file (DFI_flow2
, print_rtl_with_bb
, insns
);
3516 timevar_pop (TV_FLOW2
);
3518 #ifdef HAVE_peephole2
3519 if (optimize
> 0 && flag_peephole2
)
3521 timevar_push (TV_PEEPHOLE2
);
3522 open_dump_file (DFI_peephole2
, decl
);
3524 peephole2_optimize (rtl_dump_file
);
3526 close_dump_file (DFI_peephole2
, print_rtl_with_bb
, insns
);
3527 timevar_pop (TV_PEEPHOLE2
);
3531 if (optimize
> 0 && flag_rename_registers
)
3533 timevar_push (TV_RENAME_REGISTERS
);
3534 open_dump_file (DFI_rnreg
, decl
);
3536 regrename_optimize ();
3538 close_dump_file (DFI_rnreg
, print_rtl_with_bb
, insns
);
3539 timevar_pop (TV_RENAME_REGISTERS
);
3544 timevar_push (TV_IFCVT2
);
3545 open_dump_file (DFI_ce2
, decl
);
3549 close_dump_file (DFI_ce2
, print_rtl_with_bb
, insns
);
3550 timevar_pop (TV_IFCVT2
);
3553 #ifdef INSN_SCHEDULING
3554 if (optimize
> 0 && flag_schedule_insns_after_reload
)
3556 timevar_push (TV_SCHED2
);
3557 open_dump_file (DFI_sched2
, decl
);
3559 /* Do control and data sched analysis again,
3560 and write some more of the results to dump file. */
3562 schedule_insns (rtl_dump_file
);
3564 close_dump_file (DFI_sched2
, print_rtl_with_bb
, insns
);
3565 timevar_pop (TV_SCHED2
);
3571 #ifdef LEAF_REGISTERS
3572 current_function_uses_only_leaf_regs
3573 = optimize
> 0 && only_leaf_regs_used () && leaf_function_p ();
3576 if (optimize
> 0 && flag_reorder_blocks
)
3578 timevar_push (TV_REORDER_BLOCKS
);
3579 open_dump_file (DFI_bbro
, decl
);
3581 reorder_basic_blocks ();
3583 close_dump_file (DFI_bbro
, print_rtl_with_bb
, insns
);
3584 timevar_pop (TV_REORDER_BLOCKS
);
3587 /* One more attempt to remove jumps to .+1 left by dead-store elimination.
3588 Also do cross-jumping this time and delete no-op move insns. */
3592 timevar_push (TV_JUMP
);
3593 open_dump_file (DFI_jump2
, decl
);
3595 jump_optimize (insns
, JUMP_CROSS_JUMP
, JUMP_NOOP_MOVES
,
3596 !JUMP_AFTER_REGSCAN
);
3598 /* CFG no longer kept up to date. */
3600 close_dump_file (DFI_jump2
, print_rtl_with_bb
, insns
);
3601 timevar_pop (TV_JUMP
);
3604 /* If a machine dependent reorganization is needed, call it. */
3605 #ifdef MACHINE_DEPENDENT_REORG
3606 open_dump_file (DFI_mach
, decl
);
3608 MACHINE_DEPENDENT_REORG (insns
);
3610 close_dump_file (DFI_mach
, print_rtl_with_bb
, insns
);
3615 /* If a scheduling pass for delayed branches is to be done,
3616 call the scheduling code. */
3619 if (optimize
> 0 && flag_delayed_branch
)
3621 timevar_push (TV_DBR_SCHED
);
3622 open_dump_file (DFI_dbr
, decl
);
3624 dbr_schedule (insns
, rtl_dump_file
);
3626 close_dump_file (DFI_dbr
, print_rtl_with_bb
, insns
);
3627 timevar_pop (TV_DBR_SCHED
);
3633 /* Shorten branches.
3635 Note this must run before reg-stack because of death note (ab)use
3636 in the ia32 backend. */
3637 timevar_push (TV_SHORTEN_BRANCH
);
3638 shorten_branches (get_insns ());
3639 timevar_pop (TV_SHORTEN_BRANCH
);
3642 timevar_push (TV_REG_STACK
);
3643 open_dump_file (DFI_stack
, decl
);
3645 reg_to_stack (insns
, rtl_dump_file
);
3647 close_dump_file (DFI_stack
, print_rtl_with_bb
, insns
);
3648 timevar_pop (TV_REG_STACK
);
3653 current_function_nothrow
= nothrow_function_p ();
3654 if (current_function_nothrow
)
3655 /* Now we know that this can't throw; set the flag for the benefit
3656 of other functions later in this translation unit. */
3657 TREE_NOTHROW (current_function_decl
) = 1;
3659 /* Now turn the rtl into assembler code. */
3661 timevar_push (TV_FINAL
);
3666 /* Get the function's name, as described by its RTL. This may be
3667 different from the DECL_NAME name used in the source file. */
3669 x
= DECL_RTL (decl
);
3670 if (GET_CODE (x
) != MEM
)
3673 if (GET_CODE (x
) != SYMBOL_REF
)
3675 fnname
= XSTR (x
, 0);
3677 assemble_start_function (decl
, fnname
);
3678 final_start_function (insns
, asm_out_file
, optimize
);
3679 final (insns
, asm_out_file
, optimize
, 0);
3680 final_end_function (insns
, asm_out_file
, optimize
);
3681 assemble_end_function (decl
, fnname
);
3683 fflush (asm_out_file
);
3685 /* Release all memory allocated by flow. */
3686 free_basic_block_vars (0);
3688 /* Release all memory held by regsets now. */
3689 regset_release_memory ();
3691 timevar_pop (TV_FINAL
);
3695 /* Write DBX symbols if requested. */
3697 /* Note that for those inline functions where we don't initially
3698 know for certain that we will be generating an out-of-line copy,
3699 the first invocation of this routine (rest_of_compilation) will
3700 skip over this code by doing a `goto exit_rest_of_compilation;'.
3701 Later on, finish_compilation will call rest_of_compilation again
3702 for those inline functions that need to have out-of-line copies
3703 generated. During that call, we *will* be routed past here. */
3705 timevar_push (TV_SYMOUT
);
3706 #ifdef DBX_DEBUGGING_INFO
3707 if (write_symbols
== DBX_DEBUG
)
3708 dbxout_function (decl
);
3711 #ifdef DWARF_DEBUGGING_INFO
3712 if (write_symbols
== DWARF_DEBUG
)
3713 dwarfout_file_scope_decl (decl
, 0);
3716 #ifdef DWARF2_DEBUGGING_INFO
3717 if (write_symbols
== DWARF2_DEBUG
)
3718 dwarf2out_decl (decl
);
3720 timevar_pop (TV_SYMOUT
);
3722 exit_rest_of_compilation
:
3724 /* In case the function was not output,
3725 don't leave any temporary anonymous types
3726 queued up for sdb output. */
3727 #ifdef SDB_DEBUGGING_INFO
3728 if (write_symbols
== SDB_DEBUG
)
3729 sdbout_types (NULL_TREE
);
3732 reload_completed
= 0;
3733 flow2_completed
= 0;
3736 timevar_push (TV_FINAL
);
3738 /* Clear out the insn_length contents now that they are no
3740 init_insn_lengths ();
3742 /* Clear out the real_constant_chain before some of the rtx's
3743 it runs through become garbage. */
3744 clear_const_double_mem ();
3746 /* Show no temporary slots allocated. */
3749 free_basic_block_vars (0);
3751 timevar_pop (TV_FINAL
);
3753 /* Make sure volatile mem refs aren't considered valid operands for
3754 arithmetic insns. We must call this here if this is a nested inline
3755 function, since the above code leaves us in the init_recog state
3756 (from final.c), and the function context push/pop code does not
3757 save/restore volatile_ok.
3759 ??? Maybe it isn't necessary for expand_start_function to call this
3760 anymore if we do it here? */
3762 init_recog_no_volatile ();
3764 /* We're done with this function. Free up memory if we can. */
3765 free_after_parsing (cfun
);
3766 if (! DECL_DEFER_OUTPUT (decl
))
3767 free_after_compilation (cfun
);
3772 timevar_pop (TV_REST_OF_COMPILATION
);
3783 printf (_("Usage: %s input [switches]\n"), progname
);
3784 printf (_("Switches:\n"));
3786 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3787 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3788 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3789 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3790 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3791 printf (_(" -fdiagnostics-show-location=[once | every-line] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
3793 for (i
= ARRAY_SIZE (f_options
); i
--;)
3795 const char *description
= f_options
[i
].description
;
3797 if (description
!= NULL
&& * description
!= 0)
3798 printf (" -f%-21s %s\n",
3799 f_options
[i
].string
, description
);
3802 printf (_(" -O[number] Set optimisation level to [number]\n"));
3803 printf (_(" -Os Optimise for space rather than speed\n"));
3804 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3805 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3806 printf (_(" -w Suppress warnings\n"));
3807 printf (_(" -W Enable extra warnings\n"));
3809 for (i
= ARRAY_SIZE (W_options
); i
--;)
3811 const char *description
= W_options
[i
].description
;
3813 if (description
!= NULL
&& * description
!= 0)
3814 printf (" -W%-21s %s\n",
3815 W_options
[i
].string
, description
);
3818 printf (_(" -Wunused Enable unused warnings\n"));
3819 printf (_(" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"));
3820 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3821 printf (_(" -p Enable function profiling\n"));
3822 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3823 printf (_(" -a Enable block profiling \n"));
3825 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3826 printf (_(" -ax Enable jump profiling \n"));
3828 printf (_(" -o <file> Place output into <file> \n"));
3830 -G <number> Put global and static data smaller than <number>\n\
3831 bytes into a special section (on some targets)\n"));
3833 for (i
= ARRAY_SIZE (debug_args
); i
--;)
3835 if (debug_args
[i
].description
!= NULL
)
3836 printf (" -g%-21s %s\n",
3837 debug_args
[i
].arg
, debug_args
[i
].description
);
3840 printf (_(" -aux-info <file> Emit declaration info into <file>.X\n"));
3841 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3842 printf (_(" -version Display the compiler's version\n"));
3843 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3844 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3845 #if defined INSN_SCHEDULING
3846 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3848 printf (_(" --help Display this information\n"));
3853 /* Display descriptions of language specific options.
3854 If there is no description, note that there is an undocumented option.
3855 If the description is empty, do not display anything. (This allows
3856 options to be deliberately undocumented, for whatever reason).
3857 If the option string is missing, then this is a marker, indicating
3858 that the description string is in fact the name of a language, whose
3859 language specific options are to follow. */
3861 if (ARRAY_SIZE (documented_lang_options
) > 1)
3863 printf (_("\nLanguage specific options:\n"));
3865 for (i
= 0; i
< ARRAY_SIZE (documented_lang_options
); i
++)
3867 const char *description
= documented_lang_options
[i
].description
;
3868 const char *option
= documented_lang_options
[i
].option
;
3870 if (description
== NULL
)
3875 printf (_(" %-23.23s [undocumented]\n"), option
);
3877 else if (*description
== 0)
3879 else if (option
== NULL
)
3883 (_("\nThere are undocumented %s specific options as well.\n"),
3887 printf (_("\n Options for %s:\n"), description
);
3892 printf (" %-23.23s %s\n", option
, description
);
3897 printf (_("\nThere are undocumented %s specific options as well.\n"),
3900 display_target_options ();
3904 display_target_options ()
3908 if (ARRAY_SIZE (target_switches
) > 1
3909 #ifdef TARGET_OPTIONS
3910 || ARRAY_SIZE (target_options
) > 1
3918 printf (_("\nTarget specific options:\n"));
3920 for (i
= ARRAY_SIZE (target_switches
); i
--;)
3922 const char *option
= target_switches
[i
].name
;
3923 const char *description
= target_switches
[i
].description
;
3925 if (option
== NULL
|| *option
== 0)
3927 else if (description
== NULL
)
3932 printf (_(" -m%-23.23s [undocumented]\n"), option
);
3934 else if (* description
!= 0)
3935 doc
+= printf (" -m%-23.23s %s\n", option
, description
);
3938 #ifdef TARGET_OPTIONS
3939 for (i
= ARRAY_SIZE (target_options
); i
--;)
3941 const char *option
= target_options
[i
].prefix
;
3942 const char *description
= target_options
[i
].description
;
3944 if (option
== NULL
|| *option
== 0)
3946 else if (description
== NULL
)
3951 printf (_(" -m%-23.23s [undocumented]\n"), option
);
3953 else if (* description
!= 0)
3954 doc
+= printf (" -m%-23.23s %s\n", option
, description
);
3960 printf (_("\nThere are undocumented target specific options as well.\n"));
3962 printf (_(" They exist, but they are not documented.\n"));
3967 /* Parse a -d... comand line switch. */
3970 decode_d_option (arg
)
3979 for (i
= 0; i
< DFI_MAX
; ++i
)
3980 dump_file
[i
].enabled
= 1;
3989 flag_print_asm_name
= 1;
3992 flag_dump_rtl_in_asm
= 1;
3993 flag_print_asm_name
= 1;
3996 graph_dump_format
= vcg
;
3999 rtl_dump_and_exit
= 1;
4004 case 'D': /* These are handled by the preprocessor. */
4010 for (i
= 0; i
< DFI_MAX
; ++i
)
4011 if (c
== dump_file
[i
].debug_switch
)
4013 dump_file
[i
].enabled
= 1;
4018 warning ("unrecognized gcc debugging option: %c", c
);
4023 /* Parse a -f... comand line switch. ARG is the value after the -f.
4024 It is safe to access 'ARG - 2' to generate the full switch name.
4025 Return the number of strings consumed. */
4028 decode_f_option (arg
)
4032 const char *option_value
= NULL
;
4034 /* Search for the option in the table of binary f options. */
4035 for (j
= ARRAY_SIZE (f_options
); j
--;)
4037 if (!strcmp (arg
, f_options
[j
].string
))
4039 *f_options
[j
].variable
= f_options
[j
].on_value
;
4043 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-'
4044 && ! strcmp (arg
+ 3, f_options
[j
].string
))
4046 *f_options
[j
].variable
= ! f_options
[j
].on_value
;
4051 if ((option_value
= skip_leading_substring (arg
, "inline-limit-"))
4052 || (option_value
= skip_leading_substring (arg
, "inline-limit=")))
4054 read_integral_parameter (option_value
, arg
- 2, inline_max_insns
);
4055 #ifdef INSN_SCHEDULING
4056 else if ((option_value
= skip_leading_substring (arg
, "sched-verbose=")))
4057 fix_sched_param ("verbose", option_value
);
4059 else if ((option_value
= skip_leading_substring (arg
, "fixed-")))
4060 fix_register (option_value
, 1, 1);
4061 else if ((option_value
= skip_leading_substring (arg
, "call-used-")))
4062 fix_register (option_value
, 0, 1);
4063 else if ((option_value
= skip_leading_substring (arg
, "call-saved-")))
4064 fix_register (option_value
, 0, 0);
4065 else if ((option_value
= skip_leading_substring (arg
, "align-loops=")))
4066 align_loops
= read_integral_parameter (option_value
, arg
- 2, align_loops
);
4067 else if ((option_value
= skip_leading_substring (arg
, "align-functions=")))
4069 = read_integral_parameter (option_value
, arg
- 2, align_functions
);
4070 else if ((option_value
= skip_leading_substring (arg
, "align-jumps=")))
4071 align_jumps
= read_integral_parameter (option_value
, arg
- 2, align_jumps
);
4072 else if ((option_value
= skip_leading_substring (arg
, "align-labels=")))
4074 = read_integral_parameter (option_value
, arg
- 2, align_labels
);
4075 else if ((option_value
4076 = skip_leading_substring (arg
, "stack-limit-register=")))
4078 int reg
= decode_reg_name (option_value
);
4080 error ("unrecognized register name `%s'", option_value
);
4082 stack_limit_rtx
= gen_rtx_REG (Pmode
, reg
);
4084 else if ((option_value
4085 = skip_leading_substring (arg
, "stack-limit-symbol=")))
4088 nm
= ggc_strdup (option_value
);
4089 stack_limit_rtx
= gen_rtx_SYMBOL_REF (Pmode
, nm
);
4091 else if ((option_value
4092 = skip_leading_substring (arg
, "message-length=")))
4093 diagnostic_message_length_per_line
=
4094 read_integral_parameter (option_value
, arg
- 2,
4095 diagnostic_message_length_per_line
);
4096 else if ((option_value
4097 = skip_leading_substring (arg
, "diagnostics-show-location=")))
4099 if (!strcmp (option_value
, "once"))
4100 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE
);
4101 else if (!strcmp (option_value
, "every-line"))
4102 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
);
4104 error ("Unrecognized option `%s'", arg
- 2);
4106 else if (!strcmp (arg
, "no-stack-limit"))
4107 stack_limit_rtx
= NULL_RTX
;
4108 else if (!strcmp (arg
, "preprocessed"))
4109 /* Recognise this switch but do nothing. This prevents warnings
4110 about an unrecognized switch if cpplib has not been linked in. */
4118 /* Parse a -W... comand line switch. ARG is the value after the -W.
4119 It is safe to access 'ARG - 2' to generate the full switch name.
4120 Return the number of strings consumed. */
4123 decode_W_option (arg
)
4126 const char *option_value
= NULL
;
4129 /* Search for the option in the table of binary W options. */
4131 for (j
= ARRAY_SIZE (W_options
); j
--;)
4133 if (!strcmp (arg
, W_options
[j
].string
))
4135 *W_options
[j
].variable
= W_options
[j
].on_value
;
4139 if (arg
[0] == 'n' && arg
[1] == 'o' && arg
[2] == '-'
4140 && ! strcmp (arg
+ 3, W_options
[j
].string
))
4142 *W_options
[j
].variable
= ! W_options
[j
].on_value
;
4147 if ((option_value
= skip_leading_substring (arg
, "id-clash-")))
4149 id_clash_len
= read_integral_parameter (option_value
, arg
- 2, -1);
4151 if (id_clash_len
!= -1)
4154 else if ((option_value
= skip_leading_substring (arg
, "larger-than-")))
4156 larger_than_size
= read_integral_parameter (option_value
, arg
- 2, -1);
4158 if (larger_than_size
!= -1)
4159 warn_larger_than
= 1;
4161 else if (!strcmp (arg
, "unused"))
4165 else if (!strcmp (arg
, "no-unused"))
4175 /* Parse a -g... comand line switch. ARG is the value after the -g.
4176 It is safe to access 'ARG - 2' to generate the full switch name.
4177 Return the number of strings consumed. */
4180 decode_g_option (arg
)
4184 /* A lot of code assumes write_symbols == NO_DEBUG if the
4185 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4186 of what debugging type has been selected). This records the
4187 selected type. It is an error to specify more than one
4189 static enum debug_info_type selected_debug_type
= NO_DEBUG
;
4190 /* Non-zero if debugging format has been explicitly set.
4191 -g and -ggdb don't explicitly set the debugging format so
4192 -gdwarf -g3 is equivalent to -gdwarf3. */
4193 static int type_explicitly_set_p
= 0;
4194 /* Indexed by enum debug_info_type. */
4195 static const char *debug_type_names
[] =
4197 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4200 /* The maximum admissible debug level value. */
4201 static const unsigned max_debug_level
= 3;
4203 /* Look up ARG in the table. */
4204 for (da
= debug_args
; da
->arg
; da
++)
4206 const int da_len
= strlen (da
->arg
);
4208 if (da_len
== 0 || ! strncmp (arg
, da
->arg
, da_len
))
4210 enum debug_info_type type
= da
->debug_type
;
4211 const char *p
= arg
+ da_len
;
4213 if (*p
&& (*p
< '0' || *p
> '9'))
4216 /* A debug flag without a level defaults to level 2.
4217 Note we do not want to call read_integral_parameter
4218 for that case since it will call atoi which
4221 ??? We may want to generalize the interface to
4222 read_integral_parameter to better handle this case
4223 if this case shows up often. */
4225 level
= read_integral_parameter (p
, 0, max_debug_level
+ 1);
4229 if (da_len
> 1 && *p
&& !strncmp (arg
, "dwarf", da_len
))
4231 error ("use -gdwarf -g%d for DWARF v1, level %d",
4234 error ("use -gdwarf-2 for DWARF v2");
4237 if (level
> max_debug_level
)
4240 ignoring option `%s' due to invalid debug level specification",
4242 level
= debug_info_level
;
4245 if (type
== NO_DEBUG
)
4247 type
= PREFERRED_DEBUGGING_TYPE
;
4249 if (da_len
> 1 && strncmp (arg
, "gdb", da_len
) == 0)
4251 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4252 type
= DWARF2_DEBUG
;
4254 #ifdef DBX_DEBUGGING_INFO
4261 if (type
== NO_DEBUG
)
4262 warning ("`%s': unknown or unsupported -g option", arg
- 2);
4264 /* Does it conflict with an already selected type? */
4265 if (type_explicitly_set_p
4266 /* -g/-ggdb don't conflict with anything. */
4267 && da
->debug_type
!= NO_DEBUG
4268 && type
!= selected_debug_type
)
4269 warning ("`%s' ignored, conflicts with `-g%s'",
4270 arg
- 2, debug_type_names
[(int) selected_debug_type
]);
4273 /* If the format has already been set, -g/-ggdb
4274 only change the debug level. */
4275 if (type_explicitly_set_p
&& da
->debug_type
== NO_DEBUG
)
4276 /* Don't change debugging type. */
4280 selected_debug_type
= type
;
4281 type_explicitly_set_p
= da
->debug_type
!= NO_DEBUG
;
4284 write_symbols
= (level
== 0
4286 : selected_debug_type
);
4287 use_gnu_debug_info_extensions
= da
->use_extensions_p
;
4288 debug_info_level
= (enum debug_info_level
) level
;
4301 /* Decode the first argument in the argv as a language-independent option.
4302 Return the number of strings consumed. */
4305 independent_decode_option (argc
, argv
)
4309 char *arg
= argv
[0];
4311 if (arg
[0] != '-' || arg
[1] == 0)
4323 if (!strcmp (arg
, "-help"))
4329 if (!strcmp (arg
, "-target-help"))
4331 display_target_options ();
4344 /* Already been treated in main (). Do nothing. */
4348 set_target_switch (arg
+ 1);
4352 return decode_f_option (arg
+ 1);
4355 return decode_g_option (arg
+ 1);
4358 if (!strcmp (arg
, "dumpbase"))
4363 dump_base_name
= argv
[1];
4367 decode_d_option (arg
+ 1);
4371 if (!strcmp (arg
, "pedantic"))
4373 else if (!strcmp (arg
, "pedantic-errors"))
4374 flag_pedantic_errors
= pedantic
= 1;
4375 else if (arg
[1] == 0)
4382 if (!strcmp (arg
, "quiet"))
4389 if (!strcmp (arg
, "version"))
4397 inhibit_warnings
= 1;
4406 /* We save the value of warn_uninitialized, since if they put
4407 -Wuninitialized on the command line, we need to generate a
4408 warning about not using it without also specifying -O. */
4409 if (warn_uninitialized
!= 1)
4410 warn_uninitialized
= 2;
4413 return decode_W_option (arg
+ 1);
4419 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4420 warning ("`-a' option (basic block profile) not supported");
4422 profile_block_flag
= (profile_block_flag
< 2) ? 1 : 3;
4425 else if (!strcmp (arg
, "ax"))
4427 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4428 warning ("`-ax' option (jump profiling) not supported");
4430 profile_block_flag
= (!profile_block_flag
4431 || profile_block_flag
== 2) ? 2 : 3;
4434 else if (!strncmp (arg
, "aux-info", 8))
4436 flag_gen_aux_info
= 1;
4442 aux_info_file_name
= argv
[1];
4446 aux_info_file_name
= arg
+ 8;
4458 asm_file_name
= argv
[1];
4473 g_switch_val
= read_integral_parameter (argv
[1], 0, -1);
4478 g_switch_val
= read_integral_parameter (arg
+ 1, 0, -1);
4482 if (g_switch_val
== -1)
4486 g_switch_set
= TRUE
;
4487 g_switch_value
= g_switch_val
;
4497 /* Entry point of cc1/c++. Decode command args, then call compile_file.
4498 Exit code is 35 if can't open files, 34 if fatal error,
4499 33 if had nonfatal errors, else success. */
4501 extern int main
PARAMS ((int, char **));
4511 /* save in case md file wants to emit args as a comment. */
4515 p
= argv
[0] + strlen (argv
[0]);
4516 while (p
!= argv
[0] && !IS_DIR_SEPARATOR (p
[-1]))
4520 #ifdef HAVE_LC_MESSAGES
4521 setlocale (LC_MESSAGES
, "");
4523 (void) bindtextdomain (PACKAGE
, localedir
);
4524 (void) textdomain (PACKAGE
);
4526 /* Install handler for SIGFPE, which may be received while we do
4527 compile-time floating point arithmetic. */
4528 signal (SIGFPE
, float_signal
);
4530 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4532 signal (SIGSEGV
, crash_signal
);
4535 signal (SIGILL
, crash_signal
);
4538 signal (SIGBUS
, crash_signal
);
4541 signal (SIGABRT
, crash_signal
);
4543 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4544 signal (SIGIOT
, crash_signal
);
4547 decl_printable_name
= decl_name
;
4548 lang_expand_expr
= (lang_expand_expr_t
) do_abort
;
4550 /* Initialize whether `char' is signed. */
4551 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
4552 #ifdef DEFAULT_SHORT_ENUMS
4553 /* Initialize how much space enums occupy, by default. */
4554 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
4557 /* Initialize the garbage-collector. */
4559 ggc_add_root (&input_file_stack
, 1, sizeof input_file_stack
,
4561 ggc_add_rtx_root (&stack_limit_rtx
, 1);
4562 ggc_add_tree_root (¤t_function_decl
, 1);
4563 ggc_add_tree_root (¤t_function_func_begin_label
, 1);
4565 /* Initialize the diagnostics reporting machinery. */
4566 initialize_diagnostics ();
4568 /* Perform language-specific options intialization. */
4569 lang_init_options ();
4571 /* Scan to see what optimization level has been specified. That will
4572 determine the default value of many flags. */
4573 for (i
= 1; i
< argc
; i
++)
4575 if (!strcmp (argv
[i
], "-O"))
4580 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
4582 /* Handle -Os, -O2, -O3, -O69, ... */
4583 char *p
= &argv
[i
][2];
4585 if ((p
[0] == 's') && (p
[1] == 0))
4589 /* Optimizing for size forces optimize to be 2. */
4594 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
4595 if (optimize_val
!= -1)
4597 optimize
= optimize_val
;
4607 flag_thread_jumps
= 1;
4609 flag_delayed_branch
= 1;
4611 #ifdef CAN_DEBUG_WITHOUT_FP
4612 flag_omit_frame_pointer
= 1;
4618 flag_optimize_sibling_calls
= 1;
4619 flag_cse_follow_jumps
= 1;
4620 flag_cse_skip_blocks
= 1;
4622 flag_expensive_optimizations
= 1;
4623 flag_strength_reduce
= 1;
4624 flag_rerun_cse_after_loop
= 1;
4625 flag_rerun_loop_opt
= 1;
4626 flag_caller_saves
= 1;
4629 #ifdef INSN_SCHEDULING
4630 flag_schedule_insns
= 1;
4631 flag_schedule_insns_after_reload
= 1;
4634 flag_strict_aliasing
= 1;
4635 flag_delete_null_pointer_checks
= 1;
4636 flag_reorder_blocks
= 1;
4641 flag_inline_functions
= 1;
4642 flag_rename_registers
= 1;
4645 if (optimize
< 2 || optimize_size
)
4650 align_functions
= 1;
4653 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4656 set_target_switch ("");
4658 /* Unwind tables are always present in an ABI-conformant IA-64
4659 object file, so the default should be ON. */
4660 #ifdef IA64_UNWIND_INFO
4661 flag_unwind_tables
= IA64_UNWIND_INFO
;
4664 #ifdef OPTIMIZATION_OPTIONS
4665 /* Allow default optimizations to be specified on a per-machine basis. */
4666 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
4669 /* Initialize register usage now so switches may override. */
4672 /* Perform normal command line switch decoding. */
4673 for (i
= 1; i
< argc
;)
4675 unsigned int lang_processed
;
4676 unsigned int indep_processed
;
4678 /* Give the language a chance to decode the option for itself. */
4679 lang_processed
= lang_decode_option (argc
- i
, argv
+ i
);
4681 /* Now see if the option also has a language independent meaning.
4682 Some options are both language specific and language independent,
4684 indep_processed
= independent_decode_option (argc
- i
, argv
+ i
);
4686 if (lang_processed
|| indep_processed
)
4687 i
+= MAX (lang_processed
, indep_processed
);
4690 const char *option
= NULL
;
4691 const char *lang
= NULL
;
4694 /* It is possible that the command line switch is not valid for the
4695 current language, but it is valid for another language. In order
4696 to be compatible with previous versions of the compiler (which
4697 did not issue an error message in this case) we check for this
4698 possibility here. If we do find a match, then if extra_warnings
4699 is set we generate a warning message, otherwise we will just
4700 ignore the option. */
4701 for (j
= 0; j
< ARRAY_SIZE (documented_lang_options
); j
++)
4703 option
= documented_lang_options
[j
].option
;
4706 lang
= documented_lang_options
[j
].description
;
4707 else if (! strncmp (argv
[i
], option
, strlen (option
)))
4711 if (j
!= ARRAY_SIZE (documented_lang_options
))
4715 warning ("Ignoring command line option '%s'", argv
[i
]);
4718 ("(It is valid for %s but not the selected language)",
4722 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'g')
4723 warning ("`%s': unknown or unsupported -g option", &argv
[i
][2]);
4725 error ("Unrecognized option `%s'", argv
[i
]);
4731 /* Reflect any language-specific diagnostic option setting. */
4732 reshape_diagnostic_buffer ();
4734 /* Checker uses the frame pointer. */
4735 if (flag_check_memory_usage
)
4736 flag_omit_frame_pointer
= 0;
4740 /* Inlining does not work if not optimizing,
4741 so force it not to be done. */
4745 /* The c_decode_option and lang_decode_option functions set
4746 this to `2' if -Wall is used, so we can avoid giving out
4747 lots of errors for people who don't realize what -Wall does. */
4748 if (warn_uninitialized
== 1)
4749 warning ("-Wuninitialized is not supported without -O");
4752 #ifdef OVERRIDE_OPTIONS
4753 /* Some machines may reject certain combinations of options. */
4757 if (exceptions_via_longjmp
== 2)
4759 #ifdef DWARF2_UNWIND_INFO
4760 exceptions_via_longjmp
= ! DWARF2_UNWIND_INFO
;
4762 #ifdef IA64_UNWIND_INFO
4763 exceptions_via_longjmp
= ! IA64_UNWIND_INFO
;
4765 exceptions_via_longjmp
= 1;
4770 /* Since each function gets its own handler data, we can't support the
4771 new model currently, since it depend on a specific rethrow label
4772 which is declared at the front of the table, and we can only
4773 have one such symbol in a file. */
4774 #ifdef IA64_UNWIND_INFO
4775 flag_new_exceptions
= 0;
4778 /* Set up the align_*_log variables, defaulting them to 1 if they
4779 were still unset. */
4780 if (align_loops
<= 0) align_loops
= 1;
4781 align_loops_log
= floor_log2 (align_loops
* 2 - 1);
4782 if (align_jumps
<= 0) align_jumps
= 1;
4783 align_jumps_log
= floor_log2 (align_jumps
* 2 - 1);
4784 if (align_labels
<= 0) align_labels
= 1;
4785 align_labels_log
= floor_log2 (align_labels
* 2 - 1);
4786 if (align_functions
<= 0) align_functions
= 1;
4787 align_functions_log
= floor_log2 (align_functions
* 2 - 1);
4789 if (profile_block_flag
== 3)
4791 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4792 profile_block_flag
= 2;
4795 /* Unrolling all loops implies that standard loop unrolling must also
4797 if (flag_unroll_all_loops
)
4798 flag_unroll_loops
= 1;
4799 /* Loop unrolling requires that strength_reduction be on also. Silently
4800 turn on strength reduction here if it isn't already on. Also, the loop
4801 unrolling code assumes that cse will be run after loop, so that must
4802 be turned on also. */
4803 if (flag_unroll_loops
)
4805 flag_strength_reduce
= 1;
4806 flag_rerun_cse_after_loop
= 1;
4809 /* Warn about options that are not supported on this machine. */
4810 #ifndef INSN_SCHEDULING
4811 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
4812 warning ("instruction scheduling not supported on this target machine");
4815 if (flag_delayed_branch
)
4816 warning ("this target machine does not have delayed branches");
4819 user_label_prefix
= USER_LABEL_PREFIX
;
4820 if (flag_leading_underscore
!= -1)
4822 /* If the default prefix is more complicated than "" or "_",
4823 issue a warning and ignore this option. */
4824 if (user_label_prefix
[0] == 0 ||
4825 (user_label_prefix
[0] == '_' && user_label_prefix
[1] == 0))
4827 user_label_prefix
= flag_leading_underscore
? "_" : "";
4830 warning ("-f%sleading-underscore not supported on this target machine",
4831 flag_leading_underscore
? "" : "no-");
4834 /* If we are in verbose mode, write out the version and maybe all the
4835 option flags in use. */
4838 print_version (stderr
, "");
4840 print_switch_values (stderr
, 0, MAX_LINE
, "", " ", "\n");
4843 compile_file (filename
);
4845 #if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX)
4848 char *lim
= (char *) sbrk (0);
4850 fnotice (stderr
, "Data size %ld.\n", (long) (lim
- (char *) &environ
));
4855 system ("ps -l 1>&2");
4858 #endif /* not USG */
4861 #endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */
4864 return (FATAL_EXIT_CODE
);
4866 return (FATAL_EXIT_CODE
);
4867 return (SUCCESS_EXIT_CODE
);
4870 /* Decode -m switches. */
4871 /* Decode the switch -mNAME. */
4874 set_target_switch (name
)
4878 int valid_target_option
= 0;
4880 for (j
= 0; j
< ARRAY_SIZE (target_switches
); j
++)
4881 if (!strcmp (target_switches
[j
].name
, name
))
4883 if (target_switches
[j
].value
< 0)
4884 target_flags
&= ~-target_switches
[j
].value
;
4886 target_flags
|= target_switches
[j
].value
;
4887 valid_target_option
= 1;
4890 #ifdef TARGET_OPTIONS
4891 if (!valid_target_option
)
4892 for (j
= 0; j
< ARRAY_SIZE (target_options
); j
++)
4894 int len
= strlen (target_options
[j
].prefix
);
4895 if (!strncmp (target_options
[j
].prefix
, name
, len
))
4897 *target_options
[j
].variable
= name
+ len
;
4898 valid_target_option
= 1;
4903 if (!valid_target_option
)
4904 error ("Invalid option `%s'", name
);
4907 /* Print version information to FILE.
4908 Each line begins with INDENT (for the case where FILE is the
4909 assembler output file). */
4912 print_version (file
, indent
)
4917 #define __VERSION__ "[?]"
4921 "%s%s%s version %s (%s) compiled by GNU C version %s.\n"
4923 "%s%s%s version %s (%s) compiled by CC.\n"
4925 , indent
, *indent
!= 0 ? " " : "",
4926 language_string
, version_string
, TARGET_NAME
, __VERSION__
);
4929 /* Print an option value and return the adjusted position in the line.
4930 ??? We don't handle error returns from fprintf (disk full); presumably
4931 other code will catch a disk full though. */
4934 print_single_switch (file
, pos
, max
, indent
, sep
, term
, type
, name
)
4937 const char *indent
, *sep
, *term
, *type
, *name
;
4939 /* The ultrix fprintf returns 0 on success, so compute the result we want
4940 here since we need it for the following test. */
4941 int len
= strlen (sep
) + strlen (type
) + strlen (name
);
4946 fprintf (file
, "%s", term
);
4951 fprintf (file
, "%s", indent
);
4952 pos
= strlen (indent
);
4954 fprintf (file
, "%s%s%s", sep
, type
, name
);
4959 /* Print active target switches to FILE.
4960 POS is the current cursor position and MAX is the size of a "line".
4961 Each line begins with INDENT and ends with TERM.
4962 Each switch is separated from the next by SEP. */
4965 print_switch_values (file
, pos
, max
, indent
, sep
, term
)
4968 const char *indent
, *sep
, *term
;
4973 /* Print the options as passed. */
4975 pos
= print_single_switch (file
, pos
, max
, indent
, *indent
? " " : "", term
,
4976 _("options passed: "), "");
4978 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
4982 if (strcmp (*p
, "-o") == 0)
4988 if (strcmp (*p
, "-quiet") == 0)
4990 if (strcmp (*p
, "-version") == 0)
4995 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
, *p
, "");
4998 fprintf (file
, "%s", term
);
5000 /* Print the -f and -m options that have been enabled.
5001 We don't handle language specific options but printing argv
5004 pos
= print_single_switch (file
, 0, max
, indent
, *indent
? " " : "", term
,
5005 _("options enabled: "), "");
5007 for (j
= 0; j
< ARRAY_SIZE (f_options
); j
++)
5008 if (*f_options
[j
].variable
== f_options
[j
].on_value
)
5009 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5010 "-f", f_options
[j
].string
);
5012 /* Print target specific options. */
5014 for (j
= 0; j
< ARRAY_SIZE (target_switches
); j
++)
5015 if (target_switches
[j
].name
[0] != '\0'
5016 && target_switches
[j
].value
> 0
5017 && ((target_switches
[j
].value
& target_flags
)
5018 == target_switches
[j
].value
))
5020 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5021 "-m", target_switches
[j
].name
);
5024 #ifdef TARGET_OPTIONS
5025 for (j
= 0; j
< ARRAY_SIZE (target_options
); j
++)
5026 if (*target_options
[j
].variable
!= NULL
)
5029 sprintf (prefix
, "-m%s", target_options
[j
].prefix
);
5030 pos
= print_single_switch (file
, pos
, max
, indent
, sep
, term
,
5031 prefix
, *target_options
[j
].variable
);
5035 fprintf (file
, "%s", term
);
5038 /* Record the beginning of a new source file, named FILENAME. */
5041 debug_start_source_file (filename
)
5042 register const char *filename ATTRIBUTE_UNUSED
;
5044 #ifdef DBX_DEBUGGING_INFO
5045 if (write_symbols
== DBX_DEBUG
)
5046 dbxout_start_new_source_file (filename
);
5048 #ifdef DWARF_DEBUGGING_INFO
5049 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5050 && write_symbols
== DWARF_DEBUG
)
5051 dwarfout_start_new_source_file (filename
);
5052 #endif /* DWARF_DEBUGGING_INFO */
5053 #ifdef DWARF2_DEBUGGING_INFO
5054 if (write_symbols
== DWARF2_DEBUG
)
5055 dwarf2out_start_source_file (filename
);
5056 #endif /* DWARF2_DEBUGGING_INFO */
5057 #ifdef SDB_DEBUGGING_INFO
5058 if (write_symbols
== SDB_DEBUG
)
5059 sdbout_start_new_source_file (filename
);
5063 /* Record the resumption of a source file. LINENO is the line number in
5064 the source file we are returning to. */
5067 debug_end_source_file (lineno
)
5068 register unsigned lineno ATTRIBUTE_UNUSED
;
5070 #ifdef DBX_DEBUGGING_INFO
5071 if (write_symbols
== DBX_DEBUG
)
5072 dbxout_resume_previous_source_file ();
5074 #ifdef DWARF_DEBUGGING_INFO
5075 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5076 && write_symbols
== DWARF_DEBUG
)
5077 dwarfout_resume_previous_source_file (lineno
);
5078 #endif /* DWARF_DEBUGGING_INFO */
5079 #ifdef DWARF2_DEBUGGING_INFO
5080 if (write_symbols
== DWARF2_DEBUG
)
5081 dwarf2out_end_source_file ();
5082 #endif /* DWARF2_DEBUGGING_INFO */
5083 #ifdef SDB_DEBUGGING_INFO
5084 if (write_symbols
== SDB_DEBUG
)
5085 sdbout_resume_previous_source_file ();
5089 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5090 the tail part of the directive line, i.e. the part which is past the
5091 initial whitespace, #, whitespace, directive-name, whitespace part. */
5094 debug_define (lineno
, buffer
)
5095 register unsigned lineno ATTRIBUTE_UNUSED
;
5096 register char *buffer ATTRIBUTE_UNUSED
;
5098 #ifdef DWARF_DEBUGGING_INFO
5099 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5100 && write_symbols
== DWARF_DEBUG
)
5101 dwarfout_define (lineno
, buffer
);
5102 #endif /* DWARF_DEBUGGING_INFO */
5103 #ifdef DWARF2_DEBUGGING_INFO
5104 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5105 && write_symbols
== DWARF2_DEBUG
)
5106 dwarf2out_define (lineno
, buffer
);
5107 #endif /* DWARF2_DEBUGGING_INFO */
5110 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
5111 the tail part of the directive line, i.e. the part which is past the
5112 initial whitespace, #, whitespace, directive-name, whitespace part. */
5115 debug_undef (lineno
, buffer
)
5116 register unsigned lineno ATTRIBUTE_UNUSED
;
5117 register char *buffer ATTRIBUTE_UNUSED
;
5119 #ifdef DWARF_DEBUGGING_INFO
5120 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5121 && write_symbols
== DWARF_DEBUG
)
5122 dwarfout_undef (lineno
, buffer
);
5123 #endif /* DWARF_DEBUGGING_INFO */
5124 #ifdef DWARF2_DEBUGGING_INFO
5125 if (debug_info_level
== DINFO_LEVEL_VERBOSE
5126 && write_symbols
== DWARF2_DEBUG
)
5127 dwarf2out_undef (lineno
, buffer
);
5128 #endif /* DWARF2_DEBUGGING_INFO */
5131 /* Returns nonzero if it is appropriate not to emit any debugging
5132 information for BLOCK, because it doesn't contain any instructions.
5133 This may not be the case for blocks containing nested functions, since
5134 we may actually call such a function even though the BLOCK information
5138 debug_ignore_block (block
)
5139 tree block ATTRIBUTE_UNUSED
;
5141 /* Never delete the BLOCK for the outermost scope
5142 of the function; we can refer to names from
5143 that scope even if the block notes are messed up. */
5144 if (is_body_block (block
))
5147 #ifdef DWARF2_DEBUGGING_INFO
5148 if (write_symbols
== DWARF2_DEBUG
)
5149 return dwarf2out_ignore_block (block
);