* acinclude.m4: Check for native targets that can't link at
[official-gcc.git] / gcc / toplev.c
bloba4cd1df45887cd214d4e77cbff34751318d01558
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, 2003 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 "coretypes.h"
32 #include "tm.h"
33 #include <signal.h>
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
37 #endif
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
41 #endif
43 #include "input.h"
44 #include "tree.h"
45 #include "rtl.h"
46 #include "tm_p.h"
47 #include "flags.h"
48 #include "insn-attr.h"
49 #include "insn-config.h"
50 #include "insn-flags.h"
51 #include "hard-reg-set.h"
52 #include "recog.h"
53 #include "output.h"
54 #include "except.h"
55 #include "function.h"
56 #include "toplev.h"
57 #include "expr.h"
58 #include "basic-block.h"
59 #include "intl.h"
60 #include "ggc.h"
61 #include "graph.h"
62 #include "loop.h"
63 #include "regs.h"
64 #include "timevar.h"
65 #include "diagnostic.h"
66 #include "ssa.h"
67 #include "params.h"
68 #include "reload.h"
69 #include "dwarf2asm.h"
70 #include "integrate.h"
71 #include "real.h"
72 #include "debug.h"
73 #include "target.h"
74 #include "langhooks.h"
75 #include "cfglayout.h"
76 #include "cfgloop.h"
77 #include "hosthooks.h"
79 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
80 #include "dwarf2out.h"
81 #endif
83 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
84 #include "dbxout.h"
85 #endif
87 #ifdef SDB_DEBUGGING_INFO
88 #include "sdbout.h"
89 #endif
91 #ifdef XCOFF_DEBUGGING_INFO
92 #include "xcoffout.h" /* Needed for external data
93 declarations for e.g. AIX 4.x. */
94 #endif
96 /* Carry information from ASM_DECLARE_OBJECT_NAME
97 to ASM_FINISH_DECLARE_OBJECT. */
99 extern int size_directive_output;
100 extern tree last_assemble_variable_decl;
102 extern void reg_alloc PARAMS ((void));
104 static void general_init PARAMS ((char *));
105 static void parse_options_and_default_flags PARAMS ((int, char **));
106 static void do_compile PARAMS ((void));
107 static void process_options PARAMS ((void));
108 static void backend_init PARAMS ((void));
109 static int lang_dependent_init PARAMS ((const char *));
110 static void init_asm_output PARAMS ((const char *));
111 static void finalize PARAMS ((void));
113 static void set_target_switch PARAMS ((const char *));
115 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
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 /* Nonzero to dump debug info whilst parsing (-dy option). */
134 static int set_yydebug;
136 /* Length of line when printing switch values. */
137 #define MAX_LINE 75
139 /* Name of program invoked, sans directories. */
141 const char *progname;
143 /* Copy of arguments to toplev_main. */
144 int save_argc;
145 char **save_argv;
147 /* Name of current original source file (what was input to cpp).
148 This comes from each #-command in the actual input. */
150 const char *input_filename;
152 /* Name of top-level original source file (what was input to cpp).
153 This comes from the #-command at the beginning of the actual input.
154 If there isn't any there, then this is the cc1 input file name. */
156 const char *main_input_filename;
158 /* Current line number in real source file. */
160 int lineno;
162 /* Nonzero if it is unsafe to create any new pseudo registers. */
163 int no_new_pseudos;
165 /* Stack of currently pending input files. */
167 struct file_stack *input_file_stack;
169 /* Incremented on each change to input_file_stack. */
170 int input_file_stack_tick;
172 /* Name to use as base of names for dump output files. */
174 const char *dump_base_name;
176 /* Name to use as a base for auxiliary output files. */
178 const char *aux_base_name;
180 /* Format to use to print dumpfile index value */
181 #ifndef DUMPFILE_FORMAT
182 #define DUMPFILE_FORMAT ".%02d."
183 #endif
185 /* Bit flags that specify the machine subtype we are compiling for.
186 Bits are tested using macros TARGET_... defined in the tm.h file
187 and set by `-m...' switches. Must be defined in rtlanal.c. */
189 extern int target_flags;
191 /* A mask of target_flags that includes bit X if X was set or cleared
192 on the command line. */
194 int target_flags_explicit;
196 /* Debug hooks - dependent upon command line options. */
198 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
200 /* Describes a dump file. */
202 struct dump_file_info
204 /* The unique extension to apply, e.g. ".jump". */
205 const char *const extension;
207 /* The -d<c> character that enables this dump file. */
208 char const debug_switch;
210 /* True if there is a corresponding graph dump file. */
211 char const graph_dump_p;
213 /* True if the user selected this dump. */
214 char enabled;
216 /* True if the files have been initialized (ie truncated). */
217 char initialized;
220 /* Enumerate the extant dump files. */
222 enum dump_file_index
224 DFI_rtl,
225 DFI_sibling,
226 DFI_eh,
227 DFI_jump,
228 DFI_ssa,
229 DFI_ssa_ccp,
230 DFI_ssa_dce,
231 DFI_ussa,
232 DFI_null,
233 DFI_cse,
234 DFI_addressof,
235 DFI_gcse,
236 DFI_loop,
237 DFI_bypass,
238 DFI_cfg,
239 DFI_bp,
240 DFI_ce1,
241 DFI_tracer,
242 DFI_loop2,
243 DFI_cse2,
244 DFI_life,
245 DFI_combine,
246 DFI_ce2,
247 DFI_regmove,
248 DFI_sched,
249 DFI_lreg,
250 DFI_greg,
251 DFI_postreload,
252 DFI_flow2,
253 DFI_peephole2,
254 DFI_rnreg,
255 DFI_ce3,
256 DFI_sched2,
257 DFI_stack,
258 DFI_bbro,
259 DFI_mach,
260 DFI_dbr,
261 DFI_MAX
264 /* Describes all the dump files. Should be kept in order of the
265 pass and in sync with dump_file_index above.
267 Remaining -d letters:
269 " o q "
270 " H JK OPQ TUV YZ"
273 static struct dump_file_info dump_file[DFI_MAX] =
275 { "rtl", 'r', 0, 0, 0 },
276 { "sibling", 'i', 0, 0, 0 },
277 { "eh", 'h', 0, 0, 0 },
278 { "jump", 'j', 0, 0, 0 },
279 { "ssa", 'e', 1, 0, 0 },
280 { "ssaccp", 'W', 1, 0, 0 },
281 { "ssadce", 'X', 1, 0, 0 },
282 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
283 { "null", 'u', 0, 0, 0 },
284 { "cse", 's', 0, 0, 0 },
285 { "addressof", 'F', 0, 0, 0 },
286 { "gcse", 'G', 1, 0, 0 },
287 { "loop", 'L', 1, 0, 0 },
288 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
289 { "cfg", 'f', 1, 0, 0 },
290 { "bp", 'b', 1, 0, 0 },
291 { "ce1", 'C', 1, 0, 0 },
292 { "tracer", 'T', 1, 0, 0 },
293 { "loop2", 'L', 1, 0, 0 },
294 { "cse2", 't', 1, 0, 0 },
295 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
296 { "combine", 'c', 1, 0, 0 },
297 { "ce2", 'C', 1, 0, 0 },
298 { "regmove", 'N', 1, 0, 0 },
299 { "sched", 'S', 1, 0, 0 },
300 { "lreg", 'l', 1, 0, 0 },
301 { "greg", 'g', 1, 0, 0 },
302 { "postreload", 'o', 1, 0, 0 },
303 { "flow2", 'w', 1, 0, 0 },
304 { "peephole2", 'z', 1, 0, 0 },
305 { "rnreg", 'n', 1, 0, 0 },
306 { "ce3", 'E', 1, 0, 0 },
307 { "sched2", 'R', 1, 0, 0 },
308 { "stack", 'k', 1, 0, 0 },
309 { "bbro", 'B', 1, 0, 0 },
310 { "mach", 'M', 1, 0, 0 },
311 { "dbr", 'd', 0, 0, 0 },
314 static int open_dump_file PARAMS ((enum dump_file_index, tree));
315 static void close_dump_file PARAMS ((enum dump_file_index,
316 void (*) (FILE *, rtx), rtx));
318 /* Other flags saying which kinds of debugging dump have been requested. */
320 int rtl_dump_and_exit;
321 int flag_print_asm_name;
322 static int version_flag;
323 static char *filename;
324 enum graph_dump_types graph_dump_format;
326 /* Name for output file of assembly code, specified with -o. */
328 char *asm_file_name;
330 /* Value of the -G xx switch, and whether it was passed or not. */
331 int g_switch_value;
332 int g_switch_set;
334 /* Type(s) of debugging information we are producing (if any).
335 See flags.h for the definitions of the different possible
336 types of debugging information. */
337 enum debug_info_type write_symbols = NO_DEBUG;
339 /* Level of debugging information we are producing. See flags.h
340 for the definitions of the different possible levels. */
341 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
343 /* Nonzero means use GNU-only extensions in the generated symbolic
344 debugging information. */
345 /* Currently, this only has an effect when write_symbols is set to
346 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
347 int use_gnu_debug_info_extensions = 0;
349 /* Nonzero means do optimizations. -O.
350 Particular numeric values stand for particular amounts of optimization;
351 thus, -O2 stores 2 here. However, the optimizations beyond the basic
352 ones are not controlled directly by this variable. Instead, they are
353 controlled by individual `flag_...' variables that are defaulted
354 based on this variable. */
356 int optimize = 0;
358 /* Nonzero means optimize for size. -Os.
359 The only valid values are zero and nonzero. When optimize_size is
360 nonzero, optimize defaults to 2, but certain individual code
361 bloating optimizations are disabled. */
363 int optimize_size = 0;
365 /* Nonzero if we should exit after parsing options. */
366 static int exit_after_options = 0;
368 /* The FUNCTION_DECL for the function currently being compiled,
369 or 0 if between functions. */
370 tree current_function_decl;
372 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
373 if none. */
374 tree current_function_func_begin_label;
376 /* Nonzero if doing dwarf2 duplicate elimination. */
378 int flag_eliminate_dwarf2_dups = 0;
380 /* Nonzero if generating code to do profiling. */
382 int profile_flag = 0;
384 /* Nonzero if generating code to profile program flow graph arcs. */
386 int profile_arc_flag = 0;
388 /* Nonzero if generating info for gcov to calculate line test coverage. */
390 int flag_test_coverage = 0;
392 /* Nonzero indicates that branch taken probabilities should be calculated. */
394 int flag_branch_probabilities = 0;
396 /* Nonzero if basic blocks should be reordered. */
398 int flag_reorder_blocks = 0;
400 /* Nonzero if functions should be reordered. */
402 int flag_reorder_functions = 0;
404 /* Nonzero if registers should be renamed. */
406 int flag_rename_registers = 0;
407 int flag_cprop_registers = 0;
409 /* Nonzero for -pedantic switch: warn about anything
410 that standard spec forbids. */
412 int pedantic = 0;
414 /* Temporarily suppress certain warnings.
415 This is set while reading code from a system header file. */
417 int in_system_header = 0;
419 /* Don't print functions as they are compiled. -quiet. */
421 int quiet_flag = 0;
423 /* Print times taken by the various passes. -ftime-report. */
425 int time_report = 0;
427 /* Print memory still in use at end of compilation (which may have little
428 to do with peak memory consumption). -fmem-report. */
430 int mem_report = 0;
432 /* Nonzero means to collect statistics which might be expensive
433 and to print them when we are done. */
434 int flag_detailed_statistics = 0;
437 /* -f flags. */
439 /* Nonzero means `char' should be signed. */
441 int flag_signed_char;
443 /* Nonzero means give an enum type only as many bytes as it needs. */
445 int flag_short_enums;
447 /* Nonzero for -fcaller-saves: allocate values in regs that need to
448 be saved across function calls, if that produces overall better code.
449 Optional now, so people can test it. */
451 #ifdef DEFAULT_CALLER_SAVES
452 int flag_caller_saves = 1;
453 #else
454 int flag_caller_saves = 0;
455 #endif
457 /* Nonzero if structures and unions should be returned in memory.
459 This should only be defined if compatibility with another compiler or
460 with an ABI is needed, because it results in slower code. */
462 #ifndef DEFAULT_PCC_STRUCT_RETURN
463 #define DEFAULT_PCC_STRUCT_RETURN 1
464 #endif
466 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
468 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
470 /* Nonzero for -fforce-mem: load memory value into a register
471 before arithmetic on it. This makes better cse but slower compilation. */
473 int flag_force_mem = 0;
475 /* Nonzero for -fforce-addr: load memory address into a register before
476 reference to memory. This makes better cse but slower compilation. */
478 int flag_force_addr = 0;
480 /* Nonzero for -fdefer-pop: don't pop args after each function call;
481 instead save them up to pop many calls' args with one insns. */
483 int flag_defer_pop = 0;
485 /* Nonzero for -ffloat-store: don't allocate floats and doubles
486 in extended-precision registers. */
488 int flag_float_store = 0;
490 /* Nonzero for -fcse-follow-jumps:
491 have cse follow jumps to do a more extensive job. */
493 int flag_cse_follow_jumps;
495 /* Nonzero for -fcse-skip-blocks:
496 have cse follow a branch around a block. */
497 int flag_cse_skip_blocks;
499 /* Nonzero for -fexpensive-optimizations:
500 perform miscellaneous relatively-expensive optimizations. */
501 int flag_expensive_optimizations;
503 /* Nonzero for -fthread-jumps:
504 have jump optimize output of loop. */
506 int flag_thread_jumps;
508 /* Nonzero enables strength-reduction in loop.c. */
510 int flag_strength_reduce = 0;
512 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
513 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
514 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
515 unrolled. */
517 int flag_unroll_loops;
519 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
520 This is generally not a win. */
522 int flag_unroll_all_loops;
524 /* Nonzero enables loop unswitching. */
525 int flag_unswitch_loops;
527 /* Nonzero enables prefetch optimizations for arrays in loops. */
529 int flag_prefetch_loop_arrays;
531 /* Nonzero forces all invariant computations in loops to be moved
532 outside the loop. */
534 int flag_move_all_movables = 0;
536 /* Nonzero forces all general induction variables in loops to be
537 strength reduced. */
539 int flag_reduce_all_givs = 0;
541 /* Nonzero to perform full register move optimization passes. This is the
542 default for -O2. */
544 int flag_regmove = 0;
546 /* Nonzero for -fwritable-strings:
547 store string constants in data segment and don't uniquize them. */
549 int flag_writable_strings = 0;
551 /* Nonzero means don't put addresses of constant functions in registers.
552 Used for compiling the Unix kernel, where strange substitutions are
553 done on the assembly output. */
555 int flag_no_function_cse = 0;
557 /* Nonzero for -fomit-frame-pointer:
558 don't make a frame pointer in simple functions that don't require one. */
560 int flag_omit_frame_pointer = 0;
562 /* Nonzero means place each function into its own section on those platforms
563 which support arbitrary section names and unlimited numbers of sections. */
565 int flag_function_sections = 0;
567 /* ... and similar for data. */
569 int flag_data_sections = 0;
571 /* Nonzero to inhibit use of define_optimization peephole opts. */
573 int flag_no_peephole = 0;
575 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
577 int flag_optimize_sibling_calls = 0;
579 /* Nonzero means the front end generally wants `errno' maintained by math
580 operations, like built-in SQRT. */
582 int flag_errno_math = 1;
584 /* Nonzero means that unsafe floating-point math optimizations are allowed
585 for the sake of speed. IEEE compliance is not guaranteed, and operations
586 are allowed to assume that their arguments and results are "normal"
587 (e.g., nonnegative for SQRT). */
589 int flag_unsafe_math_optimizations = 0;
591 /* Nonzero means that no NaNs or +-Infs are expected. */
593 int flag_finite_math_only = 0;
595 /* Zero means that floating-point math operations cannot generate a
596 (user-visible) trap. This is the case, for example, in nonstop
597 IEEE 754 arithmetic. Trapping conditions include division by zero,
598 overflow, underflow, invalid and inexact, but does not include
599 operations on signaling NaNs (see below). */
601 int flag_trapping_math = 1;
603 /* Nonzero means disable transformations observable by signaling NaNs.
604 This option implies that any operation on a IEEE signaling NaN can
605 generate a (user-visible) trap. */
607 int flag_signaling_nans = 0;
609 /* 0 means straightforward implementation of complex divide acceptable.
610 1 means wide ranges of inputs must work for complex divide.
611 2 means C99-like requirements for complex divide (not yet implemented). */
613 int flag_complex_divide_method = 0;
615 /* Nonzero means just do syntax checking; don't output anything. */
617 int flag_syntax_only = 0;
619 /* Nonzero means perform loop optimizer. */
621 static int flag_loop_optimize;
623 /* Nonzero means perform crossjumping. */
625 static int flag_crossjumping;
627 /* Nonzero means perform if conversion. */
629 static int flag_if_conversion;
631 /* Nonzero means perform if conversion after reload. */
633 static int flag_if_conversion2;
635 /* Nonzero means to use global dataflow analysis to eliminate
636 useless null pointer tests. */
638 static int flag_delete_null_pointer_checks;
640 /* Nonzero means perform global CSE. */
642 int flag_gcse = 0;
644 /* Nonzero means to do the enhanced load motion during gcse, which trys
645 to hoist loads by not killing them when a store to the same location
646 is seen. */
648 int flag_gcse_lm = 1;
650 /* Nonzero means to perform store motion after gcse, which will try to
651 move stores closer to the exit block. Its not very effective without
652 flag_gcse_lm. */
654 int flag_gcse_sm = 1;
656 /* Nonzero means to rerun cse after loop optimization. This increases
657 compilation time about 20% and picks up a few more common expressions. */
659 static int flag_rerun_cse_after_loop;
661 /* Nonzero means to run loop optimizations twice. */
663 int flag_rerun_loop_opt;
665 /* Nonzero for -finline-functions: ok to inline functions that look like
666 good inline candidates. */
668 int flag_inline_functions;
670 /* Nonzero for -fkeep-inline-functions: even if we make a function
671 go inline everywhere, keep its definition around for debugging
672 purposes. */
674 int flag_keep_inline_functions;
676 /* Nonzero means that functions will not be inlined. */
678 int flag_no_inline = 2;
680 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
681 not just because the tree inliner turned us off. */
683 int flag_really_no_inline = 2;
685 /* Nonzero means that we should emit static const variables
686 regardless of whether or not optimization is turned on. */
688 int flag_keep_static_consts = 1;
690 /* Nonzero means we should be saving declaration info into a .X file. */
692 int flag_gen_aux_info = 0;
694 /* Specified name of aux-info file. */
696 static char *aux_info_file_name;
698 /* Nonzero means make the text shared if supported. */
700 int flag_shared_data;
702 /* Nonzero means schedule into delayed branch slots if supported. */
704 int flag_delayed_branch;
706 /* Nonzero if we are compiling pure (sharable) code.
707 Value is 1 if we are doing "small" pic; value is 2 if we're doing
708 "large" pic. */
710 int flag_pic;
712 /* Set to the default thread-local storage (tls) model to use. */
714 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
716 /* Nonzero means generate extra code for exception handling and enable
717 exception handling. */
719 int flag_exceptions;
721 /* Nonzero means generate frame unwind info table when supported. */
723 int flag_unwind_tables = 0;
725 /* Nonzero means generate frame unwind info table exact at each insn boundary */
727 int flag_asynchronous_unwind_tables = 0;
729 /* Nonzero means don't place uninitialized global data in common storage
730 by default. */
732 int flag_no_common;
734 /* Nonzero means change certain warnings into errors.
735 Usually these are warnings about failure to conform to some standard. */
737 int flag_pedantic_errors = 0;
739 /* flag_schedule_insns means schedule insns within basic blocks (before
740 local_alloc).
741 flag_schedule_insns_after_reload means schedule insns after
742 global_alloc. */
744 int flag_schedule_insns = 0;
745 int flag_schedule_insns_after_reload = 0;
747 /* The following flags have effect only for scheduling before register
748 allocation:
750 flag_schedule_interblock means schedule insns across basic blocks.
751 flag_schedule_speculative means allow speculative motion of non-load insns.
752 flag_schedule_speculative_load means allow speculative motion of some
753 load insns.
754 flag_schedule_speculative_load_dangerous allows speculative motion of more
755 load insns. */
757 int flag_schedule_interblock = 1;
758 int flag_schedule_speculative = 1;
759 int flag_schedule_speculative_load = 0;
760 int flag_schedule_speculative_load_dangerous = 0;
762 int flag_single_precision_constant;
764 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
765 by a cheaper branch on a count register. */
766 int flag_branch_on_count_reg = 1;
768 /* -finhibit-size-directive inhibits output of .size for ELF.
769 This is used only for compiling crtstuff.c,
770 and it may be extended to other effects
771 needed for crtstuff.c on other systems. */
772 int flag_inhibit_size_directive = 0;
774 /* -fverbose-asm causes extra commentary information to be produced in
775 the generated assembly code (to make it more readable). This option
776 is generally only of use to those who actually need to read the
777 generated assembly code (perhaps while debugging the compiler itself).
778 -fno-verbose-asm, the default, causes the extra information
779 to be omitted and is useful when comparing two assembler files. */
781 int flag_verbose_asm = 0;
783 /* -dA causes debug commentary information to be produced in
784 the generated assembly code (to make it more readable). This option
785 is generally only of use to those who actually need to read the
786 generated assembly code (perhaps while debugging the compiler itself).
787 Currently, this switch is only used by dwarfout.c; however, it is intended
788 to be a catchall for printing debug information in the assembler file. */
790 int flag_debug_asm = 0;
792 /* -dP causes the rtl to be emitted as a comment in assembly. */
794 int flag_dump_rtl_in_asm = 0;
796 /* -fgnu-linker specifies use of the GNU linker for initializations.
797 (Or, more generally, a linker that handles initializations.)
798 -fno-gnu-linker says that collect2 will be used. */
799 #ifdef USE_COLLECT2
800 int flag_gnu_linker = 0;
801 #else
802 int flag_gnu_linker = 1;
803 #endif
805 /* Nonzero means put zero initialized data in the bss section. */
806 int flag_zero_initialized_in_bss = 1;
808 /* Enable SSA. */
809 int flag_ssa = 0;
811 /* Enable ssa conditional constant propagation. */
812 int flag_ssa_ccp = 0;
814 /* Enable ssa aggressive dead code elimination. */
815 int flag_ssa_dce = 0;
817 /* Tag all structures with __attribute__(packed). */
818 int flag_pack_struct = 0;
820 /* Emit code to check for stack overflow; also may cause large objects
821 to be allocated dynamically. */
822 int flag_stack_check;
824 /* When non-NULL, indicates that whenever space is allocated on the
825 stack, the resulting stack pointer must not pass this
826 address---that is, for stacks that grow downward, the stack pointer
827 must always be greater than or equal to this address; for stacks
828 that grow upward, the stack pointer must be less than this address.
829 At present, the rtx may be either a REG or a SYMBOL_REF, although
830 the support provided depends on the backend. */
831 rtx stack_limit_rtx;
833 /* 0 if pointer arguments may alias each other. True in C.
834 1 if pointer arguments may not alias each other but may alias
835 global variables.
836 2 if pointer arguments may not alias each other and may not
837 alias global variables. True in Fortran.
838 This defaults to 0 for C. */
839 int flag_argument_noalias = 0;
841 /* Nonzero if we should do (language-dependent) alias analysis.
842 Typically, this analysis will assume that expressions of certain
843 types do not alias expressions of certain other types. Only used
844 if alias analysis (in general) is enabled. */
845 int flag_strict_aliasing = 0;
847 /* Instrument functions with calls at entry and exit, for profiling. */
848 int flag_instrument_function_entry_exit = 0;
850 /* Nonzero means ignore `#ident' directives. 0 means handle them.
851 On SVR4 targets, it also controls whether or not to emit a
852 string identifying the compiler. */
854 int flag_no_ident = 0;
856 /* This will perform a peephole pass before sched2. */
857 int flag_peephole2 = 0;
859 /* This will try to guess branch probabilities. */
860 int flag_guess_branch_prob = 0;
862 /* -fcheck-bounds causes gcc to generate array bounds checks.
863 For C, C++, ObjC: defaults to off.
864 For Java: defaults to on.
865 For Fortran: defaults to off. */
866 int flag_bounds_check = 0;
868 /* This will attempt to merge constant section constants, if 1 only
869 string constants and constants from constant pool, if 2 also constant
870 variables. */
871 int flag_merge_constants = 1;
873 /* If one, renumber instruction UIDs to reduce the number of
874 unused UIDs if there are a lot of instructions. If greater than
875 one, unconditionally renumber instruction UIDs. */
876 int flag_renumber_insns = 1;
878 /* If nonzero, use the graph coloring register allocator. */
879 int flag_new_regalloc = 0;
881 /* Nonzero if we perform superblock formation. */
883 int flag_tracer = 0;
885 /* Values of the -falign-* flags: how much to align labels in code.
886 0 means `use default', 1 means `don't align'.
887 For each variable, there is an _log variant which is the power
888 of two not less than the variable, for .align output. */
890 int align_loops;
891 int align_loops_log;
892 int align_loops_max_skip;
893 int align_jumps;
894 int align_jumps_log;
895 int align_jumps_max_skip;
896 int align_labels;
897 int align_labels_log;
898 int align_labels_max_skip;
899 int align_functions;
900 int align_functions_log;
902 /* Like align_functions_log above, but used by front-ends to force the
903 minimum function alignment. Zero means no alignment is forced. */
904 int force_align_functions_log;
906 /* Table of supported debugging formats. */
907 static const struct
909 const char *const arg;
910 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
911 constant expression, we use NO_DEBUG in its place. */
912 const enum debug_info_type debug_type;
913 const int use_extensions_p;
914 const char *const description;
915 } *da,
916 debug_args[] =
918 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
919 N_("Generate debugging info in default format") },
920 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
921 #ifdef DBX_DEBUGGING_INFO
922 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
923 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
924 #endif
925 #ifdef DWARF_DEBUGGING_INFO
926 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
927 { "dwarf+", DWARF_DEBUG, 1,
928 N_("Generate extended DWARF-1 format debug info") },
929 #endif
930 #ifdef DWARF2_DEBUGGING_INFO
931 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
932 #endif
933 #ifdef XCOFF_DEBUGGING_INFO
934 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
935 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
936 #endif
937 #ifdef SDB_DEBUGGING_INFO
938 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
939 #endif
940 #ifdef VMS_DEBUGGING_INFO
941 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
942 #endif
943 { 0, 0, 0, 0 }
946 typedef struct
948 const char *const string;
949 int *const variable;
950 const int on_value;
951 const char *const description;
953 lang_independent_options;
955 int flag_trapv = 0;
957 /* Add or remove a leading underscore from user symbols. */
958 int flag_leading_underscore = -1;
960 /* The user symbol prefix after having resolved same. */
961 const char *user_label_prefix;
963 static const param_info lang_independent_params[] = {
964 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
965 { OPTION, DEFAULT, HELP },
966 #include "params.def"
967 #undef DEFPARAM
968 { NULL, 0, NULL }
971 /* Table of language-independent -f options.
972 STRING is the option name. VARIABLE is the address of the variable.
973 ON_VALUE is the value to store in VARIABLE
974 if `-fSTRING' is seen as an option.
975 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
977 static const lang_independent_options f_options[] =
979 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
980 N_("Perform DWARF2 duplicate elimination") },
981 {"float-store", &flag_float_store, 1,
982 N_("Do not store floats in registers") },
983 {"defer-pop", &flag_defer_pop, 1,
984 N_("Defer popping functions args from stack until later") },
985 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
986 N_("When possible do not generate stack frames") },
987 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
988 N_("Optimize sibling and tail recursive calls") },
989 {"tracer", &flag_tracer, 1,
990 N_("Perform superblock formation via tail duplication") },
991 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
992 N_("When running CSE, follow jumps to their targets") },
993 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
994 N_("When running CSE, follow conditional jumps") },
995 {"expensive-optimizations", &flag_expensive_optimizations, 1,
996 N_("Perform a number of minor, expensive optimizations") },
997 {"thread-jumps", &flag_thread_jumps, 1,
998 N_("Perform jump threading optimizations") },
999 {"strength-reduce", &flag_strength_reduce, 1,
1000 N_("Perform strength reduction optimizations") },
1001 {"unroll-loops", &flag_unroll_loops, 1,
1002 N_("Perform loop unrolling when iteration count is known") },
1003 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1004 N_("Perform loop unrolling for all loops") },
1005 {"unswitch-loops", &flag_unswitch_loops, 1,
1006 N_("Perform loop unswitching") },
1007 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1008 N_("Generate prefetch instructions, if available, for arrays in loops") },
1009 {"move-all-movables", &flag_move_all_movables, 1,
1010 N_("Force all loop invariant computations out of loops") },
1011 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1012 N_("Strength reduce all loop general induction variables") },
1013 {"writable-strings", &flag_writable_strings, 1,
1014 N_("Store strings in writable data section") },
1015 {"peephole", &flag_no_peephole, 0,
1016 N_("Enable machine specific peephole optimizations") },
1017 {"force-mem", &flag_force_mem, 1,
1018 N_("Copy memory operands into registers before using") },
1019 {"force-addr", &flag_force_addr, 1,
1020 N_("Copy memory address constants into regs before using") },
1021 {"function-cse", &flag_no_function_cse, 0,
1022 N_("Allow function addresses to be held in registers") },
1023 {"inline-functions", &flag_inline_functions, 1,
1024 N_("Integrate simple functions into their callers") },
1025 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1026 N_("Generate code for funcs even if they are fully inlined") },
1027 {"inline", &flag_no_inline, 0,
1028 N_("Pay attention to the 'inline' keyword") },
1029 {"keep-static-consts", &flag_keep_static_consts, 1,
1030 N_("Emit static const variables even if they are not used") },
1031 {"syntax-only", &flag_syntax_only, 1,
1032 N_("Check for syntax errors, then stop") },
1033 {"shared-data", &flag_shared_data, 1,
1034 N_("Mark data as shared rather than private") },
1035 {"caller-saves", &flag_caller_saves, 1,
1036 N_("Enable saving registers around function calls") },
1037 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1038 N_("Return 'short' aggregates in memory, not registers") },
1039 {"reg-struct-return", &flag_pcc_struct_return, 0,
1040 N_("Return 'short' aggregates in registers") },
1041 {"delayed-branch", &flag_delayed_branch, 1,
1042 N_("Attempt to fill delay slots of branch instructions") },
1043 {"gcse", &flag_gcse, 1,
1044 N_("Perform the global common subexpression elimination") },
1045 {"gcse-lm", &flag_gcse_lm, 1,
1046 N_("Perform enhanced load motion during global subexpression elimination") },
1047 {"gcse-sm", &flag_gcse_sm, 1,
1048 N_("Perform store motion after global subexpression elimination") },
1049 {"loop-optimize", &flag_loop_optimize, 1,
1050 N_("Perform the loop optimizations") },
1051 {"crossjumping", &flag_crossjumping, 1,
1052 N_("Perform cross-jumping optimization") },
1053 {"if-conversion", &flag_if_conversion, 1,
1054 N_("Perform conversion of conditional jumps to branchless equivalents") },
1055 {"if-conversion2", &flag_if_conversion2, 1,
1056 N_("Perform conversion of conditional jumps to conditional execution") },
1057 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1058 N_("Run CSE pass after loop optimizations") },
1059 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1060 N_("Run the loop optimizer twice") },
1061 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1062 N_("Delete useless null pointer checks") },
1063 {"schedule-insns", &flag_schedule_insns, 1,
1064 N_("Reschedule instructions before register allocation") },
1065 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1066 N_("Reschedule instructions after register allocation") },
1067 {"sched-interblock",&flag_schedule_interblock, 1,
1068 N_("Enable scheduling across basic blocks") },
1069 {"sched-spec",&flag_schedule_speculative, 1,
1070 N_("Allow speculative motion of non-loads") },
1071 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1072 N_("Allow speculative motion of some loads") },
1073 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1074 N_("Allow speculative motion of more loads") },
1075 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1076 N_("Replace add,compare,branch with branch on count reg") },
1077 {"pic", &flag_pic, 1,
1078 N_("Generate position independent code, if possible") },
1079 {"PIC", &flag_pic, 2, ""},
1080 {"exceptions", &flag_exceptions, 1,
1081 N_("Enable exception handling") },
1082 {"unwind-tables", &flag_unwind_tables, 1,
1083 N_("Just generate unwind tables for exception handling") },
1084 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1085 N_("Generate unwind tables exact at each instruction boundary") },
1086 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1087 N_("Support synchronous non-call exceptions") },
1088 {"profile-arcs", &profile_arc_flag, 1,
1089 N_("Insert arc based program profiling code") },
1090 {"test-coverage", &flag_test_coverage, 1,
1091 N_("Create data files needed by gcov") },
1092 {"branch-probabilities", &flag_branch_probabilities, 1,
1093 N_("Use profiling information for branch probabilities") },
1094 {"profile", &profile_flag, 1,
1095 N_("Enable basic program profiling code") },
1096 {"reorder-blocks", &flag_reorder_blocks, 1,
1097 N_("Reorder basic blocks to improve code placement") },
1098 {"reorder-functions", &flag_reorder_functions, 1,
1099 N_("Reorder functions to improve code placement") },
1100 {"rename-registers", &flag_rename_registers, 1,
1101 N_("Do the register renaming optimization pass") },
1102 {"cprop-registers", &flag_cprop_registers, 1,
1103 N_("Do the register copy-propagation optimization pass") },
1104 {"common", &flag_no_common, 0,
1105 N_("Do not put uninitialized globals in the common section") },
1106 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1107 N_("Do not generate .size directives") },
1108 {"function-sections", &flag_function_sections, 1,
1109 N_("place each function into its own section") },
1110 {"data-sections", &flag_data_sections, 1,
1111 N_("place data items into their own section") },
1112 {"verbose-asm", &flag_verbose_asm, 1,
1113 N_("Add extra commentry to assembler output") },
1114 {"gnu-linker", &flag_gnu_linker, 1,
1115 N_("Output GNU ld formatted global initializers") },
1116 {"regmove", &flag_regmove, 1,
1117 N_("Enables a register move optimization") },
1118 {"optimize-register-move", &flag_regmove, 1,
1119 N_("Do the full regmove optimization pass") },
1120 {"pack-struct", &flag_pack_struct, 1,
1121 N_("Pack structure members together without holes") },
1122 {"stack-check", &flag_stack_check, 1,
1123 N_("Insert stack checking code into the program") },
1124 {"argument-alias", &flag_argument_noalias, 0,
1125 N_("Specify that arguments may alias each other & globals") },
1126 {"argument-noalias", &flag_argument_noalias, 1,
1127 N_("Assume arguments may alias globals but not each other") },
1128 {"argument-noalias-global", &flag_argument_noalias, 2,
1129 N_("Assume arguments do not alias each other or globals") },
1130 {"strict-aliasing", &flag_strict_aliasing, 1,
1131 N_("Assume strict aliasing rules apply") },
1132 {"align-loops", &align_loops, 0,
1133 N_("Align the start of loops") },
1134 {"align-jumps", &align_jumps, 0,
1135 N_("Align labels which are only reached by jumping") },
1136 {"align-labels", &align_labels, 0,
1137 N_("Align all labels") },
1138 {"align-functions", &align_functions, 0,
1139 N_("Align the start of functions") },
1140 {"merge-constants", &flag_merge_constants, 1,
1141 N_("Attempt to merge identical constants accross compilation units") },
1142 {"merge-all-constants", &flag_merge_constants, 2,
1143 N_("Attempt to merge identical constants and constant variables") },
1144 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1145 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1146 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1147 N_("Instrument function entry/exit with profiling calls") },
1148 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1149 N_("Put zero initialized data in the bss section") },
1150 {"ssa", &flag_ssa, 1,
1151 N_("Enable SSA optimizations") },
1152 {"ssa-ccp", &flag_ssa_ccp, 1,
1153 N_("Enable SSA conditional constant propagation") },
1154 {"ssa-dce", &flag_ssa_dce, 1,
1155 N_("Enable aggressive SSA dead code elimination") },
1156 {"leading-underscore", &flag_leading_underscore, 1,
1157 N_("External symbols have a leading underscore") },
1158 {"ident", &flag_no_ident, 0,
1159 N_("Process #ident directives") },
1160 { "peephole2", &flag_peephole2, 1,
1161 N_("Enables an rtl peephole pass run before sched2") },
1162 {"finite-math-only", &flag_finite_math_only, 1,
1163 N_("Assume no NaNs or +-Infs are generated") },
1164 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1165 N_("Enables guessing of branch probabilities") },
1166 {"math-errno", &flag_errno_math, 1,
1167 N_("Set errno after built-in math functions") },
1168 {"trapping-math", &flag_trapping_math, 1,
1169 N_("Floating-point operations can trap") },
1170 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1171 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1172 {"signaling-nans", &flag_signaling_nans, 1,
1173 N_("Disable optimizations observable by IEEE signaling NaNs") },
1174 {"bounds-check", &flag_bounds_check, 1,
1175 N_("Generate code to check bounds before indexing arrays") },
1176 {"single-precision-constant", &flag_single_precision_constant, 1,
1177 N_("Convert floating point constant to single precision constant") },
1178 {"time-report", &time_report, 1,
1179 N_("Report time taken by each compiler pass at end of run") },
1180 {"mem-report", &mem_report, 1,
1181 N_("Report on permanent memory allocation at end of run") },
1182 { "trapv", &flag_trapv, 1,
1183 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1184 { "new-ra", &flag_new_regalloc, 1,
1185 N_("Use graph coloring register allocation.") },
1188 /* Table of language-specific options. */
1190 static const struct lang_opt
1192 const char *const option;
1193 const char *const description;
1195 documented_lang_options[] =
1197 /* In order not to overload the --help output, the convention
1198 used here is to only describe those options which are not
1199 enabled by default. */
1201 { "-ansi",
1202 N_("Compile just for ISO C90") },
1203 { "-std= ",
1204 N_("Determine language standard") },
1206 { "-fsigned-bitfields", "" },
1207 { "-funsigned-bitfields",
1208 N_("Make bit-fields by unsigned by default") },
1209 { "-fno-signed-bitfields", "" },
1210 { "-fno-unsigned-bitfields","" },
1211 { "-fsigned-char",
1212 N_("Make 'char' be signed by default") },
1213 { "-funsigned-char",
1214 N_("Make 'char' be unsigned by default") },
1215 { "-fno-signed-char", "" },
1216 { "-fno-unsigned-char", "" },
1218 { "-fasm", "" },
1219 { "-fno-asm",
1220 N_("Do not recognize the 'asm' keyword") },
1221 { "-fbuiltin", "" },
1222 { "-fno-builtin",
1223 N_("Do not recognize any built in functions") },
1224 { "-fhosted",
1225 N_("Assume normal C execution environment") },
1226 { "-fno-hosted", "" },
1227 { "-ffreestanding",
1228 N_("Assume that standard libraries & main might not exist") },
1229 { "-fno-freestanding", "" },
1230 { "-fcond-mismatch",
1231 N_("Allow different types as args of ? operator") },
1232 { "-fno-cond-mismatch", "" },
1233 { "-fdollars-in-identifiers",
1234 N_("Allow the use of $ inside identifiers") },
1235 { "-fno-dollars-in-identifiers", "" },
1236 { "-fpreprocessed", "" },
1237 { "-fno-preprocessed", "" },
1238 { "-fshort-double",
1239 N_("Use the same size for double as for float") },
1240 { "-fno-short-double", "" },
1241 { "-fshort-enums",
1242 N_("Use the smallest fitting integer to hold enums") },
1243 { "-fno-short-enums", "" },
1244 { "-fshort-wchar",
1245 N_("Override the underlying type for wchar_t to `unsigned short'") },
1246 { "-fno-short-wchar", "" },
1248 { "-Wall",
1249 N_("Enable most warning messages") },
1250 { "-Wbad-function-cast",
1251 N_("Warn about casting functions to incompatible types") },
1252 { "-Wno-bad-function-cast", "" },
1253 { "-Wmissing-format-attribute",
1254 N_("Warn about functions which might be candidates for format attributes") },
1255 { "-Wno-missing-format-attribute", "" },
1256 { "-Wcast-qual",
1257 N_("Warn about casts which discard qualifiers") },
1258 { "-Wno-cast-qual", "" },
1259 { "-Wchar-subscripts",
1260 N_("Warn about subscripts whose type is 'char'") },
1261 { "-Wno-char-subscripts", "" },
1262 { "-Wcomment",
1263 N_("Warn if nested comments are detected") },
1264 { "-Wno-comment", "" },
1265 { "-Wcomments",
1266 N_("Warn if nested comments are detected") },
1267 { "-Wno-comments", "" },
1268 { "-Wconversion",
1269 N_("Warn about possibly confusing type conversions") },
1270 { "-Wno-conversion", "" },
1271 { "-Wdiv-by-zero", "" },
1272 { "-Wno-div-by-zero",
1273 N_("Do not warn about compile-time integer division by zero") },
1274 { "-Wfloat-equal",
1275 N_("Warn about testing equality of floating point numbers") },
1276 { "-Wno-float-equal", "" },
1277 { "-Wformat",
1278 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1279 { "-Wno-format", "" },
1280 { "-Wformat-extra-args", "" },
1281 { "-Wno-format-extra-args",
1282 N_("Don't warn about too many arguments to format functions") },
1283 { "-Wformat-nonliteral",
1284 N_("Warn about non-string-literal format strings") },
1285 { "-Wno-format-nonliteral", "" },
1286 { "-Wformat-security",
1287 N_("Warn about possible security problems with format functions") },
1288 { "-Wno-format-security", "" },
1289 { "-Wformat-y2k", "" },
1290 { "-Wno-format-y2k",
1291 N_("Don't warn about strftime formats yielding 2 digit years") },
1292 { "-Wimplicit-function-declaration",
1293 N_("Warn about implicit function declarations") },
1294 { "-Wno-implicit-function-declaration", "" },
1295 { "-Werror-implicit-function-declaration", "" },
1296 { "-Wimplicit-int",
1297 N_("Warn when a declaration does not specify a type") },
1298 { "-Wno-implicit-int", "" },
1299 { "-Wimplicit", "" },
1300 { "-Wno-implicit", "" },
1301 { "-Wimport",
1302 N_("Warn about the use of the #import directive") },
1303 { "-Wno-import", "" },
1304 { "-Winvalid-pch",
1305 N_("Warn about PCH files that are found but not used") },
1306 { "-Wlong-long","" },
1307 { "-Wno-long-long",
1308 N_("Do not warn about using 'long long' when -pedantic") },
1309 { "-Wmain",
1310 N_("Warn about suspicious declarations of main") },
1311 { "-Wno-main", "" },
1312 { "-Wmissing-braces",
1313 N_("Warn about possibly missing braces around initializers") },
1314 { "-Wno-missing-braces", "" },
1315 { "-Wmissing-declarations",
1316 N_("Warn about global funcs without previous declarations") },
1317 { "-Wno-missing-declarations", "" },
1318 { "-Wmissing-prototypes",
1319 N_("Warn about global funcs without prototypes") },
1320 { "-Wno-missing-prototypes", "" },
1321 { "-Wmultichar",
1322 N_("Warn about use of multicharacter literals") },
1323 { "-Wno-multichar", "" },
1324 { "-Wnested-externs",
1325 N_("Warn about externs not at file scope level") },
1326 { "-Wno-nested-externs", "" },
1327 { "-Wparentheses",
1328 N_("Warn about possible missing parentheses") },
1329 { "-Wno-parentheses", "" },
1330 { "-Wpointer-arith",
1331 N_("Warn about function pointer arithmetic") },
1332 { "-Wno-pointer-arith", "" },
1333 { "-Wredundant-decls",
1334 N_("Warn about multiple declarations of the same object") },
1335 { "-Wno-redundant-decls", "" },
1336 { "-Wreturn-type",
1337 N_("Warn whenever a function's return-type defaults to int") },
1338 { "-Wno-return-type", "" },
1339 { "-Wsequence-point",
1340 N_("Warn about possible violations of sequence point rules") },
1341 { "-Wno-sequence-point", "" },
1342 { "-Wsign-compare",
1343 N_("Warn about signed/unsigned comparisons") },
1344 { "-Wno-sign-compare", "" },
1345 { "-Wstrict-prototypes",
1346 N_("Warn about non-prototyped function decls") },
1347 { "-Wno-strict-prototypes", "" },
1348 { "-Wtraditional",
1349 N_("Warn about constructs whose meanings change in ISO C") },
1350 { "-Wno-traditional", "" },
1351 { "-Wtrigraphs",
1352 N_("Warn when trigraphs are encountered") },
1353 { "-Wno-trigraphs", "" },
1354 { "-Wundef", "" },
1355 { "-Wno-undef", "" },
1356 { "-Wunknown-pragmas",
1357 N_("Warn about unrecognized pragmas") },
1358 { "-Wno-unknown-pragmas", "" },
1359 { "-Wwrite-strings",
1360 N_("Mark strings as 'const char *'") },
1361 { "-Wno-write-strings", "" },
1363 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1365 #include "options.h"
1369 /* Here is a table, controlled by the tm.h file, listing each -m switch
1370 and which bits in `target_switches' it should set or clear.
1371 If VALUE is positive, it is bits to set.
1372 If VALUE is negative, -VALUE is bits to clear.
1373 (The sign bit is not used so there is no confusion.) */
1375 static const struct
1377 const char *const name;
1378 const int value;
1379 const char *const description;
1381 target_switches[] = TARGET_SWITCHES;
1383 /* This table is similar, but allows the switch to have a value. */
1385 #ifdef TARGET_OPTIONS
1386 static const struct
1388 const char *const prefix;
1389 const char **const variable;
1390 const char *const description;
1392 target_options[] = TARGET_OPTIONS;
1393 #endif
1395 /* Options controlling warnings. */
1397 /* Don't print warning messages. -w. */
1399 int inhibit_warnings = 0;
1401 /* Don't suppress warnings from system headers. -Wsystem-headers. */
1403 int warn_system_headers = 0;
1405 /* Print various extra warnings. -W/-Wextra. */
1407 int extra_warnings = 0;
1409 /* Treat warnings as errors. -Werror. */
1411 int warnings_are_errors = 0;
1413 /* Nonzero to warn about unused variables, functions et.al. */
1415 int warn_unused_function;
1416 int warn_unused_label;
1417 int warn_unused_parameter;
1418 int warn_unused_variable;
1419 int warn_unused_value;
1421 /* Nonzero to warn about code which is never reached. */
1423 int warn_notreached;
1425 /* Nonzero to warn about variables used before they are initialized. */
1427 int warn_uninitialized;
1429 /* Nonzero means warn about all declarations which shadow others. */
1431 int warn_shadow;
1433 /* Warn if a switch on an enum, that does not have a default case,
1434 fails to have a case for every enum value. */
1436 int warn_switch;
1438 /* Warn if a switch does not have a default case. */
1440 int warn_switch_default;
1442 /* Warn if a switch on an enum fails to have a case for every enum
1443 value (regardless of the presence or otherwise of a default case). */
1445 int warn_switch_enum;
1447 /* Nonzero means warn about function definitions that default the return type
1448 or that use a null return and have a return-type other than void. */
1450 int warn_return_type;
1452 /* Nonzero means warn about pointer casts that increase the required
1453 alignment of the target type (and might therefore lead to a crash
1454 due to a misaligned access). */
1456 int warn_cast_align;
1458 /* Nonzero means warn about any objects definitions whose size is larger
1459 than N bytes. Also want about function definitions whose returned
1460 values are larger than N bytes. The value N is in `larger_than_size'. */
1462 int warn_larger_than;
1463 HOST_WIDE_INT larger_than_size;
1465 /* Nonzero means warn if inline function is too large. */
1467 int warn_inline;
1469 /* Warn if a function returns an aggregate,
1470 since there are often incompatible calling conventions for doing this. */
1472 int warn_aggregate_return;
1474 /* Warn if packed attribute on struct is unnecessary and inefficient. */
1476 int warn_packed;
1478 /* Warn when gcc pads a structure to an alignment boundary. */
1480 int warn_padded;
1482 /* Warn when an optimization pass is disabled. */
1484 int warn_disabled_optimization;
1486 /* Warn about functions which might be candidates for attribute noreturn. */
1488 int warn_missing_noreturn;
1490 /* Nonzero means warn about uses of __attribute__((deprecated))
1491 declarations. */
1493 int warn_deprecated_decl = 1;
1495 /* Nonzero means warn about constructs which might not be
1496 strict-aliasing safe. */
1498 int warn_strict_aliasing;
1500 /* Like f_options, but for -W. */
1502 static const lang_independent_options W_options[] =
1504 {"unused-function", &warn_unused_function, 1,
1505 N_("Warn when a function is unused") },
1506 {"unused-label", &warn_unused_label, 1,
1507 N_("Warn when a label is unused") },
1508 {"unused-parameter", &warn_unused_parameter, 1,
1509 N_("Warn when a function parameter is unused") },
1510 {"unused-variable", &warn_unused_variable, 1,
1511 N_("Warn when a variable is unused") },
1512 {"unused-value", &warn_unused_value, 1,
1513 N_("Warn when an expression value is unused") },
1514 {"system-headers", &warn_system_headers, 1,
1515 N_("Do not suppress warnings from system headers") },
1516 {"error", &warnings_are_errors, 1,
1517 N_("Treat all warnings as errors") },
1518 {"shadow", &warn_shadow, 1,
1519 N_("Warn when one local variable shadows another") },
1520 {"switch", &warn_switch, 1,
1521 N_("Warn about enumerated switches, with no default, missing a case") },
1522 {"switch-default", &warn_switch_default, 1,
1523 N_("Warn about enumerated switches missing a default case") },
1524 {"switch-enum", &warn_switch_enum, 1,
1525 N_("Warn about all enumerated switches missing a specific case") },
1526 {"aggregate-return", &warn_aggregate_return, 1,
1527 N_("Warn about returning structures, unions or arrays") },
1528 {"cast-align", &warn_cast_align, 1,
1529 N_("Warn about pointer casts which increase alignment") },
1530 {"unreachable-code", &warn_notreached, 1,
1531 N_("Warn about code that will never be executed") },
1532 {"uninitialized", &warn_uninitialized, 1,
1533 N_("Warn about uninitialized automatic variables") },
1534 {"inline", &warn_inline, 1,
1535 N_("Warn when an inlined function cannot be inlined") },
1536 {"packed", &warn_packed, 1,
1537 N_("Warn when the packed attribute has no effect on struct layout") },
1538 {"padded", &warn_padded, 1,
1539 N_("Warn when padding is required to align struct members") },
1540 {"disabled-optimization", &warn_disabled_optimization, 1,
1541 N_("Warn when an optimization pass is disabled") },
1542 {"deprecated-declarations", &warn_deprecated_decl, 1,
1543 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1544 {"extra", &extra_warnings, 1,
1545 N_("Print extra (possibly unwanted) warnings") },
1546 {"missing-noreturn", &warn_missing_noreturn, 1,
1547 N_("Warn about functions which might be candidates for attribute noreturn") },
1548 {"strict-aliasing", &warn_strict_aliasing, 1,
1549 N_ ("Warn about code which might break the strict aliasing rules") }
1552 void
1553 set_Wunused (setting)
1554 int setting;
1556 warn_unused_function = setting;
1557 warn_unused_label = setting;
1558 /* Unused function parameter warnings are reported when either ``-W
1559 -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
1560 -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
1561 if (!setting)
1562 warn_unused_parameter = 0;
1563 else if (!warn_unused_parameter)
1564 warn_unused_parameter = -1;
1565 warn_unused_variable = setting;
1566 warn_unused_value = setting;
1569 /* The following routines are useful in setting all the flags that
1570 -ffast-math and -fno-fast-math imply. */
1572 void
1573 set_fast_math_flags (set)
1574 int set;
1576 flag_trapping_math = !set;
1577 flag_unsafe_math_optimizations = set;
1578 flag_finite_math_only = set;
1579 flag_errno_math = !set;
1580 if (set)
1581 flag_signaling_nans = 0;
1584 /* Return true iff flags are set as if -ffast-math. */
1585 bool
1586 fast_math_flags_set_p ()
1588 return (!flag_trapping_math
1589 && flag_unsafe_math_optimizations
1590 && flag_finite_math_only
1591 && !flag_errno_math);
1595 /* Output files for assembler code (real compiler output)
1596 and debugging dumps. */
1598 FILE *asm_out_file;
1599 FILE *aux_info_file;
1600 FILE *rtl_dump_file = NULL;
1602 /* Decode the string P as an integral parameter.
1603 If the string is indeed an integer return its numeric value else
1604 issue an Invalid Option error for the option PNAME and return DEFVAL.
1605 If PNAME is zero just return DEFVAL, do not call error. */
1608 read_integral_parameter (p, pname, defval)
1609 const char *p;
1610 const char *pname;
1611 const int defval;
1613 const char *endp = p;
1615 while (*endp)
1617 if (ISDIGIT (*endp))
1618 endp++;
1619 else
1620 break;
1623 if (*endp != 0)
1625 if (pname != 0)
1626 error ("invalid option `%s'", pname);
1627 return defval;
1630 return atoi (p);
1633 /* This calls abort and is used to avoid problems when abort is a macro.
1634 It is used when we need to pass the address of abort. */
1636 void
1637 do_abort ()
1639 abort ();
1642 /* When `malloc.c' is compiled with `rcheck' defined,
1643 it calls this function to report clobberage. */
1645 void
1646 botch (s)
1647 const char *s ATTRIBUTE_UNUSED;
1649 abort ();
1652 /* Return the logarithm of X, base 2, considering X unsigned,
1653 if X is a power of 2. Otherwise, returns -1.
1655 This should be used via the `exact_log2' macro. */
1658 exact_log2_wide (x)
1659 unsigned HOST_WIDE_INT x;
1661 int log = 0;
1662 /* Test for 0 or a power of 2. */
1663 if (x == 0 || x != (x & -x))
1664 return -1;
1665 while ((x >>= 1) != 0)
1666 log++;
1667 return log;
1670 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1671 If X is 0, return -1.
1673 This should be used via the floor_log2 macro. */
1676 floor_log2_wide (x)
1677 unsigned HOST_WIDE_INT x;
1679 int log = -1;
1680 while (x != 0)
1681 log++,
1682 x >>= 1;
1683 return log;
1686 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1687 into ICE messages, which is much more user friendly. */
1689 static void
1690 crash_signal (signo)
1691 int signo;
1693 internal_error ("%s", strsignal (signo));
1696 /* Strip off a legitimate source ending from the input string NAME of
1697 length LEN. Rather than having to know the names used by all of
1698 our front ends, we strip off an ending of a period followed by
1699 up to five characters. (Java uses ".class".) */
1701 void
1702 strip_off_ending (name, len)
1703 char *name;
1704 int len;
1706 int i;
1707 for (i = 2; i < 6 && len > i; i++)
1709 if (name[len - i] == '.')
1711 name[len - i] = '\0';
1712 break;
1717 /* Output a quoted string. */
1719 void
1720 output_quoted_string (asm_file, string)
1721 FILE *asm_file;
1722 const char *string;
1724 #ifdef OUTPUT_QUOTED_STRING
1725 OUTPUT_QUOTED_STRING (asm_file, string);
1726 #else
1727 char c;
1729 putc ('\"', asm_file);
1730 while ((c = *string++) != 0)
1732 if (ISPRINT (c))
1734 if (c == '\"' || c == '\\')
1735 putc ('\\', asm_file);
1736 putc (c, asm_file);
1738 else
1739 fprintf (asm_file, "\\%03o", (unsigned char) c);
1741 putc ('\"', asm_file);
1742 #endif
1745 /* Output NAME into FILE after having turned it into something
1746 usable as an identifier in a target's assembly file. */
1747 void
1748 output_clean_symbol_name (file, name)
1749 FILE *file;
1750 const char *name;
1752 /* Make a copy of NAME. */
1753 char *id = xstrdup (name);
1755 /* Make it look like a valid identifier for an assembler. */
1756 clean_symbol_name (id);
1758 fputs (id, file);
1759 free (id);
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%s\n\n",
1841 (*lang_hooks.decl_printable_name) (decl, 2),
1842 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1843 ? " (hot)"
1844 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1845 ? " (unlikely executed)"
1846 : "");
1848 timevar_pop (TV_DUMP);
1849 return 1;
1852 /* Routine to close a dump file. */
1854 static void
1855 close_dump_file (index, func, insns)
1856 enum dump_file_index index;
1857 void (*func) PARAMS ((FILE *, rtx));
1858 rtx insns;
1860 if (! rtl_dump_file)
1861 return;
1863 timevar_push (TV_DUMP);
1864 if (insns
1865 && graph_dump_format != no_graph
1866 && dump_file[index].graph_dump_p)
1868 char seq[16];
1869 char *suffix;
1871 sprintf (seq, DUMPFILE_FORMAT, index);
1872 suffix = concat (seq, dump_file[index].extension, NULL);
1873 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1874 free (suffix);
1877 if (func && insns)
1878 func (rtl_dump_file, insns);
1880 fflush (rtl_dump_file);
1881 fclose (rtl_dump_file);
1883 rtl_dump_file = NULL;
1884 timevar_pop (TV_DUMP);
1887 /* Do any final processing required for the declarations in VEC, of
1888 which there are LEN. We write out inline functions and variables
1889 that have been deferred until this point, but which are required.
1890 Returns nonzero if anything was put out. */
1893 wrapup_global_declarations (vec, len)
1894 tree *vec;
1895 int len;
1897 tree decl;
1898 int i;
1899 int reconsider;
1900 int output_something = 0;
1902 for (i = 0; i < len; i++)
1904 decl = vec[i];
1906 /* We're not deferring this any longer. */
1907 DECL_DEFER_OUTPUT (decl) = 0;
1909 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1910 (*lang_hooks.finish_incomplete_decl) (decl);
1913 /* Now emit any global variables or functions that we have been
1914 putting off. We need to loop in case one of the things emitted
1915 here references another one which comes earlier in the list. */
1918 reconsider = 0;
1919 for (i = 0; i < len; i++)
1921 decl = vec[i];
1923 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1924 continue;
1926 /* Don't write out static consts, unless we still need them.
1928 We also keep static consts if not optimizing (for debugging),
1929 unless the user specified -fno-keep-static-consts.
1930 ??? They might be better written into the debug information.
1931 This is possible when using DWARF.
1933 A language processor that wants static constants to be always
1934 written out (even if it is not used) is responsible for
1935 calling rest_of_decl_compilation itself. E.g. the C front-end
1936 calls rest_of_decl_compilation from finish_decl.
1937 One motivation for this is that is conventional in some
1938 environments to write things like:
1939 static const char rcsid[] = "... version string ...";
1940 intending to force the string to be in the executable.
1942 A language processor that would prefer to have unneeded
1943 static constants "optimized away" would just defer writing
1944 them out until here. E.g. C++ does this, because static
1945 constants are often defined in header files.
1947 ??? A tempting alternative (for both C and C++) would be
1948 to force a constant to be written if and only if it is
1949 defined in a main file, as opposed to an include file. */
1951 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1953 bool needed = 1;
1955 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1956 /* needed */;
1957 else if (DECL_COMDAT (decl))
1958 needed = 0;
1959 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1960 && (optimize || !flag_keep_static_consts
1961 || DECL_ARTIFICIAL (decl)))
1962 needed = 0;
1964 if (needed)
1966 reconsider = 1;
1967 rest_of_decl_compilation (decl, NULL, 1, 1);
1971 if (TREE_CODE (decl) == FUNCTION_DECL
1972 && DECL_INITIAL (decl) != 0
1973 && DECL_SAVED_INSNS (decl) != 0
1974 && (flag_keep_inline_functions
1975 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1976 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1978 reconsider = 1;
1979 output_inline_function (decl);
1983 if (reconsider)
1984 output_something = 1;
1986 while (reconsider);
1988 return output_something;
1991 /* Issue appropriate warnings for the global declarations in VEC (of
1992 which there are LEN). Output debugging information for them. */
1994 void
1995 check_global_declarations (vec, len)
1996 tree *vec;
1997 int len;
1999 tree decl;
2000 int i;
2002 for (i = 0; i < len; i++)
2004 decl = vec[i];
2006 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
2007 && ! TREE_ASM_WRITTEN (decl))
2008 /* Cancel the RTL for this decl so that, if debugging info
2009 output for global variables is still to come,
2010 this one will be omitted. */
2011 SET_DECL_RTL (decl, NULL_RTX);
2013 /* Warn about any function
2014 declared static but not defined.
2015 We don't warn about variables,
2016 because many programs have static variables
2017 that exist only to get some text into the object file. */
2018 if (TREE_CODE (decl) == FUNCTION_DECL
2019 && (warn_unused_function
2020 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2021 && DECL_INITIAL (decl) == 0
2022 && DECL_EXTERNAL (decl)
2023 && ! DECL_ARTIFICIAL (decl)
2024 && ! TREE_PUBLIC (decl))
2026 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2027 pedwarn_with_decl (decl,
2028 "`%s' used but never defined");
2029 else
2030 warning_with_decl (decl,
2031 "`%s' declared `static' but never defined");
2032 /* This symbol is effectively an "extern" declaration now. */
2033 TREE_PUBLIC (decl) = 1;
2034 assemble_external (decl);
2037 /* Warn about static fns or vars defined but not used. */
2038 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2039 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2040 && ! TREE_USED (decl)
2041 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2042 to handle multiple external decls in different scopes. */
2043 && ! TREE_USED (DECL_NAME (decl))
2044 && ! DECL_EXTERNAL (decl)
2045 && ! TREE_PUBLIC (decl)
2046 /* Global register variables must be declared to reserve them. */
2047 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2048 /* Otherwise, ask the language. */
2049 && (*lang_hooks.decls.warn_unused_global) (decl))
2050 warning_with_decl (decl, "`%s' defined but not used");
2052 /* Avoid confusing the debug information machinery when there are
2053 errors. */
2054 if (errorcount == 0 && sorrycount == 0)
2056 timevar_push (TV_SYMOUT);
2057 (*debug_hooks->global_decl) (decl);
2058 timevar_pop (TV_SYMOUT);
2063 /* Save the current INPUT_FILENAME and LINENO on the top entry in the
2064 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2065 INPUT_FILENAME and LINENO accordingly. */
2067 void
2068 push_srcloc (file, line)
2069 const char *file;
2070 int line;
2072 struct file_stack *fs;
2074 if (input_file_stack)
2076 input_file_stack->name = input_filename;
2077 input_file_stack->line = lineno;
2080 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2081 fs->name = input_filename = file;
2082 fs->line = lineno = line;
2083 fs->next = input_file_stack;
2084 input_file_stack = fs;
2085 input_file_stack_tick++;
2088 /* Pop the top entry off the stack of presently open source files.
2089 Restore the INPUT_FILENAME and LINENO from the new topmost entry on
2090 the stack. */
2092 void
2093 pop_srcloc ()
2095 struct file_stack *fs;
2097 fs = input_file_stack;
2098 input_file_stack = fs->next;
2099 free (fs);
2100 input_file_stack_tick++;
2101 /* The initial source file is never popped. */
2102 if (!input_file_stack)
2103 abort ();
2104 input_filename = input_file_stack->name;
2105 lineno = input_file_stack->line;
2108 /* Compile an entire translation unit. Write a file of assembly
2109 output and various debugging dumps. */
2111 static void
2112 compile_file ()
2114 tree globals;
2116 /* Initialize yet another pass. */
2118 init_final (main_input_filename);
2119 init_branch_prob (aux_base_name);
2121 timevar_push (TV_PARSE);
2123 /* Call the parser, which parses the entire file (calling
2124 rest_of_compilation for each function). */
2125 (*lang_hooks.parse_file) (set_yydebug);
2127 /* In case there were missing block closers,
2128 get us back to the global binding level. */
2129 (*lang_hooks.clear_binding_stack) ();
2131 /* Compilation is now finished except for writing
2132 what's left of the symbol table output. */
2133 timevar_pop (TV_PARSE);
2135 if (flag_syntax_only)
2136 return;
2138 globals = (*lang_hooks.decls.getdecls) ();
2140 /* Really define vars that have had only a tentative definition.
2141 Really output inline functions that must actually be callable
2142 and have not been output so far. */
2145 int len = list_length (globals);
2146 tree *vec = (tree *) xmalloc (sizeof (tree) * len);
2147 int i;
2148 tree decl;
2150 /* Process the decls in reverse order--earliest first.
2151 Put them into VEC from back to front, then take out from front. */
2153 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
2154 vec[len - i - 1] = decl;
2156 wrapup_global_declarations (vec, len);
2158 if (profile_arc_flag)
2159 /* This must occur after the loop to output deferred functions.
2160 Else the profiler initializer would not be emitted if all the
2161 functions in this compilation unit were deferred. */
2162 create_profiler ();
2164 check_global_declarations (vec, len);
2166 /* Clean up. */
2167 free (vec);
2170 /* Write out any pending weak symbol declarations. */
2172 weak_finish ();
2174 /* Do dbx symbols. */
2175 timevar_push (TV_SYMOUT);
2177 #ifdef DWARF2_UNWIND_INFO
2178 if (dwarf2out_do_frame ())
2179 dwarf2out_frame_finish ();
2180 #endif
2182 (*debug_hooks->finish) (main_input_filename);
2183 timevar_pop (TV_SYMOUT);
2185 /* Output some stuff at end of file if nec. */
2187 dw2_output_indirect_constants ();
2189 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2191 timevar_push (TV_DUMP);
2192 open_dump_file (DFI_bp, NULL);
2194 end_branch_prob ();
2196 close_dump_file (DFI_bp, NULL, NULL_RTX);
2197 timevar_pop (TV_DUMP);
2200 #ifdef ASM_FILE_END
2201 ASM_FILE_END (asm_out_file);
2202 #endif
2204 /* Attach a special .ident directive to the end of the file to identify
2205 the version of GCC which compiled this code. The format of the .ident
2206 string is patterned after the ones produced by native SVR4 compilers. */
2207 #ifdef IDENT_ASM_OP
2208 if (!flag_no_ident)
2209 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2210 IDENT_ASM_OP, version_string);
2211 #endif
2213 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2215 timevar_push (TV_DUMP);
2216 dump_combine_total_stats (rtl_dump_file);
2217 close_dump_file (DFI_combine, NULL, NULL_RTX);
2218 timevar_pop (TV_DUMP);
2222 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2223 and TYPE_DECL nodes.
2225 This does nothing for local (non-static) variables, unless the
2226 variable is a register variable with an ASMSPEC. In that case, or
2227 if the variable is not an automatic, it sets up the RTL and
2228 outputs any assembler code (label definition, storage allocation
2229 and initialization).
2231 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2232 the assembler symbol name to be used. TOP_LEVEL is nonzero
2233 if this declaration is not within a function. */
2235 void
2236 rest_of_decl_compilation (decl, asmspec, top_level, at_end)
2237 tree decl;
2238 const char *asmspec;
2239 int top_level;
2240 int at_end;
2242 /* We deferred calling assemble_alias so that we could collect
2243 other attributes such as visibility. Emit the alias now. */
2245 tree alias;
2246 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2247 if (alias)
2249 alias = TREE_VALUE (TREE_VALUE (alias));
2250 alias = get_identifier (TREE_STRING_POINTER (alias));
2251 assemble_alias (decl, alias);
2255 /* Forward declarations for nested functions are not "external",
2256 but we need to treat them as if they were. */
2257 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2258 || TREE_CODE (decl) == FUNCTION_DECL)
2260 timevar_push (TV_VARCONST);
2262 if (asmspec)
2263 make_decl_rtl (decl, asmspec);
2265 /* Don't output anything when a tentative file-scope definition
2266 is seen. But at end of compilation, do output code for them. */
2267 if (at_end || !DECL_DEFER_OUTPUT (decl))
2268 assemble_variable (decl, top_level, at_end, 0);
2270 #ifdef ASM_FINISH_DECLARE_OBJECT
2271 if (decl == last_assemble_variable_decl)
2273 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2274 top_level, at_end);
2276 #endif
2278 timevar_pop (TV_VARCONST);
2280 else if (DECL_REGISTER (decl) && asmspec != 0)
2282 if (decode_reg_name (asmspec) >= 0)
2284 SET_DECL_RTL (decl, NULL_RTX);
2285 make_decl_rtl (decl, asmspec);
2287 else
2289 error ("invalid register name `%s' for register variable", asmspec);
2290 DECL_REGISTER (decl) = 0;
2291 if (!top_level)
2292 expand_decl (decl);
2295 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2296 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2297 && TREE_CODE (decl) == TYPE_DECL)
2299 timevar_push (TV_SYMOUT);
2300 dbxout_symbol (decl, 0);
2301 timevar_pop (TV_SYMOUT);
2303 #endif
2304 #ifdef SDB_DEBUGGING_INFO
2305 else if (write_symbols == SDB_DEBUG && top_level
2306 && TREE_CODE (decl) == TYPE_DECL)
2308 timevar_push (TV_SYMOUT);
2309 sdbout_symbol (decl, 0);
2310 timevar_pop (TV_SYMOUT);
2312 #endif
2313 #ifdef DWARF2_DEBUGGING_INFO
2314 else if ((write_symbols == DWARF2_DEBUG
2315 || write_symbols == VMS_AND_DWARF2_DEBUG)
2316 && top_level
2317 && TREE_CODE (decl) == TYPE_DECL)
2319 timevar_push (TV_SYMOUT);
2320 dwarf2out_decl (decl);
2321 timevar_pop (TV_SYMOUT);
2323 #endif
2326 /* Called after finishing a record, union or enumeral type. */
2328 void
2329 rest_of_type_compilation (type, toplev)
2330 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
2331 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2332 tree type;
2333 int toplev;
2334 #else
2335 tree type ATTRIBUTE_UNUSED;
2336 int toplev ATTRIBUTE_UNUSED;
2337 #endif
2339 /* Avoid confusing the debug information machinery when there are
2340 errors. */
2341 if (errorcount != 0 || sorrycount != 0)
2342 return;
2344 timevar_push (TV_SYMOUT);
2345 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2346 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2347 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2348 #endif
2349 #ifdef SDB_DEBUGGING_INFO
2350 if (write_symbols == SDB_DEBUG)
2351 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2352 #endif
2353 #ifdef DWARF2_DEBUGGING_INFO
2354 if ((write_symbols == DWARF2_DEBUG
2355 || write_symbols == VMS_AND_DWARF2_DEBUG)
2356 && toplev)
2357 dwarf2out_decl (TYPE_STUB_DECL (type));
2358 #endif
2359 timevar_pop (TV_SYMOUT);
2362 /* This is called from finish_function (within langhooks.parse_file)
2363 after each top-level definition is parsed.
2364 It is supposed to compile that function or variable
2365 and output the assembler code for it.
2366 After we return, the tree storage is freed. */
2368 void
2369 rest_of_compilation (decl)
2370 tree decl;
2372 rtx insns;
2373 int tem;
2374 int failure = 0;
2375 int rebuild_label_notes_after_reload;
2377 timevar_push (TV_REST_OF_COMPILATION);
2379 /* Now that we're out of the frontend, we shouldn't have any more
2380 CONCATs anywhere. */
2381 generating_concat_p = 0;
2383 /* When processing delayed functions, prepare_function_start() won't
2384 have been run to re-initialize it. */
2385 cse_not_expected = ! optimize;
2387 /* First, make sure that NOTE_BLOCK is set correctly for each
2388 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
2389 if (!cfun->x_whole_function_mode_p)
2390 identify_blocks ();
2392 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
2393 tree in sensible shape. So, we just recalculate it here. */
2394 if (cfun->x_whole_function_mode_p)
2395 reorder_blocks ();
2397 init_flow ();
2399 /* If we are reconsidering an inline function
2400 at the end of compilation, skip the stuff for making it inline. */
2402 if (DECL_SAVED_INSNS (decl) == 0)
2404 int inlinable = 0;
2405 tree parent;
2406 const char *lose;
2408 /* If this is nested inside an inlined external function, pretend
2409 it was only declared. Since we cannot inline such functions,
2410 generating code for this one is not only not necessary but will
2411 confuse some debugging output writers. */
2412 for (parent = DECL_CONTEXT (current_function_decl);
2413 parent != NULL_TREE;
2414 parent = get_containing_scope (parent))
2415 if (TREE_CODE (parent) == FUNCTION_DECL
2416 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2418 DECL_INITIAL (decl) = 0;
2419 goto exit_rest_of_compilation;
2421 else if (TYPE_P (parent))
2422 /* A function in a local class should be treated normally. */
2423 break;
2425 /* If requested, consider whether to make this function inline. */
2426 if ((DECL_INLINE (decl) && !flag_no_inline)
2427 || flag_inline_functions)
2429 timevar_push (TV_INTEGRATION);
2430 lose = function_cannot_inline_p (decl);
2431 timevar_pop (TV_INTEGRATION);
2432 if (lose || ! optimize)
2434 if (warn_inline && DECL_INLINE (decl))
2435 warning_with_decl (decl, lose);
2436 DECL_ABSTRACT_ORIGIN (decl) = 0;
2437 /* Don't really compile an extern inline function.
2438 If we can't make it inline, pretend
2439 it was only declared. */
2440 if (DECL_EXTERNAL (decl))
2442 DECL_INITIAL (decl) = 0;
2443 goto exit_rest_of_compilation;
2446 else
2447 /* ??? Note that this has the effect of making it look
2448 like "inline" was specified for a function if we choose
2449 to inline it. This isn't quite right, but it's
2450 probably not worth the trouble to fix. */
2451 inlinable = DECL_INLINE (decl) = 1;
2454 insns = get_insns ();
2456 /* Dump the rtl code if we are dumping rtl. */
2458 if (open_dump_file (DFI_rtl, decl))
2460 if (DECL_SAVED_INSNS (decl))
2461 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2462 close_dump_file (DFI_rtl, print_rtl, insns);
2465 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2466 sorts of eh initialization. Delay this until after the
2467 initial rtl dump so that we can see the original nesting. */
2468 convert_from_eh_region_ranges ();
2470 /* If function is inline, and we don't yet know whether to
2471 compile it by itself, defer decision till end of compilation.
2472 wrapup_global_declarations will (indirectly) call
2473 rest_of_compilation again for those functions that need to
2474 be output. Also defer those functions that we are supposed
2475 to defer. */
2477 if (inlinable
2478 || (DECL_INLINE (decl)
2479 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2480 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2481 && ! flag_keep_inline_functions)
2482 || DECL_EXTERNAL (decl))))
2483 DECL_DEFER_OUTPUT (decl) = 1;
2485 if (DECL_INLINE (decl))
2486 /* DWARF wants separate debugging info for abstract and
2487 concrete instances of all inline functions, including those
2488 declared inline but not inlined, and those inlined even
2489 though they weren't declared inline. Conveniently, that's
2490 what DECL_INLINE means at this point. */
2491 (*debug_hooks->deferred_inline_function) (decl);
2493 if (DECL_DEFER_OUTPUT (decl))
2495 /* If -Wreturn-type, we have to do a bit of compilation. We just
2496 want to call cleanup the cfg to figure out whether or not we can
2497 fall off the end of the function; we do the minimum amount of
2498 work necessary to make that safe. */
2499 if (warn_return_type)
2501 int saved_optimize = optimize;
2503 optimize = 0;
2504 rebuild_jump_labels (insns);
2505 find_exception_handler_labels ();
2506 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2507 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2508 optimize = saved_optimize;
2510 /* CFG is no longer maintained up-to-date. */
2511 free_bb_for_insn ();
2514 set_nothrow_function_flags ();
2515 if (current_function_nothrow)
2516 /* Now we know that this can't throw; set the flag for the benefit
2517 of other functions later in this translation unit. */
2518 TREE_NOTHROW (current_function_decl) = 1;
2520 timevar_push (TV_INTEGRATION);
2521 save_for_inline (decl);
2522 timevar_pop (TV_INTEGRATION);
2523 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2524 goto exit_rest_of_compilation;
2527 /* If specified extern inline but we aren't inlining it, we are
2528 done. This goes for anything that gets here with DECL_EXTERNAL
2529 set, not just things with DECL_INLINE. */
2530 if (DECL_EXTERNAL (decl))
2531 goto exit_rest_of_compilation;
2534 /* If we're emitting a nested function, make sure its parent gets
2535 emitted as well. Doing otherwise confuses debug info. */
2537 tree parent;
2538 for (parent = DECL_CONTEXT (current_function_decl);
2539 parent != NULL_TREE;
2540 parent = get_containing_scope (parent))
2541 if (TREE_CODE (parent) == FUNCTION_DECL)
2542 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
2545 /* We are now committed to emitting code for this function. Do any
2546 preparation, such as emitting abstract debug info for the inline
2547 before it gets mangled by optimization. */
2548 if (DECL_INLINE (decl))
2549 (*debug_hooks->outlining_inline_function) (decl);
2551 /* Remove any notes we don't need. That will make iterating
2552 over the instruction sequence faster, and allow the garbage
2553 collector to reclaim the memory used by the notes. */
2554 remove_unnecessary_notes ();
2555 reorder_blocks ();
2557 ggc_collect ();
2559 /* Initialize some variables used by the optimizers. */
2560 init_function_for_compilation ();
2562 if (! DECL_DEFER_OUTPUT (decl))
2563 TREE_ASM_WRITTEN (decl) = 1;
2565 /* Now that integrate will no longer see our rtl, we need not
2566 distinguish between the return value of this function and the
2567 return value of called functions. Also, we can remove all SETs
2568 of subregs of hard registers; they are only here because of
2569 integrate. Also, we can now initialize pseudos intended to
2570 carry magic hard reg data throughout the function. */
2571 rtx_equal_function_value_matters = 0;
2572 purge_hard_subreg_sets (get_insns ());
2574 /* Early return if there were errors. We can run afoul of our
2575 consistency checks, and there's not really much point in fixing them.
2576 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
2577 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
2578 || errorcount || sorrycount)
2579 goto exit_rest_of_compilation;
2581 timevar_push (TV_JUMP);
2582 open_dump_file (DFI_sibling, decl);
2583 insns = get_insns ();
2584 rebuild_jump_labels (insns);
2585 find_exception_handler_labels ();
2586 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2588 delete_unreachable_blocks ();
2590 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
2591 timevar_push (TV_BRANCH_PROB);
2592 note_prediction_to_br_prob ();
2593 timevar_pop (TV_BRANCH_PROB);
2595 /* We may have potential sibling or tail recursion sites. Select one
2596 (of possibly multiple) methods of performing the call. */
2597 if (flag_optimize_sibling_calls)
2599 rtx insn;
2600 optimize_sibling_and_tail_recursive_calls ();
2602 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2603 free_bb_for_insn ();
2604 find_exception_handler_labels ();
2605 rebuild_jump_labels (insns);
2606 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2608 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2609 notes before simplifying cfg and we must do lowering after sibcall
2610 that unhides parts of RTL chain and cleans up the CFG.
2612 Until sibcall is replaced by tree-level optimizer, lets just
2613 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2614 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2615 if (GET_CODE (insn) == NOTE
2616 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2617 delete_insn (insn);
2619 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2620 timevar_pop (TV_JUMP);
2622 scope_to_insns_initialize ();
2623 /* Complete generation of exception handling code. */
2624 if (doing_eh (0))
2626 timevar_push (TV_JUMP);
2627 open_dump_file (DFI_eh, decl);
2629 finish_eh_generation ();
2631 close_dump_file (DFI_eh, print_rtl, get_insns ());
2632 timevar_pop (TV_JUMP);
2635 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
2636 generation, which might create new sets. */
2637 emit_initial_value_sets ();
2639 #ifdef FINALIZE_PIC
2640 /* If we are doing position-independent code generation, now
2641 is the time to output special prologues and epilogues.
2642 We do not want to do this earlier, because it just clutters
2643 up inline functions with meaningless insns. */
2644 if (flag_pic)
2645 FINALIZE_PIC;
2646 #endif
2648 insns = get_insns ();
2650 /* Copy any shared structure that should not be shared. */
2651 unshare_all_rtl (current_function_decl, insns);
2653 #ifdef SETJMP_VIA_SAVE_AREA
2654 /* This must be performed before virtual register instantiation.
2655 Please be aware the everything in the compiler that can look
2656 at the RTL up to this point must understand that REG_SAVE_AREA
2657 is just like a use of the REG contained inside. */
2658 if (current_function_calls_alloca)
2659 optimize_save_area_alloca (insns);
2660 #endif
2662 /* Instantiate all virtual registers. */
2663 instantiate_virtual_regs (current_function_decl, insns);
2665 open_dump_file (DFI_jump, decl);
2667 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
2668 are initialized and to compute whether control can drop off the end
2669 of the function. */
2671 timevar_push (TV_JUMP);
2672 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
2673 before jump optimization switches branch directions. */
2674 expected_value_to_br_prob ();
2676 reg_scan (insns, max_reg_num (), 0);
2677 rebuild_jump_labels (insns);
2678 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2679 if (rtl_dump_file)
2680 dump_flow_info (rtl_dump_file);
2681 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
2682 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2684 /* CFG is no longer maintained up-to-date. */
2685 free_bb_for_insn ();
2686 copy_loop_headers (insns);
2687 purge_line_number_notes (insns);
2688 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2690 timevar_pop (TV_JUMP);
2691 close_dump_file (DFI_jump, print_rtl, insns);
2693 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
2694 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
2696 goto exit_rest_of_compilation;
2699 /* Long term, this should probably move before the jump optimizer too,
2700 but I didn't want to disturb the rtl_dump_and_exit and related
2701 stuff at this time. */
2702 if (optimize > 0 && flag_ssa)
2704 /* Convert to SSA form. */
2706 timevar_push (TV_TO_SSA);
2707 open_dump_file (DFI_ssa, decl);
2709 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2710 convert_to_ssa ();
2712 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2713 timevar_pop (TV_TO_SSA);
2715 /* Perform sparse conditional constant propagation, if requested. */
2716 if (flag_ssa_ccp)
2718 timevar_push (TV_SSA_CCP);
2719 open_dump_file (DFI_ssa_ccp, decl);
2721 ssa_const_prop ();
2723 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2724 timevar_pop (TV_SSA_CCP);
2727 /* It would be useful to cleanup the CFG at this point, but block
2728 merging and possibly other transformations might leave a PHI
2729 node in the middle of a basic block, which is a strict no-no. */
2731 /* The SSA implementation uses basic block numbers in its phi
2732 nodes. Thus, changing the control-flow graph or the basic
2733 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2734 may cause problems. */
2736 if (flag_ssa_dce)
2738 /* Remove dead code. */
2740 timevar_push (TV_SSA_DCE);
2741 open_dump_file (DFI_ssa_dce, decl);
2743 insns = get_insns ();
2744 ssa_eliminate_dead_code ();
2746 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2747 timevar_pop (TV_SSA_DCE);
2750 /* Convert from SSA form. */
2752 timevar_push (TV_FROM_SSA);
2753 open_dump_file (DFI_ussa, decl);
2755 convert_from_ssa ();
2756 /* New registers have been created. Rescan their usage. */
2757 reg_scan (insns, max_reg_num (), 1);
2759 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2760 timevar_pop (TV_FROM_SSA);
2762 ggc_collect ();
2765 timevar_push (TV_JUMP);
2766 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP: 0);
2768 /* Try to identify useless null pointer tests and delete them. */
2769 if (flag_delete_null_pointer_checks)
2771 open_dump_file (DFI_null, decl);
2772 if (rtl_dump_file)
2773 dump_flow_info (rtl_dump_file);
2775 if (delete_null_pointer_checks (insns))
2776 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2778 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2781 /* Jump optimization, and the removal of NULL pointer checks, may
2782 have reduced the number of instructions substantially. CSE, and
2783 future passes, allocate arrays whose dimensions involve the
2784 maximum instruction UID, so if we can reduce the maximum UID
2785 we'll save big on memory. */
2786 renumber_insns (rtl_dump_file);
2787 timevar_pop (TV_JUMP);
2789 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
2791 ggc_collect ();
2793 /* Perform common subexpression elimination.
2794 Nonzero value from `cse_main' means that jumps were simplified
2795 and some code may now be unreachable, so do
2796 jump optimization again. */
2798 if (optimize > 0)
2800 open_dump_file (DFI_cse, decl);
2801 if (rtl_dump_file)
2802 dump_flow_info (rtl_dump_file);
2803 timevar_push (TV_CSE);
2805 reg_scan (insns, max_reg_num (), 1);
2807 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2808 if (tem)
2809 rebuild_jump_labels (insns);
2810 purge_all_dead_edges (0);
2812 delete_trivially_dead_insns (insns, max_reg_num ());
2814 /* If we are not running more CSE passes, then we are no longer
2815 expecting CSE to be run. But always rerun it in a cheap mode. */
2816 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2818 if (tem || optimize > 1)
2819 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2820 /* Try to identify useless null pointer tests and delete them. */
2821 if (flag_delete_null_pointer_checks)
2823 timevar_push (TV_JUMP);
2825 if (delete_null_pointer_checks (insns))
2826 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2827 timevar_pop (TV_JUMP);
2830 /* The second pass of jump optimization is likely to have
2831 removed a bunch more instructions. */
2832 renumber_insns (rtl_dump_file);
2834 timevar_pop (TV_CSE);
2835 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2838 open_dump_file (DFI_addressof, decl);
2840 purge_addressof (insns);
2841 if (optimize)
2842 purge_all_dead_edges (0);
2843 reg_scan (insns, max_reg_num (), 1);
2845 close_dump_file (DFI_addressof, print_rtl, insns);
2847 ggc_collect ();
2849 /* Perform global cse. */
2851 if (optimize > 0 && flag_gcse)
2853 int save_csb, save_cfj;
2854 int tem2 = 0;
2856 timevar_push (TV_GCSE);
2857 open_dump_file (DFI_gcse, decl);
2859 tem = gcse_main (insns, rtl_dump_file);
2860 rebuild_jump_labels (insns);
2861 delete_trivially_dead_insns (insns, max_reg_num ());
2863 save_csb = flag_cse_skip_blocks;
2864 save_cfj = flag_cse_follow_jumps;
2865 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2867 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2868 by gcse. */
2869 if (flag_expensive_optimizations)
2871 timevar_push (TV_CSE);
2872 reg_scan (insns, max_reg_num (), 1);
2873 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2874 purge_all_dead_edges (0);
2875 delete_trivially_dead_insns (insns, max_reg_num ());
2876 timevar_pop (TV_CSE);
2877 cse_not_expected = !flag_rerun_cse_after_loop;
2880 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2881 things up. Then possibly re-run CSE again. */
2882 while (tem || tem2)
2884 tem = tem2 = 0;
2885 timevar_push (TV_JUMP);
2886 rebuild_jump_labels (insns);
2887 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2888 timevar_pop (TV_JUMP);
2890 if (flag_expensive_optimizations)
2892 timevar_push (TV_CSE);
2893 reg_scan (insns, max_reg_num (), 1);
2894 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2895 purge_all_dead_edges (0);
2896 delete_trivially_dead_insns (insns, max_reg_num ());
2897 timevar_pop (TV_CSE);
2901 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2902 timevar_pop (TV_GCSE);
2904 ggc_collect ();
2905 flag_cse_skip_blocks = save_csb;
2906 flag_cse_follow_jumps = save_cfj;
2907 #ifdef ENABLE_CHECKING
2908 verify_flow_info ();
2909 #endif
2912 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
2913 if (optimize > 0 && flag_gcse && current_function_calls_constant_p)
2914 purge_builtin_constant_p ();
2916 /* Move constant computations out of loops. */
2918 if (optimize > 0 && flag_loop_optimize)
2920 int do_unroll, do_prefetch;
2922 timevar_push (TV_LOOP);
2923 delete_dead_jumptables ();
2924 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2925 open_dump_file (DFI_loop, decl);
2926 /* CFG is no longer maintained up-to-date. */
2927 free_bb_for_insn ();
2929 do_unroll = flag_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
2930 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
2931 if (flag_rerun_loop_opt)
2933 cleanup_barriers ();
2935 /* We only want to perform unrolling once. */
2936 loop_optimize (insns, rtl_dump_file, do_unroll);
2937 do_unroll = 0;
2939 /* The first call to loop_optimize makes some instructions
2940 trivially dead. We delete those instructions now in the
2941 hope that doing so will make the heuristics in loop work
2942 better and possibly speed up compilation. */
2943 delete_trivially_dead_insns (insns, max_reg_num ());
2945 /* The regscan pass is currently necessary as the alias
2946 analysis code depends on this information. */
2947 reg_scan (insns, max_reg_num (), 1);
2949 cleanup_barriers ();
2950 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
2952 /* Loop can create trivially dead instructions. */
2953 delete_trivially_dead_insns (insns, max_reg_num ());
2954 close_dump_file (DFI_loop, print_rtl, insns);
2955 timevar_pop (TV_LOOP);
2956 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2958 ggc_collect ();
2961 /* Perform jump bypassing and control flow optimizations. */
2962 if (optimize > 0 && flag_gcse)
2964 timevar_push (TV_BYPASS);
2965 open_dump_file (DFI_bypass, decl);
2967 cleanup_cfg (CLEANUP_EXPENSIVE);
2968 tem = bypass_jumps (rtl_dump_file);
2970 if (tem)
2972 rebuild_jump_labels (insns);
2973 cleanup_cfg (CLEANUP_EXPENSIVE);
2974 delete_trivially_dead_insns (insns, max_reg_num ());
2977 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2978 timevar_pop (TV_BYPASS);
2980 ggc_collect ();
2982 #ifdef ENABLE_CHECKING
2983 verify_flow_info ();
2984 #endif
2987 /* Do control and data flow analysis; wrote some of the results to
2988 the dump file. */
2990 timevar_push (TV_FLOW);
2991 open_dump_file (DFI_cfg, decl);
2992 if (rtl_dump_file)
2993 dump_flow_info (rtl_dump_file);
2994 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0)
2995 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2997 /* It may make more sense to mark constant functions after dead code is
2998 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2999 may insert code making function non-constant, but we still must consider
3000 it as constant, otherwise -fbranch-probabilities will not read data back.
3002 life_analysis rarely eliminates modification of external memory.
3004 if (optimize)
3005 mark_constant_function ();
3007 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
3009 /* Do branch profiling and static profile estimation passes. */
3010 if (optimize > 0 || cfun->arc_profile || flag_branch_probabilities)
3012 struct loops loops;
3014 timevar_push (TV_BRANCH_PROB);
3015 open_dump_file (DFI_bp, decl);
3016 if (cfun->arc_profile || flag_branch_probabilities)
3017 branch_prob ();
3019 /* Discover and record the loop depth at the head of each basic
3020 block. The loop infrastructure does the real job for us. */
3021 flow_loops_find (&loops, LOOP_TREE);
3023 if (rtl_dump_file)
3024 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
3026 /* Estimate using heuristics if no profiling info is available. */
3027 if (flag_guess_branch_prob)
3028 estimate_probability (&loops);
3030 flow_loops_free (&loops);
3031 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
3032 timevar_pop (TV_BRANCH_PROB);
3034 if (optimize >= 0)
3036 open_dump_file (DFI_ce1, decl);
3037 if (flag_if_conversion)
3039 timevar_push (TV_IFCVT);
3040 if (rtl_dump_file)
3041 dump_flow_info (rtl_dump_file);
3042 cleanup_cfg (CLEANUP_EXPENSIVE);
3043 reg_scan (insns, max_reg_num (), 0);
3044 if_convert (0);
3045 timevar_pop (TV_IFCVT);
3047 timevar_push (TV_JUMP);
3048 cleanup_cfg (CLEANUP_EXPENSIVE);
3049 reg_scan (insns, max_reg_num (), 0);
3050 timevar_pop (TV_JUMP);
3051 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
3053 if (flag_tracer)
3055 timevar_push (TV_TRACER);
3056 open_dump_file (DFI_tracer, decl);
3057 if (rtl_dump_file)
3058 dump_flow_info (rtl_dump_file);
3059 tracer ();
3060 cleanup_cfg (CLEANUP_EXPENSIVE);
3061 reg_scan (insns, max_reg_num (), 0);
3062 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
3063 timevar_pop (TV_TRACER);
3066 /* Perform loop optimalizations. It might be better to do them a bit
3067 sooner, but we want the profile feedback to work more efficiently. */
3068 if (optimize > 0
3069 && flag_unswitch_loops)
3071 struct loops *loops;
3072 timevar_push (TV_LOOP);
3073 open_dump_file (DFI_loop2, decl);
3074 if (rtl_dump_file)
3075 dump_flow_info (rtl_dump_file);
3077 loops = loop_optimizer_init (rtl_dump_file);
3079 if (loops)
3081 /* The optimalizations: */
3082 if (flag_unswitch_loops)
3083 unswitch_loops (loops);
3085 loop_optimizer_finalize (loops, rtl_dump_file);
3088 cleanup_cfg (CLEANUP_EXPENSIVE);
3089 delete_trivially_dead_insns (insns, max_reg_num ());
3090 reg_scan (insns, max_reg_num (), 0);
3091 if (rtl_dump_file)
3092 dump_flow_info (rtl_dump_file);
3093 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3094 timevar_pop (TV_LOOP);
3095 ggc_collect ();
3098 if (flag_rerun_cse_after_loop)
3100 timevar_push (TV_CSE2);
3101 open_dump_file (DFI_cse2, decl);
3102 if (rtl_dump_file)
3103 dump_flow_info (rtl_dump_file);
3104 /* CFG is no longer maintained up-to-date. */
3105 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3106 purge_all_dead_edges (0);
3107 delete_trivially_dead_insns (insns, max_reg_num ());
3109 if (tem)
3111 timevar_push (TV_JUMP);
3112 rebuild_jump_labels (insns);
3113 cleanup_cfg (CLEANUP_EXPENSIVE);
3114 timevar_pop (TV_JUMP);
3116 reg_scan (insns, max_reg_num (), 0);
3117 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3118 ggc_collect ();
3119 timevar_pop (TV_CSE2);
3122 cse_not_expected = 1;
3124 open_dump_file (DFI_life, decl);
3125 regclass_init ();
3127 check_function_return_warnings ();
3129 #ifdef ENABLE_CHECKING
3130 verify_flow_info ();
3131 #endif
3132 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3133 if (optimize)
3134 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3135 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3136 timevar_pop (TV_FLOW);
3138 no_new_pseudos = 1;
3140 if (warn_uninitialized || extra_warnings)
3142 uninitialized_vars_warning (DECL_INITIAL (decl));
3143 if (extra_warnings)
3144 setjmp_args_warning ();
3147 if (optimize)
3149 clear_bb_flags ();
3150 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3152 /* Insns were inserted, so things might look a bit different. */
3153 insns = get_insns ();
3154 update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
3155 PROP_LOG_LINKS | PROP_REG_INFO
3156 | PROP_DEATH_NOTES);
3160 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3162 ggc_collect ();
3164 /* If -opt, try combining insns through substitution. */
3166 if (optimize > 0)
3168 int rebuild_jump_labels_after_combine = 0;
3170 timevar_push (TV_COMBINE);
3171 open_dump_file (DFI_combine, decl);
3173 rebuild_jump_labels_after_combine
3174 = combine_instructions (insns, max_reg_num ());
3176 /* Combining insns may have turned an indirect jump into a
3177 direct jump. Rebuild the JUMP_LABEL fields of jumping
3178 instructions. */
3179 if (rebuild_jump_labels_after_combine)
3181 timevar_push (TV_JUMP);
3182 rebuild_jump_labels (insns);
3183 timevar_pop (TV_JUMP);
3185 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3188 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3189 timevar_pop (TV_COMBINE);
3191 ggc_collect ();
3194 /* Rerun if-conversion, as combine may have simplified things enough to
3195 now meet sequence length restrictions. */
3196 if (flag_if_conversion)
3198 timevar_push (TV_IFCVT);
3199 open_dump_file (DFI_ce2, decl);
3201 no_new_pseudos = 0;
3202 if_convert (1);
3203 no_new_pseudos = 1;
3205 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
3206 timevar_pop (TV_IFCVT);
3209 /* Register allocation pre-pass, to reduce number of moves
3210 necessary for two-address machines. */
3211 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3213 timevar_push (TV_REGMOVE);
3214 open_dump_file (DFI_regmove, decl);
3216 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
3218 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3219 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
3220 timevar_pop (TV_REGMOVE);
3222 ggc_collect ();
3225 /* Do unconditional splitting before register allocation to allow machine
3226 description to add extra information not needed previously. */
3227 split_all_insns (1);
3229 #ifdef OPTIMIZE_MODE_SWITCHING
3230 timevar_push (TV_MODE_SWITCH);
3232 no_new_pseudos = 0;
3233 optimize_mode_switching (NULL);
3234 no_new_pseudos = 1;
3236 timevar_pop (TV_MODE_SWITCH);
3237 #endif
3239 /* Any of the several passes since flow1 will have munged register
3240 lifetime data a bit. We need it to be up to date for scheduling
3241 (see handling of reg_known_equiv in init_alias_analysis). */
3242 recompute_reg_usage (insns, !optimize_size);
3244 timevar_push (TV_SCHED);
3246 #ifdef INSN_SCHEDULING
3248 /* Print function header into sched dump now
3249 because doing the sched analysis makes some of the dump. */
3250 if (optimize > 0 && flag_schedule_insns)
3252 open_dump_file (DFI_sched, decl);
3254 /* Do control and data sched analysis,
3255 and write some of the results to dump file. */
3257 schedule_insns (rtl_dump_file);
3259 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
3261 #endif
3262 timevar_pop (TV_SCHED);
3264 ggc_collect ();
3266 /* Determine if the current function is a leaf before running reload
3267 since this can impact optimizations done by the prologue and
3268 epilogue thus changing register elimination offsets. */
3269 current_function_is_leaf = leaf_function_p ();
3271 timevar_push (TV_LOCAL_ALLOC);
3272 open_dump_file (DFI_lreg, decl);
3274 /* Allocate pseudo-regs that are used only within 1 basic block.
3276 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the
3277 jump optimizer after register allocation and reloading are finished. */
3279 if (flag_new_regalloc)
3281 delete_trivially_dead_insns (insns, max_reg_num ());
3282 reg_alloc ();
3284 timevar_pop (TV_LOCAL_ALLOC);
3285 if (dump_file[DFI_lreg].enabled)
3287 timevar_push (TV_DUMP);
3289 close_dump_file (DFI_lreg, NULL, NULL);
3290 timevar_pop (TV_DUMP);
3293 /* XXX clean up the whole mess to bring live info in shape again. */
3294 timevar_push (TV_GLOBAL_ALLOC);
3295 open_dump_file (DFI_greg, decl);
3297 build_insn_chain (insns);
3298 failure = reload (insns, 0);
3300 timevar_pop (TV_GLOBAL_ALLOC);
3302 if (dump_file[DFI_greg].enabled)
3304 timevar_push (TV_DUMP);
3306 dump_global_regs (rtl_dump_file);
3308 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3309 timevar_pop (TV_DUMP);
3312 if (failure)
3313 goto exit_rest_of_compilation;
3314 reload_completed = 1;
3315 rebuild_label_notes_after_reload = 0;
3317 else
3319 /* Allocate the reg_renumber array. */
3320 allocate_reg_info (max_regno, FALSE, TRUE);
3322 /* And the reg_equiv_memory_loc array. */
3323 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
3325 allocate_initial_values (reg_equiv_memory_loc);
3327 regclass (insns, max_reg_num (), rtl_dump_file);
3328 rebuild_label_notes_after_reload = local_alloc ();
3330 timevar_pop (TV_LOCAL_ALLOC);
3332 if (dump_file[DFI_lreg].enabled)
3334 timevar_push (TV_DUMP);
3336 dump_flow_info (rtl_dump_file);
3337 dump_local_alloc (rtl_dump_file);
3339 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
3340 timevar_pop (TV_DUMP);
3343 ggc_collect ();
3345 timevar_push (TV_GLOBAL_ALLOC);
3346 open_dump_file (DFI_greg, decl);
3348 /* If optimizing, allocate remaining pseudo-regs. Do the reload
3349 pass fixing up any insns that are invalid. */
3351 if (optimize)
3352 failure = global_alloc (rtl_dump_file);
3353 else
3355 build_insn_chain (insns);
3356 failure = reload (insns, 0);
3359 timevar_pop (TV_GLOBAL_ALLOC);
3361 if (dump_file[DFI_greg].enabled)
3363 timevar_push (TV_DUMP);
3365 dump_global_regs (rtl_dump_file);
3367 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
3368 timevar_pop (TV_DUMP);
3371 if (failure)
3372 goto exit_rest_of_compilation;
3375 ggc_collect ();
3377 open_dump_file (DFI_postreload, decl);
3379 /* Do a very simple CSE pass over just the hard registers. */
3380 if (optimize > 0)
3382 timevar_push (TV_RELOAD_CSE_REGS);
3383 reload_cse_regs (insns);
3384 timevar_pop (TV_RELOAD_CSE_REGS);
3387 /* Register allocation and reloading may have turned an indirect jump into
3388 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3389 jumping instructions. */
3390 if (rebuild_label_notes_after_reload)
3392 timevar_push (TV_JUMP);
3394 rebuild_jump_labels (insns);
3395 purge_all_dead_edges (0);
3397 timevar_pop (TV_JUMP);
3400 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3402 /* Re-create the death notes which were deleted during reload. */
3403 timevar_push (TV_FLOW2);
3404 open_dump_file (DFI_flow2, decl);
3406 #ifdef ENABLE_CHECKING
3407 verify_flow_info ();
3408 #endif
3410 /* If optimizing, then go ahead and split insns now. */
3411 if (optimize > 0)
3412 split_all_insns (0);
3414 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
3416 /* On some machines, the prologue and epilogue code, or parts thereof,
3417 can be represented as RTL. Doing so lets us schedule insns between
3418 it and the rest of the code and also allows delayed branch
3419 scheduling to operate in the epilogue. */
3420 thread_prologue_and_epilogue_insns (insns);
3422 if (optimize)
3424 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3425 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3426 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3428 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3429 even for machines with possibly nonzero RETURN_POPS_ARGS
3430 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3431 push instructions will have popping returns. */
3432 #ifndef PUSH_ROUNDING
3433 if (!ACCUMULATE_OUTGOING_ARGS)
3434 #endif
3435 combine_stack_adjustments ();
3437 ggc_collect ();
3440 flow2_completed = 1;
3442 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3443 timevar_pop (TV_FLOW2);
3445 #ifdef HAVE_peephole2
3446 if (optimize > 0 && flag_peephole2)
3448 timevar_push (TV_PEEPHOLE2);
3449 open_dump_file (DFI_peephole2, decl);
3451 peephole2_optimize (rtl_dump_file);
3453 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3454 timevar_pop (TV_PEEPHOLE2);
3456 #endif
3458 if (optimize > 0 && (flag_rename_registers || flag_cprop_registers))
3460 timevar_push (TV_RENAME_REGISTERS);
3461 open_dump_file (DFI_rnreg, decl);
3463 if (flag_rename_registers)
3464 regrename_optimize ();
3465 if (flag_cprop_registers)
3466 copyprop_hardreg_forward ();
3468 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
3469 timevar_pop (TV_RENAME_REGISTERS);
3472 if (flag_if_conversion2)
3474 timevar_push (TV_IFCVT2);
3475 open_dump_file (DFI_ce3, decl);
3477 if_convert (1);
3479 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3480 timevar_pop (TV_IFCVT2);
3482 #ifdef STACK_REGS
3483 if (optimize)
3484 split_all_insns (1);
3485 #endif
3487 #ifdef INSN_SCHEDULING
3488 if (optimize > 0 && flag_schedule_insns_after_reload)
3490 timevar_push (TV_SCHED2);
3491 open_dump_file (DFI_sched2, decl);
3493 /* Do control and data sched analysis again,
3494 and write some more of the results to dump file. */
3496 split_all_insns (1);
3498 schedule_insns (rtl_dump_file);
3500 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
3501 timevar_pop (TV_SCHED2);
3503 ggc_collect ();
3505 #endif
3507 #ifdef LEAF_REGISTERS
3508 current_function_uses_only_leaf_regs
3509 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3510 #endif
3512 #ifdef STACK_REGS
3513 timevar_push (TV_REG_STACK);
3514 open_dump_file (DFI_stack, decl);
3516 reg_to_stack (insns, rtl_dump_file);
3518 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
3519 timevar_pop (TV_REG_STACK);
3521 ggc_collect ();
3522 #endif
3523 if (optimize > 0)
3525 timevar_push (TV_REORDER_BLOCKS);
3526 open_dump_file (DFI_bbro, decl);
3528 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
3529 splitting possibly introduced more crossjumping opportunities.
3530 Except that we can't actually run crossjumping without running
3531 another DCE pass, which we can't do after reg-stack. */
3532 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
3533 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3534 if (flag_reorder_blocks)
3536 reorder_basic_blocks ();
3537 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
3540 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
3541 timevar_pop (TV_REORDER_BLOCKS);
3543 compute_alignments ();
3545 /* CFG is no longer maintained up-to-date. */
3546 free_bb_for_insn ();
3548 /* If a machine dependent reorganization is needed, call it. */
3549 #ifdef MACHINE_DEPENDENT_REORG
3550 timevar_push (TV_MACH_DEP);
3551 open_dump_file (DFI_mach, decl);
3553 MACHINE_DEPENDENT_REORG (insns);
3555 close_dump_file (DFI_mach, print_rtl, insns);
3556 timevar_pop (TV_MACH_DEP);
3558 ggc_collect ();
3559 #endif
3561 purge_line_number_notes (insns);
3562 cleanup_barriers ();
3564 /* If a scheduling pass for delayed branches is to be done,
3565 call the scheduling code. */
3567 #ifdef DELAY_SLOTS
3568 if (optimize > 0 && flag_delayed_branch)
3570 timevar_push (TV_DBR_SCHED);
3571 open_dump_file (DFI_dbr, decl);
3573 dbr_schedule (insns, rtl_dump_file);
3575 close_dump_file (DFI_dbr, print_rtl, insns);
3576 timevar_pop (TV_DBR_SCHED);
3578 ggc_collect ();
3580 #endif
3582 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3583 timevar_push (TV_SHORTEN_BRANCH);
3584 split_all_insns_noflow ();
3585 timevar_pop (TV_SHORTEN_BRANCH);
3586 #endif
3588 convert_to_eh_region_ranges ();
3590 /* Shorten branches. */
3591 timevar_push (TV_SHORTEN_BRANCH);
3592 shorten_branches (get_insns ());
3593 timevar_pop (TV_SHORTEN_BRANCH);
3595 set_nothrow_function_flags ();
3596 if (current_function_nothrow)
3597 /* Now we know that this can't throw; set the flag for the benefit
3598 of other functions later in this translation unit. */
3599 TREE_NOTHROW (current_function_decl) = 1;
3601 /* Now turn the rtl into assembler code. */
3603 timevar_push (TV_FINAL);
3605 rtx x;
3606 const char *fnname;
3608 /* Get the function's name, as described by its RTL. This may be
3609 different from the DECL_NAME name used in the source file. */
3611 x = DECL_RTL (decl);
3612 if (GET_CODE (x) != MEM)
3613 abort ();
3614 x = XEXP (x, 0);
3615 if (GET_CODE (x) != SYMBOL_REF)
3616 abort ();
3617 fnname = XSTR (x, 0);
3619 assemble_start_function (decl, fnname);
3620 final_start_function (insns, asm_out_file, optimize);
3621 final (insns, asm_out_file, optimize, 0);
3622 final_end_function ();
3624 #ifdef IA64_UNWIND_INFO
3625 /* ??? The IA-64 ".handlerdata" directive must be issued before
3626 the ".endp" directive that closes the procedure descriptor. */
3627 output_function_exception_table ();
3628 #endif
3630 assemble_end_function (decl, fnname);
3632 #ifndef IA64_UNWIND_INFO
3633 /* Otherwise, it feels unclean to switch sections in the middle. */
3634 output_function_exception_table ();
3635 #endif
3637 if (! quiet_flag)
3638 fflush (asm_out_file);
3640 /* Release all memory allocated by flow. */
3641 free_basic_block_vars (0);
3643 /* Release all memory held by regsets now. */
3644 regset_release_memory ();
3646 timevar_pop (TV_FINAL);
3648 ggc_collect ();
3650 /* Write DBX symbols if requested. */
3652 /* Note that for those inline functions where we don't initially
3653 know for certain that we will be generating an out-of-line copy,
3654 the first invocation of this routine (rest_of_compilation) will
3655 skip over this code by doing a `goto exit_rest_of_compilation;'.
3656 Later on, wrapup_global_declarations will (indirectly) call
3657 rest_of_compilation again for those inline functions that need
3658 to have out-of-line copies generated. During that call, we
3659 *will* be routed past here. */
3661 timevar_push (TV_SYMOUT);
3662 (*debug_hooks->function_decl) (decl);
3663 timevar_pop (TV_SYMOUT);
3665 exit_rest_of_compilation:
3667 /* In case the function was not output,
3668 don't leave any temporary anonymous types
3669 queued up for sdb output. */
3670 #ifdef SDB_DEBUGGING_INFO
3671 if (write_symbols == SDB_DEBUG)
3672 sdbout_types (NULL_TREE);
3673 #endif
3675 reload_completed = 0;
3676 flow2_completed = 0;
3677 no_new_pseudos = 0;
3679 timevar_push (TV_FINAL);
3681 /* Clear out the insn_length contents now that they are no
3682 longer valid. */
3683 init_insn_lengths ();
3685 /* Show no temporary slots allocated. */
3686 init_temp_slots ();
3688 free_basic_block_vars (0);
3689 free_bb_for_insn ();
3691 timevar_pop (TV_FINAL);
3693 /* Make sure volatile mem refs aren't considered valid operands for
3694 arithmetic insns. We must call this here if this is a nested inline
3695 function, since the above code leaves us in the init_recog state
3696 (from final.c), and the function context push/pop code does not
3697 save/restore volatile_ok.
3699 ??? Maybe it isn't necessary for expand_start_function to call this
3700 anymore if we do it here? */
3702 init_recog_no_volatile ();
3704 /* We're done with this function. Free up memory if we can. */
3705 free_after_parsing (cfun);
3706 if (! DECL_DEFER_OUTPUT (decl))
3708 free_after_compilation (cfun);
3710 /* Clear integrate.c's pointer to the cfun structure we just
3711 destroyed. */
3712 DECL_SAVED_INSNS (decl) = 0;
3714 cfun = 0;
3716 ggc_collect ();
3718 timevar_pop (TV_REST_OF_COMPILATION);
3721 static void
3722 display_help ()
3724 int undoc;
3725 unsigned long i;
3726 const char *lang;
3728 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3729 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3730 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3731 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3732 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3733 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"));
3734 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3736 for (i = ARRAY_SIZE (f_options); i--;)
3738 const char *description = f_options[i].description;
3740 if (description != NULL && *description != 0)
3741 printf (" -f%-21s %s\n",
3742 f_options[i].string, _(description));
3745 printf (_(" -O[number] Set optimization level to [number]\n"));
3746 printf (_(" -Os Optimize for space rather than speed\n"));
3747 for (i = LAST_PARAM; i--;)
3749 const char *description = compiler_params[i].help;
3750 const int length = 21 - strlen (compiler_params[i].option);
3752 if (description != NULL && *description != 0)
3753 printf (" --param %s=<value>%.*s%s\n",
3754 compiler_params[i].option,
3755 length > 0 ? length : 1, " ",
3756 _(description));
3758 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3759 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3760 printf (_(" -w Suppress warnings\n"));
3762 for (i = ARRAY_SIZE (W_options); i--;)
3764 const char *description = W_options[i].description;
3766 if (description != NULL && *description != 0)
3767 printf (" -W%-21s %s\n",
3768 W_options[i].string, _(description));
3771 printf (_(" -Wunused Enable unused warnings\n"));
3772 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3773 printf (_(" -p Enable function profiling\n"));
3774 printf (_(" -o <file> Place output into <file> \n"));
3775 printf (_("\
3776 -G <number> Put global and static data smaller than <number>\n\
3777 bytes into a special section (on some targets)\n"));
3779 for (i = ARRAY_SIZE (debug_args); i--;)
3781 if (debug_args[i].description != NULL)
3782 printf (" -g%-21s %s\n",
3783 debug_args[i].arg, _(debug_args[i].description));
3786 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3787 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3788 printf (_(" -version Display the compiler's version\n"));
3789 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3790 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3791 #if defined INSN_SCHEDULING
3792 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3793 #endif
3794 printf (_(" --help Display this information\n"));
3796 undoc = 0;
3797 lang = "language";
3799 /* Display descriptions of language specific options.
3800 If there is no description, note that there is an undocumented option.
3801 If the description is empty, do not display anything. (This allows
3802 options to be deliberately undocumented, for whatever reason).
3803 If the option string is missing, then this is a marker, indicating
3804 that the description string is in fact the name of a language, whose
3805 language specific options are to follow. */
3807 if (ARRAY_SIZE (documented_lang_options) > 1)
3809 printf (_("\nLanguage specific options:\n"));
3811 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3813 const char *description = documented_lang_options[i].description;
3814 const char *option = documented_lang_options[i].option;
3816 if (description == NULL)
3818 undoc = 1;
3820 if (extra_warnings)
3821 printf (_(" %-23.23s [undocumented]\n"), option);
3823 else if (*description == 0)
3824 continue;
3825 else if (option == NULL)
3827 if (undoc)
3828 printf
3829 (_("\nThere are undocumented %s specific options as well.\n"),
3830 lang);
3831 undoc = 0;
3833 printf (_("\n Options for %s:\n"), description);
3835 lang = description;
3837 else
3838 printf (" %-23.23s %s\n", option, _(description));
3842 if (undoc)
3843 printf (_("\nThere are undocumented %s specific options as well.\n"),
3844 lang);
3846 display_target_options ();
3849 static void
3850 display_target_options ()
3852 int undoc, i;
3853 static bool displayed = false;
3855 /* Avoid double printing for --help --target-help. */
3856 if (displayed)
3857 return;
3858 displayed = true;
3860 if (ARRAY_SIZE (target_switches) > 1
3861 #ifdef TARGET_OPTIONS
3862 || ARRAY_SIZE (target_options) > 1
3863 #endif
3866 int doc = 0;
3868 undoc = 0;
3870 printf (_("\nTarget specific options:\n"));
3872 for (i = ARRAY_SIZE (target_switches); i--;)
3874 const char *option = target_switches[i].name;
3875 const char *description = target_switches[i].description;
3877 if (option == NULL || *option == 0)
3878 continue;
3879 else if (description == NULL)
3881 undoc = 1;
3883 if (extra_warnings)
3884 printf (_(" -m%-23.23s [undocumented]\n"), option);
3886 else if (*description != 0)
3887 doc += printf (" -m%-23.23s %s\n", option, _(description));
3890 #ifdef TARGET_OPTIONS
3891 for (i = ARRAY_SIZE (target_options); i--;)
3893 const char *option = target_options[i].prefix;
3894 const char *description = target_options[i].description;
3896 if (option == NULL || *option == 0)
3897 continue;
3898 else if (description == NULL)
3900 undoc = 1;
3902 if (extra_warnings)
3903 printf (_(" -m%-23.23s [undocumented]\n"), option);
3905 else if (*description != 0)
3906 doc += printf (" -m%-23.23s %s\n", option, _(description));
3908 #endif
3909 if (undoc)
3911 if (doc)
3912 printf (_("\nThere are undocumented target specific options as well.\n"));
3913 else
3914 printf (_(" They exist, but they are not documented.\n"));
3919 /* Parse a -d... command line switch. */
3921 static void
3922 decode_d_option (arg)
3923 const char *arg;
3925 int i, c, matched;
3927 while (*arg)
3928 switch (c = *arg++)
3930 case 'a':
3931 for (i = 0; i < (int) DFI_MAX; ++i)
3932 dump_file[i].enabled = 1;
3933 break;
3934 case 'A':
3935 flag_debug_asm = 1;
3936 break;
3937 case 'p':
3938 flag_print_asm_name = 1;
3939 break;
3940 case 'P':
3941 flag_dump_rtl_in_asm = 1;
3942 flag_print_asm_name = 1;
3943 break;
3944 case 'v':
3945 graph_dump_format = vcg;
3946 break;
3947 case 'x':
3948 rtl_dump_and_exit = 1;
3949 break;
3950 case 'y':
3951 set_yydebug = 1;
3952 break;
3953 case 'D': /* These are handled by the preprocessor. */
3954 case 'I':
3955 break;
3957 default:
3958 matched = 0;
3959 for (i = 0; i < (int) DFI_MAX; ++i)
3960 if (c == dump_file[i].debug_switch)
3962 dump_file[i].enabled = 1;
3963 matched = 1;
3966 if (! matched)
3967 warning ("unrecognized gcc debugging option: %c", c);
3968 break;
3972 /* Parse a -f... command line switch. ARG is the value after the -f.
3973 It is safe to access 'ARG - 2' to generate the full switch name.
3974 Return the number of strings consumed. */
3976 static int
3977 decode_f_option (arg)
3978 const char *arg;
3980 int j;
3981 const char *option_value = NULL;
3983 /* Search for the option in the table of binary f options. */
3984 for (j = ARRAY_SIZE (f_options); j--;)
3986 if (!strcmp (arg, f_options[j].string))
3988 *f_options[j].variable = f_options[j].on_value;
3989 return 1;
3992 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
3993 && ! strcmp (arg + 3, f_options[j].string))
3995 *f_options[j].variable = ! f_options[j].on_value;
3996 return 1;
4000 if (!strcmp (arg, "fast-math"))
4001 set_fast_math_flags (1);
4002 else if (!strcmp (arg, "no-fast-math"))
4003 set_fast_math_flags (0);
4004 else if ((option_value = skip_leading_substring (arg, "inline-limit-"))
4005 || (option_value = skip_leading_substring (arg, "inline-limit=")))
4007 int val =
4008 read_integral_parameter (option_value, arg - 2,
4009 MAX_INLINE_INSNS);
4010 set_param_value ("max-inline-insns", val);
4012 else if ((option_value = skip_leading_substring (arg, "tls-model=")))
4014 if (strcmp (option_value, "global-dynamic") == 0)
4015 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
4016 else if (strcmp (option_value, "local-dynamic") == 0)
4017 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
4018 else if (strcmp (option_value, "initial-exec") == 0)
4019 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
4020 else if (strcmp (option_value, "local-exec") == 0)
4021 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
4022 else
4023 warning ("`%s': unknown tls-model option", arg - 2);
4025 #ifdef INSN_SCHEDULING
4026 else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
4027 fix_sched_param ("verbose", option_value);
4028 #endif
4029 else if ((option_value = skip_leading_substring (arg, "fixed-")))
4030 fix_register (option_value, 1, 1);
4031 else if ((option_value = skip_leading_substring (arg, "call-used-")))
4032 fix_register (option_value, 0, 1);
4033 else if ((option_value = skip_leading_substring (arg, "call-saved-")))
4034 fix_register (option_value, 0, 0);
4035 else if ((option_value = skip_leading_substring (arg, "align-loops=")))
4036 align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
4037 else if ((option_value = skip_leading_substring (arg, "align-functions=")))
4038 align_functions
4039 = read_integral_parameter (option_value, arg - 2, align_functions);
4040 else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
4041 align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
4042 else if ((option_value = skip_leading_substring (arg, "align-labels=")))
4043 align_labels
4044 = read_integral_parameter (option_value, arg - 2, align_labels);
4045 else if ((option_value
4046 = skip_leading_substring (arg, "stack-limit-register=")))
4048 int reg = decode_reg_name (option_value);
4049 if (reg < 0)
4050 error ("unrecognized register name `%s'", option_value);
4051 else
4052 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
4054 else if ((option_value
4055 = skip_leading_substring (arg, "stack-limit-symbol=")))
4057 const char *nm;
4058 nm = ggc_strdup (option_value);
4059 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
4061 else if ((option_value
4062 = skip_leading_substring (arg, "message-length=")))
4063 output_set_maximum_length
4064 (&global_dc->buffer, read_integral_parameter
4065 (option_value, arg - 2, diagnostic_line_cutoff (global_dc)));
4066 else if ((option_value
4067 = skip_leading_substring (arg, "diagnostics-show-location=")))
4069 if (!strcmp (option_value, "once"))
4070 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
4071 else if (!strcmp (option_value, "every-line"))
4072 diagnostic_prefixing_rule (global_dc)
4073 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
4074 else
4075 error ("unrecognized option `%s'", arg - 2);
4077 else if (!strcmp (arg, "no-stack-limit"))
4078 stack_limit_rtx = NULL_RTX;
4079 else if (!strcmp (arg, "preprocessed"))
4080 /* Recognize this switch but do nothing. This prevents warnings
4081 about an unrecognized switch if cpplib has not been linked in. */
4083 else
4084 return 0;
4086 return 1;
4089 /* Parse a -W... command line switch. ARG is the value after the -W.
4090 It is safe to access 'ARG - 2' to generate the full switch name.
4091 Return the number of strings consumed. */
4093 static int
4094 decode_W_option (arg)
4095 const char *arg;
4097 const char *option_value = NULL;
4098 int j;
4100 /* Search for the option in the table of binary W options. */
4102 for (j = ARRAY_SIZE (W_options); j--;)
4104 if (!strcmp (arg, W_options[j].string))
4106 *W_options[j].variable = W_options[j].on_value;
4107 return 1;
4110 if (arg[0] == 'n' && arg[1] == 'o' && arg[2] == '-'
4111 && ! strcmp (arg + 3, W_options[j].string))
4113 *W_options[j].variable = ! W_options[j].on_value;
4114 return 1;
4118 if ((option_value = skip_leading_substring (arg, "id-clash-")))
4119 warning ("-Wid-clash-LEN is no longer supported");
4120 else if ((option_value = skip_leading_substring (arg, "larger-than-")))
4122 larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
4124 warn_larger_than = larger_than_size != -1;
4126 else if (!strcmp (arg, "unused"))
4128 set_Wunused (1);
4130 else if (!strcmp (arg, "no-unused"))
4132 set_Wunused (0);
4134 else if (!strcmp (arg, "extra"))
4136 /* We save the value of warn_uninitialized, since if they put
4137 -Wuninitialized on the command line, we need to generate a
4138 warning about not using it without also specifying -O. */
4139 if (warn_uninitialized != 1)
4140 warn_uninitialized = 2;
4142 else
4143 return 0;
4145 return 1;
4148 /* Parse a -g... command line switch. ARG is the value after the -g.
4149 It is safe to access 'ARG - 2' to generate the full switch name.
4150 Return the number of strings consumed. */
4152 static int
4153 decode_g_option (arg)
4154 const char *arg;
4156 static unsigned level = 0;
4157 /* A lot of code assumes write_symbols == NO_DEBUG if the
4158 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4159 of what debugging type has been selected). This records the
4160 selected type. It is an error to specify more than one
4161 debugging type. */
4162 static enum debug_info_type selected_debug_type = NO_DEBUG;
4163 /* Nonzero if debugging format has been explicitly set.
4164 -g and -ggdb don't explicitly set the debugging format so
4165 -gdwarf -g3 is equivalent to -gdwarf3. */
4166 static int type_explicitly_set_p = 0;
4167 /* Indexed by enum debug_info_type. */
4168 static const char *const debug_type_names[] =
4170 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4173 /* The maximum admissible debug level value. */
4174 static const unsigned max_debug_level = 3;
4176 /* Look up ARG in the table. */
4177 for (da = debug_args; da->arg; da++)
4179 const int da_len = strlen (da->arg);
4181 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4183 enum debug_info_type type = da->debug_type;
4184 const char *p = arg + da_len;
4186 if (*p && ! ISDIGIT (*p))
4187 continue;
4189 /* A debug flag without a level defaults to level 2.
4190 Note we do not want to call read_integral_parameter
4191 for that case since it will call atoi which
4192 will return zero.
4194 ??? We may want to generalize the interface to
4195 read_integral_parameter to better handle this case
4196 if this case shows up often. */
4197 if (*p)
4198 level = read_integral_parameter (p, 0, max_debug_level + 1);
4199 else
4200 level = (level == 0) ? 2 : level;
4202 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4204 error ("use -gdwarf -g%d for DWARF v1, level %d",
4205 level, level);
4206 if (level == 2)
4207 error ("use -gdwarf-2 for DWARF v2");
4210 if (level > max_debug_level)
4212 warning ("\
4213 ignoring option `%s' due to invalid debug level specification",
4214 arg - 2);
4215 level = debug_info_level;
4218 if (type == NO_DEBUG)
4220 type = PREFERRED_DEBUGGING_TYPE;
4222 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4224 #ifdef DWARF2_DEBUGGING_INFO
4225 type = DWARF2_DEBUG;
4226 #else
4227 #ifdef DBX_DEBUGGING_INFO
4228 type = DBX_DEBUG;
4229 #endif
4230 #endif
4234 if (type == NO_DEBUG)
4235 warning ("`%s': unknown or unsupported -g option", arg - 2);
4237 /* Does it conflict with an already selected type? */
4238 if (type_explicitly_set_p
4239 /* -g/-ggdb don't conflict with anything. */
4240 && da->debug_type != NO_DEBUG
4241 && type != selected_debug_type)
4242 warning ("`%s' ignored, conflicts with `-g%s'",
4243 arg - 2, debug_type_names[(int) selected_debug_type]);
4244 else
4246 /* If the format has already been set, -g/-ggdb
4247 only change the debug level. */
4248 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4249 /* Don't change debugging type. */
4251 else
4253 selected_debug_type = type;
4254 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4257 write_symbols = (level == 0
4258 ? NO_DEBUG
4259 : selected_debug_type);
4260 use_gnu_debug_info_extensions = da->use_extensions_p;
4261 debug_info_level = (enum debug_info_level) level;
4264 break;
4268 if (! da->arg)
4269 return 0;
4271 return 1;
4274 /* Decode the first argument in the argv as a language-independent option.
4275 Return the number of strings consumed. */
4277 static unsigned int
4278 independent_decode_option (argc, argv)
4279 int argc;
4280 char **argv;
4282 char *arg = argv[0];
4284 if (arg[0] != '-' || arg[1] == 0)
4286 if (arg[0] == '+')
4287 return 0;
4289 filename = arg;
4291 return 1;
4294 arg++;
4296 if (!strcmp (arg, "-help"))
4298 display_help ();
4299 exit_after_options = 1;
4302 if (!strcmp (arg, "-target-help"))
4304 display_target_options ();
4305 exit_after_options = 1;
4308 if (!strcmp (arg, "-version"))
4310 print_version (stderr, "");
4311 exit_after_options = 1;
4314 /* Handle '--param <name>=<value>'. */
4315 if (strcmp (arg, "-param") == 0)
4317 char *equal;
4319 if (argc == 1)
4321 error ("-param option missing argument");
4322 return 1;
4325 /* Get the '<name>=<value>' parameter. */
4326 arg = argv[1];
4327 /* Look for the `='. */
4328 equal = strchr (arg, '=');
4329 if (!equal)
4330 error ("invalid --param option: %s", arg);
4331 else
4333 int val;
4335 /* Zero out the `=' sign so that we get two separate strings. */
4336 *equal = '\0';
4337 /* Figure out what value is specified. */
4338 val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
4339 if (val != INVALID_PARAM_VAL)
4340 set_param_value (arg, val);
4341 else
4342 error ("invalid parameter value `%s'", equal + 1);
4345 return 2;
4348 if (*arg == 'Y')
4349 arg++;
4351 switch (*arg)
4353 default:
4354 return 0;
4356 case 'O':
4357 /* Already been treated in main (). Do nothing. */
4358 break;
4360 case 'm':
4361 set_target_switch (arg + 1);
4362 break;
4364 case 'f':
4365 return decode_f_option (arg + 1);
4367 case 'g':
4368 return decode_g_option (arg + 1);
4370 case 'd':
4371 if (!strcmp (arg, "dumpbase"))
4373 if (argc == 1)
4374 return 0;
4376 if (argv[1][0])
4377 dump_base_name = argv[1];
4379 return 2;
4381 else
4382 decode_d_option (arg + 1);
4383 break;
4385 case 'p':
4386 if (!strcmp (arg, "pedantic"))
4387 pedantic = 1;
4388 else if (!strcmp (arg, "pedantic-errors"))
4389 flag_pedantic_errors = pedantic = 1;
4390 else if (arg[1] == 0)
4391 profile_flag = 1;
4392 else
4393 return 0;
4394 break;
4396 case 'q':
4397 if (!strcmp (arg, "quiet"))
4398 quiet_flag = 1;
4399 else
4400 return 0;
4401 break;
4403 case 'v':
4404 if (!strcmp (arg, "version"))
4405 version_flag = 1;
4406 else
4407 return 0;
4408 break;
4410 case 'w':
4411 if (arg[1] == 0)
4412 inhibit_warnings = 1;
4413 else
4414 return 0;
4415 break;
4417 case 'W':
4418 if (arg[1] == 0)
4420 extra_warnings = 1;
4421 /* We save the value of warn_uninitialized, since if they put
4422 -Wuninitialized on the command line, we need to generate a
4423 warning about not using it without also specifying -O. */
4424 if (warn_uninitialized != 1)
4425 warn_uninitialized = 2;
4427 else
4428 return decode_W_option (arg + 1);
4429 break;
4431 case 'a':
4432 if (!strncmp (arg, "aux-info", 8))
4434 if (arg[8] == '\0')
4436 if (argc == 1)
4437 return 0;
4439 aux_info_file_name = argv[1];
4440 flag_gen_aux_info = 1;
4441 return 2;
4443 else if (arg[8] == '=')
4445 aux_info_file_name = arg + 9;
4446 flag_gen_aux_info = 1;
4448 else
4449 return 0;
4451 else if (!strcmp (arg, "auxbase"))
4453 if (argc == 1)
4454 return 0;
4456 if (argv[1][0])
4457 aux_base_name = argv[1];
4459 return 2;
4461 else if (!strcmp (arg, "auxbase-strip"))
4463 if (argc == 1)
4464 return 0;
4466 if (argv[1][0])
4468 strip_off_ending (argv[1], strlen (argv[1]));
4469 if (argv[1][0])
4470 aux_base_name = argv[1];
4473 return 2;
4475 else
4476 return 0;
4477 break;
4479 case 'o':
4480 if (arg[1] == 0)
4482 if (argc == 1)
4483 return 0;
4485 asm_file_name = argv[1];
4486 return 2;
4488 return 0;
4490 case 'G':
4492 int g_switch_val;
4493 int return_val;
4495 if (arg[1] == 0)
4497 if (argc == 1)
4498 return 0;
4500 g_switch_val = read_integral_parameter (argv[1], 0, -1);
4501 return_val = 2;
4503 else
4505 g_switch_val = read_integral_parameter (arg + 1, 0, -1);
4506 return_val = 1;
4509 if (g_switch_val == -1)
4510 return_val = 0;
4511 else
4513 g_switch_set = TRUE;
4514 g_switch_value = g_switch_val;
4517 return return_val;
4521 return 1;
4524 /* Decode -m switches. */
4525 /* Decode the switch -mNAME. */
4527 static void
4528 set_target_switch (name)
4529 const char *name;
4531 size_t j;
4532 int valid_target_option = 0;
4534 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4535 if (!strcmp (target_switches[j].name, name))
4537 if (target_switches[j].value < 0)
4538 target_flags &= ~-target_switches[j].value;
4539 else
4540 target_flags |= target_switches[j].value;
4541 if (name[0] != 0)
4543 if (target_switches[j].value < 0)
4544 target_flags_explicit |= -target_switches[j].value;
4545 else
4546 target_flags_explicit |= target_switches[j].value;
4548 valid_target_option = 1;
4551 #ifdef TARGET_OPTIONS
4552 if (!valid_target_option)
4553 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4555 int len = strlen (target_options[j].prefix);
4556 if (!strncmp (target_options[j].prefix, name, len))
4558 *target_options[j].variable = name + len;
4559 valid_target_option = 1;
4562 #endif
4564 if (!valid_target_option)
4565 error ("invalid option `%s'", name);
4568 /* Print version information to FILE.
4569 Each line begins with INDENT (for the case where FILE is the
4570 assembler output file). */
4572 static void
4573 print_version (file, indent)
4574 FILE *file;
4575 const char *indent;
4577 #ifndef __VERSION__
4578 #define __VERSION__ "[?]"
4579 #endif
4580 fnotice (file,
4581 #ifdef __GNUC__
4582 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4583 #else
4584 "%s%s%s version %s (%s) compiled by CC.\n"
4585 #endif
4586 , indent, *indent != 0 ? " " : "",
4587 lang_hooks.name, version_string, TARGET_NAME,
4588 indent, __VERSION__);
4591 /* Print an option value and return the adjusted position in the line.
4592 ??? We don't handle error returns from fprintf (disk full); presumably
4593 other code will catch a disk full though. */
4595 static int
4596 print_single_switch (file, pos, max, indent, sep, term, type, name)
4597 FILE *file;
4598 int pos, max;
4599 const char *indent, *sep, *term, *type, *name;
4601 /* The ultrix fprintf returns 0 on success, so compute the result we want
4602 here since we need it for the following test. */
4603 int len = strlen (sep) + strlen (type) + strlen (name);
4605 if (pos != 0
4606 && pos + len > max)
4608 fprintf (file, "%s", term);
4609 pos = 0;
4611 if (pos == 0)
4613 fprintf (file, "%s", indent);
4614 pos = strlen (indent);
4616 fprintf (file, "%s%s%s", sep, type, name);
4617 pos += len;
4618 return pos;
4621 /* Print active target switches to FILE.
4622 POS is the current cursor position and MAX is the size of a "line".
4623 Each line begins with INDENT and ends with TERM.
4624 Each switch is separated from the next by SEP. */
4626 static void
4627 print_switch_values (file, pos, max, indent, sep, term)
4628 FILE *file;
4629 int pos, max;
4630 const char *indent, *sep, *term;
4632 size_t j;
4633 char **p;
4635 /* Print the options as passed. */
4637 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4638 _("options passed: "), "");
4640 for (p = &save_argv[1]; *p != NULL; p++)
4641 if (**p == '-')
4643 /* Ignore these. */
4644 if (strcmp (*p, "-o") == 0)
4646 if (p[1] != NULL)
4647 p++;
4648 continue;
4650 if (strcmp (*p, "-quiet") == 0)
4651 continue;
4652 if (strcmp (*p, "-version") == 0)
4653 continue;
4654 if ((*p)[1] == 'd')
4655 continue;
4657 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4659 if (pos > 0)
4660 fprintf (file, "%s", term);
4662 /* Print the -f and -m options that have been enabled.
4663 We don't handle language specific options but printing argv
4664 should suffice. */
4666 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4667 _("options enabled: "), "");
4669 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4670 if (*f_options[j].variable == f_options[j].on_value)
4671 pos = print_single_switch (file, pos, max, indent, sep, term,
4672 "-f", f_options[j].string);
4674 /* Print target specific options. */
4676 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4677 if (target_switches[j].name[0] != '\0'
4678 && target_switches[j].value > 0
4679 && ((target_switches[j].value & target_flags)
4680 == target_switches[j].value))
4682 pos = print_single_switch (file, pos, max, indent, sep, term,
4683 "-m", target_switches[j].name);
4686 #ifdef TARGET_OPTIONS
4687 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4688 if (*target_options[j].variable != NULL)
4690 char prefix[256];
4691 sprintf (prefix, "-m%s", target_options[j].prefix);
4692 pos = print_single_switch (file, pos, max, indent, sep, term,
4693 prefix, *target_options[j].variable);
4695 #endif
4697 fprintf (file, "%s", term);
4700 /* Open assembly code output file. Do this even if -fsyntax-only is
4701 on, because then the driver will have provided the name of a
4702 temporary file or bit bucket for us. NAME is the file specified on
4703 the command line, possibly NULL. */
4704 static void
4705 init_asm_output (name)
4706 const char *name;
4708 if (name == NULL && asm_file_name == 0)
4709 asm_out_file = stdout;
4710 else
4712 if (asm_file_name == 0)
4714 int len = strlen (dump_base_name);
4715 char *dumpname = (char *) xmalloc (len + 6);
4716 memcpy (dumpname, dump_base_name, len + 1);
4717 strip_off_ending (dumpname, len);
4718 strcat (dumpname, ".s");
4719 asm_file_name = dumpname;
4721 if (!strcmp (asm_file_name, "-"))
4722 asm_out_file = stdout;
4723 else
4724 asm_out_file = fopen (asm_file_name, "w+");
4725 if (asm_out_file == 0)
4726 fatal_io_error ("can't open %s for writing", asm_file_name);
4729 #ifdef IO_BUFFER_SIZE
4730 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4731 _IOFBF, IO_BUFFER_SIZE);
4732 #endif
4734 if (!flag_syntax_only)
4736 #ifdef ASM_FILE_START
4737 ASM_FILE_START (asm_out_file);
4738 #endif
4740 #ifdef ASM_COMMENT_START
4741 if (flag_verbose_asm)
4743 /* Print the list of options in effect. */
4744 print_version (asm_out_file, ASM_COMMENT_START);
4745 print_switch_values (asm_out_file, 0, MAX_LINE,
4746 ASM_COMMENT_START, " ", "\n");
4747 /* Add a blank line here so it appears in assembler output but not
4748 screen output. */
4749 fprintf (asm_out_file, "\n");
4751 #endif
4755 /* Initialization of the front end environment, before command line
4756 options are parsed. Signal handlers, internationalization etc.
4757 ARGV0 is main's argv[0]. */
4758 static void
4759 general_init (argv0)
4760 char *argv0;
4762 char *p;
4764 p = argv0 + strlen (argv0);
4765 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4766 --p;
4767 progname = p;
4769 xmalloc_set_program_name (progname);
4771 hex_init ();
4773 gcc_init_libintl ();
4775 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4776 #ifdef SIGSEGV
4777 signal (SIGSEGV, crash_signal);
4778 #endif
4779 #ifdef SIGILL
4780 signal (SIGILL, crash_signal);
4781 #endif
4782 #ifdef SIGBUS
4783 signal (SIGBUS, crash_signal);
4784 #endif
4785 #ifdef SIGABRT
4786 signal (SIGABRT, crash_signal);
4787 #endif
4788 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4789 signal (SIGIOT, crash_signal);
4790 #endif
4791 #ifdef SIGFPE
4792 signal (SIGFPE, crash_signal);
4793 #endif
4795 /* Other host-specific signal setup. */
4796 (*host_hooks.extra_signals)();
4798 /* Initialize the diagnostics reporting machinery, so option parsing
4799 can give warnings and errors. */
4800 diagnostic_initialize (global_dc);
4802 /* Initialize the garbage-collector, string pools and tree type hash
4803 table. */
4804 init_ggc ();
4805 init_stringpool ();
4806 init_ttree ();
4809 /* Parse command line options and set default flag values, called
4810 after language-independent option-independent initialization. Do
4811 minimal options processing. Outputting diagnostics is OK, but GC
4812 and identifier hashtables etc. are not initialized yet.
4814 Return nonzero to suppress compiler back end initialization. */
4815 static void
4816 parse_options_and_default_flags (argc, argv)
4817 int argc;
4818 char **argv;
4820 int i;
4822 /* Save in case md file wants to emit args as a comment. */
4823 save_argc = argc;
4824 save_argv = argv;
4826 /* Initialize register usage now so switches may override. */
4827 init_reg_sets ();
4829 /* Register the language-independent parameters. */
4830 add_params (lang_independent_params, LAST_PARAM);
4832 /* Perform language-specific options initialization. */
4833 (*lang_hooks.init_options) ();
4835 /* Scan to see what optimization level has been specified. That will
4836 determine the default value of many flags. */
4837 for (i = 1; i < argc; i++)
4839 if (!strcmp (argv[i], "-O"))
4841 optimize = 1;
4842 optimize_size = 0;
4844 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4846 /* Handle -Os, -O2, -O3, -O69, ... */
4847 char *p = &argv[i][2];
4849 if ((p[0] == 's') && (p[1] == 0))
4851 optimize_size = 1;
4853 /* Optimizing for size forces optimize to be 2. */
4854 optimize = 2;
4856 else
4858 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4859 if (optimize_val != -1)
4861 optimize = optimize_val;
4862 optimize_size = 0;
4868 if (!optimize)
4870 flag_merge_constants = 0;
4873 if (optimize >= 1)
4875 flag_defer_pop = 1;
4876 flag_thread_jumps = 1;
4877 #ifdef DELAY_SLOTS
4878 flag_delayed_branch = 1;
4879 #endif
4880 #ifdef CAN_DEBUG_WITHOUT_FP
4881 flag_omit_frame_pointer = 1;
4882 #endif
4883 flag_guess_branch_prob = 1;
4884 flag_cprop_registers = 1;
4885 flag_loop_optimize = 1;
4886 flag_crossjumping = 1;
4887 flag_if_conversion = 1;
4888 flag_if_conversion2 = 1;
4891 if (optimize >= 2)
4893 flag_optimize_sibling_calls = 1;
4894 flag_cse_follow_jumps = 1;
4895 flag_cse_skip_blocks = 1;
4896 flag_gcse = 1;
4897 flag_expensive_optimizations = 1;
4898 flag_strength_reduce = 1;
4899 flag_rerun_cse_after_loop = 1;
4900 flag_rerun_loop_opt = 1;
4901 flag_caller_saves = 1;
4902 flag_force_mem = 1;
4903 flag_peephole2 = 1;
4904 #ifdef INSN_SCHEDULING
4905 flag_schedule_insns = 1;
4906 flag_schedule_insns_after_reload = 1;
4907 #endif
4908 flag_regmove = 1;
4909 flag_strict_aliasing = 1;
4910 flag_delete_null_pointer_checks = 1;
4911 flag_reorder_blocks = 1;
4912 flag_reorder_functions = 1;
4915 if (optimize >= 3)
4917 flag_inline_functions = 1;
4918 flag_rename_registers = 1;
4919 flag_unswitch_loops = 1;
4922 if (optimize < 2 || optimize_size)
4924 align_loops = 1;
4925 align_jumps = 1;
4926 align_labels = 1;
4927 align_functions = 1;
4929 /* Don't reorder blocks when optimizing for size because extra
4930 jump insns may be created; also barrier may create extra padding.
4932 More correctly we should have a block reordering mode that tried
4933 to minimize the combined size of all the jumps. This would more
4934 or less automatically remove extra jumps, but would also try to
4935 use more short jumps instead of long jumps. */
4936 flag_reorder_blocks = 0;
4939 /* Initialize whether `char' is signed. */
4940 flag_signed_char = DEFAULT_SIGNED_CHAR;
4941 #ifdef DEFAULT_SHORT_ENUMS
4942 /* Initialize how much space enums occupy, by default. */
4943 flag_short_enums = DEFAULT_SHORT_ENUMS;
4944 #endif
4946 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4947 modify it. */
4948 target_flags = 0;
4949 set_target_switch ("");
4951 /* Unwind tables are always present in an ABI-conformant IA-64
4952 object file, so the default should be ON. */
4953 #ifdef IA64_UNWIND_INFO
4954 flag_unwind_tables = IA64_UNWIND_INFO;
4955 #endif
4957 #ifdef OPTIMIZATION_OPTIONS
4958 /* Allow default optimizations to be specified on a per-machine basis. */
4959 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4960 #endif
4962 /* Perform normal command line switch decoding. */
4963 for (i = 1; i < argc;)
4965 int lang_processed;
4966 int indep_processed;
4968 /* Give the language a chance to decode the option for itself. */
4969 lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
4971 if (lang_processed >= 0)
4972 /* Now see if the option also has a language independent meaning.
4973 Some options are both language specific and language independent,
4974 eg --help. */
4975 indep_processed = independent_decode_option (argc - i, argv + i);
4976 else
4978 lang_processed = -lang_processed;
4979 indep_processed = 0;
4982 if (lang_processed || indep_processed)
4983 i += MAX (lang_processed, indep_processed);
4984 else
4986 const char *option = NULL;
4987 const char *lang = NULL;
4988 unsigned int j;
4990 /* It is possible that the command line switch is not valid for the
4991 current language, but it is valid for another language. In order
4992 to be compatible with previous versions of the compiler (which
4993 did not issue an error message in this case) we check for this
4994 possibility here. If we do find a match, then if extra_warnings
4995 is set we generate a warning message, otherwise we will just
4996 ignore the option. */
4997 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4999 option = documented_lang_options[j].option;
5001 if (option == NULL)
5002 lang = documented_lang_options[j].description;
5003 else if (! strncmp (argv[i], option, strlen (option)))
5004 break;
5007 if (j != ARRAY_SIZE (documented_lang_options))
5009 if (extra_warnings)
5011 warning ("ignoring command line option '%s'", argv[i]);
5012 if (lang)
5013 warning
5014 ("(it is valid for %s but not the selected language)",
5015 lang);
5018 else if (argv[i][0] == '-' && argv[i][1] == 'g')
5019 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
5020 else
5021 error ("unrecognized option `%s'", argv[i]);
5023 i++;
5027 if (flag_no_inline == 2)
5028 flag_no_inline = 0;
5029 else
5030 flag_really_no_inline = flag_no_inline;
5032 /* Set flag_no_inline before the post_options () hook. The C front
5033 ends use it to determine tree inlining defaults. FIXME: such
5034 code should be lang-independent when all front ends use tree
5035 inlining, in which case it, and this condition, should be moved
5036 to the top of process_options() instead. */
5037 if (optimize == 0)
5039 /* Inlining does not work if not optimizing,
5040 so force it not to be done. */
5041 flag_no_inline = 1;
5042 warn_inline = 0;
5044 /* The c_decode_option function and decode_option hook set
5045 this to `2' if -Wall is used, so we can avoid giving out
5046 lots of errors for people who don't realize what -Wall does. */
5047 if (warn_uninitialized == 1)
5048 warning ("-Wuninitialized is not supported without -O");
5051 if (flag_really_no_inline == 2)
5052 flag_really_no_inline = flag_no_inline;
5055 /* Process the options that have been parsed. */
5056 static void
5057 process_options ()
5059 #ifdef OVERRIDE_OPTIONS
5060 /* Some machines may reject certain combinations of options. */
5061 OVERRIDE_OPTIONS;
5062 #endif
5064 /* Set up the align_*_log variables, defaulting them to 1 if they
5065 were still unset. */
5066 if (align_loops <= 0) align_loops = 1;
5067 if (align_loops_max_skip > align_loops || !align_loops)
5068 align_loops_max_skip = align_loops - 1;
5069 align_loops_log = floor_log2 (align_loops * 2 - 1);
5070 if (align_jumps <= 0) align_jumps = 1;
5071 if (align_jumps_max_skip > align_jumps || !align_jumps)
5072 align_jumps_max_skip = align_jumps - 1;
5073 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
5074 if (align_labels <= 0) align_labels = 1;
5075 align_labels_log = floor_log2 (align_labels * 2 - 1);
5076 if (align_labels_max_skip > align_labels || !align_labels)
5077 align_labels_max_skip = align_labels - 1;
5078 if (align_functions <= 0) align_functions = 1;
5079 align_functions_log = floor_log2 (align_functions * 2 - 1);
5081 /* Unrolling all loops implies that standard loop unrolling must also
5082 be done. */
5083 if (flag_unroll_all_loops)
5084 flag_unroll_loops = 1;
5085 /* Loop unrolling requires that strength_reduction be on also. Silently
5086 turn on strength reduction here if it isn't already on. Also, the loop
5087 unrolling code assumes that cse will be run after loop, so that must
5088 be turned on also. */
5089 if (flag_unroll_loops)
5091 flag_strength_reduce = 1;
5092 flag_rerun_cse_after_loop = 1;
5095 if (flag_non_call_exceptions)
5096 flag_asynchronous_unwind_tables = 1;
5097 if (flag_asynchronous_unwind_tables)
5098 flag_unwind_tables = 1;
5100 /* Warn about options that are not supported on this machine. */
5101 #ifndef INSN_SCHEDULING
5102 if (flag_schedule_insns || flag_schedule_insns_after_reload)
5103 warning ("instruction scheduling not supported on this target machine");
5104 #endif
5105 #ifndef DELAY_SLOTS
5106 if (flag_delayed_branch)
5107 warning ("this target machine does not have delayed branches");
5108 #endif
5110 user_label_prefix = USER_LABEL_PREFIX;
5111 if (flag_leading_underscore != -1)
5113 /* If the default prefix is more complicated than "" or "_",
5114 issue a warning and ignore this option. */
5115 if (user_label_prefix[0] == 0 ||
5116 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
5118 user_label_prefix = flag_leading_underscore ? "_" : "";
5120 else
5121 warning ("-f%sleading-underscore not supported on this target machine",
5122 flag_leading_underscore ? "" : "no-");
5125 /* If we are in verbose mode, write out the version and maybe all the
5126 option flags in use. */
5127 if (version_flag)
5129 print_version (stderr, "");
5130 if (! quiet_flag)
5131 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
5134 if (! quiet_flag)
5135 time_report = 1;
5137 if (flag_syntax_only)
5139 write_symbols = NO_DEBUG;
5140 profile_flag = 0;
5143 /* Now we know write_symbols, set up the debug hooks based on it.
5144 By default we do nothing for debug output. */
5145 #if defined(DBX_DEBUGGING_INFO)
5146 if (write_symbols == DBX_DEBUG)
5147 debug_hooks = &dbx_debug_hooks;
5148 #endif
5149 #if defined(XCOFF_DEBUGGING_INFO)
5150 if (write_symbols == XCOFF_DEBUG)
5151 debug_hooks = &xcoff_debug_hooks;
5152 #endif
5153 #ifdef SDB_DEBUGGING_INFO
5154 if (write_symbols == SDB_DEBUG)
5155 debug_hooks = &sdb_debug_hooks;
5156 #endif
5157 #ifdef DWARF_DEBUGGING_INFO
5158 if (write_symbols == DWARF_DEBUG)
5159 debug_hooks = &dwarf_debug_hooks;
5160 #endif
5161 #ifdef DWARF2_DEBUGGING_INFO
5162 if (write_symbols == DWARF2_DEBUG)
5163 debug_hooks = &dwarf2_debug_hooks;
5164 #endif
5165 #ifdef VMS_DEBUGGING_INFO
5166 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
5167 debug_hooks = &vmsdbg_debug_hooks;
5168 #endif
5170 /* If auxiliary info generation is desired, open the output file.
5171 This goes in the same directory as the source file--unlike
5172 all the other output files. */
5173 if (flag_gen_aux_info)
5175 aux_info_file = fopen (aux_info_file_name, "w");
5176 if (aux_info_file == 0)
5177 fatal_io_error ("can't open %s", aux_info_file_name);
5180 if (! targetm.have_named_sections)
5182 if (flag_function_sections)
5184 warning ("-ffunction-sections not supported for this target");
5185 flag_function_sections = 0;
5187 if (flag_data_sections)
5189 warning ("-fdata-sections not supported for this target");
5190 flag_data_sections = 0;
5194 if (flag_function_sections && profile_flag)
5196 warning ("-ffunction-sections disabled; it makes profiling impossible");
5197 flag_function_sections = 0;
5200 #ifndef HAVE_prefetch
5201 if (flag_prefetch_loop_arrays)
5203 warning ("-fprefetch-loop-arrays not supported for this target");
5204 flag_prefetch_loop_arrays = 0;
5206 #else
5207 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
5209 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
5210 flag_prefetch_loop_arrays = 0;
5212 #endif
5214 /* This combination of options isn't handled for i386 targets and doesn't
5215 make much sense anyway, so don't allow it. */
5216 if (flag_prefetch_loop_arrays && optimize_size)
5218 warning ("-fprefetch-loop-arrays is not supported with -Os");
5219 flag_prefetch_loop_arrays = 0;
5222 #ifndef OBJECT_FORMAT_ELF
5223 if (flag_function_sections && write_symbols != NO_DEBUG)
5224 warning ("-ffunction-sections may affect debugging on some targets");
5225 #endif
5227 /* The presence of IEEE signaling NaNs, implies all math can trap. */
5228 if (flag_signaling_nans)
5229 flag_trapping_math = 1;
5232 /* Initialize the compiler back end. */
5233 static void
5234 backend_init ()
5236 /* init_emit_once uses reg_raw_mode and therefore must be called
5237 after init_regs which initialized reg_raw_mode. */
5238 init_regs ();
5239 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5240 || debug_info_level == DINFO_LEVEL_VERBOSE
5241 #ifdef VMS_DEBUGGING_INFO
5242 /* Enable line number info for traceback */
5243 || debug_info_level > DINFO_LEVEL_NONE
5244 #endif
5245 || flag_test_coverage
5246 || warn_notreached);
5247 init_fake_stack_mems ();
5248 init_alias_once ();
5249 init_loop ();
5250 init_reload ();
5251 init_function_once ();
5252 init_varasm_once ();
5254 /* The following initialization functions need to generate rtl, so
5255 provide a dummy function context for them. */
5256 init_dummy_function_start ();
5257 init_expmed ();
5258 if (flag_caller_saves)
5259 init_caller_save ();
5260 expand_dummy_function_end ();
5263 /* Language-dependent initialization. Returns nonzero on success. */
5264 static int
5265 lang_dependent_init (name)
5266 const char *name;
5268 if (dump_base_name == 0)
5269 dump_base_name = name ? name : "gccdump";
5271 /* Front-end initialization. This hook can assume that GC,
5272 identifier hashes etc. are set up, but debug initialization is
5273 not done yet. This routine must return the original filename
5274 (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
5275 name = (*lang_hooks.init) (name);
5276 if (name == NULL)
5277 return 0;
5279 /* Is this duplication necessary? */
5280 name = ggc_strdup (name);
5281 main_input_filename = input_filename = name;
5282 init_asm_output (name);
5284 /* These create various _DECL nodes, so need to be called after the
5285 front end is initialized. */
5286 init_eh ();
5287 init_optabs ();
5289 /* The following initialization functions need to generate rtl, so
5290 provide a dummy function context for them. */
5291 init_dummy_function_start ();
5292 init_expr_once ();
5293 expand_dummy_function_end ();
5295 /* Put an entry on the input file stack for the main input file. */
5296 push_srcloc (input_filename, 0);
5298 /* If dbx symbol table desired, initialize writing it and output the
5299 predefined types. */
5300 timevar_push (TV_SYMOUT);
5302 #ifdef DWARF2_UNWIND_INFO
5303 if (dwarf2out_do_frame ())
5304 dwarf2out_frame_init ();
5305 #endif
5307 /* Now we have the correct original filename, we can initialize
5308 debug output. */
5309 (*debug_hooks->init) (name);
5311 timevar_pop (TV_SYMOUT);
5313 return 1;
5316 /* Clean up: close opened files, etc. */
5318 static void
5319 finalize ()
5321 /* Close the dump files. */
5322 if (flag_gen_aux_info)
5324 fclose (aux_info_file);
5325 if (errorcount)
5326 unlink (aux_info_file_name);
5329 /* Close non-debugging input and output files. Take special care to note
5330 whether fclose returns an error, since the pages might still be on the
5331 buffer chain while the file is open. */
5333 if (asm_out_file)
5335 if (ferror (asm_out_file) != 0)
5336 fatal_io_error ("error writing to %s", asm_file_name);
5337 if (fclose (asm_out_file) != 0)
5338 fatal_io_error ("error closing %s", asm_file_name);
5341 /* Do whatever is necessary to finish printing the graphs. */
5342 if (graph_dump_format != no_graph)
5344 int i;
5346 for (i = 0; i < (int) DFI_MAX; ++i)
5347 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5349 char seq[16];
5350 char *suffix;
5352 sprintf (seq, DUMPFILE_FORMAT, i);
5353 suffix = concat (seq, dump_file[i].extension, NULL);
5354 finish_graph_dump_file (dump_base_name, suffix);
5355 free (suffix);
5359 if (mem_report)
5361 ggc_print_statistics ();
5362 stringpool_statistics ();
5363 dump_tree_statistics ();
5366 /* Free up memory for the benefit of leak detectors. */
5367 free_reg_info ();
5369 /* Language-specific end of compilation actions. */
5370 (*lang_hooks.finish) ();
5373 /* Initialize the compiler, and compile the input file. */
5374 static void
5375 do_compile ()
5377 /* All command line options have been parsed; allow the front end to
5378 perform consistency checks, etc. */
5379 bool no_backend = (*lang_hooks.post_options) ();
5381 /* The bulk of command line switch processing. */
5382 process_options ();
5384 /* If an error has already occurred, give up. */
5385 if (errorcount)
5386 return;
5388 if (aux_base_name)
5389 /*NOP*/;
5390 else if (filename)
5392 char *name = xstrdup (lbasename (filename));
5394 aux_base_name = name;
5395 strip_off_ending (name, strlen (name));
5397 else
5398 aux_base_name = "gccaux";
5400 /* We cannot start timing until after options are processed since that
5401 says if we run timers or not. */
5402 init_timevar ();
5403 timevar_start (TV_TOTAL);
5405 /* Set up the back-end if requested. */
5406 if (!no_backend)
5407 backend_init ();
5409 /* Language-dependent initialization. Returns true on success. */
5410 if (lang_dependent_init (filename))
5411 compile_file ();
5413 finalize ();
5415 /* Stop timing and print the times. */
5416 timevar_stop (TV_TOTAL);
5417 timevar_print (stderr);
5420 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5421 Decode command args, then call compile_file.
5422 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5423 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5425 It is not safe to call this function more than once. */
5428 toplev_main (argc, argv)
5429 int argc;
5430 char **argv;
5432 /* Initialization of GCC's environment, and diagnostics. */
5433 general_init (argv[0]);
5435 /* Parse the options and do minimal processing; basically just
5436 enough to default flags appropriately. */
5437 parse_options_and_default_flags (argc, argv);
5439 /* Exit early if we can (e.g. -help). */
5440 if (!exit_after_options)
5441 do_compile ();
5443 if (errorcount || sorrycount)
5444 return (FATAL_EXIT_CODE);
5446 return (SUCCESS_EXIT_CODE);