1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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-config.h"
49 #include "hard-reg-set.h"
56 #include "basic-block.h"
63 #include "diagnostic.h"
67 #include "dwarf2asm.h"
68 #include "integrate.h"
71 #include "langhooks.h"
73 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
74 #include "dwarf2out.h"
77 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
81 #ifdef SDB_DEBUGGING_INFO
85 #ifdef XCOFF_DEBUGGING_INFO
86 #include "xcoffout.h" /* Needed for external data
87 declarations for e.g. AIX 4.x. */
95 /* The extra parameters substantially improve the I/O performance. */
98 vms_fopen (fname, type)
102 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two
103 fixed arguments, which matches ANSI's specification but not VAXCRTL's
104 pre-ANSI implementation. This hack circumvents the mismatch problem. */
105 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen;
108 return (*vmslib_fopen) (fname, type, "mbc=32",
109 "deq=64", "fop=tef", "shr=nil");
111 return (*vmslib_fopen) (fname, type, "mbc=32");
114 #define fopen vms_fopen
117 #ifndef DEFAULT_GDB_EXTENSIONS
118 #define DEFAULT_GDB_EXTENSIONS 1
121 /* If more than one debugging type is supported, you must define
122 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
124 This is one long line cause VAXC can't handle a \-newline. */
125 #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
126 #ifndef PREFERRED_DEBUGGING_TYPE
127 You Lose! You must define PREFERRED_DEBUGGING_TYPE!
128 #endif /* no PREFERRED_DEBUGGING_TYPE */
129 #else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE
130 so the following code needn't care. */
131 #ifdef DBX_DEBUGGING_INFO
132 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
134 #ifdef SDB_DEBUGGING_INFO
135 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
137 #ifdef DWARF_DEBUGGING_INFO
138 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
140 #ifdef DWARF2_DEBUGGING_INFO
141 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
143 #ifdef XCOFF_DEBUGGING_INFO
144 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
146 #endif /* More than one debugger format enabled. */
148 /* If still not defined, must have been because no debugging formats
150 #ifndef PREFERRED_DEBUGGING_TYPE
151 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
154 #if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
155 extern char **environ;
158 /* Carry information from ASM_DECLARE_OBJECT_NAME
159 to ASM_FINISH_DECLARE_OBJECT. */
161 extern int size_directive_output;
162 extern tree last_assemble_variable_decl;
164 static void set_target_switch PARAMS ((const char *));
165 static const char *decl_name PARAMS ((tree, int));
167 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
168 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
169 static void set_float_handler PARAMS ((jmp_buf));
170 static void compile_file PARAMS ((const char *));
171 static void display_help PARAMS ((void));
172 static void display_target_options PARAMS ((void));
174 static void decode_d_option PARAMS ((const char *));
175 static int decode_f_option PARAMS ((const char *));
176 static int decode_W_option PARAMS ((const char *));
177 static int decode_g_option PARAMS ((const char *));
178 static unsigned int independent_decode_option PARAMS ((int, char **));
180 static void print_version PARAMS ((FILE *, const char *));
181 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
182 const char *, const char *,
183 const char *, const char *));
184 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
185 const char *, const char *));
187 /* Length of line when printing switch values. */
190 /* Name of program invoked, sans directories. */
192 const char *progname;
194 /* Copy of arguments to toplev_main. */
198 /* Name of current original source file (what was input to cpp).
199 This comes from each #-command in the actual input. */
201 const char *input_filename;
203 /* Name of top-level original source file (what was input to cpp).
204 This comes from the #-command at the beginning of the actual input.
205 If there isn't any there, then this is the cc1 input file name. */
207 const char *main_input_filename;
209 /* Current line number in real source file. */
213 /* Nonzero if it is unsafe to create any new pseudo registers. */
216 /* Stack of currently pending input files. */
218 struct file_stack *input_file_stack;
220 /* Incremented on each change to input_file_stack. */
221 int input_file_stack_tick;
223 /* Name to use as base of names for dump output files. */
225 const char *dump_base_name;
227 /* Bit flags that specify the machine subtype we are compiling for.
228 Bits are tested using macros TARGET_... defined in the tm.h file
229 and set by `-m...' switches. Must be defined in rtlanal.c. */
231 extern int target_flags;
233 /* Debug hooks - dependent upon command line options. */
235 struct gcc_debug_hooks *debug_hooks;
237 /* Describes a dump file. */
239 struct dump_file_info
241 /* The unique extension to apply, e.g. ".jump". */
242 const char *const extension;
244 /* The -d<c> character that enables this dump file. */
245 char const debug_switch;
247 /* True if there is a corresponding graph dump file. */
248 char const graph_dump_p;
250 /* True if the user selected this dump. */
253 /* True if the files have been initialized (ie truncated). */
257 /* Enumerate the extant dump files. */
296 /* Describes all the dump files. Should be kept in order of the
297 pass and in sync with dump_file_index above.
299 Remaining -d letters:
305 struct dump_file_info dump_file[DFI_MAX] =
307 { "rtl", 'r', 0, 0, 0 },
308 { "sibling", 'i', 0, 0, 0 },
309 { "eh", 'h', 0, 0, 0 },
310 { "jump", 'j', 0, 0, 0 },
311 { "ssa", 'e', 1, 0, 0 },
312 { "ssaccp", 'W', 1, 0, 0 },
313 { "ssadce", 'X', 1, 0, 0 },
314 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
315 { "cse", 's', 0, 0, 0 },
316 { "addressof", 'F', 0, 0, 0 },
317 { "gcse", 'G', 1, 0, 0 },
318 { "loop", 'L', 1, 0, 0 },
319 { "cse2", 't', 1, 0, 0 },
320 { "cfg", 'f', 1, 0, 0 },
321 { "bp", 'b', 1, 0, 0 },
322 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
323 { "combine", 'c', 1, 0, 0 },
324 { "ce", 'C', 1, 0, 0 },
325 { "regmove", 'N', 1, 0, 0 },
326 { "sched", 'S', 1, 0, 0 },
327 { "lreg", 'l', 1, 0, 0 },
328 { "greg", 'g', 1, 0, 0 },
329 { "postreload", 'o', 1, 0, 0 },
330 { "flow2", 'w', 1, 0, 0 },
331 { "peephole2", 'z', 1, 0, 0 },
332 { "rnreg", 'n', 1, 0, 0 },
333 { "ce2", 'E', 1, 0, 0 },
334 { "sched2", 'R', 1, 0, 0 },
335 { "stack", 'k', 1, 0, 0 },
336 { "bbro", 'B', 1, 0, 0 },
337 { "mach", 'M', 1, 0, 0 },
338 { "dbr", 'd', 0, 0, 0 },
341 static int open_dump_file PARAMS ((enum dump_file_index, tree));
342 static void close_dump_file PARAMS ((enum dump_file_index,
343 void (*) (FILE *, rtx), rtx));
345 /* Other flags saying which kinds of debugging dump have been requested. */
347 int rtl_dump_and_exit;
348 int flag_print_asm_name;
349 static int version_flag;
350 static char *filename;
351 enum graph_dump_types graph_dump_format;
353 /* Name for output file of assembly code, specified with -o. */
357 /* Value of the -G xx switch, and whether it was passed or not. */
361 /* Type(s) of debugging information we are producing (if any).
362 See flags.h for the definitions of the different possible
363 types of debugging information. */
364 enum debug_info_type write_symbols = NO_DEBUG;
366 /* Level of debugging information we are producing. See flags.h
367 for the definitions of the different possible levels. */
368 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
370 /* Nonzero means use GNU-only extensions in the generated symbolic
371 debugging information. */
372 /* Currently, this only has an effect when write_symbols is set to
373 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
374 int use_gnu_debug_info_extensions = 0;
376 /* Nonzero means do optimizations. -O.
377 Particular numeric values stand for particular amounts of optimization;
378 thus, -O2 stores 2 here. However, the optimizations beyond the basic
379 ones are not controlled directly by this variable. Instead, they are
380 controlled by individual `flag_...' variables that are defaulted
381 based on this variable. */
385 /* Nonzero means optimize for size. -Os.
386 The only valid values are zero and non-zero. When optimize_size is
387 non-zero, optimize defaults to 2, but certain individual code
388 bloating optimizations are disabled. */
390 int optimize_size = 0;
392 /* Nonzero if we should exit after parsing options. */
393 static int exit_after_options = 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 optimize sibling and tail recursive calls. */
621 int flag_optimize_sibling_calls = 0;
623 /* Nonzero means the front end generally wants `errno' maintained by math
624 operations, like built-in SQRT. */
626 int flag_errno_math = 1;
628 /* Nonzero means that unsafe floating-point math optimizations are allowed
629 for the sake of speed. IEEE compliance is not guaranteed, and operations
630 are allowed to assume that their arguments and results are "normal"
631 (e.g., nonnegative for SQRT). */
633 int flag_unsafe_math_optimizations = 0;
635 /* Zero means that floating-point math operations cannot generate a
636 (user-visible) trap. This is the case, for example, in nonstop
637 IEEE 754 arithmetic. */
639 int flag_trapping_math = 1;
641 /* 0 means straightforward implementation of complex divide acceptable.
642 1 means wide ranges of inputs must work for complex divide.
643 2 means C99-like requirements for complex divide (not yet implemented). */
645 int flag_complex_divide_method = 0;
647 /* Nonzero means all references through pointers are volatile. */
651 /* Nonzero means treat all global and extern variables as volatile. */
653 int flag_volatile_global;
655 /* Nonzero means treat all static variables as volatile. */
657 int flag_volatile_static;
659 /* Nonzero means just do syntax checking; don't output anything. */
661 int flag_syntax_only = 0;
663 /* Nonzero means perform global cse. */
665 static int flag_gcse;
667 /* Nonzero means to use global dataflow analysis to eliminate
668 useless null pointer tests. */
670 static int flag_delete_null_pointer_checks;
672 /* Nonzero means to do the enhanced load motion during gcse, which trys
673 to hoist loads by not killing them when a store to the same location
676 int flag_gcse_lm = 1;
678 /* Nonzero means to perform store motion after gcse, which will try to
679 move stores closer to the exit block. Its not very effective without
682 int flag_gcse_sm = 1;
684 /* Nonzero means to rerun cse after loop optimization. This increases
685 compilation time about 20% and picks up a few more common expressions. */
687 static int flag_rerun_cse_after_loop;
689 /* Nonzero means to run loop optimizations twice. */
691 int flag_rerun_loop_opt;
693 /* Nonzero for -finline-functions: ok to inline functions that look like
694 good inline candidates. */
696 int flag_inline_functions;
698 /* Nonzero for -fkeep-inline-functions: even if we make a function
699 go inline everywhere, keep its definition around for debugging
702 int flag_keep_inline_functions;
704 /* Nonzero means that functions will not be inlined. */
708 /* Nonzero means that we should emit static const variables
709 regardless of whether or not optimization is turned on. */
711 int flag_keep_static_consts = 1;
713 /* Nonzero means we should be saving declaration info into a .X file. */
715 int flag_gen_aux_info = 0;
717 /* Specified name of aux-info file. */
719 static char *aux_info_file_name;
721 /* Nonzero means make the text shared if supported. */
723 int flag_shared_data;
725 /* Nonzero means schedule into delayed branch slots if supported. */
727 int flag_delayed_branch;
729 /* Nonzero if we are compiling pure (sharable) code.
730 Value is 1 if we are doing reasonable (i.e. simple
731 offset into offset table) pic. Value is 2 if we can
732 only perform register offsets. */
736 /* Nonzero means generate extra code for exception handling and enable
737 exception handling. */
741 /* Nonzero means generate frame unwind info table when supported. */
743 int flag_unwind_tables = 0;
745 /* Nonzero means generate frame unwind info table exact at each insn boundary */
747 int flag_asynchronous_unwind_tables = 0;
749 /* Nonzero means don't place uninitialized global data in common storage
754 /* Nonzero means pretend it is OK to examine bits of target floats,
755 even if that isn't true. The resulting code will have incorrect constants,
756 but the same series of instructions that the native compiler would make. */
758 int flag_pretend_float;
760 /* Nonzero means change certain warnings into errors.
761 Usually these are warnings about failure to conform to some standard. */
763 int flag_pedantic_errors = 0;
765 /* flag_schedule_insns means schedule insns within basic blocks (before
767 flag_schedule_insns_after_reload means schedule insns after
770 int flag_schedule_insns = 0;
771 int flag_schedule_insns_after_reload = 0;
773 /* The following flags have effect only for scheduling before register
776 flag_schedule_interblock means schedule insns accross basic blocks.
777 flag_schedule_speculative means allow speculative motion of non-load insns.
778 flag_schedule_speculative_load means allow speculative motion of some
780 flag_schedule_speculative_load_dangerous allows speculative motion of more
783 int flag_schedule_interblock = 1;
784 int flag_schedule_speculative = 1;
785 int flag_schedule_speculative_load = 0;
786 int flag_schedule_speculative_load_dangerous = 0;
788 int flag_single_precision_constant;
790 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
791 by a cheaper branch on a count register. */
792 int flag_branch_on_count_reg = 1;
794 /* -finhibit-size-directive inhibits output of .size for ELF.
795 This is used only for compiling crtstuff.c,
796 and it may be extended to other effects
797 needed for crtstuff.c on other systems. */
798 int flag_inhibit_size_directive = 0;
800 /* -fverbose-asm causes extra commentary information to be produced in
801 the generated assembly code (to make it more readable). This option
802 is generally only of use to those who actually need to read the
803 generated assembly code (perhaps while debugging the compiler itself).
804 -fno-verbose-asm, the default, causes the extra information
805 to be omitted and is useful when comparing two assembler files. */
807 int flag_verbose_asm = 0;
809 /* -dA causes debug commentary information to be produced in
810 the generated assembly code (to make it more readable). This option
811 is generally only of use to those who actually need to read the
812 generated assembly code (perhaps while debugging the compiler itself).
813 Currently, this switch is only used by dwarfout.c; however, it is intended
814 to be a catchall for printing debug information in the assembler file. */
816 int flag_debug_asm = 0;
818 /* -dP causes the rtl to be emitted as a comment in assembly. */
820 int flag_dump_rtl_in_asm = 0;
822 /* -fgnu-linker specifies use of the GNU linker for initializations.
823 (Or, more generally, a linker that handles initializations.)
824 -fno-gnu-linker says that collect2 will be used. */
826 int flag_gnu_linker = 0;
828 int flag_gnu_linker = 1;
834 /* Enable ssa conditional constant propagation. */
835 int flag_ssa_ccp = 0;
837 /* Enable ssa aggressive dead code elimination. */
838 int flag_ssa_dce = 0;
840 /* Tag all structures with __attribute__(packed). */
841 int flag_pack_struct = 0;
843 /* Emit code to check for stack overflow; also may cause large objects
844 to be allocated dynamically. */
845 int flag_stack_check;
847 /* When non-NULL, indicates that whenever space is allocated on the
848 stack, the resulting stack pointer must not pass this
849 address---that is, for stacks that grow downward, the stack pointer
850 must always be greater than or equal to this address; for stacks
851 that grow upward, the stack pointer must be less than this address.
852 At present, the rtx may be either a REG or a SYMBOL_REF, although
853 the support provided depends on the backend. */
856 /* -fcheck-memory-usage causes extra code to be generated in order to check
857 memory accesses. This is used by a detector of bad memory accesses such
859 int flag_check_memory_usage = 0;
861 /* -fprefix-function-name causes function name to be prefixed. This
862 can be used with -fcheck-memory-usage to isolate code compiled with
863 -fcheck-memory-usage. */
864 int flag_prefix_function_name = 0;
866 /* 0 if pointer arguments may alias each other. True in C.
867 1 if pointer arguments may not alias each other but may alias
869 2 if pointer arguments may not alias each other and may not
870 alias global variables. True in Fortran.
871 This defaults to 0 for C. */
872 int flag_argument_noalias = 0;
874 /* Nonzero if we should do (language-dependent) alias analysis.
875 Typically, this analysis will assume that expressions of certain
876 types do not alias expressions of certain other types. Only used
877 if alias analysis (in general) is enabled. */
878 int flag_strict_aliasing = 0;
880 /* Instrument functions with calls at entry and exit, for profiling. */
881 int flag_instrument_function_entry_exit = 0;
883 /* Nonzero means ignore `#ident' directives. 0 means handle them.
884 On SVR4 targets, it also controls whether or not to emit a
885 string identifying the compiler. */
887 int flag_no_ident = 0;
889 /* This will perform a peephole pass before sched2. */
890 int flag_peephole2 = 0;
892 /* This will try to guess branch probabilities. */
893 int flag_guess_branch_prob = 0;
895 /* -fbounded-pointers causes gcc to compile pointers as composite
896 objects occupying three words: the pointer value, the base address
897 of the referent object, and the address immediately beyond the end
898 of the referent object. The base and extent allow us to perform
899 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
900 int flag_bounded_pointers = 0;
902 /* -fcheck-bounds causes gcc to generate array bounds checks.
903 For C, C++: defaults to value of flag_bounded_pointers.
904 For ObjC: defaults to off.
905 For Java: defaults to on.
906 For Fortran: defaults to off.
907 For CHILL: defaults to off. */
908 int flag_bounds_check = 0;
910 /* This will attempt to merge constant section constants, if 1 only
911 string constants and constants from constant pool, if 2 also constant
913 int flag_merge_constants = 1;
915 /* If one, renumber instruction UIDs to reduce the number of
916 unused UIDs if there are a lot of instructions. If greater than
917 one, unconditionally renumber instruction UIDs. */
918 int flag_renumber_insns = 1;
920 /* Values of the -falign-* flags: how much to align labels in code.
921 0 means `use default', 1 means `don't align'.
922 For each variable, there is an _log variant which is the power
923 of two not less than the variable, for .align output. */
930 int align_labels_log;
932 int align_functions_log;
934 /* Table of supported debugging formats. */
937 const char *const arg;
938 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
939 constant expression, we use NO_DEBUG in its place. */
940 const enum debug_info_type debug_type;
941 const int use_extensions_p;
942 const char *const description;
946 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
947 N_("Generate debugging info in default format") },
948 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
949 #ifdef DBX_DEBUGGING_INFO
950 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
951 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
953 #ifdef DWARF_DEBUGGING_INFO
954 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
955 { "dwarf+", DWARF_DEBUG, 1,
956 N_("Generate extended DWARF-1 format debug info") },
958 #ifdef DWARF2_DEBUGGING_INFO
959 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
961 #ifdef XCOFF_DEBUGGING_INFO
962 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
963 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
965 #ifdef SDB_DEBUGGING_INFO
966 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
976 const char *description;
978 lang_independent_options;
982 /* Add or remove a leading underscore from user symbols. */
983 int flag_leading_underscore = -1;
985 /* The user symbol prefix after having resolved same. */
986 const char *user_label_prefix;
988 static const param_info lang_independent_params[] = {
989 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
990 { OPTION, DEFAULT, HELP },
991 #include "params.def"
996 /* A default for same. */
997 #ifndef USER_LABEL_PREFIX
998 #define USER_LABEL_PREFIX ""
1001 /* Table of language-independent -f options.
1002 STRING is the option name. VARIABLE is the address of the variable.
1003 ON_VALUE is the value to store in VARIABLE
1004 if `-fSTRING' is seen as an option.
1005 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1007 lang_independent_options f_options[] =
1009 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
1010 N_("Perform DWARF2 duplicate elimination") },
1011 {"float-store", &flag_float_store, 1,
1012 N_("Do not store floats in registers") },
1013 {"volatile", &flag_volatile, 1,
1014 N_("Consider all mem refs through pointers as volatile") },
1015 {"volatile-global", &flag_volatile_global, 1,
1016 N_("Consider all mem refs to global data to be volatile") },
1017 {"volatile-static", &flag_volatile_static, 1,
1018 N_("Consider all mem refs to static data to be volatile") },
1019 {"defer-pop", &flag_defer_pop, 1,
1020 N_("Defer popping functions args from stack until later") },
1021 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1022 N_("When possible do not generate stack frames") },
1023 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1024 N_("Optimize sibling and tail recursive calls") },
1025 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1026 N_("When running CSE, follow jumps to their targets") },
1027 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1028 N_("When running CSE, follow conditional jumps") },
1029 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1030 N_("Perform a number of minor, expensive optimisations") },
1031 {"thread-jumps", &flag_thread_jumps, 1,
1032 N_("Perform jump threading optimisations") },
1033 {"strength-reduce", &flag_strength_reduce, 1,
1034 N_("Perform strength reduction optimisations") },
1035 {"unroll-loops", &flag_unroll_loops, 1,
1036 N_("Perform loop unrolling when iteration count is known") },
1037 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1038 N_("Perform loop unrolling for all loops") },
1039 {"move-all-movables", &flag_move_all_movables, 1,
1040 N_("Force all loop invariant computations out of loops") },
1041 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1042 N_("Strength reduce all loop general induction variables") },
1043 {"writable-strings", &flag_writable_strings, 1,
1044 N_("Store strings in writable data section") },
1045 {"peephole", &flag_no_peephole, 0,
1046 N_("Enable machine specific peephole optimisations") },
1047 {"force-mem", &flag_force_mem, 1,
1048 N_("Copy memory operands into registers before using") },
1049 {"force-addr", &flag_force_addr, 1,
1050 N_("Copy memory address constants into regs before using") },
1051 {"function-cse", &flag_no_function_cse, 0,
1052 N_("Allow function addresses to be held in registers") },
1053 {"inline-functions", &flag_inline_functions, 1,
1054 N_("Integrate simple functions into their callers") },
1055 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1056 N_("Generate code for funcs even if they are fully inlined") },
1057 {"inline", &flag_no_inline, 0,
1058 N_("Pay attention to the 'inline' keyword") },
1059 {"keep-static-consts", &flag_keep_static_consts, 1,
1060 N_("Emit static const variables even if they are not used") },
1061 {"syntax-only", &flag_syntax_only, 1,
1062 N_("Check for syntax errors, then stop") },
1063 {"shared-data", &flag_shared_data, 1,
1064 N_("Mark data as shared rather than private") },
1065 {"caller-saves", &flag_caller_saves, 1,
1066 N_("Enable saving registers around function calls") },
1067 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1068 N_("Return 'short' aggregates in memory, not registers") },
1069 {"reg-struct-return", &flag_pcc_struct_return, 0,
1070 N_("Return 'short' aggregates in registers") },
1071 {"delayed-branch", &flag_delayed_branch, 1,
1072 N_("Attempt to fill delay slots of branch instructions") },
1073 {"gcse", &flag_gcse, 1,
1074 N_("Perform the global common subexpression elimination") },
1075 {"gcse-lm", &flag_gcse_lm, 1,
1076 N_("Perform enhanced load motion during global subexpression elimination") },
1077 {"gcse-sm", &flag_gcse_sm, 1,
1078 N_("Perform store motion after global subexpression elimination") },
1079 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1080 N_("Run CSE pass after loop optimisations") },
1081 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1082 N_("Run the loop optimiser twice") },
1083 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1084 N_("Delete useless null pointer checks") },
1085 {"pretend-float", &flag_pretend_float, 1,
1086 N_("Pretend that host and target use the same FP format") },
1087 {"schedule-insns", &flag_schedule_insns, 1,
1088 N_("Reschedule instructions before register allocation") },
1089 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1090 N_("Reschedule instructions after register allocation") },
1091 {"sched-interblock",&flag_schedule_interblock, 1,
1092 N_("Enable scheduling across basic blocks") },
1093 {"sched-spec",&flag_schedule_speculative, 1,
1094 N_("Allow speculative motion of non-loads") },
1095 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1096 N_("Allow speculative motion of some loads") },
1097 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1098 N_("Allow speculative motion of more loads") },
1099 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1100 N_("Replace add,compare,branch with branch on count reg") },
1101 {"pic", &flag_pic, 1,
1102 N_("Generate position independent code, if possible") },
1103 {"PIC", &flag_pic, 2, ""},
1104 {"exceptions", &flag_exceptions, 1,
1105 N_("Enable exception handling") },
1106 {"unwind-tables", &flag_unwind_tables, 1,
1107 N_("Just generate unwind tables for exception handling") },
1108 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1109 N_("Generate unwind tables exact at each instruction boundary") },
1110 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1111 N_("Support synchronous non-call exceptions") },
1112 {"profile-arcs", &profile_arc_flag, 1,
1113 N_("Insert arc based program profiling code") },
1114 {"test-coverage", &flag_test_coverage, 1,
1115 N_("Create data files needed by gcov") },
1116 {"branch-probabilities", &flag_branch_probabilities, 1,
1117 N_("Use profiling information for branch probabilities") },
1118 {"reorder-blocks", &flag_reorder_blocks, 1,
1119 N_("Reorder basic blocks to improve code placement") },
1120 {"rename-registers", &flag_rename_registers, 1,
1121 N_("Do the register renaming optimization pass") },
1122 {"common", &flag_no_common, 0,
1123 N_("Do not put uninitialized globals in the common section") },
1124 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1125 N_("Do not generate .size directives") },
1126 {"function-sections", &flag_function_sections, 1,
1127 N_("place each function into its own section") },
1128 {"data-sections", &flag_data_sections, 1,
1129 N_("place data items into their own section") },
1130 {"verbose-asm", &flag_verbose_asm, 1,
1131 N_("Add extra commentry to assembler output") },
1132 {"gnu-linker", &flag_gnu_linker, 1,
1133 N_("Output GNU ld formatted global initialisers") },
1134 {"regmove", &flag_regmove, 1,
1135 N_("Enables a register move optimisation") },
1136 {"optimize-register-move", &flag_regmove, 1,
1137 N_("Do the full regmove optimization pass") },
1138 {"pack-struct", &flag_pack_struct, 1,
1139 N_("Pack structure members together without holes") },
1140 {"stack-check", &flag_stack_check, 1,
1141 N_("Insert stack checking code into the program") },
1142 {"argument-alias", &flag_argument_noalias, 0,
1143 N_("Specify that arguments may alias each other & globals") },
1144 {"argument-noalias", &flag_argument_noalias, 1,
1145 N_("Assume arguments may alias globals but not each other") },
1146 {"argument-noalias-global", &flag_argument_noalias, 2,
1147 N_("Assume arguments do not alias each other or globals") },
1148 {"strict-aliasing", &flag_strict_aliasing, 1,
1149 N_("Assume strict aliasing rules apply") },
1150 {"align-loops", &align_loops, 0,
1151 N_("Align the start of loops") },
1152 {"align-jumps", &align_jumps, 0,
1153 N_("Align labels which are only reached by jumping") },
1154 {"align-labels", &align_labels, 0,
1155 N_("Align all labels") },
1156 {"align-functions", &align_functions, 0,
1157 N_("Align the start of functions") },
1158 {"merge-constants", &flag_merge_constants, 1,
1159 N_("Attempt to merge identical constants accross compilation units") },
1160 {"merge-all-constants", &flag_merge_constants, 2,
1161 N_("Attempt to merge identical constants and constant variables") },
1162 {"check-memory-usage", &flag_check_memory_usage, 1,
1163 N_("Generate code to check every memory access") },
1164 {"prefix-function-name", &flag_prefix_function_name, 1,
1165 N_("Add a prefix to all function names") },
1166 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1167 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1168 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1169 N_("Instrument function entry/exit with profiling calls") },
1170 {"ssa", &flag_ssa, 1,
1171 N_("Enable SSA optimizations") },
1172 {"ssa-ccp", &flag_ssa_ccp, 1,
1173 N_("Enable SSA conditonal constant propagation") },
1174 {"ssa-dce", &flag_ssa_dce, 1,
1175 N_("Enable aggressive SSA dead code elimination") },
1176 {"leading-underscore", &flag_leading_underscore, 1,
1177 N_("External symbols have a leading underscore") },
1178 {"ident", &flag_no_ident, 0,
1179 N_("Process #ident directives") },
1180 { "peephole2", &flag_peephole2, 1,
1181 N_("Enables an rtl peephole pass run before sched2") },
1182 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1183 N_("Enables guessing of branch probabilities") },
1184 {"math-errno", &flag_errno_math, 1,
1185 N_("Set errno after built-in math functions") },
1186 {"trapping-math", &flag_trapping_math, 1,
1187 N_("Floating-point operations can trap") },
1188 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1189 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1190 {"bounded-pointers", &flag_bounded_pointers, 1,
1191 N_("Compile pointers as triples: value, base & end") },
1192 {"bounds-check", &flag_bounds_check, 1,
1193 N_("Generate code to check bounds before dereferencing pointers and arrays") },
1194 {"single-precision-constant", &flag_single_precision_constant, 1,
1195 N_("Convert floating point constant to single precision constant") },
1196 {"time-report", &time_report, 1,
1197 N_("Report time taken by each compiler pass at end of run") },
1198 {"mem-report", &mem_report, 1,
1199 N_("Report on permanent memory allocation at end of run") },
1200 { "trapv", &flag_trapv, 1,
1201 N_("Trap for signed overflow in addition / subtraction / multiplication.") },
1204 /* Table of language-specific options. */
1206 static const struct lang_opt
1208 const char *const option;
1209 const char *const description;
1211 documented_lang_options[] =
1213 /* In order not to overload the --help output, the convention
1214 used here is to only describe those options which are not
1215 enabled by default. */
1218 N_("Compile just for ISO C89") },
1219 { "-fallow-single-precision",
1220 N_("Do not promote floats to double if using -traditional") },
1222 N_("Determine language standard") },
1224 { "-fsigned-bitfields", "" },
1225 { "-funsigned-bitfields",
1226 N_("Make bitfields by unsigned by default") },
1227 { "-fno-signed-bitfields", "" },
1228 { "-fno-unsigned-bitfields","" },
1230 N_("Make 'char' be signed by default") },
1231 { "-funsigned-char",
1232 N_("Make 'char' be unsigned by default") },
1233 { "-fno-signed-char", "" },
1234 { "-fno-unsigned-char", "" },
1236 { "-ftraditional", "" },
1238 N_("Attempt to support traditional K&R style C") },
1239 { "-fnotraditional", "" },
1240 { "-fno-traditional", "" },
1244 N_("Do not recognise the 'asm' keyword") },
1245 { "-fbuiltin", "" },
1247 N_("Do not recognise any built in functions") },
1249 N_("Assume normal C execution environment") },
1250 { "-fno-hosted", "" },
1252 N_("Assume that standard libraries & main might not exist") },
1253 { "-fno-freestanding", "" },
1254 { "-fcond-mismatch",
1255 N_("Allow different types as args of ? operator") },
1256 { "-fno-cond-mismatch", "" },
1257 { "-fdollars-in-identifiers",
1258 N_("Allow the use of $ inside identifiers") },
1259 { "-fno-dollars-in-identifiers", "" },
1260 { "-fpreprocessed", "" },
1261 { "-fno-preprocessed", "" },
1263 N_("Use the same size for double as for float") },
1264 { "-fno-short-double", "" },
1266 N_("Use the smallest fitting integer to hold enums") },
1267 { "-fno-short-enums", "" },
1269 N_("Override the underlying type for wchar_t to `unsigned short'") },
1270 { "-fno-short-wchar", "" },
1273 N_("Enable most warning messages") },
1274 { "-Wbad-function-cast",
1275 N_("Warn about casting functions to incompatible types") },
1276 { "-Wno-bad-function-cast", "" },
1277 { "-Wno-missing-noreturn", "" },
1278 { "-Wmissing-format-attribute",
1279 N_("Warn about functions which might be candidates for format attributes") },
1280 { "-Wno-missing-format-attribute", "" },
1282 N_("Warn about casts which discard qualifiers") },
1283 { "-Wno-cast-qual", "" },
1284 { "-Wchar-subscripts",
1285 N_("Warn about subscripts whose type is 'char'") },
1286 { "-Wno-char-subscripts", "" },
1288 N_("Warn if nested comments are detected") },
1289 { "-Wno-comment", "" },
1291 N_("Warn if nested comments are detected") },
1292 { "-Wno-comments", "" },
1294 N_("Warn about possibly confusing type conversions") },
1295 { "-Wno-conversion", "" },
1297 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1298 { "-Wno-format", "" },
1299 { "-Wformat-y2k", "" },
1300 { "-Wno-format-y2k",
1301 N_("Don't warn about strftime formats yielding 2 digit years") },
1302 { "-Wformat-extra-args", "" },
1303 { "-Wno-format-extra-args",
1304 N_("Don't warn about too many arguments to format functions") },
1305 { "-Wformat-nonliteral",
1306 N_("Warn about non-string-literal format strings") },
1307 { "-Wno-format-nonliteral", "" },
1308 { "-Wformat-security",
1309 N_("Warn about possible security problems with format functions") },
1310 { "-Wno-format-security", "" },
1311 { "-Wimplicit-function-declaration",
1312 N_("Warn about implicit function declarations") },
1313 { "-Wno-implicit-function-declaration", "" },
1314 { "-Werror-implicit-function-declaration", "" },
1316 N_("Warn when a declaration does not specify a type") },
1317 { "-Wno-implicit-int", "" },
1318 { "-Wimplicit", "" },
1319 { "-Wno-implicit", "" },
1321 N_("Warn about the use of the #import directive") },
1322 { "-Wno-import", "" },
1323 { "-Wlong-long","" },
1325 N_("Do not warn about using 'long long' when -pedantic") },
1327 N_("Warn about suspicious declarations of main") },
1328 { "-Wno-main", "" },
1329 { "-Wmissing-braces",
1330 N_("Warn about possibly missing braces around initialisers") },
1331 { "-Wno-missing-braces", "" },
1332 { "-Wmissing-declarations",
1333 N_("Warn about global funcs without previous declarations") },
1334 { "-Wno-missing-declarations", "" },
1335 { "-Wmissing-prototypes",
1336 N_("Warn about global funcs without prototypes") },
1337 { "-Wno-missing-prototypes", "" },
1339 N_("Warn about use of multicharacter literals") },
1340 { "-Wno-multichar", "" },
1341 { "-Wnested-externs",
1342 N_("Warn about externs not at file scope level") },
1343 { "-Wno-nested-externs", "" },
1345 N_("Warn about possible missing parentheses") },
1346 { "-Wno-parentheses", "" },
1347 { "-Wsequence-point",
1348 N_("Warn about possible violations of sequence point rules") },
1349 { "-Wno-sequence-point", "" },
1350 { "-Wpointer-arith",
1351 N_("Warn about function pointer arithmetic") },
1352 { "-Wno-pointer-arith", "" },
1353 { "-Wredundant-decls",
1354 N_("Warn about multiple declarations of the same object") },
1355 { "-Wno-redundant-decls", "" },
1357 N_("Warn about signed/unsigned comparisons") },
1358 { "-Wno-sign-compare", "" },
1360 N_("Warn about testing equality of floating point numbers") },
1361 { "-Wno-float-equal", "" },
1362 { "-Wunknown-pragmas",
1363 N_("Warn about unrecognized pragmas") },
1364 { "-Wno-unknown-pragmas", "" },
1365 { "-Wstrict-prototypes",
1366 N_("Warn about non-prototyped function decls") },
1367 { "-Wno-strict-prototypes", "" },
1369 N_("Warn about constructs whose meaning change in ISO C") },
1370 { "-Wno-traditional", "" },
1372 N_("Warn when trigraphs are encountered") },
1373 { "-Wno-trigraphs", "" },
1375 { "-Wno-undef", "" },
1376 { "-Wwrite-strings",
1377 N_("Mark strings as 'const char *'") },
1378 { "-Wno-write-strings", "" },
1380 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1382 #include "options.h"
1386 /* Here is a table, controlled by the tm.h file, listing each -m switch
1387 and which bits in `target_switches' it should set or clear.
1388 If VALUE is positive, it is bits to set.
1389 If VALUE is negative, -VALUE is bits to clear.
1390 (The sign bit is not used so there is no confusion.) */
1394 const char *const name;
1396 const char *const description;
1398 target_switches [] = TARGET_SWITCHES;
1400 /* This table is similar, but allows the switch to have a value. */
1402 #ifdef TARGET_OPTIONS
1405 const char *const prefix;
1406 const char **const variable;
1407 const char *const description;
1409 target_options [] = TARGET_OPTIONS;
1412 /* Options controlling warnings. */
1414 /* Don't print warning messages. -w. */
1416 int inhibit_warnings = 0;
1418 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1420 int warn_system_headers = 0;
1422 /* Print various extra warnings. -W. */
1424 int extra_warnings = 0;
1426 /* Treat warnings as errors. -Werror. */
1428 int warnings_are_errors = 0;
1430 /* Nonzero to warn about unused variables, functions et.al. */
1432 int warn_unused_function;
1433 int warn_unused_label;
1434 int warn_unused_parameter;
1435 int warn_unused_variable;
1436 int warn_unused_value;
1439 set_Wunused (setting)
1442 warn_unused_function = setting;
1443 warn_unused_label = setting;
1444 /* Unused function parameter warnings are reported when either ``-W
1445 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1446 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1448 warn_unused_parameter = 0;
1449 else if (!warn_unused_parameter)
1450 warn_unused_parameter = -1;
1451 warn_unused_variable = setting;
1452 warn_unused_value = setting;
1455 /* Nonzero to warn about code which is never reached. */
1457 int warn_notreached;
1459 /* Nonzero to warn about variables used before they are initialized. */
1461 int warn_uninitialized;
1463 /* Nonzero means warn about all declarations which shadow others. */
1467 /* Warn if a switch on an enum fails to have a case for every enum value. */
1471 /* Nonzero means warn about function definitions that default the return type
1472 or that use a null return and have a return-type other than void. */
1474 int warn_return_type;
1476 /* Nonzero means warn about pointer casts that increase the required
1477 alignment of the target type (and might therefore lead to a crash
1478 due to a misaligned access). */
1480 int warn_cast_align;
1482 /* Nonzero means warn about any objects definitions whose size is larger
1483 than N bytes. Also want about function definitions whose returned
1484 values are larger than N bytes. The value N is in `larger_than_size'. */
1486 int warn_larger_than;
1487 HOST_WIDE_INT larger_than_size;
1489 /* Nonzero means warn if inline function is too large. */
1493 /* Warn if a function returns an aggregate,
1494 since there are often incompatible calling conventions for doing this. */
1496 int warn_aggregate_return;
1498 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1502 /* Warn when gcc pads a structure to an alignment boundary. */
1506 /* Warn when an optimization pass is disabled. */
1508 int warn_disabled_optimization;
1510 /* Warn about functions which might be candidates for attribute noreturn. */
1512 int warn_missing_noreturn;
1514 /* Likewise for -W. */
1516 lang_independent_options W_options[] =
1518 {"unused-function", &warn_unused_function, 1,
1519 N_("Warn when a function is unused") },
1520 {"unused-label", &warn_unused_label, 1,
1521 N_("Warn when a label is unused") },
1522 {"unused-parameter", &warn_unused_parameter, 1,
1523 N_("Warn when a function parameter is unused") },
1524 {"unused-variable", &warn_unused_variable, 1,
1525 N_("Warn when a variable is unused") },
1526 {"unused-value", &warn_unused_value, 1,
1527 N_("Warn when an expression value is unused") },
1528 {"system-headers", &warn_system_headers, 1,
1529 N_("Do not suppress warnings from system headers") },
1530 {"error", &warnings_are_errors, 1,
1531 N_("Treat all warnings as errors") },
1532 {"shadow", &warn_shadow, 1,
1533 N_("Warn when one local variable shadows another") },
1534 {"switch", &warn_switch, 1,
1535 N_("Warn about enumerated switches missing a specific case") },
1536 {"aggregate-return", &warn_aggregate_return, 1,
1537 N_("Warn about returning structures, unions or arrays") },
1538 {"cast-align", &warn_cast_align, 1,
1539 N_("Warn about pointer casts which increase alignment") },
1540 {"unreachable-code", &warn_notreached, 1,
1541 N_("Warn about code that will never be executed") },
1542 {"uninitialized", &warn_uninitialized, 1,
1543 N_("Warn about uninitialized automatic variables") },
1544 {"inline", &warn_inline, 1,
1545 N_("Warn when an inlined function cannot be inlined") },
1546 {"packed", &warn_packed, 1,
1547 N_("Warn when the packed attribute has no effect on struct layout") },
1548 {"padded", &warn_padded, 1,
1549 N_("Warn when padding is required to align struct members") },
1550 {"disabled-optimization", &warn_disabled_optimization, 1,
1551 N_("Warn when an optimization pass is disabled") },
1552 {"missing-noreturn", &warn_missing_noreturn, 1,
1553 N_("Warn about functions which might be candidates for attribute noreturn") }
1556 /* The following routines are useful in setting all the flags that
1557 -ffast-math and -fno-fast-math imply. */
1560 set_fast_math_flags ()
1562 flag_trapping_math = 0;
1563 flag_unsafe_math_optimizations = 1;
1564 flag_errno_math = 0;
1568 set_no_fast_math_flags ()
1570 flag_trapping_math = 1;
1571 flag_unsafe_math_optimizations = 0;
1572 flag_errno_math = 1;
1576 /* Output files for assembler code (real compiler output)
1577 and debugging dumps. */
1580 FILE *aux_info_file;
1581 FILE *rtl_dump_file = NULL;
1583 /* Decode the string P as an integral parameter.
1584 If the string is indeed an integer return its numeric value else
1585 issue an Invalid Option error for the option PNAME and return DEFVAL.
1586 If PNAME is zero just return DEFVAL, do not call error. */
1589 read_integral_parameter (p, pname, defval)
1594 const char *endp = p;
1598 if (ISDIGIT (*endp))
1607 error ("Invalid option `%s'", pname);
1615 /* This is the default decl_printable_name function. */
1618 decl_name (decl, verbosity)
1620 int verbosity ATTRIBUTE_UNUSED;
1622 return IDENTIFIER_POINTER (DECL_NAME (decl));
1626 /* This calls abort and is used to avoid problems when abort if a macro.
1627 It is used when we need to pass the address of abort. */
1635 /* When `malloc.c' is compiled with `rcheck' defined,
1636 it calls this function to report clobberage. */
1640 const char *s ATTRIBUTE_UNUSED;
1645 /* Return the logarithm of X, base 2, considering X unsigned,
1646 if X is a power of 2. Otherwise, returns -1.
1648 This should be used via the `exact_log2' macro. */
1652 unsigned HOST_WIDE_INT x;
1655 /* Test for 0 or a power of 2. */
1656 if (x == 0 || x != (x & -x))
1658 while ((x >>= 1) != 0)
1663 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1664 If X is 0, return -1.
1666 This should be used via the floor_log2 macro. */
1670 unsigned HOST_WIDE_INT x;
1679 static int float_handler_set;
1681 jmp_buf float_handler;
1683 /* Signals actually come here. */
1686 float_signal (signo)
1687 /* If this is missing, some compilers complain. */
1688 int signo ATTRIBUTE_UNUSED;
1690 if (float_handled == 0)
1691 crash_signal (signo);
1694 /* On System-V derived systems, we must reinstall the signal handler.
1695 This is harmless on BSD-derived systems. */
1696 signal (SIGFPE, float_signal);
1697 longjmp (float_handler, 1);
1700 /* Specify where to longjmp to when a floating arithmetic error happens.
1701 If HANDLER is 0, it means don't handle the errors any more. */
1704 set_float_handler (handler)
1707 float_handled = (handler != 0);
1709 memcpy (float_handler, handler, sizeof (float_handler));
1711 if (float_handled && ! float_handler_set)
1713 signal (SIGFPE, float_signal);
1714 float_handler_set = 1;
1718 /* This is a wrapper function for code which might elicit an
1719 arithmetic exception. That code should be passed in as a function
1720 pointer FN, and one argument DATA. DATA is usually a struct which
1721 contains the real input and output for function FN. This function
1722 returns 0 (failure) if longjmp was called (i.e. an exception
1723 occurred.) It returns 1 (success) otherwise. */
1726 do_float_handler (fn, data)
1727 void (*fn) PARAMS ((PTR));
1734 /* We got here via longjmp () caused by an exception in function
1736 set_float_handler (NULL);
1740 set_float_handler (buf);
1742 set_float_handler (NULL);
1746 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1747 into ICE messages, which is much more user friendly. */
1750 crash_signal (signo)
1753 internal_error ("Internal error: %s", strsignal (signo));
1756 /* Strip off a legitimate source ending from the input string NAME of
1757 length LEN. Rather than having to know the names used by all of
1758 our front ends, we strip off an ending of a period followed by
1759 up to five characters. (Java uses ".class".) */
1762 strip_off_ending (name, len)
1767 for (i = 2; i < 6 && len > i; i++)
1769 if (name[len - i] == '.')
1771 name[len - i] = '\0';
1777 /* Output a quoted string. */
1780 output_quoted_string (asm_file, string)
1784 #ifdef OUTPUT_QUOTED_STRING
1785 OUTPUT_QUOTED_STRING (asm_file, string);
1789 putc ('\"', asm_file);
1790 while ((c = *string++) != 0)
1792 if (c == '\"' || c == '\\')
1793 putc ('\\', asm_file);
1796 putc ('\"', asm_file);
1800 /* Output a file name in the form wanted by System V. */
1803 output_file_directive (asm_file, input_name)
1805 const char *input_name;
1807 int len = strlen (input_name);
1808 const char *na = input_name + len;
1810 /* NA gets INPUT_NAME sans directory names. */
1811 while (na > input_name)
1813 if (IS_DIR_SEPARATOR (na[-1]))
1818 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1819 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1821 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1822 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1824 fprintf (asm_file, "\t.file\t");
1825 output_quoted_string (asm_file, na);
1826 fputc ('\n', asm_file);
1831 /* Routine to open a dump file. Return true if the dump file is enabled. */
1834 open_dump_file (index, decl)
1835 enum dump_file_index index;
1839 const char *open_arg;
1842 if (! dump_file[index].enabled)
1845 timevar_push (TV_DUMP);
1846 if (rtl_dump_file != NULL)
1847 fclose (rtl_dump_file);
1849 sprintf (seq, ".%02d.", index);
1851 if (! dump_file[index].initialized)
1853 /* If we've not initialized the files, do so now. */
1854 if (graph_dump_format != no_graph
1855 && dump_file[index].graph_dump_p)
1857 dump_name = concat (seq, dump_file[index].extension, NULL);
1858 clean_graph_dump_file (dump_base_name, dump_name);
1861 dump_file[index].initialized = 1;
1867 dump_name = concat (dump_base_name, seq,
1868 dump_file[index].extension, NULL);
1870 rtl_dump_file = fopen (dump_name, open_arg);
1871 if (rtl_dump_file == NULL)
1872 fatal_io_error ("can't open %s", dump_name);
1877 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1878 decl_printable_name (decl, 2));
1880 timevar_pop (TV_DUMP);
1884 /* Routine to close a dump file. */
1887 close_dump_file (index, func, insns)
1888 enum dump_file_index index;
1889 void (*func) PARAMS ((FILE *, rtx));
1892 if (! rtl_dump_file)
1895 timevar_push (TV_DUMP);
1897 && graph_dump_format != no_graph
1898 && dump_file[index].graph_dump_p)
1903 sprintf (seq, ".%02d.", index);
1904 suffix = concat (seq, dump_file[index].extension, NULL);
1905 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1910 func (rtl_dump_file, insns);
1912 fflush (rtl_dump_file);
1913 fclose (rtl_dump_file);
1915 rtl_dump_file = NULL;
1916 timevar_pop (TV_DUMP);
1919 /* Do any final processing required for the declarations in VEC, of
1920 which there are LEN. We write out inline functions and variables
1921 that have been deferred until this point, but which are required.
1922 Returns non-zero if anything was put out. */
1925 wrapup_global_declarations (vec, len)
1932 int output_something = 0;
1934 for (i = 0; i < len; i++)
1938 /* We're not deferring this any longer. */
1939 DECL_DEFER_OUTPUT (decl) = 0;
1941 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1942 && incomplete_decl_finalize_hook != 0)
1943 (*incomplete_decl_finalize_hook) (decl);
1946 /* Now emit any global variables or functions that we have been
1947 putting off. We need to loop in case one of the things emitted
1948 here references another one which comes earlier in the list. */
1952 for (i = 0; i < len; i++)
1956 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1959 /* Don't write out static consts, unless we still need them.
1961 We also keep static consts if not optimizing (for debugging),
1962 unless the user specified -fno-keep-static-consts.
1963 ??? They might be better written into the debug information.
1964 This is possible when using DWARF.
1966 A language processor that wants static constants to be always
1967 written out (even if it is not used) is responsible for
1968 calling rest_of_decl_compilation itself. E.g. the C front-end
1969 calls rest_of_decl_compilation from finish_decl.
1970 One motivation for this is that is conventional in some
1971 environments to write things like:
1972 static const char rcsid[] = "... version string ...";
1973 intending to force the string to be in the executable.
1975 A language processor that would prefer to have unneeded
1976 static constants "optimized away" would just defer writing
1977 them out until here. E.g. C++ does this, because static
1978 constants are often defined in header files.
1980 ??? A tempting alternative (for both C and C++) would be
1981 to force a constant to be written if and only if it is
1982 defined in a main file, as opposed to an include file. */
1984 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1985 && (((! TREE_READONLY (decl) || TREE_PUBLIC (decl))
1986 && !DECL_COMDAT (decl))
1988 && flag_keep_static_consts
1989 && !DECL_ARTIFICIAL (decl))
1990 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1993 rest_of_decl_compilation (decl, NULL, 1, 1);
1996 if (TREE_CODE (decl) == FUNCTION_DECL
1997 && DECL_INITIAL (decl) != 0
1998 && DECL_SAVED_INSNS (decl) != 0
1999 && (flag_keep_inline_functions
2000 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
2001 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
2004 output_inline_function (decl);
2009 output_something = 1;
2013 return output_something;
2016 /* Issue appropriate warnings for the global declarations in VEC (of
2017 which there are LEN). Output debugging information for them. */
2020 check_global_declarations (vec, len)
2027 for (i = 0; i < len; i++)
2031 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2032 && ! TREE_ASM_WRITTEN (decl))
2033 /* Cancel the RTL for this decl so that, if debugging info
2034 output for global variables is still to come,
2035 this one will be omitted. */
2036 SET_DECL_RTL (decl, NULL_RTX);
2038 /* Warn about any function
2039 declared static but not defined.
2040 We don't warn about variables,
2041 because many programs have static variables
2042 that exist only to get some text into the object file. */
2043 if (TREE_CODE (decl) == FUNCTION_DECL
2044 && (warn_unused_function
2045 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2046 && DECL_INITIAL (decl) == 0
2047 && DECL_EXTERNAL (decl)
2048 && ! DECL_ARTIFICIAL (decl)
2049 && ! TREE_PUBLIC (decl))
2051 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2052 pedwarn_with_decl (decl,
2053 "`%s' used but never defined");
2055 warning_with_decl (decl,
2056 "`%s' declared `static' but never defined");
2057 /* This symbol is effectively an "extern" declaration now. */
2058 TREE_PUBLIC (decl) = 1;
2059 assemble_external (decl);
2062 /* Warn about static fns or vars defined but not used,
2063 but not about inline functions or static consts
2064 since defining those in header files is normal practice. */
2065 if (((warn_unused_function
2066 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2067 || (warn_unused_variable
2068 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2069 && ! DECL_IN_SYSTEM_HEADER (decl)
2070 && ! DECL_EXTERNAL (decl)
2071 && ! TREE_PUBLIC (decl)
2072 && ! TREE_USED (decl)
2073 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2074 /* The TREE_USED bit for file-scope decls
2075 is kept in the identifier, to handle multiple
2076 external decls in different scopes. */
2077 && ! TREE_USED (DECL_NAME (decl)))
2078 warning_with_decl (decl, "`%s' defined but not used");
2080 timevar_push (TV_SYMOUT);
2081 (*debug_hooks->global_decl) (decl);
2082 timevar_pop (TV_SYMOUT);
2086 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2087 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2088 INPUT_FILENAME and LINENO accordingly. */
2091 push_srcloc (file, line)
2095 struct file_stack *fs;
2097 if (input_file_stack)
2099 input_file_stack->name = input_filename;
2100 input_file_stack->line = lineno;
2103 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2104 fs->name = input_filename = file;
2105 fs->line = lineno = line;
2106 fs->indent_level = 0;
2107 fs->next = input_file_stack;
2108 input_file_stack = fs;
2109 input_file_stack_tick++;
2112 /* Pop the top entry off the stack of presently open source files.
2113 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2119 struct file_stack *fs;
2121 fs = input_file_stack;
2122 input_file_stack = fs->next;
2124 input_file_stack_tick++;
2125 /* The initial source file is never popped. */
2126 if (!input_file_stack)
2128 input_filename = input_file_stack->name;
2129 lineno = input_file_stack->line;
2132 /* Compile an entire translation unit, whose primary source file is
2133 named NAME. Write a file of assembly output and various debugging
2142 int name_specified = name != 0;
2144 if (dump_base_name == 0)
2145 dump_base_name = name ? name : "gccdump";
2150 /* Start timing total execution time. */
2153 timevar_start (TV_TOTAL);
2155 /* Open assembly code output file. Do this even if -fsyntax-only is on,
2156 because then the driver will have provided the name of a temporary
2157 file or bit bucket for us. */
2159 if (! name_specified && asm_file_name == 0)
2160 asm_out_file = stdout;
2163 if (asm_file_name == 0)
2165 int len = strlen (dump_base_name);
2166 char *dumpname = (char *) xmalloc (len + 6);
2167 memcpy (dumpname, dump_base_name, len + 1);
2168 strip_off_ending (dumpname, len);
2169 strcat (dumpname, ".s");
2170 asm_file_name = dumpname;
2172 if (!strcmp (asm_file_name, "-"))
2173 asm_out_file = stdout;
2175 asm_out_file = fopen (asm_file_name, "w");
2176 if (asm_out_file == 0)
2177 fatal_io_error ("can't open %s for writing", asm_file_name);
2180 /* Initialize data in various passes. */
2183 name = init_parse (name);
2184 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2185 || debug_info_level == DINFO_LEVEL_VERBOSE
2186 || flag_test_coverage
2187 || warn_notreached);
2190 init_decl_processing ();
2196 init_function_once ();
2197 init_stor_layout_once ();
2198 init_varasm_once ();
2199 init_EXPR_INSN_LIST_cache ();
2201 /* The following initialization functions need to generate rtl, so
2202 provide a dummy function context for them. */
2203 init_dummy_function_start ();
2206 if (flag_caller_saves)
2207 init_caller_save ();
2208 expand_dummy_function_end ();
2210 /* If auxiliary info generation is desired, open the output file.
2211 This goes in the same directory as the source file--unlike
2212 all the other output files. */
2213 if (flag_gen_aux_info)
2215 aux_info_file = fopen (aux_info_file_name, "w");
2216 if (aux_info_file == 0)
2217 fatal_io_error ("can't open %s", aux_info_file_name);
2220 #ifdef IO_BUFFER_SIZE
2221 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
2222 _IOFBF, IO_BUFFER_SIZE);
2226 name = ggc_strdup (name);
2228 input_filename = name;
2230 /* Put an entry on the input file stack for the main input file. */
2231 push_srcloc (input_filename, 0);
2233 /* Perform language-specific initialization.
2234 This may set main_input_filename. */
2235 (*lang_hooks.init) ();
2237 /* If the input doesn't start with a #line, use the input name
2238 as the official input file name. */
2239 if (main_input_filename == 0)
2240 main_input_filename = name;
2242 if (flag_syntax_only)
2244 write_symbols = NO_DEBUG;
2246 profile_block_flag = 0;
2250 #ifdef ASM_FILE_START
2251 ASM_FILE_START (asm_out_file);
2254 #ifdef ASM_COMMENT_START
2255 if (flag_verbose_asm)
2257 /* Print the list of options in effect. */
2258 print_version (asm_out_file, ASM_COMMENT_START);
2259 print_switch_values (asm_out_file, 0, MAX_LINE,
2260 ASM_COMMENT_START, " ", "\n");
2261 /* Add a blank line here so it appears in assembler output but not
2263 fprintf (asm_out_file, "\n");
2266 } /* ! flag_syntax_only */
2268 /* Set up the debug hooks based on write_symbols. Default to doing
2270 debug_hooks = &do_nothing_debug_hooks;
2271 #if defined(DBX_DEBUGGING_INFO)
2272 if (write_symbols == DBX_DEBUG)
2273 debug_hooks = &dbx_debug_hooks;
2275 #if defined(XCOFF_DEBUGGING_INFO)
2276 if (write_symbols == XCOFF_DEBUG)
2277 debug_hooks = &xcoff_debug_hooks;
2279 #ifdef SDB_DEBUGGING_INFO
2280 if (write_symbols == SDB_DEBUG)
2281 debug_hooks = &sdb_debug_hooks;
2283 #ifdef DWARF_DEBUGGING_INFO
2284 if (write_symbols == DWARF_DEBUG)
2285 debug_hooks = &dwarf_debug_hooks;
2287 #ifdef DWARF2_DEBUGGING_INFO
2288 if (write_symbols == DWARF2_DEBUG)
2289 debug_hooks = &dwarf2_debug_hooks;
2292 if (! targetm.have_named_sections)
2294 if (flag_function_sections)
2296 warning ("-ffunction-sections not supported for this target.");
2297 flag_function_sections = 0;
2299 if (flag_data_sections)
2301 warning ("-fdata-sections not supported for this target.");
2302 flag_data_sections = 0;
2306 if (flag_function_sections
2307 && (profile_flag || profile_block_flag))
2309 warning ("-ffunction-sections disabled; it makes profiling impossible.");
2310 flag_function_sections = 0;
2313 #ifndef OBJECT_FORMAT_ELF
2314 if (flag_function_sections && write_symbols != NO_DEBUG)
2315 warning ("-ffunction-sections may affect debugging on some targets.");
2318 /* If dbx symbol table desired, initialize writing it
2319 and output the predefined types. */
2320 timevar_push (TV_SYMOUT);
2321 #ifdef DWARF2_UNWIND_INFO
2322 if (dwarf2out_do_frame ())
2323 dwarf2out_frame_init ();
2326 (*debug_hooks->init) (main_input_filename);
2327 timevar_pop (TV_SYMOUT);
2329 /* Initialize yet another pass. */
2331 init_final (main_input_filename);
2332 init_branch_prob (dump_base_name);
2334 timevar_push (TV_PARSE);
2336 /* Call the parser, which parses the entire file
2337 (calling rest_of_compilation for each function). */
2340 /* In case there were missing block closers,
2341 get us back to the global binding level. */
2342 (*lang_hooks.clear_binding_stack) ();
2344 /* Compilation is now finished except for writing
2345 what's left of the symbol table output. */
2347 timevar_pop (TV_PARSE);
2349 if (flag_syntax_only)
2352 globals = getdecls ();
2354 /* Really define vars that have had only a tentative definition.
2355 Really output inline functions that must actually be callable
2356 and have not been output so far. */
2359 int len = list_length (globals);
2360 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2364 /* Process the decls in reverse order--earliest first.
2365 Put them into VEC from back to front, then take out from front. */
2367 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2368 vec[len - i - 1] = decl;
2370 wrapup_global_declarations (vec, len);
2372 /* This must occur after the loop to output deferred functions. Else
2373 the profiler initializer would not be emitted if all the functions
2374 in this compilation unit were deferred.
2376 output_func_start_profiler can not cause any additional functions or
2377 data to need to be output, so it need not be in the deferred function
2379 output_func_start_profiler ();
2381 check_global_declarations (vec, len);
2387 /* Write out any pending weak symbol declarations. */
2391 /* Do dbx symbols. */
2392 timevar_push (TV_SYMOUT);
2394 #ifdef DWARF2_UNWIND_INFO
2395 if (dwarf2out_do_frame ())
2396 dwarf2out_frame_finish ();
2399 (*debug_hooks->finish) (main_input_filename);
2400 timevar_pop (TV_SYMOUT);
2402 /* Output some stuff at end of file if nec. */
2404 dw2_output_indirect_constants ();
2406 end_final (dump_base_name);
2408 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2410 timevar_push (TV_DUMP);
2411 open_dump_file (DFI_bp, NULL);
2415 close_dump_file (DFI_bp, NULL, NULL_RTX);
2416 timevar_pop (TV_DUMP);
2420 ASM_FILE_END (asm_out_file);
2423 /* Attach a special .ident directive to the end of the file to identify
2424 the version of GCC which compiled this code. The format of the .ident
2425 string is patterned after the ones produced by native SVR4 compilers. */
2428 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2429 IDENT_ASM_OP, version_string);
2432 /* Language-specific end of compilation actions. */
2434 (*lang_hooks.finish) ();
2436 /* Close the dump files. */
2438 if (flag_gen_aux_info)
2440 fclose (aux_info_file);
2442 unlink (aux_info_file_name);
2445 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2447 timevar_push (TV_DUMP);
2448 dump_combine_total_stats (rtl_dump_file);
2449 close_dump_file (DFI_combine, NULL, NULL_RTX);
2450 timevar_pop (TV_DUMP);
2453 /* Close non-debugging input and output files. Take special care to note
2454 whether fclose returns an error, since the pages might still be on the
2455 buffer chain while the file is open. */
2459 if (ferror (asm_out_file) != 0)
2460 fatal_io_error ("error writing to %s", asm_file_name);
2461 if (fclose (asm_out_file) != 0)
2462 fatal_io_error ("error closing %s", asm_file_name);
2464 /* Do whatever is necessary to finish printing the graphs. */
2465 if (graph_dump_format != no_graph)
2469 for (i = 0; i < (int) DFI_MAX; ++i)
2470 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
2475 sprintf (seq, ".%02d.", i);
2476 suffix = concat (seq, dump_file[i].extension, NULL);
2477 finish_graph_dump_file (dump_base_name, suffix);
2484 ggc_print_statistics ();
2485 stringpool_statistics ();
2486 dump_tree_statistics ();
2489 /* Free up memory for the benefit of leak detectors. */
2492 /* Stop timing total execution time. */
2493 timevar_stop (TV_TOTAL);
2495 /* Print the times. */
2497 timevar_print (stderr);
2500 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2501 and TYPE_DECL nodes.
2503 This does nothing for local (non-static) variables, unless the
2504 variable is a register variable with an ASMSPEC. In that case, or
2505 if the variable is not an automatic, it sets up the RTL and
2506 outputs any assembler code (label definition, storage allocation
2507 and initialization).
2509 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2510 the assembler symbol name to be used. TOP_LEVEL is nonzero
2511 if this declaration is not within a function. */
2514 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2516 const char *asmspec;
2520 /* Declarations of variables, and of functions defined elsewhere. */
2522 /* The most obvious approach, to put an #ifndef around where
2523 this macro is used, doesn't work since it's inside a macro call. */
2524 #ifndef ASM_FINISH_DECLARE_OBJECT
2525 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2528 /* Forward declarations for nested functions are not "external",
2529 but we need to treat them as if they were. */
2530 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2531 || TREE_CODE (decl) == FUNCTION_DECL)
2533 timevar_push (TV_VARCONST);
2535 make_decl_rtl (decl, asmspec);
2536 /* Don't output anything
2537 when a tentative file-scope definition is seen.
2538 But at end of compilation, do output code for them. */
2539 if (at_end || !DECL_DEFER_OUTPUT (decl))
2540 assemble_variable (decl, top_level, at_end, 0);
2541 if (decl == last_assemble_variable_decl)
2543 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2546 timevar_pop (TV_VARCONST);
2548 else if (DECL_REGISTER (decl) && asmspec != 0)
2550 if (decode_reg_name (asmspec) >= 0)
2552 SET_DECL_RTL (decl, NULL_RTX);
2553 make_decl_rtl (decl, asmspec);
2557 error ("invalid register name `%s' for register variable", asmspec);
2558 DECL_REGISTER (decl) = 0;
2563 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2564 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2565 && TREE_CODE (decl) == TYPE_DECL)
2567 timevar_push (TV_SYMOUT);
2568 dbxout_symbol (decl, 0);
2569 timevar_pop (TV_SYMOUT);
2572 #ifdef SDB_DEBUGGING_INFO
2573 else if (write_symbols == SDB_DEBUG && top_level
2574 && TREE_CODE (decl) == TYPE_DECL)
2576 timevar_push (TV_SYMOUT);
2577 sdbout_symbol (decl, 0);
2578 timevar_pop (TV_SYMOUT);
2583 /* Called after finishing a record, union or enumeral type. */
2586 rest_of_type_compilation (type, toplev)
2587 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2591 tree type ATTRIBUTE_UNUSED;
2592 int toplev ATTRIBUTE_UNUSED;
2595 timevar_push (TV_SYMOUT);
2596 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2597 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2598 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2600 #ifdef SDB_DEBUGGING_INFO
2601 if (write_symbols == SDB_DEBUG)
2602 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2604 #ifdef DWARF2_DEBUGGING_INFO
2605 if (write_symbols == DWARF2_DEBUG && toplev)
2606 dwarf2out_decl (TYPE_STUB_DECL (type));
2608 timevar_pop (TV_SYMOUT);
2611 /* This is called from finish_function (within yyparse)
2612 after each top-level definition is parsed.
2613 It is supposed to compile that function or variable
2614 and output the assembler code for it.
2615 After we return, the tree storage is freed. */
2618 rest_of_compilation (decl)
2624 int rebuild_label_notes_after_reload;
2625 int register_life_up_to_date;
2627 timevar_push (TV_REST_OF_COMPILATION);
2629 /* Now that we're out of the frontend, we shouldn't have any more
2630 CONCATs anywhere. */
2631 generating_concat_p = 0;
2633 /* When processing delayed functions, prepare_function_start() won't
2634 have been run to re-initialize it. */
2635 cse_not_expected = ! optimize;
2637 /* First, make sure that NOTE_BLOCK is set correctly for each
2638 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2639 if (!cfun->x_whole_function_mode_p)
2642 /* Then remove any notes we don't need. That will make iterating
2643 over the instruction sequence faster, and allow the garbage
2644 collector to reclaim the memory used by the notes. */
2645 remove_unnecessary_notes ();
2647 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2648 tree in sensible shape. So, we just recalculate it here. */
2649 if (cfun->x_whole_function_mode_p)
2654 /* If we are reconsidering an inline function
2655 at the end of compilation, skip the stuff for making it inline. */
2657 if (DECL_SAVED_INSNS (decl) == 0)
2663 /* If this is nested inside an inlined external function, pretend
2664 it was only declared. Since we cannot inline such functions,
2665 generating code for this one is not only not necessary but will
2666 confuse some debugging output writers. */
2667 for (parent = DECL_CONTEXT (current_function_decl);
2668 parent != NULL_TREE;
2669 parent = get_containing_scope (parent))
2670 if (TREE_CODE (parent) == FUNCTION_DECL
2671 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2673 DECL_INITIAL (decl) = 0;
2674 goto exit_rest_of_compilation;
2677 /* If requested, consider whether to make this function inline. */
2678 if ((DECL_INLINE (decl) && !flag_no_inline)
2679 || flag_inline_functions)
2681 timevar_push (TV_INTEGRATION);
2682 lose = function_cannot_inline_p (decl);
2683 timevar_pop (TV_INTEGRATION);
2684 if (lose || ! optimize)
2686 if (warn_inline && DECL_INLINE (decl))
2687 warning_with_decl (decl, lose);
2688 DECL_ABSTRACT_ORIGIN (decl) = 0;
2689 /* Don't really compile an extern inline function.
2690 If we can't make it inline, pretend
2691 it was only declared. */
2692 if (DECL_EXTERNAL (decl))
2694 DECL_INITIAL (decl) = 0;
2695 goto exit_rest_of_compilation;
2699 /* ??? Note that this has the effect of making it look
2700 like "inline" was specified for a function if we choose
2701 to inline it. This isn't quite right, but it's
2702 probably not worth the trouble to fix. */
2703 inlinable = DECL_INLINE (decl) = 1;
2706 insns = get_insns ();
2708 /* Dump the rtl code if we are dumping rtl. */
2710 if (open_dump_file (DFI_rtl, decl))
2712 if (DECL_SAVED_INSNS (decl))
2713 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2714 close_dump_file (DFI_rtl, print_rtl, insns);
2717 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2718 sorts of eh initialization. Delay this until after the
2719 initial rtl dump so that we can see the original nesting. */
2720 convert_from_eh_region_ranges ();
2722 /* If function is inline, and we don't yet know whether to
2723 compile it by itself, defer decision till end of compilation.
2724 finish_compilation will call rest_of_compilation again
2725 for those functions that need to be output. Also defer those
2726 functions that we are supposed to defer. */
2729 || (DECL_INLINE (decl)
2730 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2731 && ! flag_keep_inline_functions)
2732 || DECL_EXTERNAL (decl))))
2733 DECL_DEFER_OUTPUT (decl) = 1;
2735 if (DECL_INLINE (decl))
2736 /* DWARF wants separate debugging info for abstract and
2737 concrete instances of all inline functions, including those
2738 declared inline but not inlined, and those inlined even
2739 though they weren't declared inline. Conveniently, that's
2740 what DECL_INLINE means at this point. */
2741 (*debug_hooks->deferred_inline_function) (decl);
2743 if (DECL_DEFER_OUTPUT (decl))
2745 /* If -Wreturn-type, we have to do a bit of compilation. We just
2746 want to call cleanup the cfg to figure out whether or not we can
2747 fall off the end of the function; we do the minimum amount of
2748 work necessary to make that safe. */
2749 if (warn_return_type)
2751 int saved_optimize = optimize;
2754 rebuild_jump_labels (insns);
2755 find_exception_handler_labels ();
2756 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2757 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2758 optimize = saved_optimize;
2760 /* CFG is no longer maintained up-to-date. */
2761 free_bb_for_insn ();
2764 current_function_nothrow = nothrow_function_p ();
2765 if (current_function_nothrow)
2766 /* Now we know that this can't throw; set the flag for the benefit
2767 of other functions later in this translation unit. */
2768 TREE_NOTHROW (current_function_decl) = 1;
2770 timevar_push (TV_INTEGRATION);
2771 save_for_inline (decl);
2772 timevar_pop (TV_INTEGRATION);
2773 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2774 goto exit_rest_of_compilation;
2777 /* If specified extern inline but we aren't inlining it, we are
2778 done. This goes for anything that gets here with DECL_EXTERNAL
2779 set, not just things with DECL_INLINE. */
2780 if (DECL_EXTERNAL (decl))
2781 goto exit_rest_of_compilation;
2786 /* Initialize some variables used by the optimizers. */
2787 init_function_for_compilation ();
2789 if (! DECL_DEFER_OUTPUT (decl))
2790 TREE_ASM_WRITTEN (decl) = 1;
2792 /* Now that integrate will no longer see our rtl, we need not
2793 distinguish between the return value of this function and the
2794 return value of called functions. Also, we can remove all SETs
2795 of subregs of hard registers; they are only here because of
2796 integrate. Also, we can now initialize pseudos intended to
2797 carry magic hard reg data throughout the function. */
2798 rtx_equal_function_value_matters = 0;
2799 purge_hard_subreg_sets (get_insns ());
2800 emit_initial_value_sets ();
2802 /* Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2803 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2804 goto exit_rest_of_compilation;
2806 /* We may have potential sibling or tail recursion sites. Select one
2807 (of possibly multiple) methods of performing the call. */
2808 if (flag_optimize_sibling_calls)
2810 timevar_push (TV_JUMP);
2811 open_dump_file (DFI_sibling, decl);
2813 optimize_sibling_and_tail_recursive_calls ();
2815 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2816 timevar_pop (TV_JUMP);
2819 /* Complete generation of exception handling code. */
2820 find_exception_handler_labels ();
2823 timevar_push (TV_JUMP);
2824 open_dump_file (DFI_eh, decl);
2826 finish_eh_generation ();
2828 close_dump_file (DFI_eh, print_rtl, get_insns ());
2829 timevar_pop (TV_JUMP);
2833 /* If we are doing position-independent code generation, now
2834 is the time to output special prologues and epilogues.
2835 We do not want to do this earlier, because it just clutters
2836 up inline functions with meaningless insns. */
2841 insns = get_insns ();
2843 /* Copy any shared structure that should not be shared. */
2844 unshare_all_rtl (current_function_decl, insns);
2846 #ifdef SETJMP_VIA_SAVE_AREA
2847 /* This must be performed before virtual register instantiation. */
2848 if (current_function_calls_alloca)
2849 optimize_save_area_alloca (insns);
2852 /* Instantiate all virtual registers. */
2853 instantiate_virtual_regs (current_function_decl, insns);
2855 open_dump_file (DFI_jump, decl);
2857 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2858 are initialized and to compute whether control can drop off the end
2861 timevar_push (TV_JUMP);
2862 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2863 before jump optimization switches branch directions. */
2864 expected_value_to_br_prob ();
2866 reg_scan (insns, max_reg_num (), 0);
2867 rebuild_jump_labels (insns);
2868 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2869 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP);
2871 /* CFG is no longer maintained up-to-date. */
2872 free_bb_for_insn ();
2873 copy_loop_headers (insns);
2874 purge_line_number_notes (insns);
2876 timevar_pop (TV_JUMP);
2878 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2879 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2881 close_dump_file (DFI_jump, print_rtl, insns);
2882 goto exit_rest_of_compilation;
2885 /* Long term, this should probably move before the jump optimizer too,
2886 but I didn't want to disturb the rtl_dump_and_exit and related
2887 stuff at this time. */
2888 if (optimize > 0 && flag_ssa)
2890 /* Convert to SSA form. */
2892 timevar_push (TV_TO_SSA);
2893 open_dump_file (DFI_ssa, decl);
2895 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2896 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2899 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2900 timevar_pop (TV_TO_SSA);
2902 /* Perform sparse conditional constant propagation, if requested. */
2905 timevar_push (TV_SSA_CCP);
2906 open_dump_file (DFI_ssa_ccp, decl);
2910 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2911 timevar_pop (TV_SSA_CCP);
2914 /* It would be useful to cleanup the CFG at this point, but block
2915 merging and possibly other transformations might leave a PHI
2916 node in the middle of a basic block, which is a strict no-no. */
2918 /* The SSA implementation uses basic block numbers in its phi
2919 nodes. Thus, changing the control-flow graph or the basic
2920 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2921 may cause problems. */
2925 /* Remove dead code. */
2927 timevar_push (TV_SSA_DCE);
2928 open_dump_file (DFI_ssa_dce, decl);
2930 insns = get_insns ();
2931 ssa_eliminate_dead_code();
2933 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2934 timevar_pop (TV_SSA_DCE);
2937 /* Convert from SSA form. */
2939 timevar_push (TV_FROM_SSA);
2940 open_dump_file (DFI_ussa, decl);
2942 convert_from_ssa ();
2943 /* New registers have been created. Rescan their usage. */
2944 reg_scan (insns, max_reg_num (), 1);
2946 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2947 timevar_pop (TV_FROM_SSA);
2950 /* CFG is no longer maintained up-to-date. */
2951 free_bb_for_insn ();
2954 timevar_push (TV_JUMP);
2958 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2959 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2961 /* ??? Run if-conversion before delete_null_pointer_checks,
2962 since the later does not preserve the CFG. This should
2963 be changed -- no since converting if's that are going to
2965 timevar_push (TV_IFCVT);
2967 timevar_pop (TV_IFCVT);
2969 /* CFG is no longer maintained up-to-date. */
2970 free_bb_for_insn ();
2971 /* Try to identify useless null pointer tests and delete them. */
2972 if (flag_delete_null_pointer_checks)
2973 delete_null_pointer_checks (insns);
2976 /* Jump optimization, and the removal of NULL pointer checks, may
2977 have reduced the number of instructions substantially. CSE, and
2978 future passes, allocate arrays whose dimensions involve the
2979 maximum instruction UID, so if we can reduce the maximum UID
2980 we'll save big on memory. */
2981 renumber_insns (rtl_dump_file);
2982 timevar_pop (TV_JUMP);
2984 close_dump_file (DFI_jump, print_rtl, insns);
2988 /* Perform common subexpression elimination.
2989 Nonzero value from `cse_main' means that jumps were simplified
2990 and some code may now be unreachable, so do
2991 jump optimization again. */
2995 open_dump_file (DFI_cse, decl);
2996 timevar_push (TV_CSE);
2998 reg_scan (insns, max_reg_num (), 1);
3000 if (flag_thread_jumps)
3002 timevar_push (TV_JUMP);
3003 thread_jumps (insns, max_reg_num (), 1);
3004 timevar_pop (TV_JUMP);
3007 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3009 /* If we are not running more CSE passes, then we are no longer
3010 expecting CSE to be run. But always rerun it in a cheap mode. */
3011 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
3013 if (tem || optimize > 1)
3015 timevar_push (TV_JUMP);
3016 rebuild_jump_labels (insns);
3017 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3018 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3019 timevar_pop (TV_JUMP);
3020 /* CFG is no longer maintained up-to-date. */
3021 free_bb_for_insn ();
3024 /* Run this after jump optmizations remove all the unreachable code
3025 so that unreachable code will not keep values live. */
3026 delete_trivially_dead_insns (insns, max_reg_num (), 0);
3028 /* Try to identify useless null pointer tests and delete them. */
3029 if (flag_delete_null_pointer_checks)
3031 timevar_push (TV_JUMP);
3032 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3034 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3036 delete_null_pointer_checks (insns);
3037 /* CFG is no longer maintained up-to-date. */
3038 free_bb_for_insn ();
3039 timevar_pop (TV_JUMP);
3042 /* The second pass of jump optimization is likely to have
3043 removed a bunch more instructions. */
3044 renumber_insns (rtl_dump_file);
3046 timevar_pop (TV_CSE);
3047 close_dump_file (DFI_cse, print_rtl, insns);
3050 open_dump_file (DFI_addressof, decl);
3052 purge_addressof (insns);
3053 reg_scan (insns, max_reg_num (), 1);
3055 close_dump_file (DFI_addressof, print_rtl, insns);
3059 /* Perform global cse. */
3061 if (optimize > 0 && flag_gcse)
3063 int save_csb, save_cfj;
3066 timevar_push (TV_GCSE);
3067 open_dump_file (DFI_gcse, decl);
3069 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3070 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3071 tem = gcse_main (insns, rtl_dump_file);
3073 save_csb = flag_cse_skip_blocks;
3074 save_cfj = flag_cse_follow_jumps;
3075 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
3077 /* CFG is no longer maintained up-to-date. */
3078 free_bb_for_insn ();
3079 /* If -fexpensive-optimizations, re-run CSE to clean up things done
3081 if (flag_expensive_optimizations)
3083 timevar_push (TV_CSE);
3084 reg_scan (insns, max_reg_num (), 1);
3085 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3086 timevar_pop (TV_CSE);
3087 cse_not_expected = !flag_rerun_cse_after_loop;
3090 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
3091 things up. Then possibly re-run CSE again. */
3095 timevar_push (TV_JUMP);
3096 rebuild_jump_labels (insns);
3097 delete_trivially_dead_insns (insns, max_reg_num (), 0);
3098 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3099 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3100 /* CFG is no longer maintained up-to-date. */
3101 free_bb_for_insn ();
3102 timevar_pop (TV_JUMP);
3104 if (flag_expensive_optimizations)
3106 timevar_push (TV_CSE);
3107 reg_scan (insns, max_reg_num (), 1);
3108 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3109 timevar_pop (TV_CSE);
3113 close_dump_file (DFI_gcse, print_rtl, insns);
3114 timevar_pop (TV_GCSE);
3117 flag_cse_skip_blocks = save_csb;
3118 flag_cse_follow_jumps = save_cfj;
3121 /* Move constant computations out of loops. */
3125 timevar_push (TV_LOOP);
3126 open_dump_file (DFI_loop, decl);
3127 free_bb_for_insn ();
3129 if (flag_rerun_loop_opt)
3131 cleanup_barriers ();
3133 /* We only want to perform unrolling once. */
3135 loop_optimize (insns, rtl_dump_file, 0);
3137 /* The first call to loop_optimize makes some instructions
3138 trivially dead. We delete those instructions now in the
3139 hope that doing so will make the heuristics in loop work
3140 better and possibly speed up compilation. */
3141 delete_trivially_dead_insns (insns, max_reg_num (), 0);
3143 /* The regscan pass is currently necessary as the alias
3144 analysis code depends on this information. */
3145 reg_scan (insns, max_reg_num (), 1);
3147 cleanup_barriers ();
3148 loop_optimize (insns, rtl_dump_file,
3149 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT);
3151 close_dump_file (DFI_loop, print_rtl, insns);
3152 timevar_pop (TV_LOOP);
3159 timevar_push (TV_CSE2);
3160 open_dump_file (DFI_cse2, decl);
3162 if (flag_rerun_cse_after_loop)
3164 /* Running another jump optimization pass before the second
3165 cse pass sometimes simplifies the RTL enough to allow
3166 the second CSE pass to do a better job. Jump_optimize can change
3167 max_reg_num so we must rerun reg_scan afterwards.
3168 ??? Rework to not call reg_scan so often. */
3169 timevar_push (TV_JUMP);
3171 /* The previous call to loop_optimize makes some instructions
3172 trivially dead. We delete those instructions now in the
3173 hope that doing so will make the heuristics in jump work
3174 better and possibly speed up compilation. */
3175 delete_trivially_dead_insns (insns, max_reg_num (), 0);
3177 reg_scan (insns, max_reg_num (), 0);
3179 timevar_push (TV_IFCVT);
3181 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3182 cleanup_cfg (CLEANUP_EXPENSIVE);
3185 timevar_pop(TV_IFCVT);
3187 timevar_pop (TV_JUMP);
3189 /* CFG is no longer maintained up-to-date. */
3190 free_bb_for_insn ();
3191 reg_scan (insns, max_reg_num (), 0);
3192 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3196 timevar_push (TV_JUMP);
3197 rebuild_jump_labels (insns);
3198 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3199 cleanup_cfg (CLEANUP_EXPENSIVE);
3200 /* CFG is no longer maintained up-to-date. */
3201 free_bb_for_insn ();
3202 timevar_pop (TV_JUMP);
3206 if (flag_thread_jumps)
3208 /* This pass of jump threading straightens out code
3209 that was kinked by loop optimization. */
3210 timevar_push (TV_JUMP);
3211 reg_scan (insns, max_reg_num (), 0);
3212 thread_jumps (insns, max_reg_num (), 0);
3213 timevar_pop (TV_JUMP);
3216 close_dump_file (DFI_cse2, print_rtl, insns);
3217 timevar_pop (TV_CSE2);
3222 cse_not_expected = 1;
3226 /* Do control and data flow analysis; wrote some of the results to
3229 timevar_push (TV_FLOW);
3230 open_dump_file (DFI_cfg, decl);
3232 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3233 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3234 check_function_return_warnings ();
3236 /* It may make more sense to mark constant functions after dead code is
3237 eliminated by life_analyzis, but we need to do it early, as -fprofile-arcs
3238 may insert code making function non-constant, but we still must consider
3239 it as constant, otherwise -fbranch-probabilities will not read data back.
3241 life_analyzis rarely eliminates modification of external memory.
3243 mark_constant_function ();
3245 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3247 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3249 timevar_push (TV_BRANCH_PROB);
3250 open_dump_file (DFI_bp, decl);
3254 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3255 timevar_pop (TV_BRANCH_PROB);
3258 open_dump_file (DFI_life, decl);
3263 /* Discover and record the loop depth at the head of each basic
3264 block. The loop infrastructure does the real job for us. */
3265 flow_loops_find (&loops, LOOP_TREE);
3267 /* Estimate using heuristics if no profiling info is available. */
3268 if (flag_guess_branch_prob)
3269 estimate_probability (&loops);
3272 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3274 flow_loops_free (&loops);
3276 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3277 timevar_pop (TV_FLOW);
3281 if (warn_uninitialized || extra_warnings)
3283 uninitialized_vars_warning (DECL_INITIAL (decl));
3285 setjmp_args_warning ();
3288 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3292 /* If -opt, try combining insns through substitution. */
3296 int rebuild_jump_labels_after_combine = 0;
3298 timevar_push (TV_COMBINE);
3299 open_dump_file (DFI_combine, decl);
3301 rebuild_jump_labels_after_combine
3302 = combine_instructions (insns, max_reg_num ());
3304 /* Always purge dead edges, as we may eliminate an insn throwing
3306 rebuild_jump_labels_after_combine |= purge_all_dead_edges (true);
3308 /* Combining insns may have turned an indirect jump into a
3309 direct jump. Rebuid the JUMP_LABEL fields of jumping
3311 if (rebuild_jump_labels_after_combine)
3313 timevar_push (TV_JUMP);
3314 rebuild_jump_labels (insns);
3315 timevar_pop (TV_JUMP);
3317 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3320 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3321 timevar_pop (TV_COMBINE);
3326 /* Rerun if-conversion, as combine may have simplified things enough to
3327 now meet sequence length restrictions. */
3330 timevar_push (TV_IFCVT);
3331 open_dump_file (DFI_ce, decl);
3337 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3338 timevar_pop (TV_IFCVT);
3341 /* Register allocation pre-pass, to reduce number of moves
3342 necessary for two-address machines. */
3343 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3345 timevar_push (TV_REGMOVE);
3346 open_dump_file (DFI_regmove, decl);
3348 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3350 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3351 timevar_pop (TV_REGMOVE);
3356 /* Do unconditional splitting before register allocation to allow machine
3357 description to add extra information not needed previously. */
3358 split_all_insns (1);
3360 /* Any of the several passes since flow1 will have munged register
3361 lifetime data a bit. */
3362 register_life_up_to_date = 0;
3364 #ifdef OPTIMIZE_MODE_SWITCHING
3365 timevar_push (TV_MODE_SWITCH);
3368 if (optimize_mode_switching (NULL))
3370 /* We did work, and so had to regenerate global life information.
3371 Take advantage of this and don't re-recompute register life
3372 information below. */
3373 register_life_up_to_date = 1;
3377 timevar_pop (TV_MODE_SWITCH);
3380 timevar_push (TV_SCHED);
3382 #ifdef INSN_SCHEDULING
3384 /* Print function header into sched dump now
3385 because doing the sched analysis makes some of the dump. */
3386 if (optimize > 0 && flag_schedule_insns)
3388 open_dump_file (DFI_sched, decl);
3390 /* Do control and data sched analysis,
3391 and write some of the results to dump file. */
3393 schedule_insns (rtl_dump_file);
3395 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3397 /* Register lifetime information was updated as part of verifying
3399 register_life_up_to_date = 1;
3402 timevar_pop (TV_SCHED);
3406 /* Determine if the current function is a leaf before running reload
3407 since this can impact optimizations done by the prologue and
3408 epilogue thus changing register elimination offsets. */
3409 current_function_is_leaf = leaf_function_p ();
3411 timevar_push (TV_LOCAL_ALLOC);
3412 open_dump_file (DFI_lreg, decl);
3414 /* Allocate pseudo-regs that are used only within 1 basic block.
3416 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3417 jump optimizer after register allocation and reloading are finished. */
3419 if (! register_life_up_to_date)
3420 recompute_reg_usage (insns, ! optimize_size);
3422 /* Allocate the reg_renumber array. */
3423 allocate_reg_info (max_regno, FALSE, TRUE);
3425 /* And the reg_equiv_memory_loc array. */
3426 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3428 allocate_initial_values (reg_equiv_memory_loc);
3430 regclass (insns, max_reg_num (), rtl_dump_file);
3431 rebuild_label_notes_after_reload = local_alloc ();
3433 timevar_pop (TV_LOCAL_ALLOC);
3435 if (dump_file[DFI_lreg].enabled)
3437 timevar_push (TV_DUMP);
3439 dump_flow_info (rtl_dump_file);
3440 dump_local_alloc (rtl_dump_file);
3442 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3443 timevar_pop (TV_DUMP);
3448 timevar_push (TV_GLOBAL_ALLOC);
3449 open_dump_file (DFI_greg, decl);
3451 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3452 pass fixing up any insns that are invalid. */
3455 failure = global_alloc (rtl_dump_file);
3458 build_insn_chain (insns);
3459 failure = reload (insns, 0);
3462 timevar_pop (TV_GLOBAL_ALLOC);
3464 if (dump_file[DFI_greg].enabled)
3466 timevar_push (TV_DUMP);
3468 dump_global_regs (rtl_dump_file);
3470 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3471 timevar_pop (TV_DUMP);
3475 goto exit_rest_of_compilation;
3479 open_dump_file (DFI_postreload, decl);
3481 /* Do a very simple CSE pass over just the hard registers. */
3484 timevar_push (TV_RELOAD_CSE_REGS);
3485 reload_cse_regs (insns);
3486 timevar_pop (TV_RELOAD_CSE_REGS);
3489 /* Register allocation and reloading may have turned an indirect jump into
3490 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3491 jumping instructions. */
3492 if (rebuild_label_notes_after_reload)
3494 timevar_push (TV_JUMP);
3496 rebuild_jump_labels (insns);
3498 timevar_pop (TV_JUMP);
3501 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3503 /* Re-create the death notes which were deleted during reload. */
3504 timevar_push (TV_FLOW2);
3505 open_dump_file (DFI_flow2, decl);
3507 #ifdef ENABLE_CHECKING
3508 verify_flow_info ();
3511 /* If optimizing, then go ahead and split insns now. */
3513 split_all_insns (0);
3515 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3517 /* On some machines, the prologue and epilogue code, or parts thereof,
3518 can be represented as RTL. Doing so lets us schedule insns between
3519 it and the rest of the code and also allows delayed branch
3520 scheduling to operate in the epilogue. */
3521 thread_prologue_and_epilogue_insns (insns);
3525 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_CROSSJUMP);
3526 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3528 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3529 even for machines with possibly nonzero RETURN_POPS_ARGS
3530 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3531 push instructions will have popping returns. */
3532 #ifndef PUSH_ROUNDING
3533 if (!ACCUMULATE_OUTGOING_ARGS)
3535 combine_stack_adjustments ();
3540 flow2_completed = 1;
3542 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3543 timevar_pop (TV_FLOW2);
3545 #ifdef HAVE_peephole2
3546 if (optimize > 0 && flag_peephole2)
3548 timevar_push (TV_PEEPHOLE2);
3549 open_dump_file (DFI_peephole2, decl);
3551 peephole2_optimize (rtl_dump_file);
3553 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3554 timevar_pop (TV_PEEPHOLE2);
3558 if (optimize > 0 && flag_rename_registers)
3560 timevar_push (TV_RENAME_REGISTERS);
3561 open_dump_file (DFI_rnreg, decl);
3563 regrename_optimize ();
3565 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3566 timevar_pop (TV_RENAME_REGISTERS);
3571 timevar_push (TV_IFCVT2);
3572 open_dump_file (DFI_ce2, decl);
3576 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3577 timevar_pop (TV_IFCVT2);
3581 split_all_insns (1);
3584 #ifdef INSN_SCHEDULING
3585 if (optimize > 0 && flag_schedule_insns_after_reload)
3587 timevar_push (TV_SCHED2);
3588 open_dump_file (DFI_sched2, decl);
3590 /* Do control and data sched analysis again,
3591 and write some more of the results to dump file. */
3593 split_all_insns (1);
3595 schedule_insns (rtl_dump_file);
3597 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3598 timevar_pop (TV_SCHED2);
3604 #ifdef LEAF_REGISTERS
3605 current_function_uses_only_leaf_regs
3606 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3610 timevar_push (TV_REG_STACK);
3611 open_dump_file (DFI_stack, decl);
3613 reg_to_stack (insns, rtl_dump_file);
3615 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3616 timevar_pop (TV_REG_STACK);
3622 timevar_push (TV_REORDER_BLOCKS);
3623 open_dump_file (DFI_bbro, decl);
3625 /* Last attempt to optimize CFG, as life analyzis possibly removed
3626 some instructions. */
3627 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3628 | CLEANUP_CROSSJUMP);
3629 if (flag_reorder_blocks)
3631 reorder_basic_blocks ();
3632 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3635 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3636 timevar_pop (TV_REORDER_BLOCKS);
3638 compute_alignments ();
3640 /* CFG is no longer maintained up-to-date. */
3641 free_bb_for_insn ();
3643 /* If a machine dependent reorganization is needed, call it. */
3644 #ifdef MACHINE_DEPENDENT_REORG
3645 timevar_push (TV_MACH_DEP);
3646 open_dump_file (DFI_mach, decl);
3648 MACHINE_DEPENDENT_REORG (insns);
3650 close_dump_file (DFI_mach, print_rtl, insns);
3651 timevar_pop (TV_MACH_DEP);
3656 purge_line_number_notes (insns);
3657 cleanup_barriers ();
3659 /* If a scheduling pass for delayed branches is to be done,
3660 call the scheduling code. */
3663 if (optimize > 0 && flag_delayed_branch)
3665 timevar_push (TV_DBR_SCHED);
3666 open_dump_file (DFI_dbr, decl);
3668 dbr_schedule (insns, rtl_dump_file);
3670 close_dump_file (DFI_dbr, print_rtl, insns);
3671 timevar_pop (TV_DBR_SCHED);
3677 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3678 timevar_push (TV_SHORTEN_BRANCH);
3679 split_all_insns_noflow ();
3680 timevar_pop (TV_SHORTEN_BRANCH);
3683 convert_to_eh_region_ranges ();
3685 /* Shorten branches. */
3686 timevar_push (TV_SHORTEN_BRANCH);
3687 shorten_branches (get_insns ());
3688 timevar_pop (TV_SHORTEN_BRANCH);
3690 current_function_nothrow = nothrow_function_p ();
3691 if (current_function_nothrow)
3692 /* Now we know that this can't throw; set the flag for the benefit
3693 of other functions later in this translation unit. */
3694 TREE_NOTHROW (current_function_decl) = 1;
3696 /* Now turn the rtl into assembler code. */
3698 timevar_push (TV_FINAL);
3703 /* Get the function's name, as described by its RTL. This may be
3704 different from the DECL_NAME name used in the source file. */
3706 x = DECL_RTL (decl);
3707 if (GET_CODE (x) != MEM)
3710 if (GET_CODE (x) != SYMBOL_REF)
3712 fnname = XSTR (x, 0);
3714 assemble_start_function (decl, fnname);
3715 final_start_function (insns, asm_out_file, optimize);
3716 final (insns, asm_out_file, optimize, 0);
3717 final_end_function ();
3719 #ifdef IA64_UNWIND_INFO
3720 /* ??? The IA-64 ".handlerdata" directive must be issued before
3721 the ".endp" directive that closes the procedure descriptor. */
3722 output_function_exception_table ();
3725 assemble_end_function (decl, fnname);
3727 #ifndef IA64_UNWIND_INFO
3728 /* Otherwise, it feels unclean to switch sections in the middle. */
3729 output_function_exception_table ();
3733 fflush (asm_out_file);
3735 /* Release all memory allocated by flow. */
3736 free_basic_block_vars (0);
3738 /* Release all memory held by regsets now. */
3739 regset_release_memory ();
3741 timevar_pop (TV_FINAL);
3745 /* Write DBX symbols if requested. */
3747 /* Note that for those inline functions where we don't initially
3748 know for certain that we will be generating an out-of-line copy,
3749 the first invocation of this routine (rest_of_compilation) will
3750 skip over this code by doing a `goto exit_rest_of_compilation;'.
3751 Later on, finish_compilation will call rest_of_compilation again
3752 for those inline functions that need to have out-of-line copies
3753 generated. During that call, we *will* be routed past here. */
3755 timevar_push (TV_SYMOUT);
3756 (*debug_hooks->function_decl) (decl);
3757 timevar_pop (TV_SYMOUT);
3759 exit_rest_of_compilation:
3761 /* In case the function was not output,
3762 don't leave any temporary anonymous types
3763 queued up for sdb output. */
3764 #ifdef SDB_DEBUGGING_INFO
3765 if (write_symbols == SDB_DEBUG)
3766 sdbout_types (NULL_TREE);
3769 reload_completed = 0;
3770 flow2_completed = 0;
3773 timevar_push (TV_FINAL);
3775 /* Clear out the insn_length contents now that they are no
3777 init_insn_lengths ();
3779 /* Clear out the real_constant_chain before some of the rtx's
3780 it runs through become garbage. */
3781 clear_const_double_mem ();
3783 /* Show no temporary slots allocated. */
3786 free_basic_block_vars (0);
3788 timevar_pop (TV_FINAL);
3790 /* Make sure volatile mem refs aren't considered valid operands for
3791 arithmetic insns. We must call this here if this is a nested inline
3792 function, since the above code leaves us in the init_recog state
3793 (from final.c), and the function context push/pop code does not
3794 save/restore volatile_ok.
3796 ??? Maybe it isn't necessary for expand_start_function to call this
3797 anymore if we do it here? */
3799 init_recog_no_volatile ();
3801 /* We're done with this function. Free up memory if we can. */
3802 free_after_parsing (cfun);
3803 if (! DECL_DEFER_OUTPUT (decl))
3805 free_after_compilation (cfun);
3807 /* Clear integrate.c's pointer to the cfun structure we just
3809 DECL_SAVED_INSNS (decl) = 0;
3815 timevar_pop (TV_REST_OF_COMPILATION);
3825 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3826 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3827 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3828 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3829 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3830 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"));
3832 for (i = ARRAY_SIZE (f_options); i--;)
3834 const char *description = f_options[i].description;
3836 if (description != NULL && * description != 0)
3837 printf (" -f%-21s %s\n",
3838 f_options[i].string, _(description));
3841 printf (_(" -O[number] Set optimisation level to [number]\n"));
3842 printf (_(" -Os Optimise for space rather than speed\n"));
3843 for (i = LAST_PARAM; i--;)
3845 const char *description = compiler_params[i].help;
3846 const int length = 21-strlen(compiler_params[i].option);
3848 if (description != NULL && * description != 0)
3849 printf (" --param %s=<value>%.*s%s\n",
3850 compiler_params[i].option,
3851 length > 0 ? length : 1, " ",
3854 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3855 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3856 printf (_(" -w Suppress warnings\n"));
3857 printf (_(" -W Enable extra warnings\n"));
3859 for (i = ARRAY_SIZE (W_options); i--;)
3861 const char *description = W_options[i].description;
3863 if (description != NULL && * description != 0)
3864 printf (" -W%-21s %s\n",
3865 W_options[i].string, _(description));
3868 printf (_(" -Wunused Enable unused warnings\n"));
3869 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3870 printf (_(" -p Enable function profiling\n"));
3871 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER)
3872 printf (_(" -a Enable block profiling \n"));
3874 #if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT
3875 printf (_(" -ax Enable jump profiling \n"));
3877 printf (_(" -o <file> Place output into <file> \n"));
3879 -G <number> Put global and static data smaller than <number>\n\
3880 bytes into a special section (on some targets)\n"));
3882 for (i = ARRAY_SIZE (debug_args); i--;)
3884 if (debug_args[i].description != NULL)
3885 printf (" -g%-21s %s\n",
3886 debug_args[i].arg, _(debug_args[i].description));
3889 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3890 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3891 printf (_(" -version Display the compiler's version\n"));
3892 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3893 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3894 #if defined INSN_SCHEDULING
3895 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3897 printf (_(" --help Display this information\n"));
3902 /* Display descriptions of language specific options.
3903 If there is no description, note that there is an undocumented option.
3904 If the description is empty, do not display anything. (This allows
3905 options to be deliberately undocumented, for whatever reason).
3906 If the option string is missing, then this is a marker, indicating
3907 that the description string is in fact the name of a language, whose
3908 language specific options are to follow. */
3910 if (ARRAY_SIZE (documented_lang_options) > 1)
3912 printf (_("\nLanguage specific options:\n"));
3914 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3916 const char *description = documented_lang_options[i].description;
3917 const char *option = documented_lang_options[i].option;
3919 if (description == NULL)
3924 printf (_(" %-23.23s [undocumented]\n"), option);
3926 else if (*description == 0)
3928 else if (option == NULL)
3932 (_("\nThere are undocumented %s specific options as well.\n"),
3936 printf (_("\n Options for %s:\n"), description);
3941 printf (" %-23.23s %s\n", option, _(description));
3946 printf (_("\nThere are undocumented %s specific options as well.\n"),
3949 display_target_options ();
3953 display_target_options ()
3957 if (ARRAY_SIZE (target_switches) > 1
3958 #ifdef TARGET_OPTIONS
3959 || ARRAY_SIZE (target_options) > 1
3967 printf (_("\nTarget specific options:\n"));
3969 for (i = ARRAY_SIZE (target_switches); i--;)
3971 const char *option = target_switches[i].name;
3972 const char *description = target_switches[i].description;
3974 if (option == NULL || *option == 0)
3976 else if (description == NULL)
3981 printf (_(" -m%-23.23s [undocumented]\n"), option);
3983 else if (* description != 0)
3984 doc += printf (" -m%-23.23s %s\n", option, _(description));
3987 #ifdef TARGET_OPTIONS
3988 for (i = ARRAY_SIZE (target_options); i--;)
3990 const char *option = target_options[i].prefix;
3991 const char *description = target_options[i].description;
3993 if (option == NULL || *option == 0)
3995 else if (description == NULL)
4000 printf (_(" -m%-23.23s [undocumented]\n"), option);
4002 else if (* description != 0)
4003 doc += printf (" -m%-23.23s %s\n", option, _(description));
4009 printf (_("\nThere are undocumented target specific options as well.\n"));
4011 printf (_(" They exist, but they are not documented.\n"));
4016 /* Parse a -d... command line switch. */
4019 decode_d_option (arg)
4028 for (i = 0; i < (int) DFI_MAX; ++i)
4029 dump_file[i].enabled = 1;
4035 flag_print_asm_name = 1;
4038 flag_dump_rtl_in_asm = 1;
4039 flag_print_asm_name = 1;
4042 graph_dump_format = vcg;
4045 rtl_dump_and_exit = 1;
4048 (*lang_hooks.set_yydebug) (1);
4050 case 'D': /* These are handled by the preprocessor. */
4056 for (i = 0; i < (int) DFI_MAX; ++i)
4057 if (c == dump_file[i].debug_switch)
4059 dump_file[i].enabled = 1;
4064 warning ("unrecognized gcc debugging option: %c", c);
4069 /* Parse a -f... command line switch. ARG is the value after the -f.
4070 It is safe to access 'ARG - 2' to generate the full switch name.
4071 Return the number of strings consumed. */
4074 decode_f_option (arg)
4078 const char *option_value = NULL;
4080 /* Search for the option in the table of binary f options. */
4081 for (j = ARRAY_SIZE (f_options); j--;)
4083 if (!strcmp (arg, f_options[j].string))
4085 *f_options[j].variable = f_options[j].on_value;
4089 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4090 && ! strcmp (arg + 3, f_options[j].string))
4092 *f_options[j].variable = ! f_options[j].on_value;
4097 if (!strcmp (arg, "fast-math"))
4098 set_fast_math_flags();
4099 else if (!strcmp (arg, "no-fast-math"))
4100 set_no_fast_math_flags();
4101 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4102 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4105 read_integral_parameter (option_value, arg - 2,
4107 set_param_value ("max-inline-insns", val);
4109 #ifdef INSN_SCHEDULING
4110 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4111 fix_sched_param ("verbose", option_value);
4113 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4114 fix_register (option_value, 1, 1);
4115 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4116 fix_register (option_value, 0, 1);
4117 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4118 fix_register (option_value, 0, 0);
4119 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4120 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4121 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4123 = read_integral_parameter (option_value, arg - 2, align_functions);
4124 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4125 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4126 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4128 = read_integral_parameter (option_value, arg - 2, align_labels);
4129 else if ((option_value
4130 = skip_leading_substring (arg, "stack-limit-register=")))
4132 int reg = decode_reg_name (option_value);
4134 error ("unrecognized register name `%s'", option_value);
4136 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4138 else if ((option_value
4139 = skip_leading_substring (arg, "stack-limit-symbol=")))
4142 nm = ggc_strdup (option_value);
4143 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4145 else if ((option_value
4146 = skip_leading_substring (arg, "message-length=")))
4147 output_set_maximum_length
4148 (&global_dc->buffer, read_integral_parameter
4149 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
4150 else if ((option_value
4151 = skip_leading_substring (arg, "diagnostics-show-location=")))
4153 if (!strcmp (option_value, "once"))
4154 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
4155 else if (!strcmp (option_value, "every-line"))
4156 diagnostic_prefixing_rule (global_dc)
4157 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
4159 error ("Unrecognized option `%s'", arg - 2);
4161 else if (!strcmp (arg, "no-stack-limit"))
4162 stack_limit_rtx = NULL_RTX;
4163 else if (!strcmp (arg, "preprocessed"))
4164 /* Recognise this switch but do nothing. This prevents warnings
4165 about an unrecognized switch if cpplib has not been linked in. */
4173 /* Parse a -W... command line switch. ARG is the value after the -W.
4174 It is safe to access 'ARG - 2' to generate the full switch name.
4175 Return the number of strings consumed. */
4178 decode_W_option (arg)
4181 const char *option_value = NULL;
4184 /* Search for the option in the table of binary W options. */
4186 for (j = ARRAY_SIZE (W_options); j--;)
4188 if (!strcmp (arg, W_options[j].string))
4190 *W_options[j].variable = W_options[j].on_value;
4194 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4195 && ! strcmp (arg + 3, W_options[j].string))
4197 *W_options[j].variable = ! W_options[j].on_value;
4202 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4203 warning ("-Wid-clash-LEN is no longer supported");
4204 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4206 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4208 warn_larger_than = larger_than_size != -1;
4210 else if (!strcmp (arg, "unused"))
4214 else if (!strcmp (arg, "no-unused"))
4224 /* Parse a -g... command line switch. ARG is the value after the -g.
4225 It is safe to access 'ARG - 2' to generate the full switch name.
4226 Return the number of strings consumed. */
4229 decode_g_option (arg)
4232 static unsigned level=0;
4233 /* A lot of code assumes write_symbols == NO_DEBUG if the
4234 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4235 of what debugging type has been selected). This records the
4236 selected type. It is an error to specify more than one
4238 static enum debug_info_type selected_debug_type = NO_DEBUG;
4239 /* Non-zero if debugging format has been explicitly set.
4240 -g and -ggdb don't explicitly set the debugging format so
4241 -gdwarf -g3 is equivalent to -gdwarf3. */
4242 static int type_explicitly_set_p = 0;
4243 /* Indexed by enum debug_info_type. */
4244 static const char *const debug_type_names[] =
4246 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
4249 /* The maximum admissible debug level value. */
4250 static const unsigned max_debug_level = 3;
4252 /* Look up ARG in the table. */
4253 for (da = debug_args; da->arg; da++)
4255 const int da_len = strlen (da->arg);
4257 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4259 enum debug_info_type type = da->debug_type;
4260 const char *p = arg + da_len;
4262 if (*p && ! ISDIGIT (*p))
4265 /* A debug flag without a level defaults to level 2.
4266 Note we do not want to call read_integral_parameter
4267 for that case since it will call atoi which
4270 ??? We may want to generalize the interface to
4271 read_integral_parameter to better handle this case
4272 if this case shows up often. */
4274 level = read_integral_parameter (p, 0, max_debug_level + 1);
4276 level = (level == 0) ? 2 : level;
4278 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4280 error ("use -gdwarf -g%d for DWARF v1, level %d",
4283 error ("use -gdwarf-2 for DWARF v2");
4286 if (level > max_debug_level)
4289 ignoring option `%s' due to invalid debug level specification",
4291 level = debug_info_level;
4294 if (type == NO_DEBUG)
4296 type = PREFERRED_DEBUGGING_TYPE;
4298 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4300 #if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2)
4301 type = DWARF2_DEBUG;
4303 #ifdef DBX_DEBUGGING_INFO
4310 if (type == NO_DEBUG)
4311 warning ("`%s': unknown or unsupported -g option", arg - 2);
4313 /* Does it conflict with an already selected type? */
4314 if (type_explicitly_set_p
4315 /* -g/-ggdb don't conflict with anything. */
4316 && da->debug_type != NO_DEBUG
4317 && type != selected_debug_type)
4318 warning ("`%s' ignored, conflicts with `-g%s'",
4319 arg - 2, debug_type_names[(int) selected_debug_type]);
4322 /* If the format has already been set, -g/-ggdb
4323 only change the debug level. */
4324 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4325 /* Don't change debugging type. */
4329 selected_debug_type = type;
4330 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4333 write_symbols = (level == 0
4335 : selected_debug_type);
4336 use_gnu_debug_info_extensions = da->use_extensions_p;
4337 debug_info_level = (enum debug_info_level) level;
4350 /* Decode the first argument in the argv as a language-independent option.
4351 Return the number of strings consumed. */
4354 independent_decode_option (argc, argv)
4358 char *arg = argv[0];
4360 if (arg[0] != '-' || arg[1] == 0)
4372 if (!strcmp (arg, "-help"))
4375 exit_after_options = 1;
4378 if (!strcmp (arg, "-target-help"))
4380 display_target_options ();
4381 exit_after_options = 1;
4384 if (!strcmp (arg, "-version"))
4386 print_version (stderr, "");
4387 exit_after_options = 1;
4390 /* Handle '--param <name>=<value>'. */
4391 if (strcmp (arg, "-param") == 0)
4397 error ("-param option missing argument");
4401 /* Get the '<name>=<value>' parameter. */
4403 /* Look for the `='. */
4404 equal = strchr (arg, '=');
4406 error ("invalid --param option: %s", arg);
4411 /* Zero out the `=' sign so that we get two separate strings. */
4413 /* Figure out what value is specified. */
4414 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4415 if (val != INVALID_PARAM_VAL)
4416 set_param_value (arg, val);
4418 error ("invalid parameter value `%s'", equal + 1);
4433 /* Already been treated in main (). Do nothing. */
4437 set_target_switch (arg + 1);
4441 return decode_f_option (arg + 1);
4444 return decode_g_option (arg + 1);
4447 if (!strcmp (arg, "dumpbase"))
4452 dump_base_name = argv[1];
4456 decode_d_option (arg + 1);
4460 if (!strcmp (arg, "pedantic"))
4462 else if (!strcmp (arg, "pedantic-errors"))
4463 flag_pedantic_errors = pedantic = 1;
4464 else if (arg[1] == 0)
4471 if (!strcmp (arg, "quiet"))
4478 if (!strcmp (arg, "version"))
4486 inhibit_warnings = 1;
4495 /* We save the value of warn_uninitialized, since if they put
4496 -Wuninitialized on the command line, we need to generate a
4497 warning about not using it without also specifying -O. */
4498 if (warn_uninitialized != 1)
4499 warn_uninitialized = 2;
4502 return decode_W_option (arg + 1);
4508 #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4509 warning ("`-a' option (basic block profile) not supported");
4511 profile_block_flag = (profile_block_flag < 2) ? 1 : 3;
4514 else if (!strcmp (arg, "ax"))
4516 #if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
4517 warning ("`-ax' option (jump profiling) not supported");
4519 profile_block_flag = (!profile_block_flag
4520 || profile_block_flag == 2) ? 2 : 3;
4523 else if (!strncmp (arg, "aux-info", 8))
4530 aux_info_file_name = argv[1];
4531 flag_gen_aux_info = 1;
4534 else if (arg[8] == '=')
4536 aux_info_file_name = arg + 9;
4537 flag_gen_aux_info = 1;
4552 asm_file_name = argv[1];
4567 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4572 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4576 if (g_switch_val == -1)
4580 g_switch_set = TRUE;
4581 g_switch_value = g_switch_val;
4591 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4592 Decode command args, then call compile_file.
4593 Exit code is FATAL_EXIT_CODE if can't open files or if there were
4594 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
4596 It is not safe to call this function more than once. */
4599 toplev_main (argc, argv)
4606 /* save in case md file wants to emit args as a comment. */
4610 p = argv[0] + strlen (argv[0]);
4611 while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
4615 xmalloc_set_program_name (progname);
4617 gcc_init_libintl ();
4619 /* Install handler for SIGFPE, which may be received while we do
4620 compile-time floating point arithmetic. */
4621 signal (SIGFPE, float_signal);
4623 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4625 signal (SIGSEGV, crash_signal);
4628 signal (SIGILL, crash_signal);
4631 signal (SIGBUS, crash_signal);
4634 signal (SIGABRT, crash_signal);
4636 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4637 signal (SIGIOT, crash_signal);
4640 decl_printable_name = decl_name;
4641 lang_expand_expr = (lang_expand_expr_t) do_abort;
4643 /* Initialize whether `char' is signed. */
4644 flag_signed_char = DEFAULT_SIGNED_CHAR;
4645 #ifdef DEFAULT_SHORT_ENUMS
4646 /* Initialize how much space enums occupy, by default. */
4647 flag_short_enums = DEFAULT_SHORT_ENUMS;
4650 tree_code_length[(int) IDENTIFIER_NODE]
4651 = ((lang_hooks.identifier_size - sizeof (struct tree_common))
4654 /* Initialize the garbage-collector. */
4657 ggc_add_rtx_root (&stack_limit_rtx, 1);
4658 ggc_add_tree_root (¤t_function_decl, 1);
4659 ggc_add_tree_root (¤t_function_func_begin_label, 1);
4661 /* Initialize the diagnostics reporting machinery. */
4662 diagnostic_initialize (global_dc);
4664 /* Register the language-independent parameters. */
4665 add_params (lang_independent_params, LAST_PARAM);
4667 /* Perform language-specific options intialization. */
4668 (*lang_hooks.init_options) ();
4670 /* Scan to see what optimization level has been specified. That will
4671 determine the default value of many flags. */
4672 for (i = 1; i < argc; i++)
4674 if (!strcmp (argv[i], "-O"))
4679 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4681 /* Handle -Os, -O2, -O3, -O69, ... */
4682 char *p = &argv[i][2];
4684 if ((p[0] == 's') && (p[1] == 0))
4688 /* Optimizing for size forces optimize to be 2. */
4693 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4694 if (optimize_val != -1)
4696 optimize = optimize_val;
4705 flag_merge_constants = 0;
4711 flag_thread_jumps = 1;
4713 flag_delayed_branch = 1;
4715 #ifdef CAN_DEBUG_WITHOUT_FP
4716 flag_omit_frame_pointer = 1;
4718 flag_guess_branch_prob = 1;
4723 flag_optimize_sibling_calls = 1;
4724 flag_cse_follow_jumps = 1;
4725 flag_cse_skip_blocks = 1;
4727 flag_expensive_optimizations = 1;
4728 flag_strength_reduce = 1;
4729 flag_rerun_cse_after_loop = 1;
4730 flag_rerun_loop_opt = 1;
4731 flag_caller_saves = 1;
4734 #ifdef INSN_SCHEDULING
4735 flag_schedule_insns = 1;
4736 flag_schedule_insns_after_reload = 1;
4739 flag_strict_aliasing = 1;
4740 flag_delete_null_pointer_checks = 1;
4741 flag_reorder_blocks = 1;
4746 flag_inline_functions = 1;
4747 flag_rename_registers = 1;
4750 if (optimize < 2 || optimize_size)
4755 align_functions = 1;
4758 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4761 set_target_switch ("");
4763 /* Unwind tables are always present in an ABI-conformant IA-64
4764 object file, so the default should be ON. */
4765 #ifdef IA64_UNWIND_INFO
4766 flag_unwind_tables = IA64_UNWIND_INFO;
4769 #ifdef OPTIMIZATION_OPTIONS
4770 /* Allow default optimizations to be specified on a per-machine basis. */
4771 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4774 /* Initialize register usage now so switches may override. */
4777 /* Perform normal command line switch decoding. */
4778 for (i = 1; i < argc;)
4781 int indep_processed;
4783 /* Give the language a chance to decode the option for itself. */
4784 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4786 if (lang_processed >= 0)
4787 /* Now see if the option also has a language independent meaning.
4788 Some options are both language specific and language independent,
4790 indep_processed = independent_decode_option (argc - i, argv + i);
4793 lang_processed = -lang_processed;
4794 indep_processed = 0;
4797 if (lang_processed || indep_processed)
4798 i += MAX (lang_processed, indep_processed);
4801 const char *option = NULL;
4802 const char *lang = NULL;
4805 /* It is possible that the command line switch is not valid for the
4806 current language, but it is valid for another language. In order
4807 to be compatible with previous versions of the compiler (which
4808 did not issue an error message in this case) we check for this
4809 possibility here. If we do find a match, then if extra_warnings
4810 is set we generate a warning message, otherwise we will just
4811 ignore the option. */
4812 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4814 option = documented_lang_options[j].option;
4817 lang = documented_lang_options[j].description;
4818 else if (! strncmp (argv[i], option, strlen (option)))
4822 if (j != ARRAY_SIZE (documented_lang_options))
4826 warning ("Ignoring command line option '%s'", argv[i]);
4829 ("(It is valid for %s but not the selected language)",
4833 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4834 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4836 error ("Unrecognized option `%s'", argv[i]);
4842 /* All command line options have been processed. */
4843 (*lang_hooks.post_options) ();
4845 if (exit_after_options)
4848 /* Checker uses the frame pointer. */
4849 if (flag_check_memory_usage)
4850 flag_omit_frame_pointer = 0;
4854 /* Inlining does not work if not optimizing,
4855 so force it not to be done. */
4859 /* The c_decode_option function and decode_option hook set
4860 this to `2' if -Wall is used, so we can avoid giving out
4861 lots of errors for people who don't realize what -Wall does. */
4862 if (warn_uninitialized == 1)
4863 warning ("-Wuninitialized is not supported without -O");
4866 /* We do not currently support sibling-call optimization in the
4867 presence of exceptions. See PR2975 for a test-case that will
4868 fail if we try to combine both of these features. */
4869 if (flag_exceptions)
4870 flag_optimize_sibling_calls = 0;
4872 #ifdef OVERRIDE_OPTIONS
4873 /* Some machines may reject certain combinations of options. */
4877 /* Set up the align_*_log variables, defaulting them to 1 if they
4878 were still unset. */
4879 if (align_loops <= 0) align_loops = 1;
4880 align_loops_log = floor_log2 (align_loops * 2 - 1);
4881 if (align_jumps <= 0) align_jumps = 1;
4882 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4883 if (align_labels <= 0) align_labels = 1;
4884 align_labels_log = floor_log2 (align_labels * 2 - 1);
4885 if (align_functions <= 0) align_functions = 1;
4886 align_functions_log = floor_log2 (align_functions * 2 - 1);
4888 if (profile_block_flag == 3)
4890 warning ("`-ax' and `-a' are conflicting options. `-a' ignored.");
4891 profile_block_flag = 2;
4894 /* Unrolling all loops implies that standard loop unrolling must also
4896 if (flag_unroll_all_loops)
4897 flag_unroll_loops = 1;
4898 /* Loop unrolling requires that strength_reduction be on also. Silently
4899 turn on strength reduction here if it isn't already on. Also, the loop
4900 unrolling code assumes that cse will be run after loop, so that must
4901 be turned on also. */
4902 if (flag_unroll_loops)
4904 flag_strength_reduce = 1;
4905 flag_rerun_cse_after_loop = 1;
4908 if (flag_non_call_exceptions)
4909 flag_asynchronous_unwind_tables = 1;
4910 if (flag_asynchronous_unwind_tables)
4911 flag_unwind_tables = 1;
4913 /* Warn about options that are not supported on this machine. */
4914 #ifndef INSN_SCHEDULING
4915 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4916 warning ("instruction scheduling not supported on this target machine");
4919 if (flag_delayed_branch)
4920 warning ("this target machine does not have delayed branches");
4923 /* Some operating systems do not allow profiling without a frame
4925 if (!TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
4927 && flag_omit_frame_pointer)
4929 error ("profiling does not work without a frame pointer");
4930 flag_omit_frame_pointer = 0;
4933 user_label_prefix = USER_LABEL_PREFIX;
4934 if (flag_leading_underscore != -1)
4936 /* If the default prefix is more complicated than "" or "_",
4937 issue a warning and ignore this option. */
4938 if (user_label_prefix[0] == 0 ||
4939 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4941 user_label_prefix = flag_leading_underscore ? "_" : "";
4944 warning ("-f%sleading-underscore not supported on this target machine",
4945 flag_leading_underscore ? "" : "no-");
4948 /* If we are in verbose mode, write out the version and maybe all the
4949 option flags in use. */
4952 print_version (stderr, "");
4954 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4957 compile_file (filename);
4960 return (FATAL_EXIT_CODE);
4962 return (FATAL_EXIT_CODE);
4963 return (SUCCESS_EXIT_CODE);
4966 /* Decode -m switches. */
4967 /* Decode the switch -mNAME. */
4970 set_target_switch (name)
4974 int valid_target_option = 0;
4976 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4977 if (!strcmp (target_switches[j].name, name))
4979 if (target_switches[j].value < 0)
4980 target_flags &= ~-target_switches[j].value;
4982 target_flags |= target_switches[j].value;
4983 valid_target_option = 1;
4986 #ifdef TARGET_OPTIONS
4987 if (!valid_target_option)
4988 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4990 int len = strlen (target_options[j].prefix);
4991 if (!strncmp (target_options[j].prefix, name, len))
4993 *target_options[j].variable = name + len;
4994 valid_target_option = 1;
4999 if (!valid_target_option)
5000 error ("Invalid option `%s'", name);
5003 /* Print version information to FILE.
5004 Each line begins with INDENT (for the case where FILE is the
5005 assembler output file). */
5008 print_version (file, indent)
5013 #define __VERSION__ "[?]"
5017 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
5019 "%s%s%s version %s (%s) compiled by CC.\n"
5021 , indent, *indent != 0 ? " " : "",
5022 lang_hooks.name, version_string, TARGET_NAME,
5023 indent, __VERSION__);
5026 /* Print an option value and return the adjusted position in the line.
5027 ??? We don't handle error returns from fprintf (disk full); presumably
5028 other code will catch a disk full though. */
5031 print_single_switch (file, pos, max, indent, sep, term, type, name)
5034 const char *indent, *sep, *term, *type, *name;
5036 /* The ultrix fprintf returns 0 on success, so compute the result we want
5037 here since we need it for the following test. */
5038 int len = strlen (sep) + strlen (type) + strlen (name);
5043 fprintf (file, "%s", term);
5048 fprintf (file, "%s", indent);
5049 pos = strlen (indent);
5051 fprintf (file, "%s%s%s", sep, type, name);
5056 /* Print active target switches to FILE.
5057 POS is the current cursor position and MAX is the size of a "line".
5058 Each line begins with INDENT and ends with TERM.
5059 Each switch is separated from the next by SEP. */
5062 print_switch_values (file, pos, max, indent, sep, term)
5065 const char *indent, *sep, *term;
5070 /* Print the options as passed. */
5072 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
5073 _("options passed: "), "");
5075 for (p = &save_argv[1]; *p != NULL; p++)
5079 if (strcmp (*p, "-o") == 0)
5085 if (strcmp (*p, "-quiet") == 0)
5087 if (strcmp (*p, "-version") == 0)
5092 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
5095 fprintf (file, "%s", term);
5097 /* Print the -f and -m options that have been enabled.
5098 We don't handle language specific options but printing argv
5101 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
5102 _("options enabled: "), "");
5104 for (j = 0; j < ARRAY_SIZE (f_options); j++)
5105 if (*f_options[j].variable == f_options[j].on_value)
5106 pos = print_single_switch (file, pos, max, indent, sep, term,
5107 "-f", f_options[j].string);
5109 /* Print target specific options. */
5111 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
5112 if (target_switches[j].name[0] != '\0'
5113 && target_switches[j].value > 0
5114 && ((target_switches[j].value & target_flags)
5115 == target_switches[j].value))
5117 pos = print_single_switch (file, pos, max, indent, sep, term,
5118 "-m", target_switches[j].name);
5121 #ifdef TARGET_OPTIONS
5122 for (j = 0; j < ARRAY_SIZE (target_options); j++)
5123 if (*target_options[j].variable != NULL)
5126 sprintf (prefix, "-m%s", target_options[j].prefix);
5127 pos = print_single_switch (file, pos, max, indent, sep, term,
5128 prefix, *target_options[j].variable);
5132 fprintf (file, "%s", term);