Daily bump.
[official-gcc.git] / gcc / toplev.c
blobefc7c973ac41aaae755da240ca9c287e0a4a1b39
1 /* Top level of GNU C compiler
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 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
10 version.
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
15 for more details.
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
20 02111-1307, USA. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
30 #include "system.h"
31 #include <signal.h>
32 #include <setjmp.h>
34 #ifdef HAVE_SYS_RESOURCE_H
35 # include <sys/resource.h>
36 #endif
38 #ifdef HAVE_SYS_TIMES_H
39 # include <sys/times.h>
40 #endif
42 #include "input.h"
43 #include "tree.h"
44 #include "rtl.h"
45 #include "tm_p.h"
46 #include "flags.h"
47 #include "insn-attr.h"
48 #include "insn-config.h"
49 #include "insn-flags.h"
50 #include "hard-reg-set.h"
51 #include "recog.h"
52 #include "output.h"
53 #include "except.h"
54 #include "function.h"
55 #include "toplev.h"
56 #include "expr.h"
57 #include "basic-block.h"
58 #include "intl.h"
59 #include "ggc.h"
60 #include "graph.h"
61 #include "loop.h"
62 #include "regs.h"
63 #include "timevar.h"
64 #include "diagnostic.h"
65 #include "ssa.h"
66 #include "params.h"
67 #include "reload.h"
68 #include "dwarf2asm.h"
69 #include "integrate.h"
70 #include "debug.h"
71 #include "target.h"
72 #include "langhooks.h"
74 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
75 #include "dwarf2out.h"
76 #endif
78 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
79 #include "dbxout.h"
80 #endif
82 #ifdef SDB_DEBUGGING_INFO
83 #include "sdbout.h"
84 #endif
86 #ifdef XCOFF_DEBUGGING_INFO
87 #include "xcoffout.h" /* Needed for external data
88 declarations for e.g. AIX 4.x. */
89 #endif
91 #ifdef HALF_PIC_DEBUG
92 #include "halfpic.h"
93 #endif
95 /* Carry information from ASM_DECLARE_OBJECT_NAME
96 to ASM_FINISH_DECLARE_OBJECT. */
98 extern int size_directive_output;
99 extern tree last_assemble_variable_decl;
101 static void general_init PARAMS ((char *));
102 static void parse_options_and_default_flags PARAMS ((int, char **));
103 static void do_compile PARAMS ((void));
104 static void process_options PARAMS ((void));
105 static void lang_independent_init PARAMS ((void));
106 static int lang_dependent_init PARAMS ((const char *));
107 static void init_asm_output PARAMS ((const char *));
108 static void finalize PARAMS ((void));
110 static void set_target_switch PARAMS ((const char *));
111 static const char *decl_name PARAMS ((tree, int));
113 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
114 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
115 static void set_float_handler PARAMS ((jmp_buf));
116 static void compile_file PARAMS ((void));
117 static void display_help PARAMS ((void));
118 static void display_target_options PARAMS ((void));
120 static void decode_d_option PARAMS ((const char *));
121 static int decode_f_option PARAMS ((const char *));
122 static int decode_W_option PARAMS ((const char *));
123 static int decode_g_option PARAMS ((const char *));
124 static unsigned int independent_decode_option PARAMS ((int, char **));
126 static void print_version PARAMS ((FILE *, const char *));
127 static int print_single_switch PARAMS ((FILE *, int, int, const char *,
128 const char *, const char *,
129 const char *, const char *));
130 static void print_switch_values PARAMS ((FILE *, int, int, const char *,
131 const char *, const char *));
133 /* Length of line when printing switch values. */
134 #define MAX_LINE 75
136 /* Name of program invoked, sans directories. */
138 const char *progname;
140 /* Copy of arguments to toplev_main. */
141 int save_argc;
142 char **save_argv;
144 /* Name of current original source file (what was input to cpp).
145 This comes from each #-command in the actual input. */
147 const char *input_filename;
149 /* Name of top-level original source file (what was input to cpp).
150 This comes from the #-command at the beginning of the actual input.
151 If there isn't any there, then this is the cc1 input file name. */
153 const char *main_input_filename;
155 /* Current line number in real source file. */
157 int lineno;
159 /* Nonzero if it is unsafe to create any new pseudo registers. */
160 int no_new_pseudos;
162 /* Stack of currently pending input files. */
164 struct file_stack *input_file_stack;
166 /* Incremented on each change to input_file_stack. */
167 int input_file_stack_tick;
169 /* Name to use as base of names for dump output files. */
171 const char *dump_base_name;
173 /* Format to use to print dumpfile index value */
174 #ifndef DUMPFILE_FORMAT
175 #define DUMPFILE_FORMAT ".%02d."
176 #endif
178 /* Bit flags that specify the machine subtype we are compiling for.
179 Bits are tested using macros TARGET_... defined in the tm.h file
180 and set by `-m...' switches. Must be defined in rtlanal.c. */
182 extern int target_flags;
184 /* Debug hooks - dependent upon command line options. */
186 struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
188 /* Describes a dump file. */
190 struct dump_file_info
192 /* The unique extension to apply, e.g. ".jump". */
193 const char *const extension;
195 /* The -d<c> character that enables this dump file. */
196 char const debug_switch;
198 /* True if there is a corresponding graph dump file. */
199 char const graph_dump_p;
201 /* True if the user selected this dump. */
202 char enabled;
204 /* True if the files have been initialized (ie truncated). */
205 char initialized;
208 /* Enumerate the extant dump files. */
210 enum dump_file_index
212 DFI_rtl,
213 DFI_sibling,
214 DFI_eh,
215 DFI_jump,
216 DFI_ssa,
217 DFI_ssa_ccp,
218 DFI_ssa_dce,
219 DFI_ussa,
220 DFI_cse,
221 DFI_addressof,
222 DFI_gcse,
223 DFI_loop,
224 DFI_cse2,
225 DFI_cfg,
226 DFI_bp,
227 DFI_life,
228 DFI_combine,
229 DFI_ce,
230 DFI_regmove,
231 DFI_sched,
232 DFI_lreg,
233 DFI_greg,
234 DFI_postreload,
235 DFI_flow2,
236 DFI_peephole2,
237 DFI_rnreg,
238 DFI_ce2,
239 DFI_sched2,
240 DFI_stack,
241 DFI_bbro,
242 DFI_mach,
243 DFI_dbr,
244 DFI_MAX
247 /* Describes all the dump files. Should be kept in order of the
248 pass and in sync with dump_file_index above.
250 Remaining -d letters:
252 " o q u "
253 " H JK OPQ TUV YZ"
256 static struct dump_file_info dump_file[DFI_MAX] =
258 { "rtl", 'r', 0, 0, 0 },
259 { "sibling", 'i', 0, 0, 0 },
260 { "eh", 'h', 0, 0, 0 },
261 { "jump", 'j', 0, 0, 0 },
262 { "ssa", 'e', 1, 0, 0 },
263 { "ssaccp", 'W', 1, 0, 0 },
264 { "ssadce", 'X', 1, 0, 0 },
265 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
266 { "cse", 's', 0, 0, 0 },
267 { "addressof", 'F', 0, 0, 0 },
268 { "gcse", 'G', 1, 0, 0 },
269 { "loop", 'L', 1, 0, 0 },
270 { "cse2", 't', 1, 0, 0 },
271 { "cfg", 'f', 1, 0, 0 },
272 { "bp", 'b', 1, 0, 0 },
273 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
274 { "combine", 'c', 1, 0, 0 },
275 { "ce", 'C', 1, 0, 0 },
276 { "regmove", 'N', 1, 0, 0 },
277 { "sched", 'S', 1, 0, 0 },
278 { "lreg", 'l', 1, 0, 0 },
279 { "greg", 'g', 1, 0, 0 },
280 { "postreload", 'o', 1, 0, 0 },
281 { "flow2", 'w', 1, 0, 0 },
282 { "peephole2", 'z', 1, 0, 0 },
283 { "rnreg", 'n', 1, 0, 0 },
284 { "ce2", 'E', 1, 0, 0 },
285 { "sched2", 'R', 1, 0, 0 },
286 { "stack", 'k', 1, 0, 0 },
287 { "bbro", 'B', 1, 0, 0 },
288 { "mach", 'M', 1, 0, 0 },
289 { "dbr", 'd', 0, 0, 0 },
292 static int open_dump_file PARAMS ((enum dump_file_index, tree));
293 static void close_dump_file PARAMS ((enum dump_file_index,
294 void (*) (FILE *, rtx), rtx));
296 /* Other flags saying which kinds of debugging dump have been requested. */
298 int rtl_dump_and_exit;
299 int flag_print_asm_name;
300 static int version_flag;
301 static char *filename;
302 enum graph_dump_types graph_dump_format;
304 /* Name for output file of assembly code, specified with -o. */
306 char *asm_file_name;
308 /* Value of the -G xx switch, and whether it was passed or not. */
309 int g_switch_value;
310 int g_switch_set;
312 /* Type(s) of debugging information we are producing (if any).
313 See flags.h for the definitions of the different possible
314 types of debugging information. */
315 enum debug_info_type write_symbols = NO_DEBUG;
317 /* Level of debugging information we are producing. See flags.h
318 for the definitions of the different possible levels. */
319 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
321 /* Nonzero means use GNU-only extensions in the generated symbolic
322 debugging information. */
323 /* Currently, this only has an effect when write_symbols is set to
324 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
325 int use_gnu_debug_info_extensions = 0;
327 /* Nonzero means do optimizations. -O.
328 Particular numeric values stand for particular amounts of optimization;
329 thus, -O2 stores 2 here. However, the optimizations beyond the basic
330 ones are not controlled directly by this variable. Instead, they are
331 controlled by individual `flag_...' variables that are defaulted
332 based on this variable. */
334 int optimize = 0;
336 /* Nonzero means optimize for size. -Os.
337 The only valid values are zero and non-zero. When optimize_size is
338 non-zero, optimize defaults to 2, but certain individual code
339 bloating optimizations are disabled. */
341 int optimize_size = 0;
343 /* Nonzero if we should exit after parsing options. */
344 static int exit_after_options = 0;
346 /* The FUNCTION_DECL for the function currently being compiled,
347 or 0 if between functions. */
348 tree current_function_decl;
350 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
351 if none. */
352 tree current_function_func_begin_label;
354 /* Pointer to function to compute the name to use to print a declaration.
355 DECL is the declaration in question.
356 VERBOSITY determines what information will be printed:
357 0: DECL_NAME, demangled as necessary.
358 1: and scope information.
359 2: and any other information that might be interesting, such as function
360 parameter types in C++. */
362 const char *(*decl_printable_name) PARAMS ((tree, int));
364 /* Pointer to function to compute rtl for a language-specific tree code. */
366 typedef rtx (*lang_expand_expr_t)
367 PARAMS ((union tree_node *, rtx, enum machine_mode,
368 enum expand_modifier modifier));
370 lang_expand_expr_t lang_expand_expr = 0;
372 /* Pointer to function to finish handling an incomplete decl at the
373 end of compilation. */
375 void (*incomplete_decl_finalize_hook) PARAMS ((tree)) = 0;
377 /* Nonzero if doing dwarf2 duplicate elimination. */
379 int flag_eliminate_dwarf2_dups = 0;
381 /* Nonzero if generating code to do profiling. */
383 int profile_flag = 0;
385 /* Nonzero if generating code to profile program flow graph arcs. */
387 int profile_arc_flag = 0;
389 /* Nonzero if generating info for gcov to calculate line test coverage. */
391 int flag_test_coverage = 0;
393 /* Nonzero indicates that branch taken probabilities should be calculated. */
395 int flag_branch_probabilities = 0;
397 /* Nonzero if basic blocks should be reordered. */
399 int flag_reorder_blocks = 0;
401 /* Nonzero if registers should be renamed. */
403 int flag_rename_registers = 0;
404 int flag_cprop_registers = 0;
406 /* Nonzero for -pedantic switch: warn about anything
407 that standard spec forbids. */
409 int pedantic = 0;
411 /* Temporarily suppress certain warnings.
412 This is set while reading code from a system header file. */
414 int in_system_header = 0;
416 /* Don't print functions as they are compiled. -quiet. */
418 int quiet_flag = 0;
420 /* Print times taken by the various passes. -ftime-report. */
422 int time_report = 0;
424 /* Print memory still in use at end of compilation (which may have little
425 to do with peak memory consumption). -fmem-report. */
427 int mem_report = 0;
429 /* Non-zero means to collect statistics which might be expensive
430 and to print them when we are done. */
431 int flag_detailed_statistics = 0;
434 /* -f flags. */
436 /* Nonzero means `char' should be signed. */
438 int flag_signed_char;
440 /* Nonzero means give an enum type only as many bytes as it needs. */
442 int flag_short_enums;
444 /* Nonzero for -fcaller-saves: allocate values in regs that need to
445 be saved across function calls, if that produces overall better code.
446 Optional now, so people can test it. */
448 #ifdef DEFAULT_CALLER_SAVES
449 int flag_caller_saves = 1;
450 #else
451 int flag_caller_saves = 0;
452 #endif
454 /* Nonzero if structures and unions should be returned in memory.
456 This should only be defined if compatibility with another compiler or
457 with an ABI is needed, because it results in slower code. */
459 #ifndef DEFAULT_PCC_STRUCT_RETURN
460 #define DEFAULT_PCC_STRUCT_RETURN 1
461 #endif
463 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
465 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
467 /* Nonzero for -fforce-mem: load memory value into a register
468 before arithmetic on it. This makes better cse but slower compilation. */
470 int flag_force_mem = 0;
472 /* Nonzero for -fforce-addr: load memory address into a register before
473 reference to memory. This makes better cse but slower compilation. */
475 int flag_force_addr = 0;
477 /* Nonzero for -fdefer-pop: don't pop args after each function call;
478 instead save them up to pop many calls' args with one insns. */
480 int flag_defer_pop = 0;
482 /* Nonzero for -ffloat-store: don't allocate floats and doubles
483 in extended-precision registers. */
485 int flag_float_store = 0;
487 /* Nonzero for -fcse-follow-jumps:
488 have cse follow jumps to do a more extensive job. */
490 int flag_cse_follow_jumps;
492 /* Nonzero for -fcse-skip-blocks:
493 have cse follow a branch around a block. */
494 int flag_cse_skip_blocks;
496 /* Nonzero for -fexpensive-optimizations:
497 perform miscellaneous relatively-expensive optimizations. */
498 int flag_expensive_optimizations;
500 /* Nonzero for -fthread-jumps:
501 have jump optimize output of loop. */
503 int flag_thread_jumps;
505 /* Nonzero enables strength-reduction in loop.c. */
507 int flag_strength_reduce = 0;
509 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
510 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
511 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
512 unrolled. */
514 int flag_unroll_loops;
516 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
517 This is generally not a win. */
519 int flag_unroll_all_loops;
521 /* Nonzero enables prefetch optimizations for arrays in loops. */
523 int flag_prefetch_loop_arrays;
525 /* Nonzero forces all invariant computations in loops to be moved
526 outside the loop. */
528 int flag_move_all_movables = 0;
530 /* Nonzero forces all general induction variables in loops to be
531 strength reduced. */
533 int flag_reduce_all_givs = 0;
535 /* Nonzero to perform full register move optimization passes. This is the
536 default for -O2. */
538 int flag_regmove = 0;
540 /* Nonzero for -fwritable-strings:
541 store string constants in data segment and don't uniquize them. */
543 int flag_writable_strings = 0;
545 /* Nonzero means don't put addresses of constant functions in registers.
546 Used for compiling the Unix kernel, where strange substitutions are
547 done on the assembly output. */
549 int flag_no_function_cse = 0;
551 /* Nonzero for -fomit-frame-pointer:
552 don't make a frame pointer in simple functions that don't require one. */
554 int flag_omit_frame_pointer = 0;
556 /* Nonzero means place each function into its own section on those platforms
557 which support arbitrary section names and unlimited numbers of sections. */
559 int flag_function_sections = 0;
561 /* ... and similar for data. */
563 int flag_data_sections = 0;
565 /* Nonzero to inhibit use of define_optimization peephole opts. */
567 int flag_no_peephole = 0;
569 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
571 int flag_optimize_sibling_calls = 0;
573 /* Nonzero means the front end generally wants `errno' maintained by math
574 operations, like built-in SQRT. */
576 int flag_errno_math = 1;
578 /* Nonzero means that unsafe floating-point math optimizations are allowed
579 for the sake of speed. IEEE compliance is not guaranteed, and operations
580 are allowed to assume that their arguments and results are "normal"
581 (e.g., nonnegative for SQRT). */
583 int flag_unsafe_math_optimizations = 0;
585 /* Zero means that floating-point math operations cannot generate a
586 (user-visible) trap. This is the case, for example, in nonstop
587 IEEE 754 arithmetic. */
589 int flag_trapping_math = 1;
591 /* 0 means straightforward implementation of complex divide acceptable.
592 1 means wide ranges of inputs must work for complex divide.
593 2 means C99-like requirements for complex divide (not yet implemented). */
595 int flag_complex_divide_method = 0;
597 /* Nonzero means all references through pointers are volatile. */
599 int flag_volatile;
601 /* Nonzero means treat all global and extern variables as volatile. */
603 int flag_volatile_global;
605 /* Nonzero means treat all static variables as volatile. */
607 int flag_volatile_static;
609 /* Nonzero means just do syntax checking; don't output anything. */
611 int flag_syntax_only = 0;
613 /* Nonzero means perform global cse. */
615 static int flag_gcse;
617 /* Nonzero means to use global dataflow analysis to eliminate
618 useless null pointer tests. */
620 static int flag_delete_null_pointer_checks;
622 /* Nonzero means to do the enhanced load motion during gcse, which trys
623 to hoist loads by not killing them when a store to the same location
624 is seen. */
626 int flag_gcse_lm = 1;
628 /* Nonzero means to perform store motion after gcse, which will try to
629 move stores closer to the exit block. Its not very effective without
630 flag_gcse_lm. */
632 int flag_gcse_sm = 1;
634 /* Nonzero means to rerun cse after loop optimization. This increases
635 compilation time about 20% and picks up a few more common expressions. */
637 static int flag_rerun_cse_after_loop;
639 /* Nonzero means to run loop optimizations twice. */
641 int flag_rerun_loop_opt;
643 /* Nonzero for -finline-functions: ok to inline functions that look like
644 good inline candidates. */
646 int flag_inline_functions;
648 /* Nonzero for -fkeep-inline-functions: even if we make a function
649 go inline everywhere, keep its definition around for debugging
650 purposes. */
652 int flag_keep_inline_functions;
654 /* Nonzero means that functions will not be inlined. */
656 int flag_no_inline = 2;
658 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
659 not just because the tree inliner turned us off. */
661 int flag_really_no_inline = 2;
663 /* Nonzero means that we should emit static const variables
664 regardless of whether or not optimization is turned on. */
666 int flag_keep_static_consts = 1;
668 /* Nonzero means we should be saving declaration info into a .X file. */
670 int flag_gen_aux_info = 0;
672 /* Specified name of aux-info file. */
674 static char *aux_info_file_name;
676 /* Nonzero means make the text shared if supported. */
678 int flag_shared_data;
680 /* Nonzero means schedule into delayed branch slots if supported. */
682 int flag_delayed_branch;
684 /* Nonzero if we are compiling pure (sharable) code.
685 Value is 1 if we are doing reasonable (i.e. simple
686 offset into offset table) pic. Value is 2 if we can
687 only perform register offsets. */
689 int flag_pic;
691 /* Nonzero means generate extra code for exception handling and enable
692 exception handling. */
694 int flag_exceptions;
696 /* Nonzero means generate frame unwind info table when supported. */
698 int flag_unwind_tables = 0;
700 /* Nonzero means generate frame unwind info table exact at each insn boundary */
702 int flag_asynchronous_unwind_tables = 0;
704 /* Nonzero means don't place uninitialized global data in common storage
705 by default. */
707 int flag_no_common;
709 /* Nonzero means pretend it is OK to examine bits of target floats,
710 even if that isn't true. The resulting code will have incorrect constants,
711 but the same series of instructions that the native compiler would make. */
713 int flag_pretend_float;
715 /* Nonzero means change certain warnings into errors.
716 Usually these are warnings about failure to conform to some standard. */
718 int flag_pedantic_errors = 0;
720 /* flag_schedule_insns means schedule insns within basic blocks (before
721 local_alloc).
722 flag_schedule_insns_after_reload means schedule insns after
723 global_alloc. */
725 int flag_schedule_insns = 0;
726 int flag_schedule_insns_after_reload = 0;
728 /* The following flags have effect only for scheduling before register
729 allocation:
731 flag_schedule_interblock means schedule insns accross basic blocks.
732 flag_schedule_speculative means allow speculative motion of non-load insns.
733 flag_schedule_speculative_load means allow speculative motion of some
734 load insns.
735 flag_schedule_speculative_load_dangerous allows speculative motion of more
736 load insns. */
738 int flag_schedule_interblock = 1;
739 int flag_schedule_speculative = 1;
740 int flag_schedule_speculative_load = 0;
741 int flag_schedule_speculative_load_dangerous = 0;
743 int flag_single_precision_constant;
745 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
746 by a cheaper branch on a count register. */
747 int flag_branch_on_count_reg = 1;
749 /* -finhibit-size-directive inhibits output of .size for ELF.
750 This is used only for compiling crtstuff.c,
751 and it may be extended to other effects
752 needed for crtstuff.c on other systems. */
753 int flag_inhibit_size_directive = 0;
755 /* -fverbose-asm causes extra commentary information to be produced in
756 the generated assembly code (to make it more readable). This option
757 is generally only of use to those who actually need to read the
758 generated assembly code (perhaps while debugging the compiler itself).
759 -fno-verbose-asm, the default, causes the extra information
760 to be omitted and is useful when comparing two assembler files. */
762 int flag_verbose_asm = 0;
764 /* -dA causes debug commentary information to be produced in
765 the generated assembly code (to make it more readable). This option
766 is generally only of use to those who actually need to read the
767 generated assembly code (perhaps while debugging the compiler itself).
768 Currently, this switch is only used by dwarfout.c; however, it is intended
769 to be a catchall for printing debug information in the assembler file. */
771 int flag_debug_asm = 0;
773 /* -dP causes the rtl to be emitted as a comment in assembly. */
775 int flag_dump_rtl_in_asm = 0;
777 /* -fgnu-linker specifies use of the GNU linker for initializations.
778 (Or, more generally, a linker that handles initializations.)
779 -fno-gnu-linker says that collect2 will be used. */
780 #ifdef USE_COLLECT2
781 int flag_gnu_linker = 0;
782 #else
783 int flag_gnu_linker = 1;
784 #endif
786 /* Enable SSA. */
787 int flag_ssa = 0;
789 /* Enable ssa conditional constant propagation. */
790 int flag_ssa_ccp = 0;
792 /* Enable ssa aggressive dead code elimination. */
793 int flag_ssa_dce = 0;
795 /* Tag all structures with __attribute__(packed). */
796 int flag_pack_struct = 0;
798 /* Emit code to check for stack overflow; also may cause large objects
799 to be allocated dynamically. */
800 int flag_stack_check;
802 /* When non-NULL, indicates that whenever space is allocated on the
803 stack, the resulting stack pointer must not pass this
804 address---that is, for stacks that grow downward, the stack pointer
805 must always be greater than or equal to this address; for stacks
806 that grow upward, the stack pointer must be less than this address.
807 At present, the rtx may be either a REG or a SYMBOL_REF, although
808 the support provided depends on the backend. */
809 rtx stack_limit_rtx;
811 /* 0 if pointer arguments may alias each other. True in C.
812 1 if pointer arguments may not alias each other but may alias
813 global variables.
814 2 if pointer arguments may not alias each other and may not
815 alias global variables. True in Fortran.
816 This defaults to 0 for C. */
817 int flag_argument_noalias = 0;
819 /* Nonzero if we should do (language-dependent) alias analysis.
820 Typically, this analysis will assume that expressions of certain
821 types do not alias expressions of certain other types. Only used
822 if alias analysis (in general) is enabled. */
823 int flag_strict_aliasing = 0;
825 /* Instrument functions with calls at entry and exit, for profiling. */
826 int flag_instrument_function_entry_exit = 0;
828 /* Nonzero means ignore `#ident' directives. 0 means handle them.
829 On SVR4 targets, it also controls whether or not to emit a
830 string identifying the compiler. */
832 int flag_no_ident = 0;
834 /* This will perform a peephole pass before sched2. */
835 int flag_peephole2 = 0;
837 /* This will try to guess branch probabilities. */
838 int flag_guess_branch_prob = 0;
840 /* -fbounded-pointers causes gcc to compile pointers as composite
841 objects occupying three words: the pointer value, the base address
842 of the referent object, and the address immediately beyond the end
843 of the referent object. The base and extent allow us to perform
844 runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
845 int flag_bounded_pointers = 0;
847 /* -fcheck-bounds causes gcc to generate array bounds checks.
848 For C, C++: defaults to value of flag_bounded_pointers.
849 For ObjC: defaults to off.
850 For Java: defaults to on.
851 For Fortran: defaults to off.
852 For CHILL: defaults to off. */
853 int flag_bounds_check = 0;
855 /* This will attempt to merge constant section constants, if 1 only
856 string constants and constants from constant pool, if 2 also constant
857 variables. */
858 int flag_merge_constants = 1;
860 /* If one, renumber instruction UIDs to reduce the number of
861 unused UIDs if there are a lot of instructions. If greater than
862 one, unconditionally renumber instruction UIDs. */
863 int flag_renumber_insns = 1;
865 /* Values of the -falign-* flags: how much to align labels in code.
866 0 means `use default', 1 means `don't align'.
867 For each variable, there is an _log variant which is the power
868 of two not less than the variable, for .align output. */
870 int align_loops;
871 int align_loops_log;
872 int align_loops_max_skip;
873 int align_jumps;
874 int align_jumps_log;
875 int align_jumps_max_skip;
876 int align_labels;
877 int align_labels_log;
878 int align_labels_max_skip;
879 int align_functions;
880 int align_functions_log;
882 /* Table of supported debugging formats. */
883 static const struct
885 const char *const arg;
886 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
887 constant expression, we use NO_DEBUG in its place. */
888 const enum debug_info_type debug_type;
889 const int use_extensions_p;
890 const char *const description;
891 } *da,
892 debug_args[] =
894 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
895 N_("Generate debugging info in default format") },
896 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
897 #ifdef DBX_DEBUGGING_INFO
898 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
899 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
900 #endif
901 #ifdef DWARF_DEBUGGING_INFO
902 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
903 { "dwarf+", DWARF_DEBUG, 1,
904 N_("Generate extended DWARF-1 format debug info") },
905 #endif
906 #ifdef DWARF2_DEBUGGING_INFO
907 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
908 #endif
909 #ifdef XCOFF_DEBUGGING_INFO
910 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
911 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
912 #endif
913 #ifdef SDB_DEBUGGING_INFO
914 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
915 #endif
916 #ifdef VMS_DEBUGGING_INFO
917 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
918 #endif
919 { 0, 0, 0, 0 }
922 typedef struct
924 const char *const string;
925 int *const variable;
926 const int on_value;
927 const char *const description;
929 lang_independent_options;
931 int flag_trapv = 0;
933 /* Add or remove a leading underscore from user symbols. */
934 int flag_leading_underscore = -1;
936 /* The user symbol prefix after having resolved same. */
937 const char *user_label_prefix;
939 static const param_info lang_independent_params[] = {
940 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
941 { OPTION, DEFAULT, HELP },
942 #include "params.def"
943 #undef DEFPARAM
944 { NULL, 0, NULL }
947 /* A default for same. */
948 #ifndef USER_LABEL_PREFIX
949 #define USER_LABEL_PREFIX ""
950 #endif
952 /* Table of language-independent -f options.
953 STRING is the option name. VARIABLE is the address of the variable.
954 ON_VALUE is the value to store in VARIABLE
955 if `-fSTRING' is seen as an option.
956 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
958 static const lang_independent_options f_options[] =
960 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
961 N_("Perform DWARF2 duplicate elimination") },
962 {"float-store", &flag_float_store, 1,
963 N_("Do not store floats in registers") },
964 {"volatile", &flag_volatile, 1,
965 N_("Consider all mem refs through pointers as volatile") },
966 {"volatile-global", &flag_volatile_global, 1,
967 N_("Consider all mem refs to global data to be volatile") },
968 {"volatile-static", &flag_volatile_static, 1,
969 N_("Consider all mem refs to static data to be volatile") },
970 {"defer-pop", &flag_defer_pop, 1,
971 N_("Defer popping functions args from stack until later") },
972 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
973 N_("When possible do not generate stack frames") },
974 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
975 N_("Optimize sibling and tail recursive calls") },
976 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
977 N_("When running CSE, follow jumps to their targets") },
978 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
979 N_("When running CSE, follow conditional jumps") },
980 {"expensive-optimizations", &flag_expensive_optimizations, 1,
981 N_("Perform a number of minor, expensive optimizations") },
982 {"thread-jumps", &flag_thread_jumps, 1,
983 N_("Perform jump threading optimizations") },
984 {"strength-reduce", &flag_strength_reduce, 1,
985 N_("Perform strength reduction optimizations") },
986 {"unroll-loops", &flag_unroll_loops, 1,
987 N_("Perform loop unrolling when iteration count is known") },
988 {"unroll-all-loops", &flag_unroll_all_loops, 1,
989 N_("Perform loop unrolling for all loops") },
990 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
991 N_("Generate prefetch instructions, if available, for arrays in loops") },
992 {"move-all-movables", &flag_move_all_movables, 1,
993 N_("Force all loop invariant computations out of loops") },
994 {"reduce-all-givs", &flag_reduce_all_givs, 1,
995 N_("Strength reduce all loop general induction variables") },
996 {"writable-strings", &flag_writable_strings, 1,
997 N_("Store strings in writable data section") },
998 {"peephole", &flag_no_peephole, 0,
999 N_("Enable machine specific peephole optimizations") },
1000 {"force-mem", &flag_force_mem, 1,
1001 N_("Copy memory operands into registers before using") },
1002 {"force-addr", &flag_force_addr, 1,
1003 N_("Copy memory address constants into regs before using") },
1004 {"function-cse", &flag_no_function_cse, 0,
1005 N_("Allow function addresses to be held in registers") },
1006 {"inline-functions", &flag_inline_functions, 1,
1007 N_("Integrate simple functions into their callers") },
1008 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1009 N_("Generate code for funcs even if they are fully inlined") },
1010 {"inline", &flag_no_inline, 0,
1011 N_("Pay attention to the 'inline' keyword") },
1012 {"keep-static-consts", &flag_keep_static_consts, 1,
1013 N_("Emit static const variables even if they are not used") },
1014 {"syntax-only", &flag_syntax_only, 1,
1015 N_("Check for syntax errors, then stop") },
1016 {"shared-data", &flag_shared_data, 1,
1017 N_("Mark data as shared rather than private") },
1018 {"caller-saves", &flag_caller_saves, 1,
1019 N_("Enable saving registers around function calls") },
1020 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1021 N_("Return 'short' aggregates in memory, not registers") },
1022 {"reg-struct-return", &flag_pcc_struct_return, 0,
1023 N_("Return 'short' aggregates in registers") },
1024 {"delayed-branch", &flag_delayed_branch, 1,
1025 N_("Attempt to fill delay slots of branch instructions") },
1026 {"gcse", &flag_gcse, 1,
1027 N_("Perform the global common subexpression elimination") },
1028 {"gcse-lm", &flag_gcse_lm, 1,
1029 N_("Perform enhanced load motion during global subexpression elimination") },
1030 {"gcse-sm", &flag_gcse_sm, 1,
1031 N_("Perform store motion after global subexpression elimination") },
1032 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1033 N_("Run CSE pass after loop optimizations") },
1034 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1035 N_("Run the loop optimizer twice") },
1036 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1037 N_("Delete useless null pointer checks") },
1038 {"pretend-float", &flag_pretend_float, 1,
1039 N_("Pretend that host and target use the same FP format") },
1040 {"schedule-insns", &flag_schedule_insns, 1,
1041 N_("Reschedule instructions before register allocation") },
1042 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1043 N_("Reschedule instructions after register allocation") },
1044 {"sched-interblock",&flag_schedule_interblock, 1,
1045 N_("Enable scheduling across basic blocks") },
1046 {"sched-spec",&flag_schedule_speculative, 1,
1047 N_("Allow speculative motion of non-loads") },
1048 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1049 N_("Allow speculative motion of some loads") },
1050 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1051 N_("Allow speculative motion of more loads") },
1052 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1053 N_("Replace add,compare,branch with branch on count reg") },
1054 {"pic", &flag_pic, 1,
1055 N_("Generate position independent code, if possible") },
1056 {"PIC", &flag_pic, 2, ""},
1057 {"exceptions", &flag_exceptions, 1,
1058 N_("Enable exception handling") },
1059 {"unwind-tables", &flag_unwind_tables, 1,
1060 N_("Just generate unwind tables for exception handling") },
1061 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1062 N_("Generate unwind tables exact at each instruction boundary") },
1063 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1064 N_("Support synchronous non-call exceptions") },
1065 {"profile-arcs", &profile_arc_flag, 1,
1066 N_("Insert arc based program profiling code") },
1067 {"test-coverage", &flag_test_coverage, 1,
1068 N_("Create data files needed by gcov") },
1069 {"branch-probabilities", &flag_branch_probabilities, 1,
1070 N_("Use profiling information for branch probabilities") },
1071 {"reorder-blocks", &flag_reorder_blocks, 1,
1072 N_("Reorder basic blocks to improve code placement") },
1073 {"rename-registers", &flag_rename_registers, 1,
1074 N_("Do the register renaming optimization pass") },
1075 {"cprop-registers", &flag_cprop_registers, 1,
1076 N_("Do the register copy-propagation optimization pass") },
1077 {"common", &flag_no_common, 0,
1078 N_("Do not put uninitialized globals in the common section") },
1079 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1080 N_("Do not generate .size directives") },
1081 {"function-sections", &flag_function_sections, 1,
1082 N_("place each function into its own section") },
1083 {"data-sections", &flag_data_sections, 1,
1084 N_("place data items into their own section") },
1085 {"verbose-asm", &flag_verbose_asm, 1,
1086 N_("Add extra commentry to assembler output") },
1087 {"gnu-linker", &flag_gnu_linker, 1,
1088 N_("Output GNU ld formatted global initializers") },
1089 {"regmove", &flag_regmove, 1,
1090 N_("Enables a register move optimization") },
1091 {"optimize-register-move", &flag_regmove, 1,
1092 N_("Do the full regmove optimization pass") },
1093 {"pack-struct", &flag_pack_struct, 1,
1094 N_("Pack structure members together without holes") },
1095 {"stack-check", &flag_stack_check, 1,
1096 N_("Insert stack checking code into the program") },
1097 {"argument-alias", &flag_argument_noalias, 0,
1098 N_("Specify that arguments may alias each other & globals") },
1099 {"argument-noalias", &flag_argument_noalias, 1,
1100 N_("Assume arguments may alias globals but not each other") },
1101 {"argument-noalias-global", &flag_argument_noalias, 2,
1102 N_("Assume arguments do not alias each other or globals") },
1103 {"strict-aliasing", &flag_strict_aliasing, 1,
1104 N_("Assume strict aliasing rules apply") },
1105 {"align-loops", &align_loops, 0,
1106 N_("Align the start of loops") },
1107 {"align-jumps", &align_jumps, 0,
1108 N_("Align labels which are only reached by jumping") },
1109 {"align-labels", &align_labels, 0,
1110 N_("Align all labels") },
1111 {"align-functions", &align_functions, 0,
1112 N_("Align the start of functions") },
1113 {"merge-constants", &flag_merge_constants, 1,
1114 N_("Attempt to merge identical constants accross compilation units") },
1115 {"merge-all-constants", &flag_merge_constants, 2,
1116 N_("Attempt to merge identical constants and constant variables") },
1117 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1118 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1119 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1120 N_("Instrument function entry/exit with profiling calls") },
1121 {"ssa", &flag_ssa, 1,
1122 N_("Enable SSA optimizations") },
1123 {"ssa-ccp", &flag_ssa_ccp, 1,
1124 N_("Enable SSA conditional constant propagation") },
1125 {"ssa-dce", &flag_ssa_dce, 1,
1126 N_("Enable aggressive SSA dead code elimination") },
1127 {"leading-underscore", &flag_leading_underscore, 1,
1128 N_("External symbols have a leading underscore") },
1129 {"ident", &flag_no_ident, 0,
1130 N_("Process #ident directives") },
1131 { "peephole2", &flag_peephole2, 1,
1132 N_("Enables an rtl peephole pass run before sched2") },
1133 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1134 N_("Enables guessing of branch probabilities") },
1135 {"math-errno", &flag_errno_math, 1,
1136 N_("Set errno after built-in math functions") },
1137 {"trapping-math", &flag_trapping_math, 1,
1138 N_("Floating-point operations can trap") },
1139 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1140 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1141 {"bounded-pointers", &flag_bounded_pointers, 1,
1142 N_("Compile pointers as triples: value, base & end") },
1143 {"bounds-check", &flag_bounds_check, 1,
1144 N_("Generate code to check bounds before dereferencing pointers and arrays") },
1145 {"single-precision-constant", &flag_single_precision_constant, 1,
1146 N_("Convert floating point constant to single precision constant") },
1147 {"time-report", &time_report, 1,
1148 N_("Report time taken by each compiler pass at end of run") },
1149 {"mem-report", &mem_report, 1,
1150 N_("Report on permanent memory allocation at end of run") },
1151 { "trapv", &flag_trapv, 1,
1152 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1155 /* Table of language-specific options. */
1157 static const struct lang_opt
1159 const char *const option;
1160 const char *const description;
1162 documented_lang_options[] =
1164 /* In order not to overload the --help output, the convention
1165 used here is to only describe those options which are not
1166 enabled by default. */
1168 { "-ansi",
1169 N_("Compile just for ISO C89") },
1170 { "-fallow-single-precision",
1171 N_("Do not promote floats to double if using -traditional") },
1172 { "-std= ",
1173 N_("Determine language standard") },
1175 { "-fsigned-bitfields", "" },
1176 { "-funsigned-bitfields",
1177 N_("Make bit-fields by unsigned by default") },
1178 { "-fno-signed-bitfields", "" },
1179 { "-fno-unsigned-bitfields","" },
1180 { "-fsigned-char",
1181 N_("Make 'char' be signed by default") },
1182 { "-funsigned-char",
1183 N_("Make 'char' be unsigned by default") },
1184 { "-fno-signed-char", "" },
1185 { "-fno-unsigned-char", "" },
1187 { "-ftraditional", "" },
1188 { "-traditional",
1189 N_("Attempt to support traditional K&R style C") },
1190 { "-fnotraditional", "" },
1191 { "-fno-traditional", "" },
1193 { "-fasm", "" },
1194 { "-fno-asm",
1195 N_("Do not recognize the 'asm' keyword") },
1196 { "-fbuiltin", "" },
1197 { "-fno-builtin",
1198 N_("Do not recognize any built in functions") },
1199 { "-fhosted",
1200 N_("Assume normal C execution environment") },
1201 { "-fno-hosted", "" },
1202 { "-ffreestanding",
1203 N_("Assume that standard libraries & main might not exist") },
1204 { "-fno-freestanding", "" },
1205 { "-fcond-mismatch",
1206 N_("Allow different types as args of ? operator") },
1207 { "-fno-cond-mismatch", "" },
1208 { "-fdollars-in-identifiers",
1209 N_("Allow the use of $ inside identifiers") },
1210 { "-fno-dollars-in-identifiers", "" },
1211 { "-fpreprocessed", "" },
1212 { "-fno-preprocessed", "" },
1213 { "-fshort-double",
1214 N_("Use the same size for double as for float") },
1215 { "-fno-short-double", "" },
1216 { "-fshort-enums",
1217 N_("Use the smallest fitting integer to hold enums") },
1218 { "-fno-short-enums", "" },
1219 { "-fshort-wchar",
1220 N_("Override the underlying type for wchar_t to `unsigned short'") },
1221 { "-fno-short-wchar", "" },
1223 { "-Wall",
1224 N_("Enable most warning messages") },
1225 { "-Wbad-function-cast",
1226 N_("Warn about casting functions to incompatible types") },
1227 { "-Wno-bad-function-cast", "" },
1228 { "-Wno-missing-noreturn", "" },
1229 { "-Wmissing-format-attribute",
1230 N_("Warn about functions which might be candidates for format attributes") },
1231 { "-Wno-missing-format-attribute", "" },
1232 { "-Wcast-qual",
1233 N_("Warn about casts which discard qualifiers") },
1234 { "-Wno-cast-qual", "" },
1235 { "-Wchar-subscripts",
1236 N_("Warn about subscripts whose type is 'char'") },
1237 { "-Wno-char-subscripts", "" },
1238 { "-Wcomment",
1239 N_("Warn if nested comments are detected") },
1240 { "-Wno-comment", "" },
1241 { "-Wcomments",
1242 N_("Warn if nested comments are detected") },
1243 { "-Wno-comments", "" },
1244 { "-Wconversion",
1245 N_("Warn about possibly confusing type conversions") },
1246 { "-Wno-conversion", "" },
1247 { "-Wformat",
1248 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1249 { "-Wno-format", "" },
1250 { "-Wformat-y2k", "" },
1251 { "-Wno-format-y2k",
1252 N_("Don't warn about strftime formats yielding 2 digit years") },
1253 { "-Wformat-extra-args", "" },
1254 { "-Wno-format-extra-args",
1255 N_("Don't warn about too many arguments to format functions") },
1256 { "-Wformat-nonliteral",
1257 N_("Warn about non-string-literal format strings") },
1258 { "-Wno-format-nonliteral", "" },
1259 { "-Wformat-security",
1260 N_("Warn about possible security problems with format functions") },
1261 { "-Wno-format-security", "" },
1262 { "-Wimplicit-function-declaration",
1263 N_("Warn about implicit function declarations") },
1264 { "-Wno-implicit-function-declaration", "" },
1265 { "-Werror-implicit-function-declaration", "" },
1266 { "-Wimplicit-int",
1267 N_("Warn when a declaration does not specify a type") },
1268 { "-Wno-implicit-int", "" },
1269 { "-Wimplicit", "" },
1270 { "-Wno-implicit", "" },
1271 { "-Wimport",
1272 N_("Warn about the use of the #import directive") },
1273 { "-Wno-import", "" },
1274 { "-Wlong-long","" },
1275 { "-Wno-long-long",
1276 N_("Do not warn about using 'long long' when -pedantic") },
1277 { "-Wmain",
1278 N_("Warn about suspicious declarations of main") },
1279 { "-Wno-main", "" },
1280 { "-Wmissing-braces",
1281 N_("Warn about possibly missing braces around initializers") },
1282 { "-Wno-missing-braces", "" },
1283 { "-Wmissing-declarations",
1284 N_("Warn about global funcs without previous declarations") },
1285 { "-Wno-missing-declarations", "" },
1286 { "-Wmissing-prototypes",
1287 N_("Warn about global funcs without prototypes") },
1288 { "-Wno-missing-prototypes", "" },
1289 { "-Wmultichar",
1290 N_("Warn about use of multicharacter literals") },
1291 { "-Wno-multichar", "" },
1292 { "-Wnested-externs",
1293 N_("Warn about externs not at file scope level") },
1294 { "-Wno-nested-externs", "" },
1295 { "-Wparentheses",
1296 N_("Warn about possible missing parentheses") },
1297 { "-Wno-parentheses", "" },
1298 { "-Wsequence-point",
1299 N_("Warn about possible violations of sequence point rules") },
1300 { "-Wno-sequence-point", "" },
1301 { "-Wpointer-arith",
1302 N_("Warn about function pointer arithmetic") },
1303 { "-Wno-pointer-arith", "" },
1304 { "-Wredundant-decls",
1305 N_("Warn about multiple declarations of the same object") },
1306 { "-Wno-redundant-decls", "" },
1307 { "-Wsign-compare",
1308 N_("Warn about signed/unsigned comparisons") },
1309 { "-Wno-sign-compare", "" },
1310 { "-Wfloat-equal",
1311 N_("Warn about testing equality of floating point numbers") },
1312 { "-Wno-float-equal", "" },
1313 { "-Wunknown-pragmas",
1314 N_("Warn about unrecognized pragmas") },
1315 { "-Wno-unknown-pragmas", "" },
1316 { "-Wstrict-prototypes",
1317 N_("Warn about non-prototyped function decls") },
1318 { "-Wno-strict-prototypes", "" },
1319 { "-Wtraditional",
1320 N_("Warn about constructs whose meaning change in ISO C") },
1321 { "-Wno-traditional", "" },
1322 { "-Wtrigraphs",
1323 N_("Warn when trigraphs are encountered") },
1324 { "-Wno-trigraphs", "" },
1325 { "-Wundef", "" },
1326 { "-Wno-undef", "" },
1327 { "-Wwrite-strings",
1328 N_("Mark strings as 'const char *'") },
1329 { "-Wno-write-strings", "" },
1331 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1333 #include "options.h"
1337 /* Here is a table, controlled by the tm.h file, listing each -m switch
1338 and which bits in `target_switches' it should set or clear.
1339 If VALUE is positive, it is bits to set.
1340 If VALUE is negative, -VALUE is bits to clear.
1341 (The sign bit is not used so there is no confusion.) */
1343 static const struct
1345 const char *const name;
1346 const int value;
1347 const char *const description;
1349 target_switches [] = TARGET_SWITCHES;
1351 /* This table is similar, but allows the switch to have a value. */
1353 #ifdef TARGET_OPTIONS
1354 static const struct
1356 const char *const prefix;
1357 const char **const variable;
1358 const char *const description;
1360 target_options [] = TARGET_OPTIONS;
1361 #endif
1363 /* Options controlling warnings. */
1365 /* Don't print warning messages. -w. */
1367 int inhibit_warnings = 0;
1369 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1371 int warn_system_headers = 0;
1373 /* Print various extra warnings. -W. */
1375 int extra_warnings = 0;
1377 /* Treat warnings as errors. -Werror. */
1379 int warnings_are_errors = 0;
1381 /* Nonzero to warn about unused variables, functions et.al. */
1383 int warn_unused_function;
1384 int warn_unused_label;
1385 int warn_unused_parameter;
1386 int warn_unused_variable;
1387 int warn_unused_value;
1389 /* Nonzero to warn about code which is never reached. */
1391 int warn_notreached;
1393 /* Nonzero to warn about variables used before they are initialized. */
1395 int warn_uninitialized;
1397 /* Nonzero means warn about all declarations which shadow others. */
1399 int warn_shadow;
1401 /* Warn if a switch on an enum fails to have a case for every enum value. */
1403 int warn_switch;
1405 /* Nonzero means warn about function definitions that default the return type
1406 or that use a null return and have a return-type other than void. */
1408 int warn_return_type;
1410 /* Nonzero means warn about pointer casts that increase the required
1411 alignment of the target type (and might therefore lead to a crash
1412 due to a misaligned access). */
1414 int warn_cast_align;
1416 /* Nonzero means warn about any objects definitions whose size is larger
1417 than N bytes. Also want about function definitions whose returned
1418 values are larger than N bytes. The value N is in `larger_than_size'. */
1420 int warn_larger_than;
1421 HOST_WIDE_INT larger_than_size;
1423 /* Nonzero means warn if inline function is too large. */
1425 int warn_inline;
1427 /* Warn if a function returns an aggregate,
1428 since there are often incompatible calling conventions for doing this. */
1430 int warn_aggregate_return;
1432 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1434 int warn_packed;
1436 /* Warn when gcc pads a structure to an alignment boundary. */
1438 int warn_padded;
1440 /* Warn when an optimization pass is disabled. */
1442 int warn_disabled_optimization;
1444 /* Warn about functions which might be candidates for attribute noreturn. */
1446 int warn_missing_noreturn;
1448 /* Nonzero means warn about uses of __attribute__((deprecated))
1449 declarations. */
1451 int warn_deprecated_decl = 1;
1453 /* Likewise for -W. */
1455 static const lang_independent_options W_options[] =
1457 {"unused-function", &warn_unused_function, 1,
1458 N_("Warn when a function is unused") },
1459 {"unused-label", &warn_unused_label, 1,
1460 N_("Warn when a label is unused") },
1461 {"unused-parameter", &warn_unused_parameter, 1,
1462 N_("Warn when a function parameter is unused") },
1463 {"unused-variable", &warn_unused_variable, 1,
1464 N_("Warn when a variable is unused") },
1465 {"unused-value", &warn_unused_value, 1,
1466 N_("Warn when an expression value is unused") },
1467 {"system-headers", &warn_system_headers, 1,
1468 N_("Do not suppress warnings from system headers") },
1469 {"error", &warnings_are_errors, 1,
1470 N_("Treat all warnings as errors") },
1471 {"shadow", &warn_shadow, 1,
1472 N_("Warn when one local variable shadows another") },
1473 {"switch", &warn_switch, 1,
1474 N_("Warn about enumerated switches missing a specific case") },
1475 {"aggregate-return", &warn_aggregate_return, 1,
1476 N_("Warn about returning structures, unions or arrays") },
1477 {"cast-align", &warn_cast_align, 1,
1478 N_("Warn about pointer casts which increase alignment") },
1479 {"unreachable-code", &warn_notreached, 1,
1480 N_("Warn about code that will never be executed") },
1481 {"uninitialized", &warn_uninitialized, 1,
1482 N_("Warn about uninitialized automatic variables") },
1483 {"inline", &warn_inline, 1,
1484 N_("Warn when an inlined function cannot be inlined") },
1485 {"packed", &warn_packed, 1,
1486 N_("Warn when the packed attribute has no effect on struct layout") },
1487 {"padded", &warn_padded, 1,
1488 N_("Warn when padding is required to align struct members") },
1489 {"disabled-optimization", &warn_disabled_optimization, 1,
1490 N_("Warn when an optimization pass is disabled") },
1491 {"deprecated-declarations", &warn_deprecated_decl, 1,
1492 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1493 {"missing-noreturn", &warn_missing_noreturn, 1,
1494 N_("Warn about functions which might be candidates for attribute noreturn") }
1497 void
1498 set_Wunused (setting)
1499 int setting;
1501 warn_unused_function = setting;
1502 warn_unused_label = setting;
1503 /* Unused function parameter warnings are reported when either ``-W
1504 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1505 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1506 if (!setting)
1507 warn_unused_parameter = 0;
1508 else if (!warn_unused_parameter)
1509 warn_unused_parameter = -1;
1510 warn_unused_variable = setting;
1511 warn_unused_value = setting;
1514 /* The following routines are useful in setting all the flags that
1515 -ffast-math and -fno-fast-math imply. */
1517 void
1518 set_fast_math_flags ()
1520 flag_trapping_math = 0;
1521 flag_unsafe_math_optimizations = 1;
1522 flag_errno_math = 0;
1525 void
1526 set_no_fast_math_flags ()
1528 flag_trapping_math = 1;
1529 flag_unsafe_math_optimizations = 0;
1530 flag_errno_math = 1;
1534 /* Output files for assembler code (real compiler output)
1535 and debugging dumps. */
1537 FILE *asm_out_file;
1538 FILE *aux_info_file;
1539 FILE *rtl_dump_file = NULL;
1541 /* Decode the string P as an integral parameter.
1542 If the string is indeed an integer return its numeric value else
1543 issue an Invalid Option error for the option PNAME and return DEFVAL.
1544 If PNAME is zero just return DEFVAL, do not call error. */
1547 read_integral_parameter (p, pname, defval)
1548 const char *p;
1549 const char *pname;
1550 const int defval;
1552 const char *endp = p;
1554 while (*endp)
1556 if (ISDIGIT (*endp))
1557 endp++;
1558 else
1559 break;
1562 if (*endp != 0)
1564 if (pname != 0)
1565 error ("invalid option `%s'", pname);
1566 return defval;
1569 return atoi (p);
1573 /* This is the default decl_printable_name function. */
1575 static const char *
1576 decl_name (decl, verbosity)
1577 tree decl;
1578 int verbosity ATTRIBUTE_UNUSED;
1580 return IDENTIFIER_POINTER (DECL_NAME (decl));
1584 /* This calls abort and is used to avoid problems when abort if a macro.
1585 It is used when we need to pass the address of abort. */
1587 void
1588 do_abort ()
1590 abort ();
1593 /* When `malloc.c' is compiled with `rcheck' defined,
1594 it calls this function to report clobberage. */
1596 void
1597 botch (s)
1598 const char *s ATTRIBUTE_UNUSED;
1600 abort ();
1603 /* Return the logarithm of X, base 2, considering X unsigned,
1604 if X is a power of 2. Otherwise, returns -1.
1606 This should be used via the `exact_log2' macro. */
1609 exact_log2_wide (x)
1610 unsigned HOST_WIDE_INT x;
1612 int log = 0;
1613 /* Test for 0 or a power of 2. */
1614 if (x == 0 || x != (x & -x))
1615 return -1;
1616 while ((x >>= 1) != 0)
1617 log++;
1618 return log;
1621 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1622 If X is 0, return -1.
1624 This should be used via the floor_log2 macro. */
1627 floor_log2_wide (x)
1628 unsigned HOST_WIDE_INT x;
1630 int log = -1;
1631 while (x != 0)
1632 log++,
1633 x >>= 1;
1634 return log;
1637 static int float_handler_set;
1638 int float_handled;
1639 jmp_buf float_handler;
1641 /* Signals actually come here. */
1643 static void
1644 float_signal (signo)
1645 /* If this is missing, some compilers complain. */
1646 int signo ATTRIBUTE_UNUSED;
1648 if (float_handled == 0)
1649 crash_signal (signo);
1650 float_handled = 0;
1652 /* On System-V derived systems, we must reinstall the signal handler.
1653 This is harmless on BSD-derived systems. */
1654 signal (SIGFPE, float_signal);
1655 longjmp (float_handler, 1);
1658 /* Specify where to longjmp to when a floating arithmetic error happens.
1659 If HANDLER is 0, it means don't handle the errors any more. */
1661 static void
1662 set_float_handler (handler)
1663 jmp_buf handler;
1665 float_handled = (handler != 0);
1666 if (handler)
1667 memcpy (float_handler, handler, sizeof (float_handler));
1669 if (float_handled && ! float_handler_set)
1671 signal (SIGFPE, float_signal);
1672 float_handler_set = 1;
1676 /* This is a wrapper function for code which might elicit an
1677 arithmetic exception. That code should be passed in as a function
1678 pointer FN, and one argument DATA. DATA is usually a struct which
1679 contains the real input and output for function FN. This function
1680 returns 0 (failure) if longjmp was called (i.e. an exception
1681 occurred.) It returns 1 (success) otherwise. */
1684 do_float_handler (fn, data)
1685 void (*fn) PARAMS ((PTR));
1686 PTR data;
1688 jmp_buf buf;
1690 if (setjmp (buf))
1692 /* We got here via longjmp () caused by an exception in function
1693 fn (). */
1694 set_float_handler (NULL);
1695 return 0;
1698 set_float_handler (buf);
1699 (*fn)(data);
1700 set_float_handler (NULL);
1701 return 1;
1704 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1705 into ICE messages, which is much more user friendly. */
1707 static void
1708 crash_signal (signo)
1709 int signo;
1711 internal_error ("internal error: %s", strsignal (signo));
1714 /* Strip off a legitimate source ending from the input string NAME of
1715 length LEN. Rather than having to know the names used by all of
1716 our front ends, we strip off an ending of a period followed by
1717 up to five characters. (Java uses ".class".) */
1719 void
1720 strip_off_ending (name, len)
1721 char *name;
1722 int len;
1724 int i;
1725 for (i = 2; i < 6 && len > i; i++)
1727 if (name[len - i] == '.')
1729 name[len - i] = '\0';
1730 break;
1735 /* Output a quoted string. */
1737 void
1738 output_quoted_string (asm_file, string)
1739 FILE *asm_file;
1740 const char *string;
1742 #ifdef OUTPUT_QUOTED_STRING
1743 OUTPUT_QUOTED_STRING (asm_file, string);
1744 #else
1745 char c;
1747 putc ('\"', asm_file);
1748 while ((c = *string++) != 0)
1750 if (ISPRINT (c))
1752 if (c == '\"' || c == '\\')
1753 putc ('\\', asm_file);
1754 putc (c, asm_file);
1756 else
1757 fprintf (asm_file, "\\%03o", c);
1759 putc ('\"', asm_file);
1760 #endif
1763 /* Output a file name in the form wanted by System V. */
1765 void
1766 output_file_directive (asm_file, input_name)
1767 FILE *asm_file;
1768 const char *input_name;
1770 int len = strlen (input_name);
1771 const char *na = input_name + len;
1773 /* NA gets INPUT_NAME sans directory names. */
1774 while (na > input_name)
1776 if (IS_DIR_SEPARATOR (na[-1]))
1777 break;
1778 na--;
1781 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1782 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1783 #else
1784 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1785 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1786 #else
1787 fprintf (asm_file, "\t.file\t");
1788 output_quoted_string (asm_file, na);
1789 fputc ('\n', asm_file);
1790 #endif
1791 #endif
1794 /* Routine to open a dump file. Return true if the dump file is enabled. */
1796 static int
1797 open_dump_file (index, decl)
1798 enum dump_file_index index;
1799 tree decl;
1801 char *dump_name;
1802 const char *open_arg;
1803 char seq[16];
1805 if (! dump_file[index].enabled)
1806 return 0;
1808 timevar_push (TV_DUMP);
1809 if (rtl_dump_file != NULL)
1810 fclose (rtl_dump_file);
1812 sprintf (seq, DUMPFILE_FORMAT, index);
1814 if (! dump_file[index].initialized)
1816 /* If we've not initialized the files, do so now. */
1817 if (graph_dump_format != no_graph
1818 && dump_file[index].graph_dump_p)
1820 dump_name = concat (seq, dump_file[index].extension, NULL);
1821 clean_graph_dump_file (dump_base_name, dump_name);
1822 free (dump_name);
1824 dump_file[index].initialized = 1;
1825 open_arg = "w";
1827 else
1828 open_arg = "a";
1830 dump_name = concat (dump_base_name, seq,
1831 dump_file[index].extension, NULL);
1833 rtl_dump_file = fopen (dump_name, open_arg);
1834 if (rtl_dump_file == NULL)
1835 fatal_io_error ("can't open %s", dump_name);
1837 free (dump_name);
1839 if (decl)
1840 fprintf (rtl_dump_file, "\n;; Function %s\n\n",
1841 decl_printable_name (decl, 2));
1843 timevar_pop (TV_DUMP);
1844 return 1;
1847 /* Routine to close a dump file. */
1849 static void
1850 close_dump_file (index, func, insns)
1851 enum dump_file_index index;
1852 void (*func) PARAMS ((FILE *, rtx));
1853 rtx insns;
1855 if (! rtl_dump_file)
1856 return;
1858 timevar_push (TV_DUMP);
1859 if (insns
1860 && graph_dump_format != no_graph
1861 && dump_file[index].graph_dump_p)
1863 char seq[16];
1864 char *suffix;
1866 sprintf (seq, DUMPFILE_FORMAT, index);
1867 suffix = concat (seq, dump_file[index].extension, NULL);
1868 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1869 free (suffix);
1872 if (func && insns)
1873 func (rtl_dump_file, insns);
1875 fflush (rtl_dump_file);
1876 fclose (rtl_dump_file);
1878 rtl_dump_file = NULL;
1879 timevar_pop (TV_DUMP);
1882 /* Do any final processing required for the declarations in VEC, of
1883 which there are LEN. We write out inline functions and variables
1884 that have been deferred until this point, but which are required.
1885 Returns non-zero if anything was put out. */
1888 wrapup_global_declarations (vec, len)
1889 tree *vec;
1890 int len;
1892 tree decl;
1893 int i;
1894 int reconsider;
1895 int output_something = 0;
1897 for (i = 0; i < len; i++)
1899 decl = vec[i];
1901 /* We're not deferring this any longer. */
1902 DECL_DEFER_OUTPUT (decl) = 0;
1904 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
1905 && incomplete_decl_finalize_hook != 0)
1906 (*incomplete_decl_finalize_hook) (decl);
1909 /* Now emit any global variables or functions that we have been
1910 putting off. We need to loop in case one of the things emitted
1911 here references another one which comes earlier in the list. */
1914 reconsider = 0;
1915 for (i = 0; i < len; i++)
1917 decl = vec[i];
1919 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1920 continue;
1922 /* Don't write out static consts, unless we still need them.
1924 We also keep static consts if not optimizing (for debugging),
1925 unless the user specified -fno-keep-static-consts.
1926 ??? They might be better written into the debug information.
1927 This is possible when using DWARF.
1929 A language processor that wants static constants to be always
1930 written out (even if it is not used) is responsible for
1931 calling rest_of_decl_compilation itself. E.g. the C front-end
1932 calls rest_of_decl_compilation from finish_decl.
1933 One motivation for this is that is conventional in some
1934 environments to write things like:
1935 static const char rcsid[] = "... version string ...";
1936 intending to force the string to be in the executable.
1938 A language processor that would prefer to have unneeded
1939 static constants "optimized away" would just defer writing
1940 them out until here. E.g. C++ does this, because static
1941 constants are often defined in header files.
1943 ??? A tempting alternative (for both C and C++) would be
1944 to force a constant to be written if and only if it is
1945 defined in a main file, as opposed to an include file. */
1947 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1949 bool needed = 1;
1951 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1952 /* needed */;
1953 else if (DECL_COMDAT (decl))
1954 needed = 0;
1955 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1956 && (optimize || !flag_keep_static_consts
1957 || DECL_ARTIFICIAL (decl)))
1958 needed = 0;
1960 if (needed)
1962 reconsider = 1;
1963 rest_of_decl_compilation (decl, NULL, 1, 1);
1967 if (TREE_CODE (decl) == FUNCTION_DECL
1968 && DECL_INITIAL (decl) != 0
1969 && DECL_SAVED_INSNS (decl) != 0
1970 && (flag_keep_inline_functions
1971 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1972 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1974 reconsider = 1;
1975 output_inline_function (decl);
1979 if (reconsider)
1980 output_something = 1;
1982 while (reconsider);
1984 return output_something;
1987 /* Issue appropriate warnings for the global declarations in VEC (of
1988 which there are LEN). Output debugging information for them. */
1990 void
1991 check_global_declarations (vec, len)
1992 tree *vec;
1993 int len;
1995 tree decl;
1996 int i;
1998 for (i = 0; i < len; i++)
2000 decl = vec[i];
2002 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2003 && ! TREE_ASM_WRITTEN (decl))
2004 /* Cancel the RTL for this decl so that, if debugging info
2005 output for global variables is still to come,
2006 this one will be omitted. */
2007 SET_DECL_RTL (decl, NULL_RTX);
2009 /* Warn about any function
2010 declared static but not defined.
2011 We don't warn about variables,
2012 because many programs have static variables
2013 that exist only to get some text into the object file. */
2014 if (TREE_CODE (decl) == FUNCTION_DECL
2015 && (warn_unused_function
2016 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2017 && DECL_INITIAL (decl) == 0
2018 && DECL_EXTERNAL (decl)
2019 && ! DECL_ARTIFICIAL (decl)
2020 && ! TREE_PUBLIC (decl))
2022 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2023 pedwarn_with_decl (decl,
2024 "`%s' used but never defined");
2025 else
2026 warning_with_decl (decl,
2027 "`%s' declared `static' but never defined");
2028 /* This symbol is effectively an "extern" declaration now. */
2029 TREE_PUBLIC (decl) = 1;
2030 assemble_external (decl);
2033 /* Warn about static fns or vars defined but not used,
2034 but not about inline functions or static consts
2035 since defining those in header files is normal practice. */
2036 if (((warn_unused_function
2037 && TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl))
2038 || (warn_unused_variable
2039 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
2040 && ! DECL_IN_SYSTEM_HEADER (decl)
2041 && ! DECL_EXTERNAL (decl)
2042 && ! TREE_PUBLIC (decl)
2043 && ! TREE_USED (decl)
2044 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl))
2045 /* The TREE_USED bit for file-scope decls
2046 is kept in the identifier, to handle multiple
2047 external decls in different scopes. */
2048 && ! TREE_USED (DECL_NAME (decl)))
2049 warning_with_decl (decl, "`%s' defined but not used");
2051 timevar_push (TV_SYMOUT);
2052 (*debug_hooks->global_decl) (decl);
2053 timevar_pop (TV_SYMOUT);
2057 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2058 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2059 INPUT_FILENAME and LINENO accordingly. */
2061 void
2062 push_srcloc (file, line)
2063 const char *file;
2064 int line;
2066 struct file_stack *fs;
2068 if (input_file_stack)
2070 input_file_stack->name = input_filename;
2071 input_file_stack->line = lineno;
2074 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2075 fs->name = input_filename = file;
2076 fs->line = lineno = line;
2077 fs->indent_level = 0;
2078 fs->next = input_file_stack;
2079 input_file_stack = fs;
2080 input_file_stack_tick++;
2083 /* Pop the top entry off the stack of presently open source files.
2084 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2085 the stack. */
2087 void
2088 pop_srcloc ()
2090 struct file_stack *fs;
2092 fs = input_file_stack;
2093 input_file_stack = fs->next;
2094 free (fs);
2095 input_file_stack_tick++;
2096 /* The initial source file is never popped. */
2097 if (!input_file_stack)
2098 abort ();
2099 input_filename = input_file_stack->name;
2100 lineno = input_file_stack->line;
2103 /* Compile an entire translation unit. Write a file of assembly
2104 output and various debugging dumps. */
2106 static void
2107 compile_file ()
2109 tree globals;
2111 /* Initialize yet another pass. */
2113 init_final (main_input_filename);
2114 init_branch_prob (dump_base_name);
2116 timevar_push (TV_PARSE);
2118 /* Call the parser, which parses the entire file
2119 (calling rest_of_compilation for each function). */
2120 yyparse ();
2122 /* In case there were missing block closers,
2123 get us back to the global binding level. */
2124 (*lang_hooks.clear_binding_stack) ();
2126 /* Compilation is now finished except for writing
2127 what's left of the symbol table output. */
2129 timevar_pop (TV_PARSE);
2131 if (flag_syntax_only)
2132 return;
2134 globals = getdecls ();
2136 /* Really define vars that have had only a tentative definition.
2137 Really output inline functions that must actually be callable
2138 and have not been output so far. */
2141 int len = list_length (globals);
2142 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2143 int i;
2144 tree decl;
2146 /* Process the decls in reverse order--earliest first.
2147 Put them into VEC from back to front, then take out from front. */
2149 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2150 vec[len - i - 1] = decl;
2152 wrapup_global_declarations (vec, len);
2154 /* This must occur after the loop to output deferred functions. Else
2155 the profiler initializer would not be emitted if all the functions
2156 in this compilation unit were deferred.
2158 output_func_start_profiler can not cause any additional functions or
2159 data to need to be output, so it need not be in the deferred function
2160 loop above. */
2161 output_func_start_profiler ();
2163 check_global_declarations (vec, len);
2165 /* Clean up. */
2166 free (vec);
2169 /* Write out any pending weak symbol declarations. */
2171 weak_finish ();
2173 /* Do dbx symbols. */
2174 timevar_push (TV_SYMOUT);
2176 #ifdef DWARF2_UNWIND_INFO
2177 if (dwarf2out_do_frame ())
2178 dwarf2out_frame_finish ();
2179 #endif
2181 (*debug_hooks->finish) (main_input_filename);
2182 timevar_pop (TV_SYMOUT);
2184 /* Output some stuff at end of file if nec. */
2186 dw2_output_indirect_constants ();
2188 end_final (dump_base_name);
2190 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2192 timevar_push (TV_DUMP);
2193 open_dump_file (DFI_bp, NULL);
2195 end_branch_prob ();
2197 close_dump_file (DFI_bp, NULL, NULL_RTX);
2198 timevar_pop (TV_DUMP);
2201 #ifdef ASM_FILE_END
2202 ASM_FILE_END (asm_out_file);
2203 #endif
2205 /* Attach a special .ident directive to the end of the file to identify
2206 the version of GCC which compiled this code. The format of the .ident
2207 string is patterned after the ones produced by native SVR4 compilers. */
2208 #ifdef IDENT_ASM_OP
2209 if (!flag_no_ident)
2210 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2211 IDENT_ASM_OP, version_string);
2212 #endif
2214 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2216 timevar_push (TV_DUMP);
2217 dump_combine_total_stats (rtl_dump_file);
2218 close_dump_file (DFI_combine, NULL, NULL_RTX);
2219 timevar_pop (TV_DUMP);
2223 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2224 and TYPE_DECL nodes.
2226 This does nothing for local (non-static) variables, unless the
2227 variable is a register variable with an ASMSPEC. In that case, or
2228 if the variable is not an automatic, it sets up the RTL and
2229 outputs any assembler code (label definition, storage allocation
2230 and initialization).
2232 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2233 the assembler symbol name to be used. TOP_LEVEL is nonzero
2234 if this declaration is not within a function. */
2236 void
2237 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2238 tree decl;
2239 const char *asmspec;
2240 int top_level;
2241 int at_end;
2243 /* Declarations of variables, and of functions defined elsewhere. */
2245 /* The most obvious approach, to put an #ifndef around where
2246 this macro is used, doesn't work since it's inside a macro call. */
2247 #ifndef ASM_FINISH_DECLARE_OBJECT
2248 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
2249 #endif
2251 /* We deferred calling assemble_alias so that we could collect
2252 other attributes such as visibility. Emit the alias now. */
2254 tree alias;
2255 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2256 if (alias)
2258 alias = TREE_VALUE (TREE_VALUE (alias));
2259 alias = get_identifier (TREE_STRING_POINTER (alias));
2260 assemble_alias (decl, alias);
2264 /* Forward declarations for nested functions are not "external",
2265 but we need to treat them as if they were. */
2266 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2267 || TREE_CODE (decl) == FUNCTION_DECL)
2269 timevar_push (TV_VARCONST);
2270 if (asmspec)
2271 make_decl_rtl (decl, asmspec);
2272 /* Don't output anything
2273 when a tentative file-scope definition is seen.
2274 But at end of compilation, do output code for them. */
2275 if (at_end || !DECL_DEFER_OUTPUT (decl))
2276 assemble_variable (decl, top_level, at_end, 0);
2277 if (decl == last_assemble_variable_decl)
2279 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2280 top_level, at_end);
2282 timevar_pop (TV_VARCONST);
2284 else if (DECL_REGISTER (decl) && asmspec != 0)
2286 if (decode_reg_name (asmspec) >= 0)
2288 SET_DECL_RTL (decl, NULL_RTX);
2289 make_decl_rtl (decl, asmspec);
2291 else
2293 error ("invalid register name `%s' for register variable", asmspec);
2294 DECL_REGISTER (decl) = 0;
2295 if (!top_level)
2296 expand_decl (decl);
2299 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2300 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2301 && TREE_CODE (decl) == TYPE_DECL)
2303 timevar_push (TV_SYMOUT);
2304 dbxout_symbol (decl, 0);
2305 timevar_pop (TV_SYMOUT);
2307 #endif
2308 #ifdef SDB_DEBUGGING_INFO
2309 else if (write_symbols == SDB_DEBUG && top_level
2310 && TREE_CODE (decl) == TYPE_DECL)
2312 timevar_push (TV_SYMOUT);
2313 sdbout_symbol (decl, 0);
2314 timevar_pop (TV_SYMOUT);
2316 #endif
2319 /* Called after finishing a record, union or enumeral type. */
2321 void
2322 rest_of_type_compilation (type, toplev)
2323 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO)
2324 tree type;
2325 int toplev;
2326 #else
2327 tree type ATTRIBUTE_UNUSED;
2328 int toplev ATTRIBUTE_UNUSED;
2329 #endif
2331 timevar_push (TV_SYMOUT);
2332 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2333 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2334 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2335 #endif
2336 #ifdef SDB_DEBUGGING_INFO
2337 if (write_symbols == SDB_DEBUG)
2338 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2339 #endif
2340 #ifdef DWARF2_DEBUGGING_INFO
2341 if ((write_symbols == DWARF2_DEBUG
2342 || write_symbols == VMS_AND_DWARF2_DEBUG)
2343 && toplev)
2344 dwarf2out_decl (TYPE_STUB_DECL (type));
2345 #endif
2346 timevar_pop (TV_SYMOUT);
2349 /* This is called from finish_function (within yyparse)
2350 after each top-level definition is parsed.
2351 It is supposed to compile that function or variable
2352 and output the assembler code for it.
2353 After we return, the tree storage is freed. */
2355 void
2356 rest_of_compilation (decl)
2357 tree decl;
2359 rtx insns;
2360 int tem;
2361 int failure = 0;
2362 int rebuild_label_notes_after_reload;
2363 int register_life_up_to_date;
2364 int cleanup_crossjump;
2366 timevar_push (TV_REST_OF_COMPILATION);
2368 /* Now that we're out of the frontend, we shouldn't have any more
2369 CONCATs anywhere. */
2370 generating_concat_p = 0;
2372 /* When processing delayed functions, prepare_function_start() won't
2373 have been run to re-initialize it. */
2374 cse_not_expected = ! optimize;
2376 /* First, make sure that NOTE_BLOCK is set correctly for each
2377 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2378 if (!cfun->x_whole_function_mode_p)
2379 identify_blocks ();
2381 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2382 tree in sensible shape. So, we just recalculate it here. */
2383 if (cfun->x_whole_function_mode_p)
2384 reorder_blocks ();
2386 init_flow ();
2388 /* If we are reconsidering an inline function
2389 at the end of compilation, skip the stuff for making it inline. */
2391 if (DECL_SAVED_INSNS (decl) == 0)
2393 int inlinable = 0;
2394 tree parent;
2395 const char *lose;
2397 /* If this is nested inside an inlined external function, pretend
2398 it was only declared. Since we cannot inline such functions,
2399 generating code for this one is not only not necessary but will
2400 confuse some debugging output writers. */
2401 for (parent = DECL_CONTEXT (current_function_decl);
2402 parent != NULL_TREE;
2403 parent = get_containing_scope (parent))
2404 if (TREE_CODE (parent) == FUNCTION_DECL
2405 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2407 DECL_INITIAL (decl) = 0;
2408 goto exit_rest_of_compilation;
2411 /* If requested, consider whether to make this function inline. */
2412 if ((DECL_INLINE (decl) && !flag_no_inline)
2413 || flag_inline_functions)
2415 timevar_push (TV_INTEGRATION);
2416 lose = function_cannot_inline_p (decl);
2417 timevar_pop (TV_INTEGRATION);
2418 if (lose || ! optimize)
2420 if (warn_inline && DECL_INLINE (decl))
2421 warning_with_decl (decl, lose);
2422 DECL_ABSTRACT_ORIGIN (decl) = 0;
2423 /* Don't really compile an extern inline function.
2424 If we can't make it inline, pretend
2425 it was only declared. */
2426 if (DECL_EXTERNAL (decl))
2428 DECL_INITIAL (decl) = 0;
2429 goto exit_rest_of_compilation;
2432 else
2433 /* ??? Note that this has the effect of making it look
2434 like "inline" was specified for a function if we choose
2435 to inline it. This isn't quite right, but it's
2436 probably not worth the trouble to fix. */
2437 inlinable = DECL_INLINE (decl) = 1;
2440 insns = get_insns ();
2442 /* Dump the rtl code if we are dumping rtl. */
2444 if (open_dump_file (DFI_rtl, decl))
2446 if (DECL_SAVED_INSNS (decl))
2447 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2448 close_dump_file (DFI_rtl, print_rtl, insns);
2451 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2452 sorts of eh initialization. Delay this until after the
2453 initial rtl dump so that we can see the original nesting. */
2454 convert_from_eh_region_ranges ();
2456 /* If function is inline, and we don't yet know whether to
2457 compile it by itself, defer decision till end of compilation.
2458 finish_compilation will call rest_of_compilation again
2459 for those functions that need to be output. Also defer those
2460 functions that we are supposed to defer. */
2462 if (inlinable
2463 || (DECL_INLINE (decl)
2464 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2465 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2466 && ! flag_keep_inline_functions)
2467 || DECL_EXTERNAL (decl))))
2468 DECL_DEFER_OUTPUT (decl) = 1;
2470 if (DECL_INLINE (decl))
2471 /* DWARF wants separate debugging info for abstract and
2472 concrete instances of all inline functions, including those
2473 declared inline but not inlined, and those inlined even
2474 though they weren't declared inline. Conveniently, that's
2475 what DECL_INLINE means at this point. */
2476 (*debug_hooks->deferred_inline_function) (decl);
2478 if (DECL_DEFER_OUTPUT (decl))
2480 /* If -Wreturn-type, we have to do a bit of compilation. We just
2481 want to call cleanup the cfg to figure out whether or not we can
2482 fall off the end of the function; we do the minimum amount of
2483 work necessary to make that safe. */
2484 if (warn_return_type)
2486 int saved_optimize = optimize;
2488 optimize = 0;
2489 rebuild_jump_labels (insns);
2490 find_exception_handler_labels ();
2491 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2492 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2493 optimize = saved_optimize;
2495 /* CFG is no longer maintained up-to-date. */
2496 free_bb_for_insn ();
2499 current_function_nothrow = nothrow_function_p ();
2500 if (current_function_nothrow)
2501 /* Now we know that this can't throw; set the flag for the benefit
2502 of other functions later in this translation unit. */
2503 TREE_NOTHROW (current_function_decl) = 1;
2505 timevar_push (TV_INTEGRATION);
2506 save_for_inline (decl);
2507 timevar_pop (TV_INTEGRATION);
2508 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2509 goto exit_rest_of_compilation;
2512 /* If specified extern inline but we aren't inlining it, we are
2513 done. This goes for anything that gets here with DECL_EXTERNAL
2514 set, not just things with DECL_INLINE. */
2515 if (DECL_EXTERNAL (decl))
2516 goto exit_rest_of_compilation;
2519 /* If we're emitting a nested function, make sure its parent gets
2520 emitted as well. Doing otherwise confuses debug info. */
2522 tree parent;
2523 for (parent = DECL_CONTEXT (current_function_decl);
2524 parent != NULL_TREE;
2525 parent = get_containing_scope (parent))
2526 if (TREE_CODE (parent) == FUNCTION_DECL)
2527 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
2530 /* We are now committed to emitting code for this function. Do any
2531 preparation, such as emitting abstract debug info for the inline
2532 before it gets mangled by optimization. */
2533 if (DECL_INLINE (decl))
2534 (*debug_hooks->outlining_inline_function) (decl);
2536 /* Remove any notes we don't need. That will make iterating
2537 over the instruction sequence faster, and allow the garbage
2538 collector to reclaim the memory used by the notes. */
2539 remove_unnecessary_notes ();
2540 reorder_blocks ();
2542 ggc_collect ();
2544 /* Initialize some variables used by the optimizers. */
2545 init_function_for_compilation ();
2547 if (! DECL_DEFER_OUTPUT (decl))
2548 TREE_ASM_WRITTEN (decl) = 1;
2550 /* Now that integrate will no longer see our rtl, we need not
2551 distinguish between the return value of this function and the
2552 return value of called functions. Also, we can remove all SETs
2553 of subregs of hard registers; they are only here because of
2554 integrate. Also, we can now initialize pseudos intended to
2555 carry magic hard reg data throughout the function. */
2556 rtx_equal_function_value_matters = 0;
2557 purge_hard_subreg_sets (get_insns ());
2559 /* Early return if there were errors. We can run afoul of our
2560 consistency checks, and there's not really much point in fixing them.
2561 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2562 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2563 || errorcount || sorrycount)
2564 goto exit_rest_of_compilation;
2566 /* We may have potential sibling or tail recursion sites. Select one
2567 (of possibly multiple) methods of performing the call. */
2568 if (flag_optimize_sibling_calls)
2570 timevar_push (TV_JUMP);
2571 open_dump_file (DFI_sibling, decl);
2573 optimize_sibling_and_tail_recursive_calls ();
2575 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2576 timevar_pop (TV_JUMP);
2579 /* Complete generation of exception handling code. */
2580 find_exception_handler_labels ();
2581 if (doing_eh (0))
2583 timevar_push (TV_JUMP);
2584 open_dump_file (DFI_eh, decl);
2586 finish_eh_generation ();
2588 close_dump_file (DFI_eh, print_rtl, get_insns ());
2589 timevar_pop (TV_JUMP);
2592 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
2593 generation, which might create new sets. */
2594 emit_initial_value_sets ();
2596 #ifdef FINALIZE_PIC
2597 /* If we are doing position-independent code generation, now
2598 is the time to output special prologues and epilogues.
2599 We do not want to do this earlier, because it just clutters
2600 up inline functions with meaningless insns. */
2601 if (flag_pic)
2602 FINALIZE_PIC;
2603 #endif
2605 insns = get_insns ();
2607 /* Copy any shared structure that should not be shared. */
2608 unshare_all_rtl (current_function_decl, insns);
2610 #ifdef SETJMP_VIA_SAVE_AREA
2611 /* This must be performed before virtual register instantiation. */
2612 if (current_function_calls_alloca)
2613 optimize_save_area_alloca (insns);
2614 #endif
2616 /* Instantiate all virtual registers. */
2617 instantiate_virtual_regs (current_function_decl, insns);
2619 open_dump_file (DFI_jump, decl);
2621 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2622 are initialized and to compute whether control can drop off the end
2623 of the function. */
2625 timevar_push (TV_JUMP);
2626 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2627 before jump optimization switches branch directions. */
2628 expected_value_to_br_prob ();
2630 reg_scan (insns, max_reg_num (), 0);
2631 rebuild_jump_labels (insns);
2632 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2633 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP);
2635 /* CFG is no longer maintained up-to-date. */
2636 free_bb_for_insn ();
2637 copy_loop_headers (insns);
2638 purge_line_number_notes (insns);
2640 timevar_pop (TV_JUMP);
2642 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2643 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2645 close_dump_file (DFI_jump, print_rtl, insns);
2646 goto exit_rest_of_compilation;
2649 /* Long term, this should probably move before the jump optimizer too,
2650 but I didn't want to disturb the rtl_dump_and_exit and related
2651 stuff at this time. */
2652 if (optimize > 0 && flag_ssa)
2654 /* Convert to SSA form. */
2656 timevar_push (TV_TO_SSA);
2657 open_dump_file (DFI_ssa, decl);
2659 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2660 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2661 convert_to_ssa ();
2663 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2664 timevar_pop (TV_TO_SSA);
2666 /* Perform sparse conditional constant propagation, if requested. */
2667 if (flag_ssa_ccp)
2669 timevar_push (TV_SSA_CCP);
2670 open_dump_file (DFI_ssa_ccp, decl);
2672 ssa_const_prop ();
2674 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2675 timevar_pop (TV_SSA_CCP);
2678 /* It would be useful to cleanup the CFG at this point, but block
2679 merging and possibly other transformations might leave a PHI
2680 node in the middle of a basic block, which is a strict no-no. */
2682 /* The SSA implementation uses basic block numbers in its phi
2683 nodes. Thus, changing the control-flow graph or the basic
2684 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2685 may cause problems. */
2687 if (flag_ssa_dce)
2689 /* Remove dead code. */
2691 timevar_push (TV_SSA_DCE);
2692 open_dump_file (DFI_ssa_dce, decl);
2694 insns = get_insns ();
2695 ssa_eliminate_dead_code();
2697 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2698 timevar_pop (TV_SSA_DCE);
2701 /* Convert from SSA form. */
2703 timevar_push (TV_FROM_SSA);
2704 open_dump_file (DFI_ussa, decl);
2706 convert_from_ssa ();
2707 /* New registers have been created. Rescan their usage. */
2708 reg_scan (insns, max_reg_num (), 1);
2710 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2711 timevar_pop (TV_FROM_SSA);
2713 ggc_collect ();
2714 /* CFG is no longer maintained up-to-date. */
2715 free_bb_for_insn ();
2718 timevar_push (TV_JUMP);
2720 if (optimize > 0)
2722 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2723 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP
2724 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2726 /* ??? Run if-conversion before delete_null_pointer_checks,
2727 since the later does not preserve the CFG. This should
2728 be changed -- no since converting if's that are going to
2729 be deleted. */
2730 timevar_push (TV_IFCVT);
2731 if_convert (0);
2732 timevar_pop (TV_IFCVT);
2734 /* CFG is no longer maintained up-to-date. */
2735 free_bb_for_insn ();
2736 /* Try to identify useless null pointer tests and delete them. */
2737 if (flag_delete_null_pointer_checks)
2738 delete_null_pointer_checks (insns);
2741 /* Jump optimization, and the removal of NULL pointer checks, may
2742 have reduced the number of instructions substantially. CSE, and
2743 future passes, allocate arrays whose dimensions involve the
2744 maximum instruction UID, so if we can reduce the maximum UID
2745 we'll save big on memory. */
2746 renumber_insns (rtl_dump_file);
2747 timevar_pop (TV_JUMP);
2749 close_dump_file (DFI_jump, print_rtl, insns);
2751 ggc_collect ();
2753 /* Perform common subexpression elimination.
2754 Nonzero value from `cse_main' means that jumps were simplified
2755 and some code may now be unreachable, so do
2756 jump optimization again. */
2758 if (optimize > 0)
2760 open_dump_file (DFI_cse, decl);
2761 timevar_push (TV_CSE);
2763 reg_scan (insns, max_reg_num (), 1);
2765 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2767 /* If we are not running more CSE passes, then we are no longer
2768 expecting CSE to be run. But always rerun it in a cheap mode. */
2769 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2771 if (tem || optimize > 1)
2773 timevar_push (TV_JUMP);
2774 rebuild_jump_labels (insns);
2775 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2776 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2777 timevar_pop (TV_JUMP);
2778 /* CFG is no longer maintained up-to-date. */
2779 free_bb_for_insn ();
2782 /* Run this after jump optmizations remove all the unreachable code
2783 so that unreachable code will not keep values live. */
2784 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2786 /* Try to identify useless null pointer tests and delete them. */
2787 if (flag_delete_null_pointer_checks || flag_thread_jumps)
2789 timevar_push (TV_JUMP);
2790 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2792 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP
2793 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2795 if (flag_delete_null_pointer_checks)
2796 delete_null_pointer_checks (insns);
2797 /* CFG is no longer maintained up-to-date. */
2798 free_bb_for_insn ();
2799 timevar_pop (TV_JUMP);
2802 /* The second pass of jump optimization is likely to have
2803 removed a bunch more instructions. */
2804 renumber_insns (rtl_dump_file);
2806 timevar_pop (TV_CSE);
2807 close_dump_file (DFI_cse, print_rtl, insns);
2810 open_dump_file (DFI_addressof, decl);
2812 purge_addressof (insns);
2813 reg_scan (insns, max_reg_num (), 1);
2815 close_dump_file (DFI_addressof, print_rtl, insns);
2817 ggc_collect ();
2819 /* Perform global cse. */
2821 if (optimize > 0 && flag_gcse)
2823 int save_csb, save_cfj;
2824 int tem2 = 0;
2826 timevar_push (TV_GCSE);
2827 open_dump_file (DFI_gcse, decl);
2829 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2830 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2831 tem = gcse_main (insns, rtl_dump_file);
2832 rebuild_jump_labels (insns);
2834 save_csb = flag_cse_skip_blocks;
2835 save_cfj = flag_cse_follow_jumps;
2836 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2838 /* CFG is no longer maintained up-to-date. */
2839 free_bb_for_insn ();
2840 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2841 by gcse. */
2842 if (flag_expensive_optimizations)
2844 timevar_push (TV_CSE);
2845 reg_scan (insns, max_reg_num (), 1);
2846 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2847 timevar_pop (TV_CSE);
2848 cse_not_expected = !flag_rerun_cse_after_loop;
2851 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2852 things up. Then possibly re-run CSE again. */
2853 while (tem || tem2)
2855 tem = tem2 = 0;
2856 timevar_push (TV_JUMP);
2857 rebuild_jump_labels (insns);
2858 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2859 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2860 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2861 /* CFG is no longer maintained up-to-date. */
2862 free_bb_for_insn ();
2863 timevar_pop (TV_JUMP);
2865 if (flag_expensive_optimizations)
2867 timevar_push (TV_CSE);
2868 reg_scan (insns, max_reg_num (), 1);
2869 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2870 timevar_pop (TV_CSE);
2874 close_dump_file (DFI_gcse, print_rtl, insns);
2875 timevar_pop (TV_GCSE);
2877 ggc_collect ();
2878 flag_cse_skip_blocks = save_csb;
2879 flag_cse_follow_jumps = save_cfj;
2882 /* Move constant computations out of loops. */
2884 if (optimize > 0)
2886 timevar_push (TV_LOOP);
2887 open_dump_file (DFI_loop, decl);
2888 free_bb_for_insn ();
2890 if (flag_rerun_loop_opt)
2892 cleanup_barriers ();
2894 /* We only want to perform unrolling once. */
2895 loop_optimize (insns, rtl_dump_file, LOOP_FIRST_PASS);
2897 /* The first call to loop_optimize makes some instructions
2898 trivially dead. We delete those instructions now in the
2899 hope that doing so will make the heuristics in loop work
2900 better and possibly speed up compilation. */
2901 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2903 /* The regscan pass is currently necessary as the alias
2904 analysis code depends on this information. */
2905 reg_scan (insns, max_reg_num (), 1);
2907 cleanup_barriers ();
2908 loop_optimize (insns, rtl_dump_file,
2909 (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT
2910 | (flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0));
2912 close_dump_file (DFI_loop, print_rtl, insns);
2913 timevar_pop (TV_LOOP);
2915 ggc_collect ();
2918 if (optimize > 0)
2920 timevar_push (TV_CSE2);
2921 open_dump_file (DFI_cse2, decl);
2923 if (flag_rerun_cse_after_loop)
2925 /* Running another jump optimization pass before the second
2926 cse pass sometimes simplifies the RTL enough to allow
2927 the second CSE pass to do a better job. Jump_optimize can change
2928 max_reg_num so we must rerun reg_scan afterwards.
2929 ??? Rework to not call reg_scan so often. */
2930 timevar_push (TV_JUMP);
2932 /* The previous call to loop_optimize makes some instructions
2933 trivially dead. We delete those instructions now in the
2934 hope that doing so will make the heuristics in jump work
2935 better and possibly speed up compilation. */
2936 delete_trivially_dead_insns (insns, max_reg_num (), 0);
2938 reg_scan (insns, max_reg_num (), 0);
2940 timevar_push (TV_IFCVT);
2942 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2943 cleanup_cfg (CLEANUP_EXPENSIVE);
2944 if_convert (0);
2946 timevar_pop(TV_IFCVT);
2948 timevar_pop (TV_JUMP);
2950 /* CFG is no longer maintained up-to-date. */
2951 free_bb_for_insn ();
2952 reg_scan (insns, max_reg_num (), 0);
2953 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
2955 if (tem)
2957 timevar_push (TV_JUMP);
2958 rebuild_jump_labels (insns);
2959 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2960 cleanup_cfg (CLEANUP_EXPENSIVE);
2961 /* CFG is no longer maintained up-to-date. */
2962 free_bb_for_insn ();
2963 timevar_pop (TV_JUMP);
2967 close_dump_file (DFI_cse2, print_rtl, insns);
2968 timevar_pop (TV_CSE2);
2970 ggc_collect ();
2973 cse_not_expected = 1;
2975 regclass_init ();
2977 /* Do control and data flow analysis; wrote some of the results to
2978 the dump file. */
2980 timevar_push (TV_FLOW);
2981 open_dump_file (DFI_cfg, decl);
2983 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2984 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
2985 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2986 check_function_return_warnings ();
2988 /* It may make more sense to mark constant functions after dead code is
2989 eliminated by life_analyzis, but we need to do it early, as -fprofile-arcs
2990 may insert code making function non-constant, but we still must consider
2991 it as constant, otherwise -fbranch-probabilities will not read data back.
2993 life_analyzis rarely eliminates modification of external memory.
2995 mark_constant_function ();
2997 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2999 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3001 timevar_push (TV_BRANCH_PROB);
3002 open_dump_file (DFI_bp, decl);
3004 branch_prob ();
3006 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3007 timevar_pop (TV_BRANCH_PROB);
3010 open_dump_file (DFI_life, decl);
3011 if (optimize)
3013 struct loops loops;
3015 /* Discover and record the loop depth at the head of each basic
3016 block. The loop infrastructure does the real job for us. */
3017 flow_loops_find (&loops, LOOP_TREE);
3019 /* Estimate using heuristics if no profiling info is available. */
3020 if (flag_guess_branch_prob)
3021 estimate_probability (&loops);
3023 if (rtl_dump_file)
3024 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3026 flow_loops_free (&loops);
3028 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3029 timevar_pop (TV_FLOW);
3031 no_new_pseudos = 1;
3033 if (warn_uninitialized || extra_warnings)
3035 uninitialized_vars_warning (DECL_INITIAL (decl));
3036 if (extra_warnings)
3037 setjmp_args_warning ();
3040 if (optimize)
3042 if (initialize_uninitialized_subregs ())
3044 /* Insns were inserted, so things might look a bit different. */
3045 insns = get_insns ();
3046 life_analysis (insns, rtl_dump_file,
3047 (PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES));
3051 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3053 ggc_collect ();
3055 /* If -opt, try combining insns through substitution. */
3057 if (optimize > 0)
3059 int rebuild_jump_labels_after_combine = 0;
3061 timevar_push (TV_COMBINE);
3062 open_dump_file (DFI_combine, decl);
3064 rebuild_jump_labels_after_combine
3065 = combine_instructions (insns, max_reg_num ());
3067 /* Always purge dead edges, as we may eliminate an insn throwing
3068 exception. */
3069 rebuild_jump_labels_after_combine |= purge_all_dead_edges (true);
3071 /* Combining insns may have turned an indirect jump into a
3072 direct jump. Rebuid the JUMP_LABEL fields of jumping
3073 instructions. */
3074 if (rebuild_jump_labels_after_combine)
3076 timevar_push (TV_JUMP);
3077 rebuild_jump_labels (insns);
3078 timevar_pop (TV_JUMP);
3080 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3083 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3084 timevar_pop (TV_COMBINE);
3086 ggc_collect ();
3089 /* Rerun if-conversion, as combine may have simplified things enough to
3090 now meet sequence length restrictions. */
3091 if (optimize > 0)
3093 timevar_push (TV_IFCVT);
3094 open_dump_file (DFI_ce, decl);
3096 no_new_pseudos = 0;
3097 if_convert (1);
3098 no_new_pseudos = 1;
3100 close_dump_file (DFI_ce, print_rtl_with_bb, insns);
3101 timevar_pop (TV_IFCVT);
3104 /* Register allocation pre-pass, to reduce number of moves
3105 necessary for two-address machines. */
3106 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3108 timevar_push (TV_REGMOVE);
3109 open_dump_file (DFI_regmove, decl);
3111 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3113 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3114 timevar_pop (TV_REGMOVE);
3116 ggc_collect ();
3119 /* Do unconditional splitting before register allocation to allow machine
3120 description to add extra information not needed previously. */
3121 split_all_insns (1);
3123 /* Any of the several passes since flow1 will have munged register
3124 lifetime data a bit. */
3125 register_life_up_to_date = 0;
3127 #ifdef OPTIMIZE_MODE_SWITCHING
3128 timevar_push (TV_MODE_SWITCH);
3130 no_new_pseudos = 0;
3131 if (optimize_mode_switching (NULL))
3133 /* We did work, and so had to regenerate global life information.
3134 Take advantage of this and don't re-recompute register life
3135 information below. */
3136 register_life_up_to_date = 1;
3138 no_new_pseudos = 1;
3140 timevar_pop (TV_MODE_SWITCH);
3141 #endif
3143 timevar_push (TV_SCHED);
3145 #ifdef INSN_SCHEDULING
3147 /* Print function header into sched dump now
3148 because doing the sched analysis makes some of the dump. */
3149 if (optimize > 0 && flag_schedule_insns)
3151 open_dump_file (DFI_sched, decl);
3153 /* Do control and data sched analysis,
3154 and write some of the results to dump file. */
3156 schedule_insns (rtl_dump_file);
3158 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3160 /* Register lifetime information was updated as part of verifying
3161 the schedule. */
3162 register_life_up_to_date = 1;
3164 #endif
3165 timevar_pop (TV_SCHED);
3167 ggc_collect ();
3169 /* Determine if the current function is a leaf before running reload
3170 since this can impact optimizations done by the prologue and
3171 epilogue thus changing register elimination offsets. */
3172 current_function_is_leaf = leaf_function_p ();
3174 timevar_push (TV_LOCAL_ALLOC);
3175 open_dump_file (DFI_lreg, decl);
3177 /* Allocate pseudo-regs that are used only within 1 basic block.
3179 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3180 jump optimizer after register allocation and reloading are finished. */
3182 if (! register_life_up_to_date)
3183 recompute_reg_usage (insns, ! optimize_size);
3185 /* Allocate the reg_renumber array. */
3186 allocate_reg_info (max_regno, FALSE, TRUE);
3188 /* And the reg_equiv_memory_loc array. */
3189 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3191 allocate_initial_values (reg_equiv_memory_loc);
3193 regclass (insns, max_reg_num (), rtl_dump_file);
3194 rebuild_label_notes_after_reload = local_alloc ();
3196 timevar_pop (TV_LOCAL_ALLOC);
3198 if (dump_file[DFI_lreg].enabled)
3200 timevar_push (TV_DUMP);
3202 dump_flow_info (rtl_dump_file);
3203 dump_local_alloc (rtl_dump_file);
3205 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3206 timevar_pop (TV_DUMP);
3209 ggc_collect ();
3211 timevar_push (TV_GLOBAL_ALLOC);
3212 open_dump_file (DFI_greg, decl);
3214 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3215 pass fixing up any insns that are invalid. */
3217 if (optimize)
3218 failure = global_alloc (rtl_dump_file);
3219 else
3221 build_insn_chain (insns);
3222 failure = reload (insns, 0);
3225 timevar_pop (TV_GLOBAL_ALLOC);
3227 if (dump_file[DFI_greg].enabled)
3229 timevar_push (TV_DUMP);
3231 dump_global_regs (rtl_dump_file);
3233 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3234 timevar_pop (TV_DUMP);
3237 if (failure)
3238 goto exit_rest_of_compilation;
3240 ggc_collect ();
3242 open_dump_file (DFI_postreload, decl);
3244 /* Do a very simple CSE pass over just the hard registers. */
3245 if (optimize > 0)
3247 timevar_push (TV_RELOAD_CSE_REGS);
3248 reload_cse_regs (insns);
3249 timevar_pop (TV_RELOAD_CSE_REGS);
3252 /* Register allocation and reloading may have turned an indirect jump into
3253 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3254 jumping instructions. */
3255 if (rebuild_label_notes_after_reload)
3257 timevar_push (TV_JUMP);
3259 rebuild_jump_labels (insns);
3261 timevar_pop (TV_JUMP);
3264 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3266 /* Re-create the death notes which were deleted during reload. */
3267 timevar_push (TV_FLOW2);
3268 open_dump_file (DFI_flow2, decl);
3270 #ifdef ENABLE_CHECKING
3271 verify_flow_info ();
3272 #endif
3274 /* If optimizing, then go ahead and split insns now. */
3275 if (optimize > 0)
3276 split_all_insns (0);
3278 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3280 /* On some machines, the prologue and epilogue code, or parts thereof,
3281 can be represented as RTL. Doing so lets us schedule insns between
3282 it and the rest of the code and also allows delayed branch
3283 scheduling to operate in the epilogue. */
3284 thread_prologue_and_epilogue_insns (insns);
3286 /* Cross-jumping is O(N^3) on the number of edges, thus trying to
3287 perform cross-jumping on flow graphs which have a high connectivity
3288 will take a long time. This is similar to the test to disable GCSE. */
3289 cleanup_crossjump = CLEANUP_CROSSJUMP;
3290 if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
3292 if (optimize && warn_disabled_optimization)
3293 warning ("crossjump disabled: %d > 1000 basic blocks and %d >= 20 edges/basic block",
3294 n_basic_blocks, n_edges / n_basic_blocks);
3295 cleanup_crossjump = 0;
3298 if (optimize)
3300 cleanup_cfg (CLEANUP_EXPENSIVE | cleanup_crossjump);
3301 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3303 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3304 even for machines with possibly nonzero RETURN_POPS_ARGS
3305 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3306 push instructions will have popping returns. */
3307 #ifndef PUSH_ROUNDING
3308 if (!ACCUMULATE_OUTGOING_ARGS)
3309 #endif
3310 combine_stack_adjustments ();
3312 ggc_collect ();
3315 flow2_completed = 1;
3317 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3318 timevar_pop (TV_FLOW2);
3320 #ifdef HAVE_peephole2
3321 if (optimize > 0 && flag_peephole2)
3323 timevar_push (TV_PEEPHOLE2);
3324 open_dump_file (DFI_peephole2, decl);
3326 peephole2_optimize (rtl_dump_file);
3328 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3329 timevar_pop (TV_PEEPHOLE2);
3331 #endif
3333 if (optimize > 0 && (flag_rename_registers || flag_cprop_registers))
3335 timevar_push (TV_RENAME_REGISTERS);
3336 open_dump_file (DFI_rnreg, decl);
3338 if (flag_rename_registers)
3339 regrename_optimize ();
3340 if (flag_cprop_registers)
3341 copyprop_hardreg_forward ();
3343 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3344 timevar_pop (TV_RENAME_REGISTERS);
3347 if (optimize > 0)
3349 timevar_push (TV_IFCVT2);
3350 open_dump_file (DFI_ce2, decl);
3352 if_convert (1);
3354 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3355 timevar_pop (TV_IFCVT2);
3357 #ifdef STACK_REGS
3358 if (optimize)
3359 split_all_insns (1);
3360 #endif
3362 #ifdef INSN_SCHEDULING
3363 if (optimize > 0 && flag_schedule_insns_after_reload)
3365 timevar_push (TV_SCHED2);
3366 open_dump_file (DFI_sched2, decl);
3368 /* Do control and data sched analysis again,
3369 and write some more of the results to dump file. */
3371 split_all_insns (1);
3373 schedule_insns (rtl_dump_file);
3375 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3376 timevar_pop (TV_SCHED2);
3378 ggc_collect ();
3380 #endif
3382 #ifdef LEAF_REGISTERS
3383 current_function_uses_only_leaf_regs
3384 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3385 #endif
3387 #ifdef STACK_REGS
3388 timevar_push (TV_REG_STACK);
3389 open_dump_file (DFI_stack, decl);
3391 reg_to_stack (insns, rtl_dump_file);
3393 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3394 timevar_pop (TV_REG_STACK);
3396 ggc_collect ();
3397 #endif
3398 if (optimize > 0)
3400 timevar_push (TV_REORDER_BLOCKS);
3401 open_dump_file (DFI_bbro, decl);
3403 /* Last attempt to optimize CFG, as life analysis possibly removed
3404 some instructions. Note that we can't rerun crossjump at this
3405 point, because it can turn a switch into a direct branch, which
3406 can leave the tablejump address calculation in the code, which
3407 can lead to referencing an undefined label. */
3408 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3409 if (flag_reorder_blocks)
3411 reorder_basic_blocks ();
3412 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3415 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3416 timevar_pop (TV_REORDER_BLOCKS);
3418 compute_alignments ();
3420 /* CFG is no longer maintained up-to-date. */
3421 free_bb_for_insn ();
3423 /* If a machine dependent reorganization is needed, call it. */
3424 #ifdef MACHINE_DEPENDENT_REORG
3425 timevar_push (TV_MACH_DEP);
3426 open_dump_file (DFI_mach, decl);
3428 MACHINE_DEPENDENT_REORG (insns);
3430 close_dump_file (DFI_mach, print_rtl, insns);
3431 timevar_pop (TV_MACH_DEP);
3433 ggc_collect ();
3434 #endif
3436 purge_line_number_notes (insns);
3437 cleanup_barriers ();
3439 /* If a scheduling pass for delayed branches is to be done,
3440 call the scheduling code. */
3442 #ifdef DELAY_SLOTS
3443 if (optimize > 0 && flag_delayed_branch)
3445 timevar_push (TV_DBR_SCHED);
3446 open_dump_file (DFI_dbr, decl);
3448 dbr_schedule (insns, rtl_dump_file);
3450 close_dump_file (DFI_dbr, print_rtl, insns);
3451 timevar_pop (TV_DBR_SCHED);
3453 ggc_collect ();
3455 #endif
3457 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3458 timevar_push (TV_SHORTEN_BRANCH);
3459 split_all_insns_noflow ();
3460 timevar_pop (TV_SHORTEN_BRANCH);
3461 #endif
3463 convert_to_eh_region_ranges ();
3465 /* Shorten branches. */
3466 timevar_push (TV_SHORTEN_BRANCH);
3467 shorten_branches (get_insns ());
3468 timevar_pop (TV_SHORTEN_BRANCH);
3470 current_function_nothrow = nothrow_function_p ();
3471 if (current_function_nothrow)
3472 /* Now we know that this can't throw; set the flag for the benefit
3473 of other functions later in this translation unit. */
3474 TREE_NOTHROW (current_function_decl) = 1;
3476 /* Now turn the rtl into assembler code. */
3478 timevar_push (TV_FINAL);
3480 rtx x;
3481 const char *fnname;
3483 /* Get the function's name, as described by its RTL. This may be
3484 different from the DECL_NAME name used in the source file. */
3486 x = DECL_RTL (decl);
3487 if (GET_CODE (x) != MEM)
3488 abort ();
3489 x = XEXP (x, 0);
3490 if (GET_CODE (x) != SYMBOL_REF)
3491 abort ();
3492 fnname = XSTR (x, 0);
3494 assemble_start_function (decl, fnname);
3495 final_start_function (insns, asm_out_file, optimize);
3496 final (insns, asm_out_file, optimize, 0);
3497 final_end_function ();
3499 #ifdef IA64_UNWIND_INFO
3500 /* ??? The IA-64 ".handlerdata" directive must be issued before
3501 the ".endp" directive that closes the procedure descriptor. */
3502 output_function_exception_table ();
3503 #endif
3505 assemble_end_function (decl, fnname);
3507 #ifndef IA64_UNWIND_INFO
3508 /* Otherwise, it feels unclean to switch sections in the middle. */
3509 output_function_exception_table ();
3510 #endif
3512 if (! quiet_flag)
3513 fflush (asm_out_file);
3515 /* Release all memory allocated by flow. */
3516 free_basic_block_vars (0);
3518 /* Release all memory held by regsets now. */
3519 regset_release_memory ();
3521 timevar_pop (TV_FINAL);
3523 ggc_collect ();
3525 /* Write DBX symbols if requested. */
3527 /* Note that for those inline functions where we don't initially
3528 know for certain that we will be generating an out-of-line copy,
3529 the first invocation of this routine (rest_of_compilation) will
3530 skip over this code by doing a `goto exit_rest_of_compilation;'.
3531 Later on, finish_compilation will call rest_of_compilation again
3532 for those inline functions that need to have out-of-line copies
3533 generated. During that call, we *will* be routed past here. */
3535 timevar_push (TV_SYMOUT);
3536 (*debug_hooks->function_decl) (decl);
3537 timevar_pop (TV_SYMOUT);
3539 exit_rest_of_compilation:
3541 /* In case the function was not output,
3542 don't leave any temporary anonymous types
3543 queued up for sdb output. */
3544 #ifdef SDB_DEBUGGING_INFO
3545 if (write_symbols == SDB_DEBUG)
3546 sdbout_types (NULL_TREE);
3547 #endif
3549 reload_completed = 0;
3550 flow2_completed = 0;
3551 no_new_pseudos = 0;
3553 timevar_push (TV_FINAL);
3555 /* Clear out the insn_length contents now that they are no
3556 longer valid. */
3557 init_insn_lengths ();
3559 /* Clear out the real_constant_chain before some of the rtx's
3560 it runs through become garbage. */
3561 clear_const_double_mem ();
3563 /* Show no temporary slots allocated. */
3564 init_temp_slots ();
3566 free_basic_block_vars (0);
3567 free_bb_for_insn ();
3569 timevar_pop (TV_FINAL);
3571 /* Make sure volatile mem refs aren't considered valid operands for
3572 arithmetic insns. We must call this here if this is a nested inline
3573 function, since the above code leaves us in the init_recog state
3574 (from final.c), and the function context push/pop code does not
3575 save/restore volatile_ok.
3577 ??? Maybe it isn't necessary for expand_start_function to call this
3578 anymore if we do it here? */
3580 init_recog_no_volatile ();
3582 /* We're done with this function. Free up memory if we can. */
3583 free_after_parsing (cfun);
3584 if (! DECL_DEFER_OUTPUT (decl))
3586 free_after_compilation (cfun);
3588 /* Clear integrate.c's pointer to the cfun structure we just
3589 destroyed. */
3590 DECL_SAVED_INSNS (decl) = 0;
3592 cfun = 0;
3594 ggc_collect ();
3596 timevar_pop (TV_REST_OF_COMPILATION);
3599 static void
3600 display_help ()
3602 int undoc;
3603 unsigned long i;
3604 const char *lang;
3606 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3607 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3608 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3609 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3610 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3611 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"));
3613 for (i = ARRAY_SIZE (f_options); i--;)
3615 const char *description = f_options[i].description;
3617 if (description != NULL && * description != 0)
3618 printf (" -f%-21s %s\n",
3619 f_options[i].string, _(description));
3622 printf (_(" -O[number] Set optimization level to [number]\n"));
3623 printf (_(" -Os Optimize for space rather than speed\n"));
3624 for (i = LAST_PARAM; i--;)
3626 const char *description = compiler_params[i].help;
3627 const int length = 21-strlen(compiler_params[i].option);
3629 if (description != NULL && * description != 0)
3630 printf (" --param %s=<value>%.*s%s\n",
3631 compiler_params[i].option,
3632 length > 0 ? length : 1, " ",
3633 _(description));
3635 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3636 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3637 printf (_(" -w Suppress warnings\n"));
3638 printf (_(" -W Enable extra warnings\n"));
3640 for (i = ARRAY_SIZE (W_options); i--;)
3642 const char *description = W_options[i].description;
3644 if (description != NULL && * description != 0)
3645 printf (" -W%-21s %s\n",
3646 W_options[i].string, _(description));
3649 printf (_(" -Wunused Enable unused warnings\n"));
3650 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3651 printf (_(" -p Enable function profiling\n"));
3652 printf (_(" -o <file> Place output into <file> \n"));
3653 printf (_("\
3654 -G <number> Put global and static data smaller than <number>\n\
3655 bytes into a special section (on some targets)\n"));
3657 for (i = ARRAY_SIZE (debug_args); i--;)
3659 if (debug_args[i].description != NULL)
3660 printf (" -g%-21s %s\n",
3661 debug_args[i].arg, _(debug_args[i].description));
3664 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3665 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3666 printf (_(" -version Display the compiler's version\n"));
3667 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3668 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3669 #if defined INSN_SCHEDULING
3670 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3671 #endif
3672 printf (_(" --help Display this information\n"));
3674 undoc = 0;
3675 lang = "language";
3677 /* Display descriptions of language specific options.
3678 If there is no description, note that there is an undocumented option.
3679 If the description is empty, do not display anything. (This allows
3680 options to be deliberately undocumented, for whatever reason).
3681 If the option string is missing, then this is a marker, indicating
3682 that the description string is in fact the name of a language, whose
3683 language specific options are to follow. */
3685 if (ARRAY_SIZE (documented_lang_options) > 1)
3687 printf (_("\nLanguage specific options:\n"));
3689 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3691 const char *description = documented_lang_options[i].description;
3692 const char *option = documented_lang_options[i].option;
3694 if (description == NULL)
3696 undoc = 1;
3698 if (extra_warnings)
3699 printf (_(" %-23.23s [undocumented]\n"), option);
3701 else if (*description == 0)
3702 continue;
3703 else if (option == NULL)
3705 if (undoc)
3706 printf
3707 (_("\nThere are undocumented %s specific options as well.\n"),
3708 lang);
3709 undoc = 0;
3711 printf (_("\n Options for %s:\n"), description);
3713 lang = description;
3715 else
3716 printf (" %-23.23s %s\n", option, _(description));
3720 if (undoc)
3721 printf (_("\nThere are undocumented %s specific options as well.\n"),
3722 lang);
3724 display_target_options ();
3727 static void
3728 display_target_options ()
3730 int undoc, i;
3731 static bool displayed = false;
3733 /* Avoid double printing for --help --target-help. */
3734 if (displayed)
3735 return;
3736 displayed = true;
3738 if (ARRAY_SIZE (target_switches) > 1
3739 #ifdef TARGET_OPTIONS
3740 || ARRAY_SIZE (target_options) > 1
3741 #endif
3744 int doc = 0;
3746 undoc = 0;
3748 printf (_("\nTarget specific options:\n"));
3750 for (i = ARRAY_SIZE (target_switches); i--;)
3752 const char *option = target_switches[i].name;
3753 const char *description = target_switches[i].description;
3755 if (option == NULL || *option == 0)
3756 continue;
3757 else if (description == NULL)
3759 undoc = 1;
3761 if (extra_warnings)
3762 printf (_(" -m%-23.23s [undocumented]\n"), option);
3764 else if (* description != 0)
3765 doc += printf (" -m%-23.23s %s\n", option, _(description));
3768 #ifdef TARGET_OPTIONS
3769 for (i = ARRAY_SIZE (target_options); i--;)
3771 const char *option = target_options[i].prefix;
3772 const char *description = target_options[i].description;
3774 if (option == NULL || *option == 0)
3775 continue;
3776 else if (description == NULL)
3778 undoc = 1;
3780 if (extra_warnings)
3781 printf (_(" -m%-23.23s [undocumented]\n"), option);
3783 else if (* description != 0)
3784 doc += printf (" -m%-23.23s %s\n", option, _(description));
3786 #endif
3787 if (undoc)
3789 if (doc)
3790 printf (_("\nThere are undocumented target specific options as well.\n"));
3791 else
3792 printf (_(" They exist, but they are not documented.\n"));
3797 /* Parse a -d... command line switch. */
3799 static void
3800 decode_d_option (arg)
3801 const char *arg;
3803 int i, c, matched;
3805 while (*arg)
3806 switch (c = *arg++)
3808 case 'a':
3809 for (i = 0; i < (int) DFI_MAX; ++i)
3810 dump_file[i].enabled = 1;
3811 break;
3812 case 'A':
3813 flag_debug_asm = 1;
3814 break;
3815 case 'p':
3816 flag_print_asm_name = 1;
3817 break;
3818 case 'P':
3819 flag_dump_rtl_in_asm = 1;
3820 flag_print_asm_name = 1;
3821 break;
3822 case 'v':
3823 graph_dump_format = vcg;
3824 break;
3825 case 'x':
3826 rtl_dump_and_exit = 1;
3827 break;
3828 case 'y':
3829 (*lang_hooks.set_yydebug) (1);
3830 break;
3831 case 'D': /* These are handled by the preprocessor. */
3832 case 'I':
3833 break;
3835 default:
3836 matched = 0;
3837 for (i = 0; i < (int) DFI_MAX; ++i)
3838 if (c == dump_file[i].debug_switch)
3840 dump_file[i].enabled = 1;
3841 matched = 1;
3844 if (! matched)
3845 warning ("unrecognized gcc debugging option: %c", c);
3846 break;
3850 /* Parse a -f... command line switch. ARG is the value after the -f.
3851 It is safe to access 'ARG - 2' to generate the full switch name.
3852 Return the number of strings consumed. */
3854 static int
3855 decode_f_option (arg)
3856 const char *arg;
3858 int j;
3859 const char *option_value = NULL;
3861 /* Search for the option in the table of binary f options. */
3862 for (j = ARRAY_SIZE (f_options); j--;)
3864 if (!strcmp (arg, f_options[j].string))
3866 *f_options[j].variable = f_options[j].on_value;
3867 return 1;
3870 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3871 && ! strcmp (arg + 3, f_options[j].string))
3873 *f_options[j].variable = ! f_options[j].on_value;
3874 return 1;
3878 if (!strcmp (arg, "fast-math"))
3879 set_fast_math_flags ();
3880 else if (!strcmp (arg, "no-fast-math"))
3881 set_no_fast_math_flags ();
3882 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
3883 || (option_value = skip_leading_substring (arg, "inline-limit=")))
3885 int val =
3886 read_integral_parameter (option_value, arg - 2,
3887 MAX_INLINE_INSNS);
3888 set_param_value ("max-inline-insns", val);
3890 #ifdef INSN_SCHEDULING
3891 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
3892 fix_sched_param ("verbose", option_value);
3893 #endif
3894 else if ((option_value = skip_leading_substring (arg, "fixed-")))
3895 fix_register (option_value, 1, 1);
3896 else if ((option_value = skip_leading_substring (arg, "call-used-")))
3897 fix_register (option_value, 0, 1);
3898 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
3899 fix_register (option_value, 0, 0);
3900 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
3901 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
3902 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
3903 align_functions
3904 = read_integral_parameter (option_value, arg - 2, align_functions);
3905 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
3906 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
3907 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
3908 align_labels
3909 = read_integral_parameter (option_value, arg - 2, align_labels);
3910 else if ((option_value
3911 = skip_leading_substring (arg, "stack-limit-register=")))
3913 int reg = decode_reg_name (option_value);
3914 if (reg < 0)
3915 error ("unrecognized register name `%s'", option_value);
3916 else
3917 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
3919 else if ((option_value
3920 = skip_leading_substring (arg, "stack-limit-symbol=")))
3922 const char *nm;
3923 nm = ggc_strdup (option_value);
3924 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
3926 else if ((option_value
3927 = skip_leading_substring (arg, "message-length=")))
3928 output_set_maximum_length
3929 (&global_dc->buffer, read_integral_parameter
3930 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
3931 else if ((option_value
3932 = skip_leading_substring (arg, "diagnostics-show-location=")))
3934 if (!strcmp (option_value, "once"))
3935 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
3936 else if (!strcmp (option_value, "every-line"))
3937 diagnostic_prefixing_rule (global_dc)
3938 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
3939 else
3940 error ("unrecognized option `%s'", arg - 2);
3942 else if (!strcmp (arg, "no-stack-limit"))
3943 stack_limit_rtx = NULL_RTX;
3944 else if (!strcmp (arg, "preprocessed"))
3945 /* Recognise this switch but do nothing. This prevents warnings
3946 about an unrecognized switch if cpplib has not been linked in. */
3948 else
3949 return 0;
3951 return 1;
3954 /* Parse a -W... command line switch. ARG is the value after the -W.
3955 It is safe to access 'ARG - 2' to generate the full switch name.
3956 Return the number of strings consumed. */
3958 static int
3959 decode_W_option (arg)
3960 const char *arg;
3962 const char *option_value = NULL;
3963 int j;
3965 /* Search for the option in the table of binary W options. */
3967 for (j = ARRAY_SIZE (W_options); j--;)
3969 if (!strcmp (arg, W_options[j].string))
3971 *W_options[j].variable = W_options[j].on_value;
3972 return 1;
3975 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3976 && ! strcmp (arg + 3, W_options[j].string))
3978 *W_options[j].variable = ! W_options[j].on_value;
3979 return 1;
3983 if ((option_value = skip_leading_substring (arg, "id-clash-")))
3984 warning ("-Wid-clash-LEN is no longer supported");
3985 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
3987 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
3989 warn_larger_than = larger_than_size != -1;
3991 else if (!strcmp (arg, "unused"))
3993 set_Wunused (1);
3995 else if (!strcmp (arg, "no-unused"))
3997 set_Wunused (0);
3999 else
4000 return 0;
4002 return 1;
4005 /* Parse a -g... command line switch. ARG is the value after the -g.
4006 It is safe to access 'ARG - 2' to generate the full switch name.
4007 Return the number of strings consumed. */
4009 static int
4010 decode_g_option (arg)
4011 const char *arg;
4013 static unsigned level=0;
4014 /* A lot of code assumes write_symbols == NO_DEBUG if the
4015 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4016 of what debugging type has been selected). This records the
4017 selected type. It is an error to specify more than one
4018 debugging type. */
4019 static enum debug_info_type selected_debug_type = NO_DEBUG;
4020 /* Non-zero if debugging format has been explicitly set.
4021 -g and -ggdb don't explicitly set the debugging format so
4022 -gdwarf -g3 is equivalent to -gdwarf3. */
4023 static int type_explicitly_set_p = 0;
4024 /* Indexed by enum debug_info_type. */
4025 static const char *const debug_type_names[] =
4027 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4030 /* The maximum admissible debug level value. */
4031 static const unsigned max_debug_level = 3;
4033 /* Look up ARG in the table. */
4034 for (da = debug_args; da->arg; da++)
4036 const int da_len = strlen (da->arg);
4038 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4040 enum debug_info_type type = da->debug_type;
4041 const char *p = arg + da_len;
4043 if (*p && ! ISDIGIT (*p))
4044 continue;
4046 /* A debug flag without a level defaults to level 2.
4047 Note we do not want to call read_integral_parameter
4048 for that case since it will call atoi which
4049 will return zero.
4051 ??? We may want to generalize the interface to
4052 read_integral_parameter to better handle this case
4053 if this case shows up often. */
4054 if (*p)
4055 level = read_integral_parameter (p, 0, max_debug_level + 1);
4056 else
4057 level = (level == 0) ? 2 : level;
4059 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4061 error ("use -gdwarf -g%d for DWARF v1, level %d",
4062 level, level);
4063 if (level == 2)
4064 error ("use -gdwarf-2 for DWARF v2");
4067 if (level > max_debug_level)
4069 warning ("\
4070 ignoring option `%s' due to invalid debug level specification",
4071 arg - 2);
4072 level = debug_info_level;
4075 if (type == NO_DEBUG)
4077 type = PREFERRED_DEBUGGING_TYPE;
4079 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4081 #ifdef DWARF2_DEBUGGING_INFO
4082 type = DWARF2_DEBUG;
4083 #else
4084 #ifdef DBX_DEBUGGING_INFO
4085 type = DBX_DEBUG;
4086 #endif
4087 #endif
4091 if (type == NO_DEBUG)
4092 warning ("`%s': unknown or unsupported -g option", arg - 2);
4094 /* Does it conflict with an already selected type? */
4095 if (type_explicitly_set_p
4096 /* -g/-ggdb don't conflict with anything. */
4097 && da->debug_type != NO_DEBUG
4098 && type != selected_debug_type)
4099 warning ("`%s' ignored, conflicts with `-g%s'",
4100 arg - 2, debug_type_names[(int) selected_debug_type]);
4101 else
4103 /* If the format has already been set, -g/-ggdb
4104 only change the debug level. */
4105 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4106 /* Don't change debugging type. */
4108 else
4110 selected_debug_type = type;
4111 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4114 write_symbols = (level == 0
4115 ? NO_DEBUG
4116 : selected_debug_type);
4117 use_gnu_debug_info_extensions = da->use_extensions_p;
4118 debug_info_level = (enum debug_info_level) level;
4121 break;
4125 if (! da->arg)
4126 return 0;
4128 return 1;
4131 /* Decode the first argument in the argv as a language-independent option.
4132 Return the number of strings consumed. */
4134 static unsigned int
4135 independent_decode_option (argc, argv)
4136 int argc;
4137 char **argv;
4139 char *arg = argv[0];
4141 if (arg[0] != '-' || arg[1] == 0)
4143 if (arg[0] == '+')
4144 return 0;
4146 filename = arg;
4148 return 1;
4151 arg++;
4153 if (!strcmp (arg, "-help"))
4155 display_help ();
4156 exit_after_options = 1;
4159 if (!strcmp (arg, "-target-help"))
4161 display_target_options ();
4162 exit_after_options = 1;
4165 if (!strcmp (arg, "-version"))
4167 print_version (stderr, "");
4168 exit_after_options = 1;
4171 /* Handle '--param <name>=<value>'. */
4172 if (strcmp (arg, "-param") == 0)
4174 char *equal;
4176 if (argc == 1)
4178 error ("-param option missing argument");
4179 return 1;
4182 /* Get the '<name>=<value>' parameter. */
4183 arg = argv[1];
4184 /* Look for the `='. */
4185 equal = strchr (arg, '=');
4186 if (!equal)
4187 error ("invalid --param option: %s", arg);
4188 else
4190 int val;
4192 /* Zero out the `=' sign so that we get two separate strings. */
4193 *equal = '\0';
4194 /* Figure out what value is specified. */
4195 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4196 if (val != INVALID_PARAM_VAL)
4197 set_param_value (arg, val);
4198 else
4199 error ("invalid parameter value `%s'", equal + 1);
4202 return 2;
4205 if (*arg == 'Y')
4206 arg++;
4208 switch (*arg)
4210 default:
4211 return 0;
4213 case 'O':
4214 /* Already been treated in main (). Do nothing. */
4215 break;
4217 case 'm':
4218 set_target_switch (arg + 1);
4219 break;
4221 case 'f':
4222 return decode_f_option (arg + 1);
4224 case 'g':
4225 return decode_g_option (arg + 1);
4227 case 'd':
4228 if (!strcmp (arg, "dumpbase"))
4230 if (argc == 1)
4231 return 0;
4233 dump_base_name = argv[1];
4234 return 2;
4236 else
4237 decode_d_option (arg + 1);
4238 break;
4240 case 'p':
4241 if (!strcmp (arg, "pedantic"))
4242 pedantic = 1;
4243 else if (!strcmp (arg, "pedantic-errors"))
4244 flag_pedantic_errors = pedantic = 1;
4245 else if (arg[1] == 0)
4246 profile_flag = 1;
4247 else
4248 return 0;
4249 break;
4251 case 'q':
4252 if (!strcmp (arg, "quiet"))
4253 quiet_flag = 1;
4254 else
4255 return 0;
4256 break;
4258 case 'v':
4259 if (!strcmp (arg, "version"))
4260 version_flag = 1;
4261 else
4262 return 0;
4263 break;
4265 case 'w':
4266 if (arg[1] == 0)
4267 inhibit_warnings = 1;
4268 else
4269 return 0;
4270 break;
4272 case 'W':
4273 if (arg[1] == 0)
4275 extra_warnings = 1;
4276 /* We save the value of warn_uninitialized, since if they put
4277 -Wuninitialized on the command line, we need to generate a
4278 warning about not using it without also specifying -O. */
4279 if (warn_uninitialized != 1)
4280 warn_uninitialized = 2;
4282 else
4283 return decode_W_option (arg + 1);
4284 break;
4286 case 'a':
4287 if (!strncmp (arg, "aux-info", 8))
4289 if (arg[8] == '\0')
4291 if (argc == 1)
4292 return 0;
4294 aux_info_file_name = argv[1];
4295 flag_gen_aux_info = 1;
4296 return 2;
4298 else if (arg[8] == '=')
4300 aux_info_file_name = arg + 9;
4301 flag_gen_aux_info = 1;
4303 else
4304 return 0;
4306 else
4307 return 0;
4308 break;
4310 case 'o':
4311 if (arg[1] == 0)
4313 if (argc == 1)
4314 return 0;
4316 asm_file_name = argv[1];
4317 return 2;
4319 return 0;
4321 case 'G':
4323 int g_switch_val;
4324 int return_val;
4326 if (arg[1] == 0)
4328 if (argc == 1)
4329 return 0;
4331 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4332 return_val = 2;
4334 else
4336 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4337 return_val = 1;
4340 if (g_switch_val == -1)
4341 return_val = 0;
4342 else
4344 g_switch_set = TRUE;
4345 g_switch_value = g_switch_val;
4348 return return_val;
4352 return 1;
4355 /* Decode -m switches. */
4356 /* Decode the switch -mNAME. */
4358 static void
4359 set_target_switch (name)
4360 const char *name;
4362 size_t j;
4363 int valid_target_option = 0;
4365 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4366 if (!strcmp (target_switches[j].name, name))
4368 if (target_switches[j].value < 0)
4369 target_flags &= ~-target_switches[j].value;
4370 else
4371 target_flags |= target_switches[j].value;
4372 valid_target_option = 1;
4375 #ifdef TARGET_OPTIONS
4376 if (!valid_target_option)
4377 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4379 int len = strlen (target_options[j].prefix);
4380 if (!strncmp (target_options[j].prefix, name, len))
4382 *target_options[j].variable = name + len;
4383 valid_target_option = 1;
4386 #endif
4388 if (!valid_target_option)
4389 error ("invalid option `%s'", name);
4392 /* Print version information to FILE.
4393 Each line begins with INDENT (for the case where FILE is the
4394 assembler output file). */
4396 static void
4397 print_version (file, indent)
4398 FILE *file;
4399 const char *indent;
4401 #ifndef __VERSION__
4402 #define __VERSION__ "[?]"
4403 #endif
4404 fnotice (file,
4405 #ifdef __GNUC__
4406 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4407 #else
4408 "%s%s%s version %s (%s) compiled by CC.\n"
4409 #endif
4410 , indent, *indent != 0 ? " " : "",
4411 lang_hooks.name, version_string, TARGET_NAME,
4412 indent, __VERSION__);
4415 /* Print an option value and return the adjusted position in the line.
4416 ??? We don't handle error returns from fprintf (disk full); presumably
4417 other code will catch a disk full though. */
4419 static int
4420 print_single_switch (file, pos, max, indent, sep, term, type, name)
4421 FILE *file;
4422 int pos, max;
4423 const char *indent, *sep, *term, *type, *name;
4425 /* The ultrix fprintf returns 0 on success, so compute the result we want
4426 here since we need it for the following test. */
4427 int len = strlen (sep) + strlen (type) + strlen (name);
4429 if (pos != 0
4430 && pos + len > max)
4432 fprintf (file, "%s", term);
4433 pos = 0;
4435 if (pos == 0)
4437 fprintf (file, "%s", indent);
4438 pos = strlen (indent);
4440 fprintf (file, "%s%s%s", sep, type, name);
4441 pos += len;
4442 return pos;
4445 /* Print active target switches to FILE.
4446 POS is the current cursor position and MAX is the size of a "line".
4447 Each line begins with INDENT and ends with TERM.
4448 Each switch is separated from the next by SEP. */
4450 static void
4451 print_switch_values (file, pos, max, indent, sep, term)
4452 FILE *file;
4453 int pos, max;
4454 const char *indent, *sep, *term;
4456 size_t j;
4457 char **p;
4459 /* Print the options as passed. */
4461 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4462 _("options passed: "), "");
4464 for (p = &save_argv[1]; *p != NULL; p++)
4465 if (**p == '-')
4467 /* Ignore these. */
4468 if (strcmp (*p, "-o") == 0)
4470 if (p[1] != NULL)
4471 p++;
4472 continue;
4474 if (strcmp (*p, "-quiet") == 0)
4475 continue;
4476 if (strcmp (*p, "-version") == 0)
4477 continue;
4478 if ((*p)[1] == 'd')
4479 continue;
4481 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4483 if (pos > 0)
4484 fprintf (file, "%s", term);
4486 /* Print the -f and -m options that have been enabled.
4487 We don't handle language specific options but printing argv
4488 should suffice. */
4490 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4491 _("options enabled: "), "");
4493 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4494 if (*f_options[j].variable == f_options[j].on_value)
4495 pos = print_single_switch (file, pos, max, indent, sep, term,
4496 "-f", f_options[j].string);
4498 /* Print target specific options. */
4500 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4501 if (target_switches[j].name[0] != '\0'
4502 && target_switches[j].value > 0
4503 && ((target_switches[j].value & target_flags)
4504 == target_switches[j].value))
4506 pos = print_single_switch (file, pos, max, indent, sep, term,
4507 "-m", target_switches[j].name);
4510 #ifdef TARGET_OPTIONS
4511 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4512 if (*target_options[j].variable != NULL)
4514 char prefix[256];
4515 sprintf (prefix, "-m%s", target_options[j].prefix);
4516 pos = print_single_switch (file, pos, max, indent, sep, term,
4517 prefix, *target_options[j].variable);
4519 #endif
4521 fprintf (file, "%s", term);
4524 /* Open assembly code output file. Do this even if -fsyntax-only is
4525 on, because then the driver will have provided the name of a
4526 temporary file or bit bucket for us. NAME is the file specified on
4527 the command line, possibly NULL. */
4528 static void
4529 init_asm_output (name)
4530 const char *name;
4532 if (name == NULL && asm_file_name == 0)
4533 asm_out_file = stdout;
4534 else
4536 if (asm_file_name == 0)
4538 int len = strlen (dump_base_name);
4539 char *dumpname = (char *) xmalloc (len + 6);
4540 memcpy (dumpname, dump_base_name, len + 1);
4541 strip_off_ending (dumpname, len);
4542 strcat (dumpname, ".s");
4543 asm_file_name = dumpname;
4545 if (!strcmp (asm_file_name, "-"))
4546 asm_out_file = stdout;
4547 else
4548 asm_out_file = fopen (asm_file_name, "w");
4549 if (asm_out_file == 0)
4550 fatal_io_error ("can't open %s for writing", asm_file_name);
4553 #ifdef IO_BUFFER_SIZE
4554 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4555 _IOFBF, IO_BUFFER_SIZE);
4556 #endif
4558 if (!flag_syntax_only)
4560 #ifdef ASM_FILE_START
4561 ASM_FILE_START (asm_out_file);
4562 #endif
4564 #ifdef ASM_COMMENT_START
4565 if (flag_verbose_asm)
4567 /* Print the list of options in effect. */
4568 print_version (asm_out_file, ASM_COMMENT_START);
4569 print_switch_values (asm_out_file, 0, MAX_LINE,
4570 ASM_COMMENT_START, " ", "\n");
4571 /* Add a blank line here so it appears in assembler output but not
4572 screen output. */
4573 fprintf (asm_out_file, "\n");
4575 #endif
4579 /* Initialization of the front end environment, before command line
4580 options are parsed. Signal handlers, internationalization etc.
4581 ARGV0 is main's argv[0]. */
4582 static void
4583 general_init (argv0)
4584 char *argv0;
4586 char *p;
4588 p = argv0 + strlen (argv0);
4589 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4590 --p;
4591 progname = p;
4593 xmalloc_set_program_name (progname);
4595 gcc_init_libintl ();
4597 /* Install handler for SIGFPE, which may be received while we do
4598 compile-time floating point arithmetic. */
4599 signal (SIGFPE, float_signal);
4601 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4602 #ifdef SIGSEGV
4603 signal (SIGSEGV, crash_signal);
4604 #endif
4605 #ifdef SIGILL
4606 signal (SIGILL, crash_signal);
4607 #endif
4608 #ifdef SIGBUS
4609 signal (SIGBUS, crash_signal);
4610 #endif
4611 #ifdef SIGABRT
4612 signal (SIGABRT, crash_signal);
4613 #endif
4614 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4615 signal (SIGIOT, crash_signal);
4616 #endif
4618 /* Initialize the diagnostics reporting machinery, so option parsing
4619 can give warnings and errors. */
4620 diagnostic_initialize (global_dc);
4623 /* Parse command line options and set default flag values, called
4624 after language-independent option-independent initialization. Do
4625 minimal options processing. Outputting diagnostics is OK, but GC
4626 and identifier hashtables etc. are not initialized yet. */
4627 static void
4628 parse_options_and_default_flags (argc, argv)
4629 int argc;
4630 char **argv;
4632 int i;
4634 /* Save in case md file wants to emit args as a comment. */
4635 save_argc = argc;
4636 save_argv = argv;
4638 /* Initialize register usage now so switches may override. */
4639 init_reg_sets ();
4641 /* Register the language-independent parameters. */
4642 add_params (lang_independent_params, LAST_PARAM);
4644 /* Perform language-specific options initialization. */
4645 (*lang_hooks.init_options) ();
4647 /* Scan to see what optimization level has been specified. That will
4648 determine the default value of many flags. */
4649 for (i = 1; i < argc; i++)
4651 if (!strcmp (argv[i], "-O"))
4653 optimize = 1;
4654 optimize_size = 0;
4656 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4658 /* Handle -Os, -O2, -O3, -O69, ... */
4659 char *p = &argv[i][2];
4661 if ((p[0] == 's') && (p[1] == 0))
4663 optimize_size = 1;
4665 /* Optimizing for size forces optimize to be 2. */
4666 optimize = 2;
4668 else
4670 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4671 if (optimize_val != -1)
4673 optimize = optimize_val;
4674 optimize_size = 0;
4680 if (!optimize)
4682 flag_merge_constants = 0;
4685 if (optimize >= 1)
4687 flag_defer_pop = 1;
4688 flag_thread_jumps = 1;
4689 #ifdef DELAY_SLOTS
4690 flag_delayed_branch = 1;
4691 #endif
4692 #ifdef CAN_DEBUG_WITHOUT_FP
4693 flag_omit_frame_pointer = 1;
4694 #endif
4695 flag_guess_branch_prob = 1;
4696 flag_cprop_registers = 1;
4699 if (optimize >= 2)
4701 flag_optimize_sibling_calls = 1;
4702 flag_cse_follow_jumps = 1;
4703 flag_cse_skip_blocks = 1;
4704 flag_gcse = 1;
4705 flag_expensive_optimizations = 1;
4706 flag_strength_reduce = 1;
4707 flag_rerun_cse_after_loop = 1;
4708 flag_rerun_loop_opt = 1;
4709 flag_caller_saves = 1;
4710 flag_force_mem = 1;
4711 flag_peephole2 = 1;
4712 #ifdef INSN_SCHEDULING
4713 flag_schedule_insns = 1;
4714 flag_schedule_insns_after_reload = 1;
4715 #endif
4716 flag_regmove = 1;
4717 flag_strict_aliasing = 1;
4718 flag_delete_null_pointer_checks = 1;
4719 flag_reorder_blocks = 1;
4722 if (optimize >= 3)
4724 flag_inline_functions = 1;
4725 flag_rename_registers = 1;
4728 if (optimize < 2 || optimize_size)
4730 align_loops = 1;
4731 align_jumps = 1;
4732 align_labels = 1;
4733 align_functions = 1;
4736 /* Initialize whether `char' is signed. */
4737 flag_signed_char = DEFAULT_SIGNED_CHAR;
4738 #ifdef DEFAULT_SHORT_ENUMS
4739 /* Initialize how much space enums occupy, by default. */
4740 flag_short_enums = DEFAULT_SHORT_ENUMS;
4741 #endif
4743 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4744 modify it. */
4745 target_flags = 0;
4746 set_target_switch ("");
4748 /* Unwind tables are always present in an ABI-conformant IA-64
4749 object file, so the default should be ON. */
4750 #ifdef IA64_UNWIND_INFO
4751 flag_unwind_tables = IA64_UNWIND_INFO;
4752 #endif
4754 #ifdef OPTIMIZATION_OPTIONS
4755 /* Allow default optimizations to be specified on a per-machine basis. */
4756 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4757 #endif
4759 /* Perform normal command line switch decoding. */
4760 for (i = 1; i < argc;)
4762 int lang_processed;
4763 int indep_processed;
4765 /* Give the language a chance to decode the option for itself. */
4766 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4768 if (lang_processed >= 0)
4769 /* Now see if the option also has a language independent meaning.
4770 Some options are both language specific and language independent,
4771 eg --help. */
4772 indep_processed = independent_decode_option (argc - i, argv + i);
4773 else
4775 lang_processed = -lang_processed;
4776 indep_processed = 0;
4779 if (lang_processed || indep_processed)
4780 i += MAX (lang_processed, indep_processed);
4781 else
4783 const char *option = NULL;
4784 const char *lang = NULL;
4785 unsigned int j;
4787 /* It is possible that the command line switch is not valid for the
4788 current language, but it is valid for another language. In order
4789 to be compatible with previous versions of the compiler (which
4790 did not issue an error message in this case) we check for this
4791 possibility here. If we do find a match, then if extra_warnings
4792 is set we generate a warning message, otherwise we will just
4793 ignore the option. */
4794 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4796 option = documented_lang_options[j].option;
4798 if (option == NULL)
4799 lang = documented_lang_options[j].description;
4800 else if (! strncmp (argv[i], option, strlen (option)))
4801 break;
4804 if (j != ARRAY_SIZE (documented_lang_options))
4806 if (extra_warnings)
4808 warning ("ignoring command line option '%s'", argv[i]);
4809 if (lang)
4810 warning
4811 ("(it is valid for %s but not the selected language)",
4812 lang);
4815 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4816 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4817 else
4818 error ("unrecognized option `%s'", argv[i]);
4820 i++;
4824 if (flag_no_inline == 2)
4825 flag_no_inline = 0;
4826 else
4827 flag_really_no_inline = flag_no_inline;
4829 /* Set flag_no_inline before the post_options () hook. The C front
4830 ends use it to determine tree inlining defaults. FIXME: such
4831 code should be lang-independent when all front ends use tree
4832 inlining, in which case it, and this condition, should be moved
4833 to the top of process_options() instead. */
4834 if (optimize == 0)
4836 /* Inlining does not work if not optimizing,
4837 so force it not to be done. */
4838 flag_no_inline = 1;
4839 warn_inline = 0;
4841 /* The c_decode_option function and decode_option hook set
4842 this to `2' if -Wall is used, so we can avoid giving out
4843 lots of errors for people who don't realize what -Wall does. */
4844 if (warn_uninitialized == 1)
4845 warning ("-Wuninitialized is not supported without -O");
4848 if (flag_really_no_inline == 2)
4849 flag_really_no_inline = flag_no_inline;
4851 /* All command line options have been parsed; allow the front end to
4852 perform consistency checks, etc. */
4853 (*lang_hooks.post_options) ();
4856 /* Process the options that have been parsed. */
4857 static void
4858 process_options ()
4860 #ifdef OVERRIDE_OPTIONS
4861 /* Some machines may reject certain combinations of options. */
4862 OVERRIDE_OPTIONS;
4863 #endif
4865 /* Set up the align_*_log variables, defaulting them to 1 if they
4866 were still unset. */
4867 if (align_loops <= 0) align_loops = 1;
4868 if (align_loops_max_skip > align_loops || !align_loops)
4869 align_loops_max_skip = align_loops - 1;
4870 align_loops_log = floor_log2 (align_loops * 2 - 1);
4871 if (align_jumps <= 0) align_jumps = 1;
4872 if (align_jumps_max_skip > align_jumps || !align_jumps)
4873 align_jumps_max_skip = align_jumps - 1;
4874 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4875 if (align_labels <= 0) align_labels = 1;
4876 align_labels_log = floor_log2 (align_labels * 2 - 1);
4877 if (align_labels_max_skip > align_labels || !align_labels)
4878 align_labels_max_skip = align_labels - 1;
4879 if (align_functions <= 0) align_functions = 1;
4880 align_functions_log = floor_log2 (align_functions * 2 - 1);
4882 /* Unrolling all loops implies that standard loop unrolling must also
4883 be done. */
4884 if (flag_unroll_all_loops)
4885 flag_unroll_loops = 1;
4886 /* Loop unrolling requires that strength_reduction be on also. Silently
4887 turn on strength reduction here if it isn't already on. Also, the loop
4888 unrolling code assumes that cse will be run after loop, so that must
4889 be turned on also. */
4890 if (flag_unroll_loops)
4892 flag_strength_reduce = 1;
4893 flag_rerun_cse_after_loop = 1;
4896 if (flag_non_call_exceptions)
4897 flag_asynchronous_unwind_tables = 1;
4898 if (flag_asynchronous_unwind_tables)
4899 flag_unwind_tables = 1;
4901 /* Warn about options that are not supported on this machine. */
4902 #ifndef INSN_SCHEDULING
4903 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4904 warning ("instruction scheduling not supported on this target machine");
4905 #endif
4906 #ifndef DELAY_SLOTS
4907 if (flag_delayed_branch)
4908 warning ("this target machine does not have delayed branches");
4909 #endif
4911 /* Some operating systems do not allow profiling without a frame
4912 pointer. */
4913 if (!TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER
4914 && profile_flag
4915 && flag_omit_frame_pointer)
4917 error ("profiling does not work without a frame pointer");
4918 flag_omit_frame_pointer = 0;
4921 user_label_prefix = USER_LABEL_PREFIX;
4922 if (flag_leading_underscore != -1)
4924 /* If the default prefix is more complicated than "" or "_",
4925 issue a warning and ignore this option. */
4926 if (user_label_prefix[0] == 0 ||
4927 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4929 user_label_prefix = flag_leading_underscore ? "_" : "";
4931 else
4932 warning ("-f%sleading-underscore not supported on this target machine",
4933 flag_leading_underscore ? "" : "no-");
4936 /* If we are in verbose mode, write out the version and maybe all the
4937 option flags in use. */
4938 if (version_flag)
4940 print_version (stderr, "");
4941 if (! quiet_flag)
4942 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4945 if (! quiet_flag)
4946 time_report = 1;
4948 if (flag_syntax_only)
4950 write_symbols = NO_DEBUG;
4951 profile_flag = 0;
4954 /* Now we know write_symbols, set up the debug hooks based on it.
4955 By default we do nothing for debug output. */
4956 #if defined(DBX_DEBUGGING_INFO)
4957 if (write_symbols == DBX_DEBUG)
4958 debug_hooks = &dbx_debug_hooks;
4959 #endif
4960 #if defined(XCOFF_DEBUGGING_INFO)
4961 if (write_symbols == XCOFF_DEBUG)
4962 debug_hooks = &xcoff_debug_hooks;
4963 #endif
4964 #ifdef SDB_DEBUGGING_INFO
4965 if (write_symbols == SDB_DEBUG)
4966 debug_hooks = &sdb_debug_hooks;
4967 #endif
4968 #ifdef DWARF_DEBUGGING_INFO
4969 if (write_symbols == DWARF_DEBUG)
4970 debug_hooks = &dwarf_debug_hooks;
4971 #endif
4972 #ifdef DWARF2_DEBUGGING_INFO
4973 if (write_symbols == DWARF2_DEBUG)
4974 debug_hooks = &dwarf2_debug_hooks;
4975 #endif
4976 #ifdef VMS_DEBUGGING_INFO
4977 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4978 debug_hooks = &vmsdbg_debug_hooks;
4979 #endif
4981 /* If auxiliary info generation is desired, open the output file.
4982 This goes in the same directory as the source file--unlike
4983 all the other output files. */
4984 if (flag_gen_aux_info)
4986 aux_info_file = fopen (aux_info_file_name, "w");
4987 if (aux_info_file == 0)
4988 fatal_io_error ("can't open %s", aux_info_file_name);
4991 if (! targetm.have_named_sections)
4993 if (flag_function_sections)
4995 warning ("-ffunction-sections not supported for this target");
4996 flag_function_sections = 0;
4998 if (flag_data_sections)
5000 warning ("-fdata-sections not supported for this target");
5001 flag_data_sections = 0;
5005 if (flag_function_sections && profile_flag)
5007 warning ("-ffunction-sections disabled; it makes profiling impossible");
5008 flag_function_sections = 0;
5011 #ifndef HAVE_prefetch
5012 if (flag_prefetch_loop_arrays)
5014 warning ("-fprefetch-loop-arrays not supported for this target");
5015 flag_prefetch_loop_arrays = 0;
5017 #else
5018 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
5020 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
5021 flag_prefetch_loop_arrays = 0;
5023 #endif
5025 /* This combination of options isn't handled for i386 targets and doesn't
5026 make much sense anyway, so don't allow it. */
5027 if (flag_prefetch_loop_arrays && optimize_size)
5029 warning ("-fprefetch-loop-arrays is not supported with -Os");
5030 flag_prefetch_loop_arrays = 0;
5033 #ifndef OBJECT_FORMAT_ELF
5034 if (flag_function_sections && write_symbols != NO_DEBUG)
5035 warning ("-ffunction-sections may affect debugging on some targets");
5036 #endif
5039 /* Language-independent initialization, before language-dependent
5040 initialization. */
5041 static void
5042 lang_independent_init ()
5044 decl_printable_name = decl_name;
5045 lang_expand_expr = (lang_expand_expr_t) do_abort;
5047 /* Set the language-dependent identifier size. */
5048 tree_code_length[(int) IDENTIFIER_NODE]
5049 = ((lang_hooks.identifier_size - sizeof (struct tree_common)
5050 + sizeof (tree) - 1) / sizeof (tree));
5052 /* Initialize the garbage-collector, and string pools. */
5053 init_ggc ();
5054 ggc_add_rtx_root (&stack_limit_rtx, 1);
5055 ggc_add_tree_root (&current_function_decl, 1);
5056 ggc_add_tree_root (&current_function_func_begin_label, 1);
5058 init_stringpool ();
5059 init_obstacks ();
5061 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5062 || debug_info_level == DINFO_LEVEL_VERBOSE
5063 #ifdef VMS_DEBUGGING_INFO
5064 /* Enable line number info for traceback */
5065 || debug_info_level > DINFO_LEVEL_NONE
5066 #endif
5067 || flag_test_coverage
5068 || warn_notreached);
5069 init_regs ();
5070 init_alias_once ();
5071 init_stmt ();
5072 init_loop ();
5073 init_reload ();
5074 init_function_once ();
5075 init_stor_layout_once ();
5076 init_varasm_once ();
5077 init_EXPR_INSN_LIST_cache ();
5079 /* The following initialization functions need to generate rtl, so
5080 provide a dummy function context for them. */
5081 init_dummy_function_start ();
5082 init_expmed ();
5083 init_expr_once ();
5084 if (flag_caller_saves)
5085 init_caller_save ();
5086 expand_dummy_function_end ();
5089 /* Language-dependent initialization. Returns non-zero on success. */
5090 static int
5091 lang_dependent_init (name)
5092 const char *name;
5094 if (dump_base_name == 0)
5095 dump_base_name = name ? name : "gccdump";
5097 /* Front-end initialization. This hook can assume that GC,
5098 identifier hashes etc. are set up, but debug initialization is
5099 not done yet. This routine must return the original filename
5100 (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
5101 name = (*lang_hooks.init) (name);
5102 if (name == NULL)
5103 return 0;
5105 /* Is this duplication necessary? */
5106 name = ggc_strdup (name);
5107 main_input_filename = input_filename = name;
5108 init_asm_output (name);
5110 /* These create various _DECL nodes, so need to be called after the
5111 front end is initialized. */
5112 init_eh ();
5113 init_optabs ();
5115 /* Put an entry on the input file stack for the main input file. */
5116 push_srcloc (input_filename, 0);
5118 /* If dbx symbol table desired, initialize writing it and output the
5119 predefined types. */
5120 timevar_push (TV_SYMOUT);
5122 #ifdef DWARF2_UNWIND_INFO
5123 if (dwarf2out_do_frame ())
5124 dwarf2out_frame_init ();
5125 #endif
5127 /* Now we have the correct original filename, we can initialize
5128 debug output. */
5129 (*debug_hooks->init) (name);
5131 timevar_pop (TV_SYMOUT);
5133 return 1;
5136 /* Clean up: close opened files, etc. */
5138 static void
5139 finalize ()
5141 /* Close the dump files. */
5142 if (flag_gen_aux_info)
5144 fclose (aux_info_file);
5145 if (errorcount)
5146 unlink (aux_info_file_name);
5149 /* Close non-debugging input and output files. Take special care to note
5150 whether fclose returns an error, since the pages might still be on the
5151 buffer chain while the file is open. */
5153 if (asm_out_file)
5155 if (ferror (asm_out_file) != 0)
5156 fatal_io_error ("error writing to %s", asm_file_name);
5157 if (fclose (asm_out_file) != 0)
5158 fatal_io_error ("error closing %s", asm_file_name);
5161 /* Do whatever is necessary to finish printing the graphs. */
5162 if (graph_dump_format != no_graph)
5164 int i;
5166 for (i = 0; i < (int) DFI_MAX; ++i)
5167 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5169 char seq[16];
5170 char *suffix;
5172 sprintf (seq, DUMPFILE_FORMAT, i);
5173 suffix = concat (seq, dump_file[i].extension, NULL);
5174 finish_graph_dump_file (dump_base_name, suffix);
5175 free (suffix);
5179 if (mem_report)
5181 ggc_print_statistics ();
5182 stringpool_statistics ();
5183 dump_tree_statistics ();
5186 /* Free up memory for the benefit of leak detectors. */
5187 free_reg_info ();
5189 /* Language-specific end of compilation actions. */
5190 (*lang_hooks.finish) ();
5193 /* Initialize the compiler, and compile the input file. */
5194 static void
5195 do_compile ()
5197 /* The bulk of command line switch processing. */
5198 process_options ();
5200 /* We cannot start timing until after options are processed since that
5201 says if we run timers or not. */
5202 init_timevar ();
5203 timevar_start (TV_TOTAL);
5205 /* Language-independent initialization. Also sets up GC, identifier
5206 hashes etc. */
5207 lang_independent_init ();
5209 /* Language-dependent initialization. Returns true on success. */
5210 if (lang_dependent_init (filename))
5211 compile_file ();
5213 finalize ();
5215 /* Stop timing and print the times. */
5216 timevar_stop (TV_TOTAL);
5217 timevar_print (stderr);
5220 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5221 Decode command args, then call compile_file.
5222 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5223 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5225 It is not safe to call this function more than once. */
5228 toplev_main (argc, argv)
5229 int argc;
5230 char **argv;
5232 hex_init ();
5234 /* Initialization of GCC's environment, and diagnostics. */
5235 general_init (argv [0]);
5237 /* Parse the options and do minimal processing; basically just
5238 enough to default flags appropriately. */
5239 parse_options_and_default_flags (argc, argv);
5241 /* Exit early if we can (e.g. -help). */
5242 if (!errorcount && !exit_after_options)
5243 do_compile ();
5245 if (errorcount || sorrycount)
5246 return (FATAL_EXIT_CODE);
5248 return (SUCCESS_EXIT_CODE);